/* Dollar Printer admin console. Dependency-free: no framework, no CDN. */

:root {
  --bg: #0a0d12;
  --bg-panel: #10151d;
  --bg-raised: #161d27;
  --bg-hover: #1b2330;
  --border: #212b38;
  --border-strong: #2e3a4a;
  --text: #e9eff6;
  --text-muted: #93a1b3;
  --text-dim: #66748a;
  /* Brand blue from the app (AppColors.primary = Color(0xFF0047FF)). On these
     dark panels #0047FF only reaches ~3.1:1, so --accent is the app's own
     dark-theme primary and --brand is the true brand fill behind white text. */
  --accent: #3d6bff;
  --brand: #0047ff;
  --accent-dim: #0030a4;
  --accent-soft: rgba(61, 107, 255, 0.16);
  --on-accent: #ffffff;
  --warn: #f5b544;
  --warn-soft: rgba(245, 181, 68, 0.13);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.13);
  --info: #6aa9ff;
  --info-soft: rgba(106, 169, 255, 0.13);
  --radius: 11px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; letter-spacing: -0.02em; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

/* ---------- login ---------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 400px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 34px;
}
.login-logo { display: flex; align-items: center; gap: 11px; margin-bottom: 26px; font-weight: 700; font-size: 17px; }
.logo-mark {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center; flex: none;
  overflow: hidden;
}
/* The app icon carries its own outer padding, which reads as an empty blue
   tile at nav size. Scaling past the box (with overflow hidden on the
   parent) crops that margin so the mark itself fills the space. */
.logo-mark img { width: 100%; height: 100%; display: block; transform: scale(1.16); }

/* ---------- layout ---------- */

.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .login-logo { margin-bottom: 22px; padding-inline: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 9px;
  color: var(--text-muted); font-size: 14.5px; font-weight: 500;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  font-family: inherit;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; flex: none; font-size: 15px; }
.sidebar-foot { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--border); }
.who { padding: 4px 12px 12px; font-size: 12.5px; color: var(--text-dim); word-break: break-all; }

main { padding: 26px 30px 70px; min-width: 0; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 24px;
}
.page-head p { color: var(--text-muted); margin: 5px 0 0; font-size: 14px; max-width: 70ch; }

/* ---------- controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 9px;
  font-size: 14px; font-weight: 600; font-family: inherit;
  border: 1px solid transparent; cursor: pointer;
  transition: background .15s ease, border-color .15s ease, opacity .15s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent); }
.btn-ghost { background: var(--bg-raised); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); }
.btn-danger { background: var(--danger-soft); border-color: rgba(255,107,107,.35); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: rgba(255,107,107,.22); }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; padding: 10px 13px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 9px;
  font-family: inherit; font-size: 14.5px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 92px; }
.field { margin-bottom: 15px; }
.field-hint { font-size: 12.5px; color: var(--text-dim); margin-top: 5px; }
.row { display: flex; gap: 11px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 150px; }
.row > .btn { flex: none; }

/* ---------- panels & tables ---------- */

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 22px;
}
.panel-head {
  padding: 15px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
}
.panel-body { padding: 18px; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; padding: 11px 16px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-dim); background: var(--bg-raised);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
.num { font-family: var(--mono); font-size: 13px; }
.nowrap { white-space: nowrap; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); font-size: 13px; }

/* ---------- KPIs ---------- */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 17px 19px;
}
.kpi-label { font-size: 12.5px; color: var(--text-dim); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.kpi-value { font-size: 28px; font-weight: 750; letter-spacing: -.03em; margin-top: 7px; line-height: 1.1; }
.kpi-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 5px; }
.kpi.accent .kpi-value { color: var(--accent); }
.kpi.warn .kpi-value { color: var(--warn); }

/* ---------- badges ---------- */

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 6px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap;
}
.badge-ok { background: rgba(52,211,153,.15); color: #34d399; }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-idle { background: var(--bg-hover); color: var(--text-dim); }

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4, 6, 10, .72);
  display: grid; place-items: center; padding: 20px;
}
.modal {
  width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
  background: var(--bg-panel); border: 1px solid var(--border-strong);
  border-radius: 15px; padding: 26px;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
}
.modal h2 { margin-bottom: 4px; }
.modal .sub { color: var(--text-muted); font-size: 13.5px; margin: 0 0 20px; }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.modal-actions .btn { flex: 1; }

