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

* { box-sizing: border-box; }

body {
  background:
    radial-gradient(circle at 20% -10%, rgba(94, 106, 210, 0.2), transparent 32%),
    radial-gradient(circle at 95% 5%, rgba(34, 197, 94, 0.08), transparent 26%),
    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; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(24px, 3vw, 34px); letter-spacing: 0; line-height: 1.05; }
h2 { font-size: 18px; line-height: 1.2; }
h3 { font-size: 14px; margin-top: 14px; }
small { color: var(--muted); }

.hidden { display: none !important; }
.muted-copy { color: var(--muted); line-height: 1.6; }
.eyebrow { color: var(--accent-2); font-size: 11px; font-weight: 900; letter-spacing: 0.08em; margin-bottom: 6px; text-transform: uppercase; }

.admin-shell { min-height: 100vh; }

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

.login-card {
  background: rgba(11, 11, 16, 0.88);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  max-width: 460px;
  padding: 28px;
  width: 100%;
}

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

.brand-logo-small {
  border-radius: 10px;
  height: 38px;
  width: 38px;
}

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

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

.sidebar {
  background: rgba(8, 7, 16, 0.92);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  align-items: center;
  display: flex;
  gap: 12px;
  padding-bottom: 14px;
}

.sidebar-brand span { color: var(--muted); display: block; font-size: 12px; margin-top: 2px; }

.nav-list { display: grid; gap: 6px; }
.nav-item {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  min-height: 42px;
  padding: 0 12px;
  text-align: left;
}
.nav-item:hover, .nav-item.active {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 14px;
}

