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

:root {
  color-scheme: dark;

  /* Palette */
  --bg:            #0a0a0f;
  --bg-elevated:   #0d0d14;
  --panel:         rgba(16, 16, 24, 0.86);
  --panel-solid:   #101018;
  --panel-soft:    rgba(255, 255, 255, 0.025);
  --line:          rgba(255, 255, 255, 0.075);
  --line-soft:     rgba(255, 255, 255, 0.055);
  --line-strong:   rgba(255, 255, 255, 0.12);
  --text:          #ededf7;
  --text-dim:      #c8c9db;
  --muted:         #9b9caf;
  --faint:         #646577;
  --violet:        #8b5cf6;
  --violet-2:      #a78bfa;
  --violet-dim:    rgba(139, 92, 246, 0.16);
  --green:         #2fd187;
  --green-bg:      rgba(47, 209, 135, 0.12);
  --red:           #ff5c72;
  --red-bg:        rgba(255, 92, 114, 0.12);
  --blue:          #5aa9ff;
  --blue-bg:       rgba(90, 169, 255, 0.13);
  --amber:         #f6c350;
  --amber-bg:      rgba(246, 195, 80, 0.14);
  --orange:        #ff8a3d;
  --orange-bg:     rgba(255, 138, 61, 0.14);
  --shadow:        0 16px 60px rgba(0, 0, 0, 0.45);
  --shadow-sm:     0 4px 16px rgba(0, 0, 0, 0.35);

  /* Legacy alias names (used by existing pages) */
  --border:        var(--line);
  --border-hover:  rgba(255, 255, 255, 0.16);
  --accent:        var(--violet);
  --accent-2:      var(--violet-2);
  --accent-glow:   var(--violet-dim);
  --good:          var(--green);
  --good-bg:       var(--green-bg);
  --bad:           var(--red);
  --bad-bg:        var(--red-bg);
  --warn:          var(--amber);
  --warn-bg:       var(--amber-bg);
  --panel-2:       rgba(14, 14, 22, 0.92);
  --panel-hover:   rgba(25, 25, 38, 0.95);

  --radius:    12px;
  --radius-sm: 9px;
  --sidebar-width: 218px;
  --sidebar-collapsed-width: 58px;

  --font: 'Space Grotesk', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: 'SFMono-Regular', 'Cascadia Code', 'Roboto Mono', Menlo, Consolas, monospace;

  font-family: var(--font);
  font-size: 13px;
}

/* ── Light theme overrides ── */
[data-theme="light"] {
  color-scheme: light;
  --bg:            #f4f5f7;
  --bg-elevated:   #ffffff;
  --panel:         rgba(255, 255, 255, 0.92);
  --panel-solid:   #ffffff;
  --panel-soft:    rgba(0, 0, 0, 0.035);
  --line:          rgba(0, 0, 0, 0.09);
  --line-soft:     rgba(0, 0, 0, 0.065);
  --line-strong:   rgba(0, 0, 0, 0.14);
  --text:          #1a1a2e;
  --text-dim:      #2d2d44;
  --muted:         #6b6b88;
  --faint:         #9898b0;
  --violet:        #7c3aed;
  --violet-2:      #8b5cf6;
  --violet-dim:    rgba(124, 58, 237, 0.12);
  --green:         #059669;
  --green-bg:      rgba(5, 150, 105, 0.1);
  --red:           #dc2626;
  --red-bg:        rgba(220, 38, 38, 0.1);
  --blue:          #2563eb;
  --blue-bg:       rgba(37, 99, 235, 0.1);
  --amber:         #b45309;
  --amber-bg:      rgba(180, 83, 9, 0.1);
  --orange:        #c2410c;
  --orange-bg:     rgba(194, 65, 12, 0.1);
  --shadow:        0 16px 60px rgba(0, 0, 0, 0.1);
  --shadow-sm:     0 4px 16px rgba(0, 0, 0, 0.07);
  --border:        var(--line);
  --border-hover:  rgba(0, 0, 0, 0.18);
  --accent:        var(--violet);
  --accent-2:      var(--violet-2);
  --accent-glow:   var(--violet-dim);
  --good:          var(--green);
  --good-bg:       var(--green-bg);
  --bad:           var(--red);
  --bad-bg:        var(--red-bg);
  --warn:          var(--amber);
  --warn-bg:       var(--amber-bg);
  --panel-2:       rgba(248, 248, 252, 0.95);
  --panel-hover:   rgba(240, 240, 248, 0.98);
}