/* ---------- toast ---------- */

.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: grid; gap: 10px; max-width: 380px; }
.toast {
  background: var(--bg-raised); border: 1px solid var(--border-strong);
  border-left-width: 3px; border-radius: 10px; padding: 13px 17px;
  font-size: 14px; box-shadow: 0 10px 34px rgba(0,0,0,.45);
  animation: slide .22s ease;
}
.toast.ok { border-left-color: #34d399; }
.toast.err { border-left-color: var(--danger); }
@keyframes slide { from { opacity: 0; transform: translateX(14px); } }

/* ---------- misc ---------- */

.empty { padding: 44px 20px; text-align: center; color: var(--text-dim); }
.error-box {
  background: var(--danger-soft); border: 1px solid rgba(255,107,107,.3);
  color: var(--danger); border-radius: 9px; padding: 11px 14px; font-size: 13.5px; margin-bottom: 15px;
}
.warn-box {
  background: var(--warn-soft); border: 1px solid rgba(245,181,68,.3);
  color: var(--warn); border-radius: 9px; padding: 13px 16px; font-size: 13.5px; margin-bottom: 18px;
}
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,.25); border-top-color: currentColor;
  animation: spin .6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 13px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--bg-raised); border: 1px solid var(--border-strong);
  color: var(--text-muted); cursor: pointer; font-family: inherit;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.search { max-width: 300px; }
.cell-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- payments ---------- */

