@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&family=JetBrains+Mono:wght@400;600&family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap');

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

:root {
  --bg:        #0a0a0f;
  --card:      #12121a;
  --border:    rgba(255,255,255,0.08);
  --primary:   #6366f1;
  --primary-d: #4f52d4;
  --success:   #10b981;
  --danger:    #ef4444;
  --warn:      #f59e0b;
  --text:      #f0f0f5;
  --muted:     #8888a0;
  --font-body: 'DM Sans', sans-serif;
  --font-head: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  color-scheme: dark;
}

html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100svh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
body.login-page { padding-bottom: 0; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }
* { -webkit-tap-highlight-color: transparent; }

/* ── Typography ── */
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 700; }
.mono { font-family: var(--font-mono); }
.text-muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-primary { color: var(--primary); }
.text-warn    { color: var(--warn); }

/* ── Layout ── */
.page { max-width: 900px; margin: 0 auto; padding: 16px 16px 0; }
.page-title { padding-top: 8px; margin-bottom: 20px; }
.page-title h1 { font-size: 1.5rem; }
.page-title p  { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
.card-pad { padding: 16px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-head); font-weight: 600;
}
.card-head a { color: var(--primary); font-size: 0.85rem; text-decoration: none; font-family: var(--font-body); font-weight: 400; }
.card + .card, .card + .grid, .grid + .card, section + section { margin-top: 16px; }

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 640px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: scale(1.02); box-shadow: 0 0 30px rgba(99,102,241,.15); }
.stat-card.accent { border-color: rgba(99,102,241,.4); box-shadow: 0 0 30px rgba(99,102,241,.12); }
.stat-card .label { color: var(--muted); font-size: 0.8rem; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; }
.stat-card .value { font-family: var(--font-mono); font-size: 1.4rem; font-weight: 600; }
.stat-card .sub   { color: var(--muted); font-size: 0.75rem; margin-top: 6px; }
.stat-card .trend-up   { color: var(--success); font-size: 0.75rem; }
.stat-card .trend-down { color: var(--danger);  font-size: 0.75rem; }

/* ── Progress Bar ── */
.progress-wrap { background: rgba(255,255,255,0.07); border-radius: 99px; height: 5px; overflow: hidden; }
.progress-bar  { height: 100%; border-radius: 99px; background: var(--primary); transition: width .6s ease; }
.progress-bar.green  { background: var(--success); }
.progress-bar.yellow { background: var(--warn); }
.progress-bar.red    { background: var(--danger); }