[data-theme="light"] body {
  background:
    radial-gradient(900px circle at 18% -15%, rgba(139, 92, 246, 0.06), transparent 42%),
    radial-gradient(760px circle at 118% 12%, rgba(90, 169, 255, 0.04), transparent 38%),
    linear-gradient(180deg, #f8f8fc 0%, #f4f5f7 100%);
}
[data-theme="light"] body::after {
  background-image:
    linear-gradient(rgba(0,0,0,0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.016) 1px, transparent 1px);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.2), transparent 55%);
}
[data-theme="light"] .sidebar {
  background: rgba(248, 248, 252, 0.94);
}
[data-theme="light"] input,
[data-theme="light"] select {
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
}
[data-theme="light"] input[type="date"] { color-scheme: light; }
[data-theme="light"] select option { background: #ffffff; }
[data-theme="light"] .filterbar {
  background: rgba(248, 248, 252, 0.92);
}
[data-theme="light"] .table-scroll thead th {
  background: rgba(240, 240, 248, 0.98);
}
[data-theme="light"] .table-scroll tbody tr:nth-child(odd)  { background: rgba(0,0,0,0.015); }
[data-theme="light"] .table-scroll tbody tr:nth-child(even) { background: rgba(0,0,0,0.03); }
[data-theme="light"] .table-scroll tbody tr:hover { background: rgba(124,58,237,0.06); }
[data-theme="light"] .control {
  background: rgba(255,255,255,0.8);
}
[data-theme="light"] .control:hover { background: rgba(255,255,255,0.95); }
[data-theme="light"] .control:focus { background: #ffffff; }
[data-theme="light"] .btn {
  background: rgba(0,0,0,0.04);
  color: var(--muted);
}
[data-theme="light"] .btn:hover { background: rgba(0,0,0,0.07); color: var(--text); }
[data-theme="light"] .nav-section { color: var(--faint); }
[data-theme="light"] .table-panel { background: rgba(255,255,255,0.8); }
[data-theme="light"] .table-toolbar {
  background: linear-gradient(180deg, rgba(0,0,0,0.025), rgba(0,0,0,0.008));
}
[data-theme="light"] .stats-region {
  background: linear-gradient(180deg, rgba(0,0,0,0.012), rgba(0,0,0,0.004));
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }
html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(900px circle at 18% -15%, rgba(139, 92, 246, 0.14), transparent 42%),
    radial-gradient(760px circle at 118% 12%, rgba(90, 169, 255, 0.06), transparent 38%),
    linear-gradient(180deg, #0b0b11 0%, var(--bg) 44%, #07070b 100%);
  color: var(--text);
  line-height: 1.45;
  letter-spacing: -0.01em;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.38), transparent 65%);
  z-index: 0;
}

button, input, select, textarea { font: inherit; cursor: pointer; }
a { color: inherit; }
::selection { background: rgba(139, 92, 246, 0.32); }

/* ── Boot / loading ── */
.boot-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 1;
}
.boot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .03em;
}
.boot-spinner {
  width: 32px;
  height: 32px;
  border: 2.5px solid var(--line);
  border-top-color: var(--violet);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Skeleton loading ── */
.skeleton {
  background: linear-gradient(90deg, var(--panel-solid) 25%, rgba(30, 30, 46, 0.9) 50%, var(--panel-solid) 75%);
  background-size: 400% 100%;
  animation: shimmer 1.6s ease infinite;
  border-radius: 8px;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.skeleton-text  { height: 13px; margin: 5px 0; }
.skeleton-title { height: 26px; margin-bottom: 12px; width: 60%; }
.skeleton-card  { height: 80px; }

/* ── Login ── */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  z-index: 1;
}
.login-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.login-logo-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.36), transparent 24%),
              linear-gradient(135deg, #7c3aed, #a78bfa 58%, #4c1d95);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.14), 0 12px 28px rgba(139,92,246,0.22);
  flex-shrink: 0;
}
.login-logo-mark::before {
  content: '';
  width: 13px;
  height: 13px;
  border: 2.5px solid rgba(255,255,255,0.88);
  border-top-color: transparent;
  border-radius: 50%;
  transform: rotate(-35deg);
}
.login-logo-text {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.015em;
}
.login-card h2 {
  margin: 0 0 4px;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -.025em;
}
.login-card p {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
}

/* ── Forms ── */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
}
input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(10, 10, 15, 0.72);
  color: var(--text);
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
  cursor: text;
}
select { cursor: pointer; }
input:hover, select:hover { border-color: rgba(255,255,255,0.13); }
input:focus, select:focus {
  border-color: rgba(139, 92, 246, 0.65);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.13);
  background: rgba(13, 13, 20, 0.92);
}
input[type="date"] { color-scheme: dark; }
select option { background: #0d0d14; }
input::placeholder { color: var(--faint); }

/* ── Compact filterbar controls ── */
.control {
  width: 100%;
  min-width: 0;
  height: 29px;
  color: var(--text);
  background: rgba(255,255,255,0.035);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  padding: 0 9px;
  font-size: 12px;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}
select.control { padding-right: 24px; color-scheme: dark; cursor: pointer; }
input[type="date"].control { color-scheme: dark; }
.control::placeholder { color: var(--faint); }
.control:hover { border-color: rgba(255,255,255,0.13); background: rgba(255,255,255,0.048); }
.control:focus {
  border-color: rgba(139,92,246,0.68);
  box-shadow: 0 0 0 3px rgba(139,92,246,0.13);
  background: rgba(13,13,20,0.92);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.035);
  color: var(--muted);
  padding: 0 12px;
  height: 29px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color .15s, background .15s, color .15s, transform .1s;
}
.btn:hover { color: var(--text); border-color: rgba(255,255,255,0.16); background: rgba(255,255,255,0.055); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  color: #fff;
  border-color: rgba(139,92,246,0.58);
  background: linear-gradient(180deg, #9a70ff, #7c3aed);
  box-shadow: 0 8px 24px rgba(124,58,237,0.22), inset 0 1px 0 rgba(255,255,255,0.22);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #a984ff, #8450f1);
  border-color: rgba(167,139,250,0.82);
  color: #fff;
}
.btn-danger {
  border-color: rgba(255, 92, 114, 0.28);
  color: var(--red);
}
.btn-danger:hover {
  border-color: rgba(255, 92, 114, 0.52);
  background: var(--red-bg);
  color: #ffa0af;
}
.btn-sm {
  padding: 0 10px;
  height: 26px;
  font-size: 11px;
  border-radius: 7px;
}
.btn-block { width: 100%; display: flex; }
.btn:disabled { opacity: .4; pointer-events: none; }

/* ── App shell ── */
.app-shell {
  position: relative;
  z-index: 1;
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  transition: grid-template-columns 180ms ease;
}
.app-shell--collapsed {
  grid-template-columns: var(--sidebar-collapsed-width) minmax(0, 1fr);
}

/* ── Sidebar ── */
.sidebar {
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(7, 7, 11, 0.72);
  backdrop-filter: blur(20px) saturate(1.3);
}

/* Sidebar top strip: logo + brand + toggle */
.side-top {
  height: 52px;
  flex: 0 0 52px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
  overflow: hidden;
}

.logo-mark {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.36), transparent 24%),
              linear-gradient(135deg, #7c3aed, #a78bfa 58%, #4c1d95);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.13), 0 10px 28px rgba(139,92,246,0.22);
}
.logo-mark::before {
  content: '';
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255,255,255,0.88);
  border-top-color: transparent;
  border-radius: 50%;
  transform: rotate(-35deg);
}