.src-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
@media (min-width: 1300px) { .src-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.src-card { display: flex; flex-direction: column; }
.src-head { display: flex; align-items: center; gap: 11px; }
.src-head .dim { font-size: 12px; }
.src-ico {
  width: 34px; height: 34px; border-radius: 9px; flex: none; display: grid; place-items: center;
  font-size: 11px; font-weight: 800; letter-spacing: .02em; color: #fff;
}
.src-apple { background: #2c2c2e; border: 1px solid var(--border-strong); }
.src-google { background: #1f7a4d; }
.src-nowpayments { background: var(--brand); }
.src-cash { background: #8a6d1f; }
.share { margin-top: auto; padding-top: 12px; }
.share i { display: block; height: 4px; border-radius: 2px; background: var(--accent); }
.net-line {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 10px;
  padding: 7px 10px; border-radius: 8px; background: rgba(52,211,153,.09); font-size: 12.5px; color: var(--text-muted);
}
.net-line strong { color: #34d399; font-size: 15px; font-family: var(--mono); white-space: nowrap; }
.note { color: var(--text-muted); font-size: 13.5px; margin: -6px 0 22px; max-width: 110ch; }

/* ---------- monitoring ---------- */

.head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tabs {
  display: flex; gap: 4px; margin: -6px 0 20px; border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.tab {
  padding: 10px 14px; border: none; background: none; cursor: pointer; font-family: inherit;
  font-size: 14px; font-weight: 600; color: var(--text-muted); white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.kpi.bad .kpi-value { color: var(--danger); }
.kpis-6 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
@media (min-width: 1300px) { .kpis-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.kpi-unit { font-size: 15px; font-weight: 600; color: var(--text-muted); margin-left: 3px; letter-spacing: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 0 22px; }
.r { text-align: right; }
th.r { text-align: right; }
.warn-text { color: var(--warn); }
.method {
  display: inline-block; min-width: 46px; font-family: var(--mono); font-size: 11.5px; font-weight: 700;
  color: var(--text-muted); letter-spacing: .03em;
}
.path { font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.call-cell { display: flex; align-items: baseline; gap: 8px; min-width: 300px; }
.call-cell .method { flex: none; }
.clip { max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.err-cell { color: var(--warn); font-size: 13px; min-width: 180px; max-width: 360px; }
tr.row-bad td:first-child { box-shadow: inset 3px 0 0 var(--danger); }

.ip-link {
  font-family: var(--mono); font-size: 13px; color: var(--accent); background: none; border: none;
  padding: 0; cursor: pointer; text-align: left;
}
.ip-link:hover { text-decoration: underline; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; flex: 1; min-width: 0; }
.toolbar .search { flex: 1 1 220px; }
.toolbar .ip-input { flex: 0 1 190px; font-family: var(--mono); font-size: 13.5px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.pill button {
  border: none; background: none; color: inherit; cursor: pointer; font-size: 16px; line-height: 1;
  width: 22px; height: 22px; border-radius: 50%;
}
.pill button:hover { background: rgba(61,107,255,.2); }
.panel-foot { padding: 12px 18px; border-top: 1px solid var(--border); text-align: center; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw-ok, .seg-ok { background: var(--accent); }
.sw-warn, .seg-warn { background: var(--warn); }
.sw-bad, .seg-bad { background: var(--danger); }

.bars-wrap { display: flex; gap: 10px; height: 200px; }
.bars-axis {
  display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end;
  font-family: var(--mono); font-size: 11px; color: var(--text-dim); min-width: 28px;
}
.bars {
  flex: 1; display: flex; align-items: flex-end; gap: 2px; min-width: 0;
  border-bottom: 1px solid var(--border-strong);
  background-image: linear-gradient(var(--border) 1px, transparent 1px);
  background-size: 100% 50%;
}
.bar {
  flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end;
  border-radius: 3px 3px 0 0; overflow: hidden; min-width: 2px; cursor: default;
}
.bar:hover { background: var(--bg-hover); }
.seg { display: block; width: 100%; flex: none; }
.bars-x {
  display: flex; justify-content: space-between; margin: 8px 0 0 38px;
  font-family: var(--mono); font-size: 11px; color: var(--text-dim);
}

.log-list { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.log-list li {
  display: grid; grid-template-columns: 150px 64px minmax(0, 1fr); gap: 12px; align-items: start;
  padding: 10px 18px; border-bottom: 1px solid var(--border);
}
.log-list li:last-child { border-bottom: none; }
.log-list li:hover { background: var(--bg-hover); }
.log-list li.log-error, .log-list li.log-fatal { box-shadow: inset 3px 0 0 var(--danger); }
.log-list li.log-warn { box-shadow: inset 3px 0 0 var(--warn); }
.log-time { font-family: var(--mono); font-size: 12px; padding-top: 2px; }
.log-list .badge { justify-self: start; }
.log-text { min-width: 0; }
.log-ctx { font-family: var(--mono); font-size: 12px; color: var(--accent); margin-right: 8px; }
.log-msg { font-family: var(--mono); font-size: 12.5px; word-break: break-word; white-space: pre-wrap; }
.log-text details { margin-top: 6px; }
.log-text summary { cursor: pointer; color: var(--text-dim); font-size: 12.5px; }
.log-text pre {
  margin: 8px 0 0; padding: 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; overflow-x: auto; font-size: 12px; color: var(--text-muted);
}

@media (max-width: 860px) {
  .log-list li { grid-template-columns: 1fr auto; gap: 6px 10px; padding: 10px 14px; }
  .log-list .log-text { grid-column: 1 / -1; }
  .bars-wrap { height: 160px; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap;
    border-right: none; border-bottom: 1px solid var(--border); padding: 12px;
  }
  .sidebar .login-logo { width: 100%; margin-bottom: 10px; }
  .nav-item { width: auto; }
  .sidebar-foot { margin: 0; padding: 0; border: none; width: 100%; }
  .who { display: none; }
  main { padding: 20px 16px 60px; }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Dev environment marker (admin.dev.dollar-printer.com only, see app.js). */
.env-badge {
  position: fixed;
  left: 10px;
  bottom: 10px;
  z-index: 2147483647;
  padding: 3px 9px;
  border-radius: 999px;
  background: #f59e0b;
  color: #1a1200;
  font: 700 11px/1.4 system-ui, sans-serif;
  letter-spacing: 0.08em;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