/* ── Badge ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 99px;
  font-size: 0.7rem; font-weight: 600; white-space: nowrap;
}
.badge-primary { background: rgba(99,102,241,.15); color: var(--primary); }
.badge-success { background: rgba(16,185,129,.15); color: var(--success); }
.badge-danger  { background: rgba(239,68,68,.15);  color: var(--danger); }
.badge-warn    { background: rgba(245,158,11,.15); color: var(--warn); }
.badge-muted   { background: rgba(255,255,255,.07); color: var(--muted); }

/* ── List Rows ── */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.row:last-child { border-bottom: none; }
.row:hover { background: rgba(255,255,255,.02); }
.row a { text-decoration: none; color: inherit; display: flex; align-items: center; gap: 12px; width: 100%; }
.row-icon {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(99,102,241,.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.row-body { flex: 1; min-width: 0; }
.row-body .title { font-weight: 500; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-body .sub   { color: var(--muted); font-size: 0.75rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-end { text-align: right; flex-shrink: 0; }
.row-end .amount { font-family: var(--font-mono); font-size: 0.9rem; }
.row-end .sub    { color: var(--muted); font-size: 0.75rem; }

/* ── Transaction expanded detail ── */
.tx-detail {
  display: none; padding: 12px 16px 16px;
  background: rgba(0,0,0,.2);
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
}
.tx-detail.open { display: block; }
.tx-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.tx-meta-item .key { color: var(--muted); font-size: 0.72rem; margin-bottom: 2px; }
.tx-meta-item .val { font-family: var(--font-mono); font-size: 0.8rem; word-break: break-all; }
.ticket-row { display: flex; justify-content: space-between; background: rgba(0,0,0,.2); border-radius: 8px; padding: 6px 10px; margin-bottom: 4px; }

/* ── Horizontal scroll strip ── */
.hscroll { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.hscroll::-webkit-scrollbar { height: 0; }
.event-card {
  min-width: 190px; max-width: 190px;
  background: rgba(0,0,0,.2);
  border: 1px solid var(--border);
  border-radius: 14px; padding: 12px;
  flex-shrink: 0;
  text-decoration: none; color: inherit;
  transition: border-color .15s;
  display: block;
}
.event-card:hover { border-color: rgba(99,102,241,.4); }
.event-card .name { font-weight: 600; font-size: 0.85rem; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.event-card .date { color: var(--muted); font-size: 0.72rem; margin-bottom: 8px; }

/* ── Forms & Inputs ── */
.input {
  width: 100%; height: 44px;
  background: rgba(0,0,0,.25); border: 1px solid var(--border);
  border-radius: 12px; padding: 0 14px;
  color: var(--text); font-family: var(--font-body); font-size: 0.9rem;
  outline: none; transition: border-color .15s;
  appearance: none;
}
.input:focus { border-color: rgba(99,102,241,.6); }
.input::placeholder { color: var(--muted); }
.input-wrap { position: relative; display: flex; gap: 8px; }
.label-text { color: var(--muted); font-size: 0.75rem; margin-bottom: 6px; display: block; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 44px; padding: 0 18px;
  border-radius: 12px; border: none; cursor: pointer;
  font-family: var(--font-body); font-size: 0.9rem; font-weight: 500;
  transition: filter .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(1.12); }
.btn-ghost    { background: var(--card); border: 1px solid var(--border); color: var(--muted); }
.btn-ghost:hover  { color: var(--text); }
.btn-danger   { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); color: var(--danger); }
.btn-danger:hover { background: rgba(239,68,68,.2); }
.btn-sm       { height: 34px; padding: 0 12px; font-size: 0.8rem; }
.btn-full     { width: 100%; }

/* ── Tabs ── */
.tabs { display: flex; gap: 8px; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; margin-bottom: 16px; }
.tabs::-webkit-scrollbar { height: 0; }
.tab-btn {
  padding: 7px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--card); color: var(--muted);
  font-family: var(--font-body); font-size: 0.82rem; cursor: pointer;
  white-space: nowrap; transition: background .12s, color .12s;
}
.tab-btn.active, .tab-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Bottom Navigation ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: rgba(18,18,26,.96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 10px 4px;
  text-decoration: none; color: var(--muted);
  font-size: 0.68rem; gap: 3px;
  transition: color .15s;
}
.nav-item:hover, .nav-item.active { color: var(--primary); }
.nav-item .nav-icon { font-size: 1.3rem; line-height: 1; }

/* ── Notification banner ── */
.notif-banner {
  position: sticky; top: 0; z-index: 50;
  padding: 8px 16px; text-align: center; font-size: 0.82rem;
  backdrop-filter: blur(8px);
}
.notif-offline { background: rgba(245,158,11,.9); color: #000; }
.notif-info    { background: rgba(99,102,241,.9); color: #fff; }

/* ── Chart wrapper ── */
.chart-wrap { width: 100%; height: 200px; position: relative; }
canvas { width: 100% !important; }

/* ── Skeleton ── */
@keyframes shimmer { 0%,100%{opacity:.4} 50%{opacity:.8} }
.skeleton { background: rgba(255,255,255,.06); border-radius: 8px; animation: shimmer 1.6s ease infinite; }

/* ── Toast ── */
#toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 16px;
  font-size: 0.85rem; max-width: 300px;
  animation: slideIn .25s ease;
  pointer-events: all;
}
.toast.success { border-color: rgba(16,185,129,.4); }
.toast.danger  { border-color: rgba(239,68,68,.4); }
.toast.info    { border-color: rgba(99,102,241,.4); }
@keyframes slideIn { from{opacity:0;transform:translateX(20px)} to{opacity:1;transform:translateX(0)} }

/* ── Spinner ── */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.2); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utilities ── */
.flex          { display: flex; }
.flex-1        { flex: 1; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2         { gap: 8px; }
.gap-3         { gap: 12px; }
.mt-1          { margin-top: 4px; }
.mt-2          { margin-top: 8px; }
.mt-3          { margin-top: 12px; }
.mb-1          { margin-bottom: 4px; }
.mb-2          { margin-bottom: 8px; }
.mb-3          { margin-bottom: 12px; }
.truncate      { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid-2        { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.divider       { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.w-full        { width: 100%; }
.fs-sm         { font-size: 0.82rem; }
.fs-xs         { font-size: 0.72rem; }
.fw-600        { font-weight: 600; }
.text-right    { text-align: right; }
.strikethrough { text-decoration: line-through; opacity: .5; }
.clickable     { cursor: pointer; }