.brand {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  transition: opacity 140ms ease;
}
.brand strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand span {
  display: block;
  margin-top: 1px;
  color: var(--faint);
  font-size: 10px;
  white-space: nowrap;
}

.sidebar-toggle {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  color: var(--muted);
  background: rgba(255,255,255,0.032);
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}
.sidebar-toggle:hover {
  color: var(--text);
  border-color: rgba(139,92,246,0.42);
  background: rgba(139,92,246,0.09);
}
.sidebar-toggle svg { transition: transform 180ms ease; flex-shrink: 0; }
.app-shell--collapsed .sidebar-toggle svg { transform: rotate(180deg); }

/* Nav */
.nav {
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }

.nav a {
  height: 32px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  padding: 0 9px;
  white-space: nowrap;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  transition: color .15s, background .15s, border-color .15s;
}
.nav a:hover { color: var(--text-dim); background: rgba(255,255,255,0.04); }
.nav a.active {
  color: var(--text);
  background: linear-gradient(90deg, rgba(139,92,246,0.16), rgba(255,255,255,0.022));
  border-color: rgba(139,92,246,0.24);
  box-shadow: inset 2px 0 0 rgba(167,139,250,0.78);
}
.nav a.disabled { pointer-events: none; opacity: .4; }

.nav-icon { font-size: 14px; flex-shrink: 0; line-height: 1; }
.nav-label { overflow: hidden; text-overflow: ellipsis; transition: opacity 140ms ease; }
.nav-section {
  margin: 12px 2px 4px;
  padding: 0 9px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--faint);
}

/* Collapsed sidebar states */
.app-shell--collapsed .brand,
.app-shell--collapsed .nav-label,
.app-shell--collapsed .nav-section,
.app-shell--collapsed .side-footer { opacity: 0; pointer-events: none; }
.app-shell--collapsed .side-top { justify-content: center; padding-inline: 8px; }
.app-shell--collapsed .nav a { justify-content: center; padding: 0; }

/* Zero-out hidden flex items so icons center correctly in the 58px rail */
.app-shell--collapsed .logo-mark { display: none; }
.app-shell--collapsed .brand { flex: 0 0 0; overflow: hidden; }
.app-shell--collapsed .nav-label { width: 0; overflow: hidden; }

/* Timezone selector */
.tz-selector {
  padding: 10px 10px 4px;
  flex-shrink: 0;
}
.tz-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--faint);
  margin-bottom: 5px;
  transition: opacity 140ms ease;
}
.tz-selector select { width: 100%; font-size: 12px; }
.app-shell--collapsed .tz-label,
.app-shell--collapsed .tz-selector select { opacity: 0; pointer-events: none; }

/* Theme toggle row */
.theme-toggle-row {
  padding: 0 10px 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.theme-toggle-btn {
  flex-shrink: 0;
  gap: 5px;
}
.theme-toggle-btn .theme-icon { font-size: 13px; line-height: 1; }
.app-shell--collapsed .theme-toggle-row { justify-content: center; padding-inline: 0; }
.app-shell--collapsed .theme-toggle-row .tz-label,
.app-shell--collapsed .theme-toggle-btn .theme-toggle-text { opacity: 0; width: 0; overflow: hidden; pointer-events: none; padding: 0; }

/* Column picker popover */
.col-picker-wrap { position: relative; }
.col-picker-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 5px);
  z-index: 80;
  min-width: 154px;
  max-height: 340px;
  overflow-y: auto;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 5px;
  scrollbar-width: thin;
  scrollbar-color: rgba(139,92,246,0.3) transparent;
}
.col-picker-title {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
  padding: 2px 6px 5px;
}
.col-picker-list { display: flex; flex-direction: column; gap: 1px; }
.col-picker-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.1s;
  text-transform: none;
  font-weight: 400;
  letter-spacing: normal;
  white-space: nowrap;
  user-select: none;
}
.col-picker-item:hover { background: rgba(139,92,246,0.08); }
.col-picker-item input[type="checkbox"] {
  width: 13px; height: 13px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--violet);
}

/* Sidebar footer */
.side-footer,
.sidebar-footer {
  margin-top: auto;
  flex-shrink: 0;
  padding: 10px;
  border-top: 1px solid var(--line);
  transition: opacity 140ms ease;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,0.32), transparent 22%),
              linear-gradient(135deg, #7c3aed, #a78bfa);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.user-name { font-weight: 500; color: var(--text-dim); }
.user-role { color: var(--muted); font-size: 11px; }

/* ── Main content area ── */
.main {
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 24px 28px;
  position: relative;
  z-index: 1;
}
.main-flush {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Page header (non-flush pages) */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-header h1 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -.025em;
}
.page-subtitle { color: var(--muted); font-size: 13px; margin: 0; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Filterbar (compact sticky row — transactions page) ── */
.filterbar {
  position: sticky;
  top: 0;
  z-index: 30;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns:
    minmax(112px, 0.82fr)
    minmax(106px, 0.66fr)
    minmax(106px, 0.66fr)
    minmax(124px, 0.96fr)
    minmax(150px, 1.36fr)
    max-content;
  align-items: end;
  gap: 8px;
  min-height: 52px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 10, 15, 0.84);
  backdrop-filter: blur(20px) saturate(1.25);
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.filterbar::-webkit-scrollbar { display: none; width: 0; height: 0; }

.field {
  min-width: 0;
  display: grid;
  gap: 3px;
}
.field label {
  color: var(--faint);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.filterbar .actions {
  justify-self: end;
  display: flex;
  gap: 6px;
  min-width: max-content;
  align-items: flex-end;
}

/* ── Stats region (chip strip — transactions page) ── */
.stats-region {
  flex: 0 0 auto;
  padding: 8px 12px 7px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.016), rgba(255,255,255,0.005));
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

.breakdown-strip {
  display: flex;
  gap: 6px;
  min-width: 0;
  margin-top: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 34px), transparent 100%);
}
.breakdown-strip::-webkit-scrollbar { display: none; }

