@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* Light theme (default) - same brand accents as the dark theme below, just
   swapped structural tokens (bg/panel/border/text). Mirrors the palette
   already used on the customer-facing /pay pages (pay.css). */
:root {
  --bg: #eef0f4;
  --bg-raised: #ffffff;
  --panel: #ffffff;
  --panel-2: #f6f7fa;
  --border: #e3e6ec;
  --border-soft: #ececf1;
  --text: #10151f;
  --text-dim: #5b6577;
  --text-faint: #9aa3b2;

  --mint: #0f9d70;
  --mint-soft: rgba(15, 157, 112, 0.12);
  --amber: #b8790a;
  --amber-soft: rgba(184, 121, 10, 0.12);
  --red: #c8371f;
  --red-soft: rgba(200, 55, 31, 0.12);
  --blue: #2f6fd6;
  --blue-soft: rgba(47, 111, 214, 0.12);
  --purple: #8b4fd6;
  --purple-soft: rgba(139, 79, 214, 0.12);
  --slate-soft: rgba(91, 101, 119, 0.1);

  --radius: 12px;
  --shadow-card: 0 1px 2px rgba(16,21,31,0.04), 0 12px 28px rgba(16,21,31,0.08);
  --grid-line: rgba(16,21,31,0.035);
}

/* Dark theme - identical to what this dashboard looked like before the
   toggle was added. Applied via data-theme="dark" on <html>. */
:root[data-theme='dark'] {
  --bg: #0a0e17;
  --bg-raised: #10141f;
  --panel: #131826;
  --panel-2: #171d2c;
  --border: #232a3b;
  --border-soft: #1a2032;
  --text: #eef1f7;
  --text-dim: #9aa3b8;
  --text-faint: #626b82;

  --mint: #16c98d;
  --mint-soft: rgba(22, 201, 141, 0.12);
  --amber: #f2b13e;
  --amber-soft: rgba(242, 177, 62, 0.12);
  --red: #f0584f;
  --red-soft: rgba(240, 88, 79, 0.12);
  --blue: #4f8cf0;
  --blue-soft: rgba(79, 140, 240, 0.12);
  --purple: #a06bf0;
  --purple-soft: rgba(160, 107, 240, 0.12);
  --slate-soft: rgba(154, 163, 184, 0.12);

  --shadow-card: 0 1px 2px rgba(0,0,0,0.2), 0 12px 28px rgba(0,0,0,0.35);
  --grid-line: rgba(255,255,255,0.03);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

h1, h2, h3 { font-family: 'Space Grotesk', 'Inter', sans-serif; margin: 0; letter-spacing: -0.01em; }

.mono, .amount, .id-cell, code {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

a { color: inherit; }
button { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--mint);
  outline-offset: 2px;
}

/* ---------------- Layout shell ---------------- */

.app-shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-raised);
  border-right: 1px solid var(--border-soft);
  color: var(--text);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sidebar .brand {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 6px;
}

.sidebar .brand .mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--mint), #0e8f66);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #08130e;
  font-weight: 700;
}

.balance-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 15px;
}
.balance-card .label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  font-weight: 600;
  margin-bottom: 6px;
}
.balance-card .value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
}

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar nav button {
  all: unset;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 500;
  border-left: 2px solid transparent;
}

.sidebar nav button:hover { color: var(--text); background: var(--panel-2); }
.sidebar nav button.active {
  color: var(--mint);
  background: var(--mint-soft);
  border-left: 2px solid var(--mint);
}

.sidebar .spacer { flex: 1; }

.sidebar .signed-in {
  font-size: 12px;
  color: var(--text-faint);
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
}

.sidebar .signed-in strong { display: block; color: var(--text-dim); font-weight: 500; margin-bottom: 8px; word-break: break-all; }

.sidebar .signed-in button {
  all: unset;
  cursor: pointer;
  color: var(--red);
  font-size: 12.5px;
  font-weight: 600;
}

.main {
  padding: 26px 36px 64px;
  max-width: 1280px;
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 22px;
}

.page-header h1 { font-size: 21px; }
.page-header p { color: var(--text-dim); margin: 4px 0 0; font-size: 13px; }

