:root {
  --bg: #080c14;
  --surface: #0f1623;
  --surface-2: #161f31;
  --border: rgba(255, 255, 255, 0.08);
  --border-hi: rgba(255, 255, 255, 0.16);
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.14);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.14);
  --blue: #3b82f6;
  --blue-soft: rgba(59, 130, 246, 0.15);
  --accent: #10b981;
  --radius: 14px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.num, .kpi-value, .mini-stat, .curr-btn {
  font-variant-numeric: tabular-nums;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(8, 12, 20, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.brand-logo {
  display: block;
  border-radius: 9px;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.22);
}

.fx-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}

.show-sm-only { display: none; }

.brand-text {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.brand-title {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

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

.status-pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

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

.curr-switch {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: 9px;
  padding: 2px;
}

.curr-btn {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 7px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.curr-btn.active {
  background: var(--green);
  color: #041b11;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 13px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--green);
  color: #041b11;
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--border-hi);
}

.btn-sm { padding: 5px 9px; font-size: 12px; border-radius: 7px; }
.btn-xs { padding: 4px 8px; font-size: 11px; border-radius: 6px; }
.btn-icon { padding: 7px 10px; }
.btn-full { width: 100%; padding: 10px 14px; }

.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Main Layout */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.highlight-card {
  background: linear-gradient(155deg, rgba(16, 185, 129, 0.08), var(--surface) 60%);
  border-color: rgba(16, 185, 129, 0.25);
}

.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.green-text { color: var(--green); }
.pos { color: var(--green); }
.neg { color: var(--red); }

.kpi-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

.kpi-badge, .kpi-delta {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-dim);
}

.kpi-badge.pos-badge,
.kpi-delta.pos { background: var(--green-soft); color: var(--green); }
.kpi-delta.neg { background: var(--red-soft); color: var(--red); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.alert-card {
  border-color: rgba(245, 158, 11, 0.4);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.08), var(--surface));
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.card-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.select-sm {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 9px;
  font-size: 12px;
  font-family: inherit;
}

/* Chart Card */
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.chart-controls-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.seg-group {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 2px;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--text-dim);
  padding: 5px 11px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--surface-2);
  color: var(--text);
}

.chart-stats-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-stat {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 4px 8px;
}

.chart-box {
  position: relative;
  height: 270px;
  width: 100%;
}

.legend-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.legend-pill.dim { opacity: 0.38; }
.legend-pill .swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Desktop Table */
.table-wrap { overflow-x: auto; }
.svc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.svc-table th {
  text-align: left;
  padding: 9px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.svc-table th.num, .svc-table td.num { text-align: right; }
.svc-table th.center, .svc-table td.center { text-align: center; }

.svc-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.svc-table tr:last-child td { border-bottom: none; }
.svc-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

.svc-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.svc-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.svc-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.svc-meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

.svc-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s ease;
}

.svc-link:hover {
  color: var(--green);
}

.svc-link .ext-ind {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.65;
  transition: transform 0.15s ease, opacity 0.15s ease, color 0.15s ease;
}

.svc-link:hover .ext-ind {
  color: var(--green);
  opacity: 1;
  transform: translate(1px, -1px);
}

.pot-inline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(245, 158, 11, 0.28);
  background: var(--amber-soft);
  color: #fbbf24;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, filter 0.15s ease;
}

.pot-inline:hover {
  border-color: rgba(245, 158, 11, 0.55);
  filter: brightness(1.08);
}

.pot-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
}

.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--text-dim);
}
.tag.ok { background: var(--green-soft); color: var(--green); }
.tag.warn { background: var(--amber-soft); color: var(--amber); }
.tag.err { background: var(--red-soft); color: var(--red); }

.sub-val {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Progress bars */
.bar-track {
  width: 100%;
  height: 6px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--blue);
}
.bar-fill.green { background: var(--green); }
.bar-fill.amber { background: var(--amber); }
.bar-fill.red { background: var(--red); }

.payout-cell { min-width: 155px; }
.payout-top {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 600;
  margin-bottom: 4px;
}

.action-row {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Mobile Service Cards */
.mobile-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.m-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.m-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.m-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 10px;
}

.m-metric-lbl {
  font-size: 10.5px;
  color: var(--text-muted);
}

.m-metric-val {
  font-size: 12.5px;
  font-weight: 700;
  margin-top: 1px;
}

.m-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mobile-only { display: none; }
.desktop-only { display: block; }

@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-value { font-size: 21px; }
  .desktop-only { display: none; }
  .mobile-only { display: flex; }
  .hide-sm { display: none; }
  .show-sm-only { display: inline; }
  .chart-box { height: 230px; }
  .fx-pill { padding: 4px 7px; font-size: 11px; }
  .curr-btn { padding: 5px 8px; }
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(3, 6, 12, 0.78);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: 16px;
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-lg { max-width: 820px; }

.modal-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.modal-head-actions { display: flex; align-items: center; gap: 8px; }

.btn-close {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.log-terminal {
  margin: 0;
  background: #05080e;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  color: #cbd5e1;
  max-height: 60vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.field-label input, .field-label select {
  background: var(--bg);
  border: 1px solid var(--border-hi);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 13px;
}

.field-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.info-note, .test-box {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.test-box.ok { background: var(--green-soft); color: var(--green); border-color: rgba(16, 185, 129, 0.35); }
.test-box.err { background: var(--red-soft); color: var(--red); border-color: rgba(239, 68, 68, 0.35); }

.pot-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.pot-table th, .pot-table td {
  padding: 7px 6px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.pot-table th { color: var(--text-muted); font-size: 11px; }

.pending-list { display: flex; flex-direction: column; gap: 8px; }
.pending-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

/* Toasts */
.toast-root {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.toast.ok { border-color: rgba(16, 185, 129, 0.5); }
.toast.err { border-color: rgba(239, 68, 68, 0.5); }

/* Login Page */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(circle at top, rgba(16, 185, 129, 0.1), var(--bg) 55%);
}
.login-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: 18px;
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand h1 { margin: 0; font-size: 20px; font-weight: 800; }
.login-brand p { margin: 2px 0 0; font-size: 12px; color: var(--text-muted); }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.alert-error {
  background: var(--red-soft);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12.5px;
}