.metric-chip {
  min-width: 0;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.028);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.032);
}
/* chip-label / chip-value (legacy) and .label / .value (GPT design) */
.metric-chip .chip-label,
.metric-chip .label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--faint);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  white-space: nowrap;
}
.metric-chip .chip-value,
.metric-chip .value {
  flex: 0 0 auto;
  color: var(--text);
  font: 650 12px/1 var(--mono);
  font-variant-numeric: tabular-nums;
}
/* legacy class names */
.metric-chip.chip-violet { border-color: rgba(139,92,246,0.28); background: rgba(139,92,246,0.09); }
.metric-chip.chip-green  { border-color: rgba(47,209,135,0.2); }
.metric-chip.chip-red    { border-color: rgba(255,92,114,0.2); }
/* GPT class names */
.metric-chip.violet { border-color: rgba(139,92,246,0.24); background: rgba(139,92,246,0.08); }
.metric-chip.good   { border-color: rgba(47,209,135,0.18); }
.metric-chip.bad    { border-color: rgba(255,92,114,0.18); }

.breakdown-chip {
  height: 26px;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 7px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255,255,255,0.02);
  font-size: 11px;
  white-space: nowrap;
}
.breakdown-chip strong,
.breakdown-chip .chip-amount {
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* Status dot */
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  flex-shrink: 0;
  box-shadow: 0 0 12px currentColor;
}
/* BEM style (legacy) */
.dot-success    { background: var(--green);  box-shadow: 0 0 8px rgba(47,209,135,0.7); }
.dot-fail,
.dot-declined   { background: var(--red);    box-shadow: 0 0 8px rgba(255,92,114,0.6); }
.dot-card,
.dot-pay_form,
.dot-abandoned  { background: var(--blue);   box-shadow: 0 0 8px rgba(90,169,255,0.6); }
.dot-refund     { background: var(--amber);  box-shadow: 0 0 8px rgba(246,195,80,0.6); }
.dot-chargeback { background: var(--orange); box-shadow: 0 0 8px rgba(255,138,61,0.6); }
/* Modifier style (GPT design) */
.dot.success { background: var(--green);  color: var(--green); }
.dot.danger  { background: var(--red);    color: var(--red); }
.dot.info    { background: var(--blue);   color: var(--blue); }
.dot.refund  { background: var(--amber);  color: var(--amber); }
.dot.chargeback { background: var(--orange); color: var(--orange); }

/* ── Status badge (GPT pill style — used in table Status column) ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  min-width: 72px;
  justify-content: center;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 10px;
  font-weight: 720;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  white-space: nowrap;
}
.status-badge.success    { color: var(--green);  background: var(--green-bg); }
.status-badge.danger     { color: var(--red);    background: var(--red-bg); }
.status-badge.info       { color: var(--blue);   background: var(--blue-bg); }
.status-badge.refund     { color: var(--amber);  background: var(--amber-bg); }
.status-badge.chargeback { color: var(--orange); background: var(--orange-bg); }
.status-badge.neutral    { color: var(--muted);  background: rgba(255,255,255,0.04); border-color: var(--line); }

/* ── Table cell helpers ── */
.positive { color: #dffdf0; }
.negative { color: #ffd5da; }
.numeric  { text-align: right; }
.id-cell  { color: #fafaff; font-weight: 640; }
.descriptor-cell { color: #f1f1f8; font-weight: 580; }

/* ── Risk pill ── */
.risk-pill {
  display: inline-flex;
  min-width: 30px;
  height: 20px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  font-family: var(--mono);
  font-size: 11px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.026);
  color: var(--muted);
}
.risk-pill.low  { color: var(--green);  border-color: rgba(47,209,135,0.2);  background: rgba(47,209,135,0.07); }
.risk-pill.mid  { color: var(--amber);  border-color: rgba(246,195,80,0.2);  background: rgba(246,195,80,0.075); }
.risk-pill.high { color: var(--red);    border-color: rgba(255,92,114,0.24); background: rgba(255,92,114,0.08); }

/* ── Sort controls (used in .table-scroll sortable headers) ── */
.table-scroll thead th button {
  all: unset;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  max-width: 100%;
  width: 100%;
}
.table-scroll thead th.numeric button { justify-content: flex-end; }
.sort-arrow {
  width: 8px;
  color: var(--violet-2);
  font-size: 9px;
  opacity: 0;
  flex-shrink: 0;
}
.table-scroll thead th.sorted .sort-arrow { opacity: 1; }
.table-scroll thead th.sorted { color: #d8d0ff; }

/* ── Empty table row ── */
.empty-row td {
  height: 120px;
  color: var(--faint);
  text-align: center;
}

/* ── Scroll hint in toolbar ── */
.scroll-hint {
  color: var(--faint);
  font: 11px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Table panel (transactions page) ── */
.table-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 10px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(13,13,20,0.72);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.032);
}

.table-toolbar {
  height: 35px;
  flex: 0 0 35px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px 0 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,0.032), rgba(255,255,255,0.01));
}
.table-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.table-title strong {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.accent-line {
  width: 28px;
  height: 1px;
  background: linear-gradient(90deg, var(--violet), transparent);
  flex-shrink: 0;
}
.row-count {
  color: var(--faint);
  font: 11px/1 var(--mono);
  font-variant-numeric: tabular-nums;
}
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(139,92,246,0.42) rgba(255,255,255,0.022);
}
.table-scroll::-webkit-scrollbar { width: 9px; height: 9px; }
.table-scroll::-webkit-scrollbar-track { background: rgba(255,255,255,0.022); }
.table-scroll::-webkit-scrollbar-corner { background: transparent; }
.table-scroll::-webkit-scrollbar-thumb {
  background: rgba(139,92,246,0.44);
  border: 2px solid rgba(13,13,20,0.96);
  background-clip: padding-box;
  border-radius: 999px;
}
.table-scroll::-webkit-scrollbar-thumb:hover { background: rgba(167,139,250,0.64); background-clip: padding-box; }

/* Table inside .table-scroll (transactions page) */
.table-scroll table {
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 0;
}
.table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
  color: var(--faint);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(12,12,19,0.98);
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
  user-select: none;
}
.table-scroll tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.042);
  color: var(--text-dim);
  vertical-align: top;
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
}
/* Columns that wrap — full value stays in DOM for Ctrl+F */
.table-scroll td.col-wrap {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
/* Mono ID columns — tighter font for dense IDs, both wrap and nowrap */
.table-scroll td.mono {
  font-size: 12px;
}
/* Columns that never wrap (explicit, mirrors the default) */
.table-scroll td.col-nowrap {
  white-space: nowrap;
}
.tx-date-cell { line-height: 1.3; }
.tx-date-cell span { display: block; white-space: nowrap; }
.tx-date-cell .tx-date-time { font-size: 0.82em; color: var(--muted); }
.table-scroll tbody tr:nth-child(odd)  { background: rgba(255,255,255,0.011); }
.table-scroll tbody tr:nth-child(even) { background: rgba(0,0,0,0.06); }
.table-scroll tbody tr:hover { background: rgba(139,92,246,0.07); }
.table-scroll tbody tr:last-child td { border-bottom: 0; }

/* ── Cards (non-flush pages) ── */
.card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card {
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.04), transparent 60%);
  pointer-events: none;
}
.card-title {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 6px;
}
.card-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.1;
}
.card-subtitle {
  color: var(--muted);
  font-size: 11px;
  margin-top: 5px;
}
.card-delta-pos { color: var(--green);  font-size: 11px; }
.card-delta-neg { color: var(--red);    font-size: 11px; }

