:root {
  --bg: #090b10;
  --bg-gradient: radial-gradient(circle at 50% 0%, #161c2d 0%, #090b10 70%);
  --panel: #111522;
  --panel-card: #151a2b;
  --line: #1f273d;
  --line-light: #2c3754;
  --text: #f1f4fb;
  --muted: #8d98b0;
  --acc: #3b82f6;
  --acc-gradient: linear-gradient(135deg, #3b82f6, #6366f1);
  --acc-glow: rgba(59, 130, 246, 0.3);
  --ok: #10b981;
  --ok-bg: rgba(16, 185, 129, 0.12);
  --ok-border: rgba(16, 185, 129, 0.3);
  --warn: #f59e0b;
  --warn-bg: rgba(245, 158, 11, 0.12);
  --bad: #ef4444;
  --bad-bg: rgba(239, 68, 68, 0.12);
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.5 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  letter-spacing: -0.01em;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Buttons */
button {
  background: var(--acc-gradient);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px var(--acc-glow);
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
button:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--acc-glow);
}
button:active {
  transform: translateY(0);
}
button.ghost {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: none;
}
button.ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line-light);
  filter: none;
}
button.ok {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}
button.ok:hover {
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}
button.bad {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}
button.sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 7px;
}

/* Inputs, Select, Textarea */
input, select, textarea {
  background: #0d101a;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 11px;
  font: inherit;
  transition: all 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--acc);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
textarea {
  width: 100%;
  min-height: 200px;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 13px;
}

/* Login screen */
.login {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}
.login form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 320px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

/* Cards & Containers */
.card {
  background: var(--panel-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}
h1 { margin: 0 0 8px; font-size: 20px; font-weight: 700; }
h2 { font-size: 16px; margin: 0 0 14px; font-weight: 600; }

/* Header & Nav */
header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 21, 34, 0.82);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-wrap: wrap;
}
.logo {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #60a5fa, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo::before {
  content: '⚡';
  -webkit-text-fill-color: initial;
  font-size: 15px;
}
nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
nav a {
  padding: 7px 13px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  font-weight: 500;
  font-size: 13.5px;
  transition: all 0.15s ease;
}
nav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}
nav a.on {
  background: #1c2438;
  color: #fff;
  font-weight: 600;
  border: 1px solid var(--line-light);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.right {
  margin-left: auto;
  display: flex;
  gap: 12px;
  align-items: center;
}
.banner {
  background: #2b220d;
  color: #fde68a;
  padding: 8px 24px;
  border-bottom: 1px solid #4d3d17;
  font-size: 13px;
  font-weight: 500;
}
main {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}
.muted { color: var(--muted); }
.err { color: var(--bad); min-height: 18px; font-size: 12.5px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.grow { flex: 1; min-width: 290px; }

/* Tables */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
th, td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #0e121d;
}
tr:last-child td { border-bottom: 0; }
tr:hover td { background: rgba(255, 255, 255, 0.015); }

.mono { font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace; }
.copy {
  cursor: pointer;
  border-bottom: 1px dashed var(--muted);
  transition: all 0.15s;
}
.copy:hover {
  color: var(--acc);
  border-color: var(--acc);
}

/* Badges & Pills */
.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  background: #1a2030;
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.s-pending { background: var(--warn-bg); color: var(--warn); border-color: rgba(245, 158, 11, 0.3); }
.s-queued, .s-ordering { background: rgba(59, 130, 246, 0.12); color: #93c5fd; border-color: rgba(59, 130, 246, 0.3); }
.s-done, .s-active { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.s-partial { background: var(--warn-bg); color: var(--warn); }
.s-error, .s-rejected, .s-closed { background: var(--bad-bg); color: #fca5a5; border-color: rgba(239, 68, 68, 0.3); }

/* Stats Bar */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--panel-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}
.stat::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--line-light), transparent);
}
.stat .muted { font-size: 12px; font-weight: 500; }
.stat b { display: block; font-size: 24px; font-weight: 700; margin-top: 4px; color: #fff; }

/* 6-Digit Codes & 3DS Badges */
.code-box {
  font-family: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.14em;
  background: linear-gradient(135deg, #131b2e, #18243e);
  border: 1px solid rgba(96, 165, 250, 0.4);
  color: #60a5fa;
  padding: 5px 12px;
  border-radius: 8px;
  display: inline-block;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.15);
  transition: all 0.15s ease;
  user-select: all;
}
.code-box:hover {
  background: linear-gradient(135deg, #1a2540, #223255);
  border-color: #60a5fa;
  color: #fff;
  transform: scale(1.04);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.35);
}
.copy-btn {
  vertical-align: middle;
  margin-left: 8px;
  cursor: pointer;
}
.pill-fresh {
  background: var(--ok-bg);
  color: var(--ok);
  border: 1px solid var(--ok-border);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.fresh-row {
  background: rgba(16, 185, 129, 0.06) !important;
}
.fresh-row:hover td {
  background: rgba(16, 185, 129, 0.09) !important;
}
.pill-merchant {
  background: #141926;
  border: 1px solid var(--line);
  padding: 3px 9px;
  border-radius: 7px;
  font-size: 12px;
  color: #cbd5e1;
  display: inline-block;
  max-width: 340px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Toolbar & Modals */
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease-out;
}
.modal {
  background: var(--panel-card);
  border: 1px solid var(--line-light);
  border-radius: 14px;
  padding: 24px;
  max-width: 540px;
  width: 90%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  animation: scaleUp 0.18s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleUp { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1c2438;
  border: 1px solid var(--line-light);
  color: #fff;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  z-index: 9999;
}
#toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Spend KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--panel-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-light);
}
.kpi-card.highlight {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(6, 78, 59, 0.03));
  border-color: rgba(16, 185, 129, 0.35);
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.1);
}
.kpi-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.kpi-value {
  font-size: 24px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: #fff;
  letter-spacing: -0.5px;
}
.kpi-card.highlight .kpi-value {
  color: #10b981;
}
.kpi-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

@media (max-width: 768px) {
  header { padding: 12px 14px; }
  main { padding: 12px; }
  th, td { padding: 8px; }
  .right { margin-left: 0; width: 100%; justify-content: space-between; }
  .code-box { font-size: 16px; padding: 4px 8px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}
