:root{
  /* Dark mode (default) */
  --bg:#0b0f14;
  --surface:#0f172a;
  --surface-2:#111c33;
  --border:rgba(255,255,255,.10);
  --text:#e5e7eb;
  --muted:#9ca3af;

  /* Chrome + accents (img.zip-ish) */
  --nav:#0b1220;
  --nav-border:rgba(255,255,255,.12);
  --primary:#3b82f6;
  --primary-hover:#2563eb;
  --success:#22c55e;
  --danger:#ef4444;
  --warning:#f59e0b;

  /* Conditional value colours */
  --val-pos: var(--success);
  --val-neg: var(--danger);
  --val-zero: var(--warning);

  --radius:14px;
  --radius-sm:10px;
  --shadow: 0 10px 28px rgba(0,0,0,.45);
  --shadow-sm: 0 6px 16px rgba(0,0,0,.35);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a{ color: var(--primary); text-decoration:none; }
a:hover{ text-decoration:underline; }

/* Top navigation (img.zip vibe) */
.topbar{
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--nav);
  border-bottom: 1px solid var(--nav-border);
}
.topbar-inner{
  width: min(1180px, 94vw);
  margin: 0 auto;
  padding: 14px 0;
  display:flex;
  align-items:center;
  gap:18px;
}

.brand{
  display:inline-flex;
  align-items:center;
  gap:10px;
  color:#fff;
  text-decoration:none;
  white-space:nowrap;
}
.brand:hover{ text-decoration:none; }
.brand-dot{
  width:28px; height:28px;
  border-radius:8px;
  display:grid; place-items:center;
  background: linear-gradient(135deg, rgba(13,110,253,1), rgba(25,135,84,1));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.brand-text{ font-weight:800; letter-spacing:.2px; }

.nav{ flex: 1; display:flex; align-items:center; justify-content:space-between; gap:14px; }
.nav-left{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.nav-right{ display:flex; align-items:center; gap:10px; }

/* Mobile hamburger */
.nav-toggle{
  display:none;
  appearance:none;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  width: 44px;
  height: 40px;
  cursor:pointer;
}
.nav-toggle:hover{ background: rgba(255,255,255,.12); }
.burger{
  display:block;
  width: 18px;
  height: 2px;
  margin: 0 auto;
  background: rgba(255,255,255,.92);
  border-radius: 99px;
  position: relative;
}
.burger::before,.burger::after{
  content:"";
  position:absolute;
  left:0;
  width: 18px;
  height: 2px;
  background: rgba(255,255,255,.92);
  border-radius: 99px;
}
.burger::before{ top: -6px; }
.burger::after{ top: 6px; }

.mobile-menu{
  position:absolute;
  right: 3vw;
  top: calc(100% + 10px);
  width: min(420px, 94vw);
  background: #11161b;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0,0,0,.40);
  padding: 10px;
}
.mobile-menu-head{ padding: 8px; }
.mobile-menu-links{ display:flex; flex-direction:column; gap:6px; padding: 6px; }
.mobile-menu-foot{ padding: 8px; }
.mobile-menu-sep{ height:1px; background: rgba(255,255,255,.10); margin: 6px 8px; border-radius:999px; }

.mnav{
  color: rgba(255,255,255,.88);
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.06);
  font-weight: 750;
}
.mnav:hover{ background: rgba(255,255,255,.10); text-decoration:none; }
.mnav.active{
  background: rgba(13,110,253,.22);
  border-color: rgba(13,110,253,.40);
  color: #fff;
}

.navlink{
  color: rgba(255,255,255,.86);
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  text-decoration:none;
}
.navlink:hover{
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.10);
  text-decoration:none;
}
.navlink.active{
  background: rgba(13,110,253,.18);
  border-color: rgba(13,110,253,.38);
  color:#fff;
}

.nav-sep{ width:1px; height:22px; background: rgba(255,255,255,.18); border-radius:999px; margin:0 4px; }

.chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color:#fff;
  font-size: 13px;
}
.chip .dot{ width:8px; height:8px; border-radius:999px; background: var(--success); box-shadow: 0 0 0 3px rgba(25,135,84,.22); }

/* Page container */
.app{ width: min(1180px, 94vw); margin: 26px auto 60px; }

/* Panels / cards */
.panel{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}

/* Card value conditional formatting */
.val-pos{ color: var(--val-pos); }
.val-neg{ color: var(--val-neg); }
.val-zero{ color: var(--val-zero); }