/* ── Panel ── */
.panel { padding: 20px; }
.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.panel-title { font-size: 14px; font-weight: 600; margin: 0 0 2px; }
.panel-desc   { color: var(--muted); font-size: 12px; margin: 0; }

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

/* ── Filters bar (non-flush pages) ── */
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}
.filters .form-row { margin: 0; }

/* ── Generic table (non-flush pages) ── */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-height: 520px;
  scrollbar-width: thin;
  scrollbar-color: rgba(139,92,246,0.35) rgba(255,255,255,0.02);
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}
thead tr { position: sticky; top: 0; z-index: 2; }
th {
  padding: 8px 11px;
  background: rgba(10, 10, 15, 0.96);
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-strong);
  backdrop-filter: blur(8px);
}
td {
  padding: 9px 11px;
  border-bottom: 1px solid rgba(255,255,255,0.045);
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(139, 92, 246, 0.05); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  border: 1px solid transparent;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.badge-success    { color: var(--green);  background: var(--green-bg);  border-color: rgba(47, 209, 135, 0.28); }
.badge-declined   { color: var(--red);    background: var(--red-bg);    border-color: rgba(255, 92, 114, 0.28); }
.badge-fail       { color: var(--red);    background: var(--red-bg);    border-color: rgba(255, 92, 114, 0.28); }
.badge-refund     { color: var(--amber);  background: var(--amber-bg);  border-color: rgba(246, 195, 80, 0.28); }
.badge-chargeback { color: var(--orange); background: var(--orange-bg); border-color: rgba(255, 138, 61, 0.28); }
.badge-pending    { color: var(--blue);   background: var(--blue-bg);   border-color: rgba(90, 169, 255, 0.28); }
.badge-default    { color: var(--muted);  background: rgba(255,255,255,0.05); border-color: var(--line); }

/* ── Topbar filters (non-flush pages) ── */
.topbar-filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.topbar-filters select,
.topbar-filters input[type="date"] {
  width: auto;
  min-width: 110px;
  padding: 6px 9px;
  font-size: 12px;
}
.topbar-label { font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.topbar-sep { width: 1px; height: 18px; background: var(--line); }

/* ── Toast ── */
.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  box-shadow: var(--shadow);
  max-width: 320px;
  font-size: 13px;
  animation: slideup .22s ease;
  pointer-events: auto;
}
.toast-success { border-color: rgba(47, 209, 135, 0.38); color: var(--green); }
.toast-error   { border-color: rgba(255, 92, 114, 0.38); color: var(--red); }
.toast-info    { border-color: rgba(139, 92, 246, 0.38); color: var(--violet-2); }
@keyframes slideup {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.58);
  display: grid;
  place-items: center;
  z-index: 200;
  padding: 16px;
  animation: fadein .16s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  width: min(500px, 100%);
  animation: scalein .16s ease;
}
@keyframes scalein {
  from { opacity: 0; transform: scale(.96); }
  to   { opacity: 1; transform: scale(1); }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-title { font-size: 15px; font-weight: 600; margin: 0; }
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ── Misc utils ── */
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.error-box {
  background: var(--red-bg);
  border: 1px solid rgba(255, 92, 114, 0.28);
  border-radius: var(--radius-sm);
  color: var(--red);
  padding: 10px 13px;
  font-size: 13px;
  margin: 8px 0;
}
.error-text   { color: var(--red); }
.success-text { color: var(--green); }
.muted        { color: var(--muted); }
.faint        { color: var(--faint); }
.actions      { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mt-16        { margin-top: 16px; }
.mt-8         { margin-top: 8px; }
.text-sm      { font-size: 12px; }

/* Stat row for overview */
.stat-row { display: flex; gap: 8px; align-items: center; }
.stat-row .badge { font-size: 10px; }

/* Monospace utility */
.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .grid-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  :root { --sidebar-width: var(--sidebar-collapsed-width); }
  .app-shell--collapsed .brand,
  .app-shell--collapsed .nav-label { opacity: 0; }
  .brand, .nav-label { opacity: 0; pointer-events: none; }
  .side-top { justify-content: center; }
  .nav a { justify-content: center; padding: 0; }
  .sidebar-footer { display: none; }
  .metric-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .filterbar {
    grid-template-columns: 1fr 1fr 1fr max-content;
    grid-auto-rows: auto;
    height: auto;
    min-height: unset;
    padding: 7px 8px;
    gap: 5px;
    overflow-x: visible;
  }
  .filterbar .field:nth-child(5) { grid-column: 1 / -1; }
  .filterbar .actions { grid-column: 1 / -1; justify-self: end; }
  .field label { display: none; }
  .metric-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .grid-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { padding: 14px; }
  .metric-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 400px) {
  .grid-cards { grid-template-columns: 1fr; }
  .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Column alignment ── */
.col-center { text-align: center; }
.table-scroll thead th.col-center button { justify-content: center; }

/* ── Action buttons in table cells ── */
.btn-action {
  padding: 0 8px;
  height: 22px;
  font-size: 11px;
  border-radius: 6px;
}

/* ── Transaction details modal ── */
.tx-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.tx-modal {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  width: min(480px, 90vw);
  overflow: hidden;
}
.tx-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.tx-modal-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.tx-modal-close:hover { color: var(--text); background: var(--line); }
.tx-modal-body {
  padding: 24px 18px;
  color: var(--text-dim);
  font-size: 13px;
}

/* ── Bulletproof transactions table (GPT percent-colgroup design) ── */

/* Reset .table-scroll tr striping so .transactions-table td backgrounds take over */
.table-scroll .transactions-table tbody tr:nth-child(odd),
.table-scroll .transactions-table tbody tr:nth-child(even),
.table-scroll .transactions-table tbody tr:hover { background: transparent; }
[data-theme="light"] .table-scroll .transactions-table tbody tr:nth-child(odd),
[data-theme="light"] .table-scroll .transactions-table tbody tr:nth-child(even),
[data-theme="light"] .table-scroll .transactions-table tbody tr:hover { background: transparent; }

table.transactions-table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  line-height: 1.45;
}

.transactions-table th,
.transactions-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
  min-width: 0;
}

