:root {
  --bg: #f4f5f7;
  --bg-2: #ffffff;
  --card: #ffffff;
  --border: #e6e8ec;
  --border-strong: #d5d9e0;
  --text: #1b1f27;
  --text-2: #4a5160;
  --muted: #8a92a3;
  --accent: #4338ca;
  --shadow: 0 1px 3px rgba(20,25,40,.06), 0 8px 24px rgba(20,25,40,.05);
  --shadow-lg: 0 20px 60px rgba(15,20,35,.22);
  --row-hover: #f6f7fb;
}
:root.dark {
  --bg: #0e1117;
  --bg-2: #151a22;
  --card: #171d27;
  --border: #262d3a;
  --border-strong: #333c4c;
  --text: #eef1f6;
  --text-2: #b6becc;
  --muted: #6c7688;
  --accent: #8b8bff;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 24px 70px rgba(0,0,0,.6);
  --row-hover: #1c2330;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}
.num, .amount, .cell-id, .brand-sub, .live-pill, .panel-id {
  font-family: 'IBM Plex Mono', monospace;
}

.app { min-height: 100vh; display: flex; flex-direction: column; }
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; flex: 1; }

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  background: color-mix(in srgb, var(--bg-2) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; display: grid; place-items: center;
  font-size: 20px; border-radius: 12px;
  background: linear-gradient(135deg, #ff7eb6, #ff5c8a);
  box-shadow: 0 4px 14px rgba(255,92,138,.35);
}
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: .01em; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.live-pill {
  font-size: 10.5px; padding: 5px 10px; border-radius: 999px;
  color: #059669; background: rgba(16,185,129,.12);
  border: 1px solid rgba(16,185,129,.25);
}
:root.dark .live-pill { color: #4ade80; background: rgba(74,222,128,.1); }
.mode-btn {
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  font-size: 16px; transition: .2s;
}
.mode-btn:hover { border-color: var(--border-strong); transform: translateY(-1px); }

/* ===== Stats ===== */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px;
}
.stat-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-icon {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-size: 18px; font-weight: 700;
}
.ac-slate { background: rgba(99,102,120,.14); color: #64748b; }
.ac-amber { background: rgba(245,158,11,.16); color: #d97706; }
.ac-green { background: rgba(16,185,129,.16); color: #059669; }
.ac-violet { background: rgba(99,102,241,.16); color: #6366f1; }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.stat-sub { font-size: 10.5px; color: var(--muted); margin-top: 2px; }

/* ===== Controls ===== */
.controls {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.controls-top { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.search-wrap { position: relative; flex: 1; }
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 17px;
}
.search-input {
  width: 100%; padding: 11px 38px 11px 40px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: 14px; font-family: inherit; outline: none;
  transition: .2s;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.clear-x {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px;
}
.view-toggle { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: 11px; padding: 3px; flex: none; }
.vt-btn {
  border: none; background: transparent; color: var(--text-2); cursor: pointer;
  padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; font-family: inherit;
  transition: .18s; white-space: nowrap;
}
.vt-active { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.1); }

.status-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.pill {
  border: 1px solid var(--border); background: var(--bg); color: var(--text-2);
  padding: 7px 14px; border-radius: 999px; font-size: 12.5px; cursor: pointer;
  font-family: inherit; font-weight: 500; transition: .18s;
}
.pill:hover { border-color: var(--border-strong); }
.pill-active { background: var(--text); color: var(--bg-2); border-color: var(--text); }

.selects { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.sel-group { display: flex; flex-direction: column; gap: 4px; }
.sel-label { font-size: 11px; color: var(--muted); font-weight: 500; padding-left: 2px; }
.sel {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  padding: 9px 12px; border-radius: 10px; font-size: 13px; font-family: inherit;
  cursor: pointer; outline: none; min-width: 150px;
}
.sel:focus { border-color: var(--accent); }
.reset-btn {
  border: 1px solid var(--border); background: transparent; color: var(--text-2);
  padding: 9px 16px; border-radius: 10px; font-size: 13px; cursor: pointer;
  font-family: inherit; font-weight: 500; transition: .18s;
}
.reset-btn:hover { border-color: var(--border-strong); color: var(--text); }
.result-count { font-size: 12px; color: var(--muted); margin-top: 14px; }

/* ===== Badges ===== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; }
.badge-amber { background: rgba(245,158,11,.14); color: #b45309; }
.badge-blue  { background: rgba(14,165,233,.14); color: #0369a1; }
.badge-green { background: rgba(16,185,129,.15); color: #047857; }
.badge-red   { background: rgba(244,63,94,.14); color: #be123c; }
:root.dark .badge-amber { color: #fbbf24; }
:root.dark .badge-blue  { color: #38bdf8; }
:root.dark .badge-green { color: #34d399; }
:root.dark .badge-red   { color: #fb7185; }

.pr {
  display: inline-block; padding: 3px 9px; border-radius: 7px;
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
}
.pr-low    { background: rgba(120,130,150,.14); color: #6b7280; }
.pr-medium { background: rgba(14,165,233,.13); color: #0284c7; }
.pr-high   { background: rgba(249,115,22,.15); color: # c2410c; color: #c2410c; }
.pr-urgent { background: rgba(244,63,94,.16); color: #e11d48; }
:root.dark .pr-medium { color: #38bdf8; }
:root.dark .pr-high   { color: #fb923c; }
:root.dark .pr-urgent { color: #fb7185; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(244,63,94,.4); }
  50% { box-shadow: 0 0 0 5px rgba(244,63,94,0); }
}

/* ===== Avatars ===== */
.avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 10px; font-weight: 700;
  color: #fff; border: 2px solid var(--card);
}
.av-1 { background: #6366f1; } .av-2 { background: #0ea5e9; }
.av-3 { background: #10b981; } .av-4 { background: #f59e0b; }
.av-5 { background: #ec4899; }
.av-extra { background: var(--border-strong); color: var(--text-2); }

/* ===== Table ===== */
.table-wrap {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; overflow: hidden; box-shadow: var(--shadow);
  overflow-x: auto;
}
.tbl { width: 100%; border-collapse: collapse; min-width: 860px; }
.tbl thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600; padding: 14px 16px;
  border-bottom: 1px solid var(--border); background: var(--bg);
}
.tbl th.num, .tbl td.num { text-align: right; }
.row {
  cursor: pointer; border-bottom: 1px solid var(--border);
  animation: fadeUp .4s ease both;
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--row-hover); }
.tbl td { padding: 13px 16px; font-size: 13.5px; vertical-align: middle; }
.cell-name { font-weight: 600; }
.cell-id { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.muted { color: var(--muted); }
.amount { font-weight: 600; }
.kat-tag {
  font-size: 11px; padding: 3px 8px; border-radius: 6px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text-2);
}
.detail-link { font-size: 12px; color: var(--accent); font-weight: 600; }

/* ===== Cards ===== */
.cards-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 16px; cursor: pointer; box-shadow: var(--shadow);
  transition: .2s; animation: fadeUp .4s ease both;
  display: flex; flex-direction: column; gap: 10px;
}
.card:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-name { font-weight: 700; font-size: 14.5px; line-height: 1.3; letter-spacing: -.01em; }
.card-amount { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; }
.dot-sep { color: var(--muted); }
.card-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--border);
}

/* ===== Empty ===== */
.empty {
  text-align: center; padding: 70px 20px;
  background: var(--card); border: 1px dashed var(--border-strong);
  border-radius: 16px;
}
.empty-emoji { font-size: 46px; }
.empty-title { font-weight: 700; font-size: 17px; margin-top: 10px; }
.empty-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.mt-4 { margin-top: 16px; }

/* ===== Detail Panel ===== */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10,14,22,.5); backdrop-filter: blur(3px);
  display: flex; justify-content: flex-end;
  animation: fadeIn .2s ease;
}
.panel {
  width: min(460px, 100%); height: 100%; overflow-y: auto;
  background: var(--bg-2); box-shadow: var(--shadow-lg);
  padding: 24px; animation: slideIn .3s cubic-bezier(.2,.8,.2,1);
}
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.panel-id { font-size: 11px; color: var(--muted); }
.panel-title { font-size: 21px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 0; line-height: 1.25; }
.close-btn {
  border: 1px solid var(--border); background: var(--card); color: var(--text-2);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; flex: none; font-size: 14px;
}
.close-btn:hover { color: var(--text); }
.panel-badges { display: flex; align-items: center; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
.approved-flair { font-size: 12px; font-weight: 600; color: #059669; }
:root.dark .approved-flair { color: #34d399; }
.panel-amount {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 30px; font-weight: 800; letter-spacing: -.02em;
  padding: 16px; border-radius: 14px; background: var(--bg);
  border: 1px solid var(--border); margin-bottom: 20px;
}
.panel-amount-label { font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; font-family: 'Bricolage Grotesque'; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.field { min-width: 0; }
.field.full { margin-top: 18px; }
.field-label { font-size: 11px; color: var(--muted); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 3px; }
.field-value { font-size: 14px; font-weight: 500; word-break: break-word; }
.field-note {
  font-size: 13.5px; line-height: 1.5; color: var(--text-2);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px;
}
.approval-block { margin-top: 22px; }
.approver-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 8px; }
.approver-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px;
}
.approver-name { font-size: 13.5px; font-weight: 600; flex: 1; }
.approver-check { font-size: 11.5px; font-weight: 600; color: #059669; }
:root.dark .approver-check { color: #34d399; }
.no-approver {
  font-size: 13px; color: var(--muted); margin-top: 8px;
  background: var(--bg); border: 1px dashed var(--border-strong);
  border-radius: 10px; padding: 14px; text-align: center;
}

/* ===== Footer ===== */
.footer {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 24px; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--border);
}
.remix { color: var(--accent); text-decoration: none; font-weight: 600; }
.remix:hover { text-decoration: underline; }

/* ===== Animations ===== */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateX(30px); opacity: .5; } to { transform: none; opacity: 1; } }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .controls-top { flex-direction: column; align-items: stretch; }
  .view-toggle { justify-content: center; }
  .cards-grid { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .selects { flex-direction: column; align-items: stretch; }
  .sel { width: 100%; }
  .panel { width: 100%; }
  .brand-sub { display: none; }
  .stat-value { font-size: 21px; }
}