:root {
  color-scheme: dark;
  --bg: #050508;
  --panel: #0b0b10;
  --panel-strong: #12111a;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --muted: #8a8993;
  --faint: #5f5e68;
  --primary: #5e6ad2;
  --primary-dark: #4f58b8;
  --primary-soft: rgba(94, 106, 210, 0.14);
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.1);
  --amber: #f59e0b;
  --amber-bg: rgba(245, 158, 11, 0.1);
  --red: #f43f5e;
  --red-bg: rgba(244, 63, 94, 0.1);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  background:
    radial-gradient(circle at 22% -10%, rgba(94, 106, 210, 0.18), transparent 34%),
    radial-gradient(circle at 92% 6%, rgba(34, 197, 94, 0.08), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

.shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: 0 auto;
  max-width: 1440px;
  min-height: 100vh;
  padding: 22px;
}

.muted-copy { color: var(--muted); line-height: 1.6; }

.login-screen {
  align-items: center;
  display: flex;
  min-height: 100vh;
  justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  max-width: 440px;
  padding: 30px;
  width: 100%;
}

.brand-logo-large {
  border-radius: 14px;
  height: 60px;
  width: 60px;
}

.security-note {
  background: var(--primary-soft);
  border: 1px solid rgba(94, 106, 210, 0.25);
  border-radius: 8px;
  color: #cdd1ff;
  display: grid;
  gap: 4px;
  font-size: 13px;
  padding: 12px;
}

.button.full { width: 100%; }

.dashboard { display: flex; flex-direction: column; gap: 18px; }

.topbar-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; }

.topbar,
.settings-panel,
.stats-grid,
.workspace {
  width: 100%;
}

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

.brand-inline {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-bottom: 4px;
}

.brand-inline img {
  border-radius: 8px;
  height: 34px;
  width: 34px;
}

.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  font-size: 20px;
  line-height: 1.2;
}

h3 {
  font-size: 14px;
  margin-top: 18px;
}

.status-pill,
.badge {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  min-height: 32px;
  padding: 6px 12px;
  text-transform: capitalize;
  white-space: nowrap;
}

.status-pill.ok,
.badge.ok {
  background: var(--green-bg);
  border-color: rgba(34, 197, 94, 0.24);
  color: var(--green);
}

.status-pill.warn,
.badge.warn {
  background: var(--amber-bg);
  border-color: rgba(245, 158, 11, 0.24);
  color: var(--amber);
}

.status-pill.bad,
.badge.bad {
  background: var(--red-bg);
  border-color: rgba(244, 63, 94, 0.24);
  color: var(--red);
}

.settings-panel {
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  gap: 12px;
  padding: 14px;
}

.field {
  display: flex;
  flex: 0 0 280px;
  flex-direction: column;
  gap: 6px;
}