.transactions-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: rgba(12,12,19,.98);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: .055em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 -1px 0 rgba(255,255,255,.03);
}
[data-theme="light"] .transactions-table th {
  background: rgba(240,240,248,.98);
}

.transactions-table th button {
  all: unset;
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: inherit;
  letter-spacing: inherit;
  color: inherit;
}
.transactions-table th button .th-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.transactions-table th button .sort-mark {
  flex: 0 0 auto;
  opacity: .45;
  color: var(--violet);
  font-size: 10px;
  line-height: 1;
}

/* Row striping via td (not tr) so card-mode can reset easily */
.transactions-table tbody tr:nth-child(odd)  td { background: rgba(255,255,255,.017); }
.transactions-table tbody tr:nth-child(even) td { background: rgba(255,255,255,.035); }
.transactions-table tbody tr:hover td {
  background: rgba(139,92,246,.095);
  border-bottom-color: rgba(139,92,246,.20);
}
[data-theme="light"] .transactions-table tbody tr:nth-child(odd)  td { background: rgba(0,0,0,.012); }
[data-theme="light"] .transactions-table tbody tr:nth-child(even) td { background: rgba(0,0,0,.028); }
[data-theme="light"] .transactions-table tbody tr:hover td {
  background: rgba(124,58,237,.06);
  border-bottom-color: rgba(124,58,237,.18);
}

/* cell-value wrapper */
.transactions-table .cell-value {
  display: block;
  min-width: 0;
  max-width: 100%;
}

