:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #141820;
  --muted: #677084;
  --line: #dde3ee;
  --brand: #1f7ae0;
  --brand-dark: #1559ab;
  --green: #16875d;
  --red: #c74343;
  --amber: #b8741a;
  --blue-soft: #edf5ff;
  --shadow: 0 18px 50px rgba(28, 39, 61, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.splash,
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    linear-gradient(135deg, rgba(31, 122, 224, 0.14), transparent 34%),
    linear-gradient(315deg, rgba(22, 135, 93, 0.12), transparent 36%),
    #f7f9fd;
}

.loader {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 3px solid #c7d5ec;
  border-top-color: var(--brand);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.login-panel {
  width: min(440px, 100%);
  padding: 38px;
  border: 1px solid rgba(221, 227, 238, 0.88);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.login-panel h1,
.topbar h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.login-panel h1 {
  font-size: 28px;
}

.login-panel p,
.panel-head p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.login-form,
.settings-panel label {
  display: grid;
  gap: 10px;
  margin-top: 26px;
  color: #394153;
  font-size: 14px;
  font-weight: 700;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.settings-panel .account-grid label {
  margin-top: 0;
}

.divider {
  height: 1px;
  margin: 26px 0;
  background: var(--line);
}

.panel-head.compact {
  margin-bottom: 14px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input {
  height: 44px;
  padding: 0 13px;
}

textarea {
  min-height: 260px;
  padding: 14px;
  resize: vertical;
  line-height: 1.6;
}

input:focus,
textarea:focus {
  border-color: rgba(31, 122, 224, 0.76);
  box-shadow: 0 0 0 3px rgba(31, 122, 224, 0.12);
}

.login-form button,
.form-actions button,
.top-actions button,
.row-actions button,
.file-button,
.ghost,
.secondary,
.danger {
  min-height: 40px;
  padding: 0 15px;
  border-radius: 8px;
  font-weight: 750;
}

.login-form button,
.form-actions button {
  color: #fff;
  background: var(--brand);
}

.login-form button:hover,
.form-actions button:hover {
  background: var(--brand-dark);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px;
  color: #eef5ff;
  background: #111827;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.11);
}

.side-brand strong,
.side-brand span {
  display: block;
}

.side-brand span {
  margin-top: 3px;
  color: #96a2b8;
  font-size: 12px;
}

.sidebar nav {
  display: grid;
  gap: 8px;
  margin-top: 26px;
}

.sidebar nav button,
.ghost {
  width: 100%;
  min-height: 42px;
  color: #bdc8da;
  background: transparent;
  text-align: left;
}

.sidebar nav button {
  padding: 0 14px;
  border-radius: 8px;
}

.sidebar nav button:hover,
.sidebar nav button.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.side-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
  color: #96a2b8;
  font-size: 13px;
}

.ghost {
  border: 1px solid rgba(255, 255, 255, 0.14);
  text-align: center;
}

.workspace {
  min-width: 0;
  padding: 30px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.topbar h2 {
  font-size: 30px;
}

.top-actions,
.form-actions,
.row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.secondary {
  border: 1px solid var(--line);
  color: #253048;
  background: #fff;
}

.danger {
  color: #fff;
  background: var(--red);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 26px 0;
}

.stat-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.stat-card span,
.meta-line,
.log-row small {
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.stat-card.green strong { color: var(--green); }
.stat-card.red strong { color: var(--red); }
.stat-card.blue strong { color: var(--brand); }

.queue-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: -8px 0 22px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.queue-panel strong,
.queue-panel span {
  display: block;
}

.queue-panel strong {
  font-size: 15px;
}

.queue-panel span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.queue-panel.active {
  border-color: #b8d7ff;
  background: var(--blue-soft);
}

.queue-progress {
  min-width: 260px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.queue-progress > span {
  min-width: 70px;
  margin-top: 0;
  text-align: right;
}

.queue-bar {
  position: relative;
  flex: 1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #d9e2ef;
}

.queue-bar i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: var(--brand);
  transition: width 0.2s ease;
}

.panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 12px 34px rgba(28, 39, 61, 0.07);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.file-button {
  position: relative;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  color: #253048;
  background: #fff;
  white-space: nowrap;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.notice {
  display: flex;
  gap: 12px;
  margin: 14px 0 18px;
  padding: 13px 14px;
  border: 1px solid #d6e7ff;
  border-radius: 8px;
  color: #244463;
  background: var(--blue-soft);
  line-height: 1.6;
}

.notice strong {
  flex: 0 0 auto;
}

.success-text {
  color: var(--green);
  font-weight: 700;
}

.error-text {
  color: var(--red);
  font-weight: 700;
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7f9fc;
}

.segmented button {
  height: 34px;
  padding: 0 12px;
  border-radius: 7px;
  color: #5f687a;
  background: transparent;
  font-weight: 750;
}

.segmented button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 4px 14px rgba(28, 39, 61, 0.09);
}

.search {
  max-width: 360px;
}

.record-list,
.log-list {
  display: grid;
  gap: 10px;
}

.record-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  background: #e8eef7;
}

.avatar.empty {
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #31405a, #1f7ae0);
  font-weight: 850;
}

.record-main {
  min-width: 0;
}

.record-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.record-title strong,
.record-main p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-main p {
  margin: 6px 0;
  color: #4b5567;
}

.badge {
  padding: 4px 8px;
  border-radius: 999px;
  color: #6a7282;
  background: #eef1f6;
  font-size: 12px;
  font-weight: 800;
}

.badge.success {
  color: var(--green);
  background: #eaf8f2;
}

.badge.failed {
  color: var(--red);
  background: #fff0f0;
}

.badge.unsupported {
  color: var(--amber);
  background: #fff6e8;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.log-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 180px;
  gap: 12px;
  align-items: start;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.log-row span {
  color: var(--brand);
  font-weight: 850;
  text-transform: uppercase;
}

.log-row.warn span { color: var(--amber); }
.log-row.error span { color: var(--red); }

.log-row code {
  grid-column: 2 / 4;
  padding: 8px;
  border-radius: 8px;
  color: #42506a;
  background: #f5f7fb;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty-state {
  padding: 42px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  padding: 12px 16px;
  border-radius: 10px;
  color: #fff;
  background: #111827;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .sidebar nav button {
    text-align: center;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .queue-panel {
    align-items: stretch;
    display: grid;
  }

  .queue-progress {
    min-width: 0;
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 18px;
  }

  .topbar,
  .panel-head,
  .table-toolbar,
  .record-row {
    display: grid;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .sidebar nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .record-row {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .row-actions {
    grid-column: 1 / 3;
  }

  .search {
    max-width: none;
  }

  .log-row {
    grid-template-columns: 1fr;
  }

  .account-grid {
    grid-template-columns: 1fr;
  }

  .log-row code {
    grid-column: auto;
  }
}