/* ---------------- Stat cards ---------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 26px;
}

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

.stat-card .label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 600;
  margin-bottom: 8px;
}

.stat-card .value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 21px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.stat-card.volume { border-color: rgba(22,201,141,0.35); }
.stat-card.volume .value { color: var(--mint); }

/* ---------------- Cards & panels ---------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 20px;
  margin-bottom: 22px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel h2 { font-size: 15px; margin-bottom: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.field input, .field select, .field textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: inherit;
  background: var(--panel-2);
  color: var(--text);
}
.field textarea { resize: vertical; min-height: 60px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--mint); }
.field .hint { font-size: 11.5px; color: var(--text-faint); font-weight: 400; text-transform: none; letter-spacing: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, opacity 0.12s ease;
}
.btn-primary { background: var(--mint); color: #06150f; }
.btn-primary:hover { background: #22e0a2; }
.btn-primary:disabled { background: var(--border); color: var(--text-faint); cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid rgba(240,88,79,0.4); }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-icon {
  all: unset; cursor: pointer; width: 30px; height: 30px; display: inline-flex;
  align-items: center; justify-content: center; border-radius: 7px; color: var(--text-faint);
}
.btn-icon:hover { background: var(--panel-2); color: var(--text); }

/* ---------------- Status pills ---------------- */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 7px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: capitalize;
}
.status-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.status-pending { background: var(--amber-soft); color: var(--amber); }
.status-pending::before { background: var(--amber); }
.status-processing { background: var(--blue-soft); color: var(--blue); }
.status-processing::before { background: var(--blue); }
.status-paid { background: var(--mint-soft); color: var(--mint); }
.status-paid::before { background: var(--mint); }
.status-failed { background: var(--red-soft); color: var(--red); }
.status-failed::before { background: var(--red); }
.status-expired, .status-cancelled { background: var(--slate-soft); color: var(--text-dim); }
.status-expired::before, .status-cancelled::before { background: var(--text-dim); }
.status-refunded { background: var(--purple-soft); color: var(--purple); }
.status-refunded::before { background: var(--purple); }

/* ---------------- Public-link badge (which link a transaction came through) ---------------- */

.link-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 7px;
  border-radius: 100px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 600;
}
.link-badge.direct { background: var(--slate-soft); color: var(--text-dim); }
.link-badge .glyph { font-size: 10px; }
.txn-id-sub { display: block; margin-top: 4px; font-size: 10.5px; color: var(--text-faint); }

/* ---------------- Tag chips (payment methods / preset amounts) ---------------- */

.chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  color: var(--text-dim);
  background: var(--panel-2);
  border-radius: 7px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 500;
  margin: 2px 4px 2px 0;
}
.chip.mono { font-family: 'IBM Plex Mono', monospace; }
.chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0; max-width: 220px; }

/* ---------------- Table ---------------- */

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  font-size: 13px;
  color: var(--text);
}
tbody tr:hover { background: var(--panel-2); cursor: pointer; }
tbody tr:last-child td { border-bottom: none; }
.link-name { font-weight: 600; }
.link-url { color: var(--mint); font-family: 'IBM Plex Mono', monospace; font-size: 12px; }

.table-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.table-toolbar input[type="search"], .table-toolbar select, .table-toolbar input[type="date"] {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  background: var(--panel-2);
  color: var(--text);
}
.table-toolbar input[type="search"] { min-width: 220px; }

.empty-state { text-align: center; padding: 48px 16px; color: var(--text-faint); }
.empty-state .glyph { font-size: 28px; margin-bottom: 10px; }

/* ---------------- Honest "not supported / not configured" notices ---------------- */

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-dim);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12.5px;
  margin-bottom: 18px;
}
.notice.amber { border-color: rgba(242,177,62,0.35); background: var(--amber-soft); color: var(--amber); }
.notice .glyph { flex-shrink: 0; }

/* ---------------- Payment method checkbox grid ---------------- */

.method-checks { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.method-check {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text-dim);
  border-radius: 7px; padding: 6px 10px; font-size: 12.5px; cursor: pointer; user-select: none;
}
.method-check input { accent-color: var(--mint); }
.method-check.checked { border-color: var(--mint); color: var(--text); }