/* wrap classes */
.transactions-table td.wrap    { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.transactions-table td.break-anywhere { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.transactions-table td.nowrap  { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.transactions-table td.num     { text-align: right; color: #f0f0f8; font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 700; }

/* date-stack: two-line date/time */
.date-stack {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  max-width: 100%;
}
.date-stack span:first-child { color: var(--text); }
.date-stack span:last-child  { color: var(--muted); }

/* Scoped status-badge for transactions-table (GPT status-* classes) */
.transactions-table .status-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-width: 0;
  height: 22px;
  padding: 0 8px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: lowercase;
}
.transactions-table .status-badge::before {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 14px currentColor;
}
.transactions-table .status-badge.status-success                               { color: var(--green);  background: var(--green-bg); }
.transactions-table .status-badge.status-fail,
.transactions-table .status-badge.status-declined                              { color: var(--red);    background: var(--red-bg); }
.transactions-table .status-badge.status-card,
.transactions-table .status-badge.status-pay_form,
.transactions-table .status-badge.status-abandoned                             { color: var(--blue);   background: var(--blue-bg); }
.transactions-table .status-badge.status-refund                                { color: var(--amber);  background: var(--amber-bg); }
.transactions-table .status-badge.status-chargeback                            { color: var(--orange); background: var(--orange-bg); }

/* Details button */
.transactions-table .details-btn {
  display: inline-flex;
  width: 100%;
  max-width: 58px;
  min-width: 0;
  height: 24px;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -.01em;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.045);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
  cursor: pointer;
  white-space: nowrap;
}
.transactions-table .details-btn:hover {
  border-color: rgba(139,92,246,.42);
  background: rgba(139,92,246,.18);
}

/* Action pair (Ref + Charge stacked) */
.transactions-table .action-pair {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  vertical-align: top;
  box-sizing: border-box;
}
.transactions-table .mini-btn {
  width: 100%;
  min-width: 0;
  height: 22px;
  padding: 0 4px;
  font-size: 10.5px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -.02em;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.045);
  color: var(--text);
  cursor: pointer;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
}
.transactions-table .mini-btn:hover {
  border-color: rgba(139,92,246,.42);
  background: rgba(139,92,246,.18);
}
.transactions-table .tx-dash {
  color: var(--faint);
  font-family: var(--mono);
  font-weight: 800;
}

/* Desktop fix: Card column — wrap within its column, never bleed into R/C */
.transactions-table td[data-label="Card"] {
  white-space: normal;
  overflow: hidden;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Desktop fix: R/C action column — clamp buttons inside column */
.transactions-table td.action-cell {
  min-width: 0;
  box-sizing: border-box;
  overflow: hidden;
}

/* ── Mobile card fallback: <1279px ── */
@media (max-width: 1279px) {
  table.transactions-table,
  .transactions-table tbody,
  .transactions-table tr,
  .transactions-table td { display: block; width: 100%; }

  .transactions-table colgroup,
  .transactions-table thead { display: none; }

  .transactions-table tbody { padding: 10px; }

  .transactions-table tbody tr {
    border: 1px solid var(--line);
    border-radius: 13px;
    overflow: hidden;
    background:
      linear-gradient(135deg, rgba(139,92,246,.08), transparent 38%),
      rgba(255,255,255,.026);
    margin-bottom: 10px;
  }
  [data-theme="light"] .transactions-table tbody tr {
    background:
      linear-gradient(135deg, rgba(124,58,237,.05), transparent 38%),
      rgba(0,0,0,.018);
  }

  /* transparent td backgrounds inside card rows */
  .transactions-table tbody tr:nth-child(odd) td,
  .transactions-table tbody tr:nth-child(even) td,
  .transactions-table tbody tr:hover td,
  [data-theme="light"] .transactions-table tbody tr:nth-child(odd) td,
  [data-theme="light"] .transactions-table tbody tr:nth-child(even) td,
  [data-theme="light"] .transactions-table tbody tr:hover td { background: transparent; }

  .transactions-table td {
    display: grid;
    grid-template-columns: 90px minmax(0, 1fr);
    align-items: start;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line-soft);
    white-space: normal;
    overflow: hidden;
    text-overflow: clip;
  }
  .transactions-table td:last-child { border-bottom: 0; }

  .transactions-table td::before {
    content: attr(data-label);
    color: var(--faint);
    font-size: 10.5px;
    line-height: 1.55;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-top: 2px;
  }

  .transactions-table td.num { text-align: left; }

  .transactions-table .cell-value {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  /* Badge/button elements: size to content, don't stretch */
  .transactions-table .status-badge { min-width: 0; }
  .transactions-table .details-btn,
  .transactions-table .action-pair { width: auto; max-width: none; display: inline-flex; }
  .transactions-table .action-pair { flex-direction: row; justify-content: flex-start; gap: 5px; }
  .transactions-table .mini-btn    { width: auto; padding: 0 10px; min-width: 0; }

  /* Card column: allow overflow in card-mode too */
  .transactions-table td[data-label="Card"] {
    overflow: visible;
  }

  /* Date stack renders cleanly as two stacked lines */
  .date-stack { display: inline-flex; }
}

@media (max-width: 480px) {
  .transactions-table td {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 7px;
    padding: 9px 10px;
  }
}


/* ============================================================
   TABULATOR — DARK THEME OVERRIDES
   ============================================================ */

/* Mount container: flex-fill so table uses panel height */
.tabulator-mount {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

/* Core table */
.tabulator {
  height: 100%;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  overflow: hidden;
}

/* Header */
.tabulator .tabulator-header {
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.tabulator .tabulator-col {
  background: transparent;
  border-right: 1px solid var(--line-soft);
}

.tabulator .tabulator-col:last-child {
  border-right: none;
}

.tabulator .tabulator-col-title {
  font-weight: 600;
}

/* Sort arrows */
.tabulator .tabulator-col .tabulator-col-sorter .tabulator-arrow {
  border-top-color: var(--muted);
  border-bottom-color: var(--muted);
}

.tabulator .tabulator-col.tabulator-col-sorter-element:hover .tabulator-arrow,
.tabulator .tabulator-col[aria-sort="asc"] .tabulator-arrow,
.tabulator .tabulator-col[aria-sort="desc"] .tabulator-arrow {
  border-top-color: #8b5cf6;
  border-bottom-color: #8b5cf6;
}

/* Resize handle */
.tabulator .tabulator-col .tabulator-col-resize-handle {
  border-right: 2px solid var(--line-soft);
}

.tabulator .tabulator-col .tabulator-col-resize-handle:hover {
  border-right-color: #8b5cf6;
}

/* Header menu icon */
.tabulator .tabulator-header-filter input,
.tabulator .tabulator-col .tabulator-header-menu-button {
  color: var(--muted);
}

.tabulator .tabulator-col .tabulator-header-menu-button:hover {
  color: #8b5cf6;
}

/* Rows */
.tabulator .tabulator-tableholder {
  background: transparent;
}

.tabulator .tabulator-row {
  background: transparent;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
}

.tabulator .tabulator-row.tabulator-row-even {
  background: rgba(255, 255, 255, 0.02);
}

.tabulator .tabulator-row:hover {
  background: rgba(139, 92, 246, 0.08) !important;
}

.tabulator .tabulator-row.tabulator-selected,
.tabulator .tabulator-row.tabulator-selected:hover {
  background: rgba(139, 92, 246, 0.18) !important;
}

/* Cells */
.tabulator .tabulator-cell {
  border-right: 1px solid var(--line-soft);
}

.tabulator .tabulator-cell:last-child {
  border-right: none;
}

/* Frozen / calc rows */
.tabulator .tabulator-row.tabulator-calcs-top,
.tabulator .tabulator-row.tabulator-calcs-bottom {
  background: rgba(139, 92, 246, 0.06);
  color: var(--muted);
}

/* Footer */
.tabulator .tabulator-footer {
  background: rgba(255, 255, 255, 0.03);
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.tabulator .tabulator-footer .tabulator-page {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}

.tabulator .tabulator-footer .tabulator-page:hover,
.tabulator .tabulator-footer .tabulator-page.active {
  background: rgba(139, 92, 246, 0.18);
  border-color: #8b5cf6;
  color: #8b5cf6;
}

/* Dark scrollbars */
.tabulator ::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.tabulator ::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
}

.tabulator ::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.45);
  border-radius: 3px;
}

.tabulator ::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 92, 246, 0.7);
}