.connection {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.connection.ok { color: var(--green); }
.connection.warn { color: var(--amber); }
.connection.bad { color: var(--red); }

.main-content {
  display: grid;
  gap: 18px;
  padding: 22px;
}

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

.topbar-actions, .segmented, .history-actions, .surge-control {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.view { display: grid; gap: 18px; }

.panel, .kpi-card {
  background: rgba(11, 11, 16, 0.9);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-head {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 16px;
}
.panel-head p, .review-head p, .chat-head p, .empty-review p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.panel-head > select { flex-shrink: 0; width: auto; min-width: 190px; }

.button {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  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(--accent), #7c86e8); border-color: transparent; color: white; }
.button.success { background: var(--green-soft); border-color: rgba(34, 197, 94, 0.24); color: var(--green); }
.button.danger { background: var(--red-soft); border-color: rgba(244, 63, 94, 0.24); color: var(--red); }
.button.ghost { background: transparent; }
.button.small { min-height: 34px; padding: 0 10px; }
.button.full { width: 100%; }
.button.active, .history-filter.active { background: var(--accent-soft); border-color: rgba(94, 106, 210, 0.36); color: #cdd1ff; }

.field { display: grid; gap: 7px; }
.field span { color: var(--muted); font-size: 12px; font-weight: 900; }
input, select {
  background: var(--surface-2);
  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(--accent); box-shadow: 0 0 0 3px rgba(94, 106, 210, 0.16); }

.kpi-grid { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-card { display: grid; gap: 8px; min-height: 118px; padding: 16px; }
.kpi-card span { color: var(--muted); font-size: 12px; font-weight: 900; }
.kpi-card strong { font-size: 22px; line-height: 1.1; }
.kpi-icon {
  align-items: center;
  background: var(--accent-soft);
  border: 1px solid rgba(94, 106, 210, 0.24);
  border-radius: 10px;
  color: var(--accent-2);
  display: flex;
  height: 32px;
  justify-content: center;
  width: 32px;
}

.analytics-grid { display: grid; gap: 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

.chart {
  align-items: end;
  display: flex;
  gap: 14px;
  height: 260px;
  padding: 18px;
}
.chart.compact { height: 220px; }
.bar-item { align-items: center; display: grid; flex: 1; gap: 8px; min-width: 0; text-align: center; }
.bar-track { align-items: end; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; display: flex; height: 160px; overflow: hidden; }
.bar-fill { background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-radius: 8px 8px 0 0; width: 100%; }
.bar-item span { color: var(--text); font-size: 12px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-item small { font-size: 11px; }

.donut-wrap { align-items: center; display: grid; gap: 18px; justify-items: center; padding: 24px; }
.donut {
  --pct: 70;
  align-items: center;
  background: conic-gradient(var(--green) calc(var(--pct) * 1%), var(--red) 0);
  border-radius: 50%;
  display: grid;
  height: 164px;
  justify-items: center;
  place-content: center;
  position: relative;
  width: 164px;
}
.donut::after { background: var(--surface); border-radius: 50%; content: ""; height: 118px; position: absolute; width: 118px; }
.donut strong, .donut span { position: relative; z-index: 1; }
.donut strong { font-size: 28px; }
.ratio-meta { display: grid; gap: 8px; }
.dot { border-radius: 50%; display: inline-block; height: 9px; margin-right: 8px; width: 9px; }
.dot.green { background: var(--green); }
.dot.red { background: var(--red); }

.workspace { align-items: start; display: grid; gap: 18px; grid-template-columns: minmax(320px, 410px) minmax(0, 1fr); }
.queue-list { display: grid; gap: 8px; padding: 12px; }
.queue-row {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  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(--accent); box-shadow: 0 0 0 3px rgba(94, 106, 210, 0.12); }
.avatar {
  align-items: center;
  background: var(--accent-soft);
  border: 1px solid rgba(94, 106, 210, 0.24);
  border-radius: 22px;
  color: var(--accent-2);
  display: flex;
  font-size: 13px;
  font-weight: 900;
  height: 44px;
  justify-content: center;
  width: 44px;
}
.avatar.large { height: 58px; width: 58px; }
.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; }

.review-panel { padding: 18px; }
.empty-review, .empty-state { color: var(--muted); padding: 30px; text-align: center; }
.review-content { display: grid; gap: 12px; }
.review-head, .chat-head, .decision-row, .row-between {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.badge {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 11px;
  font-weight: 900;
  min-height: 28px;
  padding: 5px 10px;
  text-transform: capitalize;
  white-space: nowrap;
}
.badge.ok { background: var(--green-soft); border-color: rgba(34, 197, 94, 0.24); color: var(--green); }
.badge.warn { background: var(--amber-soft); border-color: rgba(245, 158, 11, 0.24); color: var(--amber); }
.badge.bad { background: var(--red-soft); border-color: rgba(244, 63, 94, 0.24); color: var(--red); }

.detail-grid { display: grid; gap: 10px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.compact-grid { margin-top: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.detail { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.detail span { color: var(--muted); display: block; font-size: 10px; font-weight: 900; margin-bottom: 5px; text-transform: uppercase; }
.detail strong { font-size: 14px; }

.cards-list, .uploads-list { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mini-card, .upload-item, .profile-card, .kyc-review, .log-row {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}
.mini-card strong, .upload-item strong { display: block; font-size: 14px; margin-bottom: 5px; }
.mini-card span, .upload-item span { color: var(--muted); display: block; font-size: 12px; line-height: 1.4; }

.chat-section { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.chat-head { background: var(--surface-2); 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(--surface-2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); line-height: 1.45; padding: 10px 12px; }
.agent .bubble { background: var(--accent-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; }
.compact-actions { border-top: 0; }

.history-list { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px; }
.history-row { align-items: center; background: var(--surface-2); 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-soft); color: var(--green); }
.history-status.rejected { background: var(--red-soft); color: var(--red); }
.history-title { align-items: center; display: flex; gap: 8px; margin-bottom: 4px; }
.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; }

.table-wrap { overflow-x: auto; padding: 12px; }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid var(--border); padding: 12px; text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 11px; font-weight: 900; text-transform: uppercase; }
td small { display: block; margin-top: 4px; }
tr.selected, tbody tr:hover { background: rgba(94, 106, 210, 0.08); }
.rate-input { min-width: 92px; }

.split-grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr); }
.table-tools { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr) 180px; padding: 12px; }
.pagination { align-items: center; display: flex; gap: 10px; justify-content: flex-end; padding: 12px; }
.profile-card { align-items: center; display: flex; gap: 14px; margin: 12px; }
.kyc-review { display: grid; gap: 10px; margin: 12px; }
.kyc-review p { color: var(--muted); line-height: 1.5; }

.logs-list { display: grid; gap: 8px; padding: 12px; }
.log-row { display: grid; gap: 4px; grid-template-columns: 72px 160px minmax(0, 1fr); }
.log-row span { color: var(--faint); font-size: 12px; font-weight: 800; }
.log-row p { color: var(--muted); font-size: 13px; }

.rate-form { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; padding: 12px; }
.rate-form .button { align-self: end; }

.queue-panel .queue-list { max-height: 640px; overflow-y: auto; }
.kyc-row, .dispute-row, .ticket-row {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 12px;
}
.kyc-row, .dispute-row { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.ticket-row { text-align: left; width: 100%; }
.ticket-row:hover, .ticket-row.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(94, 106, 210, 0.12); }
.row-actions { align-items: center; display: flex; gap: 8px; }
.resolve-form { display: grid; gap: 8px; grid-template-columns: 160px minmax(0, 1fr) auto; }

.skeleton-row { animation: pulse 1.2s ease-in-out infinite; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); border-radius: 8px; height: 72px; }
@keyframes pulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }

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

@media (max-width: 1180px) {
  .dashboard { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; }
  .nav-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpi-grid, .analytics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: span 2; }
  .workspace, .split-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .main-content, .sidebar { padding: 14px; }
  .topbar, .panel-head, .review-head, .decision-row { align-items: stretch; flex-direction: column; }
  .nav-list, .kpi-grid, .analytics-grid, .detail-grid, .cards-list, .uploads-list, .history-list, .table-tools, .rate-form, .resolve-form { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .queue-row, .history-row, .log-row, .kyc-row, .dispute-row { grid-template-columns: 1fr; }
  .history-money { text-align: left; }
  .chart { overflow-x: auto; }
  .bar-item { min-width: 72px; }
}