/* ---------------- QR code ---------------- */

.qr-box { display: inline-flex; flex-direction: column; align-items: center; gap: 8px; background: #fff; border-radius: 10px; padding: 12px; }
.qr-box img { width: 140px; height: 140px; display: block; }

/* ---------------- Bar chart (daily pay-in) ---------------- */

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  padding: 8px 2px 0;
  border-bottom: 1px solid var(--border-soft);
}
.bar-chart .bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
}
.bar-chart .bar {
  width: 100%;
  max-width: 22px;
  background: var(--mint);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  cursor: default;
}
.bar-chart .bar.zero { background: var(--border); }
.bar-chart .bar-label {
  font-size: 9px;
  color: var(--text-faint);
  margin-top: 6px;
  white-space: nowrap;
  transform: rotate(0deg);
}

/* ---------------- Line chart (daily sales, link detail page) ---------------- */

.line-chart-wrap { padding-top: 6px; }
.line-chart { width: 100%; height: 180px; display: block; overflow: visible; }
.line-chart .area { fill: var(--mint-soft); stroke: none; }
.line-chart .line { fill: none; stroke: var(--mint); stroke-width: 2; }
.line-chart .point { fill: var(--bg-raised); stroke: var(--mint); stroke-width: 2; }
.line-chart .gridline { stroke: var(--border-soft); stroke-width: 1; }
.line-chart-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 10px;
  color: var(--text-faint);
}

/* ---------------- Report cards ---------------- */

.report-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 22px; }
.report-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.report-card .label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); font-weight: 600; margin-bottom: 8px; }
.report-card .value { font-family: 'IBM Plex Mono', monospace; font-size: 18px; font-weight: 500; color: var(--text); }
.report-card .sub { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; }

@media (max-width: 880px) {
  .report-grid { grid-template-columns: 1fr; }
}

/* ---------------- Link result card ---------------- */

.link-result {
  border: 1px solid rgba(22,201,141,0.4);
  background: var(--mint-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
}
.link-result .url { font-family: 'IBM Plex Mono', monospace; font-size: 13px; word-break: break-all; color: var(--mint); }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-card);
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.18s ease;
  pointer-events: none;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------------- Modal / drawer ---------------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  justify-content: flex-end;
  z-index: 50;
}
.hidden { display: none !important; }

.drawer {
  background: var(--bg-raised);
  border-left: 1px solid var(--border);
  width: 460px;
  max-width: 92vw;
  height: 100%;
  overflow-y: auto;
  padding: 26px;
  box-shadow: -8px 0 30px rgba(0,0,0,0.4);
}
.drawer .drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}
.drawer .close-btn { all: unset; cursor: pointer; color: var(--text-faint); font-size: 20px; line-height: 1; }
.drawer .close-btn:hover { color: var(--text); }

.kv-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.kv-row .k { color: var(--text-faint); }
.kv-row .v { font-weight: 500; text-align: right; color: var(--text); }

.tl-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; }
.tl-item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); margin-top: 5px; flex-shrink: 0; }
.tl-item .meta { color: var(--text-faint); font-size: 11px; margin-top: 2px; }

/* ---------------- Login page ---------------- */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 20% 20%, rgba(22,201,141,0.08), transparent 40%),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: auto, 28px 28px, 28px 28px;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 32px;
  width: 360px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
.login-card .brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 4px;
}
.login-card .brand .mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--mint), #0e8f66);
}
.login-card p.sub { color: var(--text-dim); font-size: 13px; margin: 4px 0 24px; }
.login-card .btn-primary { width: 100%; margin-top: 6px; }
.login-error {
  background: var(--red-soft);
  color: var(--red);
  font-size: 12.5px;
  padding: 9px 11px;
  border-radius: 7px;
  margin-bottom: 14px;
}

@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; padding: 14px 18px; }
  .sidebar nav { flex-direction: row; }
  .sidebar .spacer, .balance-card { display: none; }
  .sidebar .signed-in { display: none; }
  .main { padding: 18px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .drawer { width: 100%; }
}