/* ============================================================
   TABULATOR — LIGHT THEME REVERT  [data-theme="light"]
   ============================================================ */

[data-theme="light"] .tabulator {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.09);
  color: #1a1a2e;
}

[data-theme="light"] .tabulator .tabulator-header {
  background: #f5f5fa;
  border-bottom-color: rgba(0, 0, 0, 0.09);
  color: #6b6b88;
}

[data-theme="light"] .tabulator .tabulator-col {
  background: transparent;
  border-right-color: rgba(0, 0, 0, 0.065);
}

[data-theme="light"] .tabulator .tabulator-col .tabulator-col-sorter .tabulator-arrow {
  border-top-color: #6b6b88;
  border-bottom-color: #6b6b88;
}

[data-theme="light"] .tabulator .tabulator-col[aria-sort="asc"] .tabulator-arrow,
[data-theme="light"] .tabulator .tabulator-col[aria-sort="desc"] .tabulator-arrow {
  border-top-color: #7c3aed;
  border-bottom-color: #7c3aed;
}

[data-theme="light"] .tabulator .tabulator-row {
  background: transparent;
  border-bottom-color: rgba(0, 0, 0, 0.065);
  color: #1a1a2e;
}

[data-theme="light"] .tabulator .tabulator-row.tabulator-row-even {
  background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .tabulator .tabulator-row:hover {
  background: rgba(124, 58, 237, 0.06) !important;
}

[data-theme="light"] .tabulator .tabulator-row.tabulator-selected {
  background: rgba(124, 58, 237, 0.12) !important;
}

[data-theme="light"] .tabulator .tabulator-cell {
  border-right-color: rgba(0, 0, 0, 0.065);
}

[data-theme="light"] .tabulator .tabulator-footer {
  background: #f5f5fa;
  border-top-color: rgba(0, 0, 0, 0.09);
  color: #6b6b88;
}

[data-theme="light"] .tabulator .tabulator-footer .tabulator-page {
  border-color: rgba(0, 0, 0, 0.09);
  color: #6b6b88;
}

[data-theme="light"] .tabulator .tabulator-footer .tabulator-page:hover,
[data-theme="light"] .tabulator .tabulator-footer .tabulator-page.active {
  background: rgba(124, 58, 237, 0.1);
  border-color: #7c3aed;
  color: #7c3aed;
}

[data-theme="light"] .tabulator ::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .tabulator ::-webkit-scrollbar-thumb {
  background: rgba(124, 58, 237, 0.35);
}

[data-theme="light"] .tabulator ::-webkit-scrollbar-thumb:hover {
  background: rgba(124, 58, 237, 0.6);
}

/* ── Dark theme: force readable light text ─────────────────────────────── */
.tabulator .tabulator-header,
.tabulator .tabulator-col {
  color: #c9c9d4 !important;
}

.tabulator .tabulator-col-title {
  color: #c9c9d4 !important;
}

.tabulator .tabulator-row {
  color: #e8e8f0;
}

.tabulator .tabulator-row.tabulator-row-even {
  color: #e8e8f0;
}

.tabulator .tabulator-row:hover {
  color: #e8e8f0 !important;
}

.tabulator .tabulator-row.tabulator-selected,
.tabulator .tabulator-row.tabulator-selected:hover {
  color: #e8e8f0 !important;
}

.tabulator .tabulator-cell {
  color: #e8e8f0 !important;
}

.tabulator .tabulator-row.tabulator-calcs-top,
.tabulator .tabulator-row.tabulator-calcs-bottom {
  color: #c9c9d4 !important;
}

/* ── Light theme overrides: readable dark-on-light text ─────────────────── */
[data-theme="light"] .tabulator .tabulator-header,
[data-theme="light"] .tabulator .tabulator-col {
  color: #444 !important;
}

[data-theme="light"] .tabulator .tabulator-col-title {
  color: #444 !important;
}

[data-theme="light"] .tabulator .tabulator-cell {
  color: #1a1a2e !important;
}

[data-theme="light"] .tabulator .tabulator-row {
  color: #1a1a2e;
}

[data-theme="light"] .tabulator .tabulator-row:hover {
  color: #1a1a2e !important;
}

[data-theme="light"] .tabulator .tabulator-row.tabulator-selected,
[data-theme="light"] .tabulator .tabulator-row.tabulator-selected:hover {
  color: #1a1a2e !important;
}