h1{ font-size: 34px; margin: 0 0 6px; letter-spacing:.2px; }
h2{ font-size: 18px; margin: 0 0 8px; }
h3{ font-size: 16px; margin: 0 0 8px; }
.muted{ color: var(--muted); }
.small{ font-size: 13px; }
.mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }

.stack{ display:flex; flex-direction:column; gap:14px; }
.inline{ display:inline-flex; align-items:center; gap:10px; }
.row-between{ display:flex; align-items:flex-start; justify-content:space-between; gap:14px; }
.pad{ padding: 10px 0; }

/* Dashboard grids */
.cards{
  display:grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.cards .k{ color: var(--muted); font-size: 12px; }
.cards .v{ font-weight: 850; font-size: 20px; margin-top: 6px; }
.cards .v.big{ font-size: 24px; }


.dash-groups{ display:flex; flex-direction:column; gap:14px; }

.cards.cards-2{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cards.cards-3{ grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (max-width: 980px){
  .cards.cards-3{ grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 520px){
  .cards.cards-2, .cards.cards-3{ grid-template-columns: 1fr; }
}

.layout{
  display:grid;
  grid-template-columns: 420px 1fr;
  gap: 14px;
}
@media (max-width: 980px){
  .cards{ grid-template-columns: repeat(2, minmax(0,1fr)); }
  .layout{ grid-template-columns: 1fr; }
}

/* Switch to dropdown navigation on mobile */
@media (max-width: 860px){
  /* Make the topbar + app span the full viewport width on mobile
     (prevents the "tables are wider than panels/nav" look when panning/zooming) */
  .topbar-inner{
    position: relative;
    width: 100vw;
    max-width: 100vw;
    margin: 0;
    padding: 14px 14px;
  }
  .app{
    width: 100vw;
    max-width: 100vw;
    margin: 18px 0 60px;
    padding: 0 14px;
  }

  .nav-left, .nav-right{ display:none; }
  .nav-toggle{ display:inline-flex; align-items:center; justify-content:center; }
  .nav{ justify-content:flex-end; }

  /* Align the dropdown with the same gutters as the container */
  .mobile-menu{
    left: 14px;
    right: 14px;
    width: auto;
  }

  body.nav-open .mobile-menu{ display:block; }
}

/* Forms */
label{ display:block; font-size: 12px; color: var(--muted); }
.form .field{ display:flex; flex-direction:column; gap:6px; }
input, select{
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255,255,255,.03);
  color: var(--text);
  outline:none;
}
input:focus, select:focus{
  border-color: rgba(13,110,253,.55);
  box-shadow: 0 0 0 4px rgba(13,110,253,.15);
}
.actions{ display:flex; align-items:center; gap:10px; }

/* Buttons (no more default white rectangles) */
.btn{
  appearance:none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  cursor:pointer;
  transition: transform .05s ease, filter .12s ease, background-color .12s ease;
}
.btn:active{ transform: translateY(1px); }

.btn.primary{
  background: var(--primary);
  color:#fff;
}
.btn.primary:hover{ background: var(--primary-hover); }

.btn.ghost{
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn.ghost:hover{ background: rgba(255,255,255,.06); }

/* On dark nav, keep ghost buttons readable */
.topbar .btn.ghost{
  border-color: rgba(255,255,255,.22);
  color:#fff;
}
.topbar .btn.ghost:hover{ background: rgba(255,255,255,.10); }

.btn.gray{
  background: #6c757d;
  color:#fff;
}
.btn.gray:hover{ filter: brightness(1.03); }

.btn.ok{ background: var(--success); color:#fff; }
.btn.ok:hover{ filter: brightness(1.03); }

.btn.danger{ background: var(--danger); color:#fff; }
.btn.danger:hover{ filter: brightness(1.03); }

.btn.tiny{ padding: 7px 10px; border-radius: 9px; font-size: 12px; }

.btn:disabled,
.btn[disabled]{
  pointer-events:none;
  cursor:not-allowed;
  opacity:.55;
  filter: grayscale(.35);
  transform:none;
}

.btn.primary:disabled,
.btn.primary[disabled]{
  background: rgba(255,255,255,.14);
  color: rgba(255,255,255,.72);
}

/* Dashboard panel drag handle */
.panel{ position: relative; }
.drag-handle{
  position: absolute;
  top: 10px;
  right: 64px; /* leaves room for the Hide button */
  width: 34px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.8);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
}
.hideable.has-top-action > .drag-handle{ right: 140px; }
.drag-handle:hover{ filter: brightness(1.12); }
.drag-handle:active{ cursor: grabbing; }

.panel.is-dragging{
  opacity: .75;
  outline: 2px dashed rgba(255,255,255,.22);
  outline-offset: 3px;
}

/* Modern toggle switch (used in bulk edit) */
.switch{
  position: relative;
  display: inline-block;
  width: 52px;
  height: 30px;
}
.switch input{
  opacity: 0;
  width: 0;
  height: 0;
}
.slider{
  position:absolute;
  inset:0;
  background: rgba(255,255,255,.14);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background-color .16s ease, border-color .16s ease, filter .16s ease;
}
.slider:before{
  content:"";
  position:absolute;
  height: 24px;
  width: 24px;
  left: 3px;
  top: 2px;
  background: rgba(255,255,255,.92);
  border-radius: 999px;
  transition: transform .16s ease, filter .16s ease;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}
.switch input:checked + .slider{
  background: rgba(74, 144, 226, .85);
  border-color: rgba(255,255,255,.18);
}
.switch input:checked + .slider:before{
  transform: translateX(22px);
}

.bulk-grid{ display:flex; flex-direction:column; gap: 10px; }
.bulk-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.bulk-left{ flex:1; min-width:0; }
.bulk-right{ flex:0 0 auto; display:flex; align-items:center; }

/* Tables (standings-style spacing) */
.table-wrap{ width:100%; overflow-x:auto; overflow-y:auto; -webkit-overflow-scrolling:touch; border-radius: var(--radius); border:1px solid var(--border); }
table{ width:100%; border-collapse: separate; border-spacing: 0; background: var(--surface); }
.table-wrap table{ min-width: 680px; }

thead th{
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 800;
  font-size: 13px;
  text-align:left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space:nowrap;
}
tbody td{
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  vertical-align: middle;
}
tbody tr:nth-child(even){ background: rgba(255,255,255,.02); }
tbody tr:hover{ background: rgba(59,130,246,.10); }

/* Little status pills */
.badge{
  display:inline-flex;
  align-items:center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
}
.badge.ok{ background: rgba(34,197,94,.14); border-color: rgba(34,197,94,.25); color: #a7f3d0; }
.badge.warn{ background: rgba(245,158,11,.16); border-color: rgba(245,158,11,.28); color: #fde68a; }

.right{ text-align:right; }
.center{ text-align:center; }
.hidden{ display:none !important; }

.tag{
  display:inline-flex;
  align-items:center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text);
}

.row-dim{ opacity: .72; }

/* Simple dialogs used by bills/transactions */
.dialog{
  border: none;
  padding: 0;
  border-radius: var(--radius);
  width: min(720px, 94vw);
  box-shadow: 0 22px 70px rgba(0,0,0,.25);
}
.dialog::backdrop{ background: rgba(17,24,39,.55); }
.dialog-body{
  margin:0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.grid2{
  display:grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 720px){
  .grid2{ grid-template-columns: 1fr; }
}

/* --- Hideable panels/cards + Customize dropdown --- */
.hideable{ position: relative; }
.hide-btn{
  position:absolute;
  top: 10px;
  right: 10px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.86);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}
.hide-btn:hover{ background: rgba(255,255,255,.10); }

/* If there's already a top-right action button/link in the panel header (e.g. "All", "Open"),
   shift Hide left so the controls don't overlap. */
.hideable.has-top-action > .hide-btn{ right: 86px; }

.customize{ position: relative; display:inline-flex; align-items:center; }
.customize-menu{
  position:absolute;
  right: 0;
  top: calc(100% + 10px);
  width: min(360px, 90vw);
  background: #11161b;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0,0,0,.40);
  padding: 10px;
  z-index: 60;
}
.customize-title{ font-weight: 700; padding: 8px 8px 6px; }
.customize-list{ display:flex; flex-direction:column; gap:6px; padding: 6px; }
.customize-item{
  display:flex; align-items:center; justify-content:space-between;
  gap: 10px;
  padding: 10px 10px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 12px;
  background: rgba(255,255,255,.03);
}
.customize-item .label{ color: rgba(255,255,255,.88); font-size: 13px; }