.field-grow {
  flex: 1;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.field span small {
  color: var(--faint);
  display: block;
  font-size: 11px;
  font-weight: 700;
  margin-top: 2px;
}

input,
select {
  background: var(--panel-strong);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  color: var(--text);
  min-height: 42px;
  outline: none;
  padding: 0 12px;
  width: 100%;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(94, 106, 210, 0.16);
}

.button {
  align-items: center;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font-weight: 900;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
}

.button:hover {
  border-color: var(--border-strong);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button.primary {
  background: linear-gradient(135deg, var(--primary), #7c86e8);
  border-color: transparent;
  color: #ffffff;
}

.button.primary:hover {
  background: var(--primary-dark);
}

.button.success {
  background: var(--green-bg);
  border-color: rgba(34, 197, 94, 0.24);
  color: var(--green);
}

.button.danger {
  background: var(--red-bg);
  border-color: rgba(244, 63, 94, 0.24);
  color: var(--red);
}

.button.small {
  min-height: 34px;
  padding: 0 10px;
}

.button.history-filter.active {
  background: var(--primary-soft);
  border-color: rgba(94, 106, 210, 0.38);
  color: #c9cdfd;
}

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

.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.stat span {
  display: block;
  font-size: 24px;
  font-weight: 900;
}

.stat small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.workspace {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
}

.queue-panel,
.review-panel,
.history-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.queue-panel,
.review-panel {
  min-height: 620px;
}

.panel-head,
.review-head,
.chat-head,
.decision-row {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.panel-head {
  border-bottom: 1px solid var(--border);
  padding: 16px;
}

.panel-head p,
.review-head p,
.chat-head p,
.empty-review p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

#queueCount,
#historyCount {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}

.queue-row {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 10px;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  padding: 12px;
  text-align: left;
}

.queue-row:hover,
.queue-row.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(94, 106, 210, 0.12);
}

.avatar {
  align-items: center;
  background: var(--primary-soft);
  border: 1px solid rgba(94, 106, 210, 0.24);
  border-radius: 22px;
  color: #c9cdfd;
  display: flex;
  font-size: 13px;
  font-weight: 900;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.queue-title {
  font-size: 14px;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-sub {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  margin-top: 3px;
}

.queue-meta {
  align-items: end;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.queue-wait {
  color: var(--faint);
  font-size: 12px;
  font-weight: 800;
}

.review-panel {
  padding: 18px;
}

.empty-review,
.empty-state {
  color: var(--muted);
  padding: 30px;
  text-align: center;
}

.review-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hidden {
  display: none !important;
}

.detail-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.detail {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.detail span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 900;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.detail strong {
  font-size: 15px;
}

.cards-list,
.uploads-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mini-card,
.upload-item {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.upload-item {
  align-items: center;
  display: flex;
  gap: 10px;
}

.upload-thumb {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  height: 48px;
  object-fit: cover;
  width: 48px;
}

.upload-thumb-placeholder {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  display: flex;
  flex-shrink: 0;
  font-size: 10px;
  height: 48px;
  justify-content: center;
  text-align: center;
  width: 48px;
}

.upload-info {
  min-width: 0;
}

.mini-card strong,
.upload-info strong {
  display: block;
  font-size: 14px;
  margin-bottom: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-card span,
.upload-info span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.4;
}

.lightbox {
  align-items: center;
  background: rgba(0, 0, 0, 0.85);
  cursor: zoom-out;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 30;
}

.lightbox img {
  border-radius: 8px;
  max-height: 100%;
  max-width: 100%;
}

.chat-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.chat-head {
  background: var(--panel-strong);
  border-bottom: 1px solid var(--border);
  padding: 12px;
}

.messages {
  background: #080710;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  min-height: 180px;
  overflow-y: auto;
  padding: 14px;
}

.message {
  align-self: flex-start;
  max-width: 78%;
}

.message.agent {
  align-self: flex-end;
}

.bubble {
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  line-height: 1.45;
  padding: 10px 12px;
}

.agent .bubble {
  background: var(--primary-soft);
  border-color: rgba(94, 106, 210, 0.26);
}

.message small {
  color: var(--faint);
  display: block;
  font-size: 11px;
  margin-top: 4px;
}

.chat-compose {
  border-top: 1px solid var(--border);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 12px;
}

.quick-actions {
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 12px 12px;
}

.decision-row {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 14px;
}

.decision-row select {
  flex: 1;
}

.history-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.history-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 12px;
}

.history-row {
  align-items: center;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  padding: 12px;
}

.history-status {
  align-items: center;
  border-radius: 14px;
  display: flex;
  font-weight: 900;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.history-status.approved {
  background: var(--green-bg);
  color: var(--green);
}

.history-status.rejected {
  background: var(--red-bg);
  color: var(--red);
}

.history-title {
  align-items: center;
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}

.history-title strong,
.history-money strong {
  font-size: 14px;
}

.history-main p,
.history-main small,
.history-money span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.4;
}

.history-money {
  text-align: right;
}

.toast {
  background: var(--panel-strong);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  bottom: 18px;
  color: #ffffff;
  font-weight: 900;
  left: 50%;
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  position: fixed;
  transform: translateX(-50%);
  z-index: 20;
}

@media (max-width: 980px) {
  .settings-panel,
  .workspace,
  .decision-row {
    grid-template-columns: 1fr;
  }

  .settings-panel,
  .decision-row {
    align-items: stretch;
    flex-direction: column;
  }

  .field {
    flex: 1;
  }

  .stats-grid,
  .detail-grid,
  .cards-list,
  .uploads-list,
  .history-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats-grid,
  .detail-grid,
  .cards-list,
  .uploads-list,
  .history-list {
    grid-template-columns: 1fr;
  }

  .queue-row,
  .history-row {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .queue-meta {
    align-items: start;
    grid-column: 2;
  }

  .history-money {
    grid-column: 2;
    text-align: left;
  }
}
