:root {
  --bg: #070604;
  --bg-2: #100e09;
  --surface: #17140e;
  --surface-2: #221d14;
  --line: rgba(245, 215, 110, 0.14);
  --text: #f6edd2;
  --muted: #b7a57a;
  --faint: #7a6a45;
  --gold: #f5d76e;
  --gold-2: #c9a227;
  --gold-dim: rgba(245, 215, 110, 0.12);
  --danger: #e07070;
  --danger-dim: rgba(224, 112, 112, 0.12);
  --ok: #8fd4a2;
  --warn: #f0b45a;
  --info: #8cb4e8;
  --radius: 18px;
  --font: "Sora", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(245, 215, 110, 0.08), transparent 55%),
    var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
input, select, textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 13px;
  outline: none;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--gold-2);
  box-shadow: 0 0 0 3px var(--gold-dim);
}
label {
  display: block;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.field { margin-bottom: 12px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.hidden { display: none !important; }

.auth-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: calc(20px + var(--safe-top)) 18px calc(20px + var(--safe-bot));
  overflow: auto;
}
.auth-card {
  width: min(440px, 100%);
  background: linear-gradient(180deg, rgba(245,215,110,.05), transparent 40%), var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 22px 22px 20px;
}
.logo-wrap { text-align: center; margin-bottom: 16px; }
.logo-wrap img { width: min(280px, 80%); height: auto; filter: drop-shadow(0 8px 24px rgba(0,0,0,.55)); }
.auth-card h2 { font-size: 20px; margin-bottom: 6px; }
.lede { color: var(--muted); margin-bottom: 16px; font-size: 14px; }
.err { color: var(--danger); font-size: 13px; min-height: 16px; margin: 4px 0 10px; }
.hint { color: var(--faint); font-size: 12px; margin-top: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 16px; border-radius: 12px; font-weight: 600;
}
.btn-primary { background: linear-gradient(180deg, #f8e39a, #c9a227); color: #1a1204; width: 100%; }
.btn-ghost { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); }
.btn-danger { background: var(--danger-dim); color: var(--danger); }
.btn-sm { padding: 8px 11px; font-size: 13px; }

.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  padding: calc(8px + var(--safe-top)) 14px 8px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(7,6,4,.88);
  backdrop-filter: blur(16px);
}
.topbar img { height: 36px; width: auto; }
.topbar .titles { flex: 1; min-width: 0; }
.topbar h1 { font-size: 15px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.topbar .who { color: var(--muted); font-size: 12px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
}

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; padding: 10px 14px 4px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 8px 7px;
  min-width: 0;
}
.stat b { display: block; font-size: 13px; font-family: var(--mono); color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }

.search-bar { padding: 8px 14px 0; }
.filters { display: flex; gap: 7px; padding: 8px 14px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 6px 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--muted); font-size: 12px; font-weight: 600;
}
.chip.active { background: var(--gold-dim); color: var(--gold); border-color: transparent; }

.list { flex: 1; overflow: auto; padding: 6px 14px calc(92px + var(--safe-bot)); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  border-left-width: 4px;
}
.tone-ordered {
  background: linear-gradient(90deg, rgba(140,180,232,.16), var(--surface) 28%);
  border-color: rgba(140,180,232,.28);
  border-left-color: #8cb4e8;
}
.tone-expected {
  background: linear-gradient(90deg, rgba(196,122,34,.18), var(--surface) 28%);
  border-color: rgba(196,122,34,.32);
  border-left-color: #c47a22;
}
.tone-landed {
  background: linear-gradient(90deg, rgba(143,212,162,.16), var(--surface) 28%);
  border-color: rgba(143,212,162,.28);
  border-left-color: #8fd4a2;
}
.tone-disbursed {
  background: linear-gradient(90deg, rgba(245,215,110,.16), var(--surface) 28%);
  border-color: rgba(245,215,110,.28);
  border-left-color: #f5d76e;
}
.tone-sold {
  background: linear-gradient(90deg, rgba(196,166,232,.16), var(--surface) 28%);
  border-color: rgba(196,166,232,.28);
  border-left-color: #c4a6e8;
}
.tone-other { border-left-color: var(--line); }
.tone-today {
  background: linear-gradient(90deg, rgba(245,215,110,.22), var(--surface) 28%);
  border-left-color: #f5d76e;
}
.tone-soon {
  background: linear-gradient(90deg, rgba(140,180,232,.16), var(--surface) 28%);
  border-left-color: #8cb4e8;
}
.tone-past {
  opacity: .72;
  border-left-color: #7a6a45;
}
.cal-when { font-family: var(--mono); font-size: 12px; color: var(--gold); }
.badge.sold { background: rgba(196,166,232,.16); color: #c4a6e8; }
.card-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.card h3 { font-size: 15px; letter-spacing: -0.02em; }
.meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.price { font-family: var(--mono); font-size: 12px; color: var(--gold); white-space: nowrap; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.badge {
  font-size: 10px; font-weight: 600; padding: 3px 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
}
.badge.ok { background: rgba(143,212,162,.12); color: var(--ok); }
.badge.warn { background: rgba(240,180,90,.14); color: var(--warn); }
.badge.info { background: rgba(140,180,232,.14); color: var(--info); }
.badge.danger { background: var(--danger-dim); color: var(--danger); }
.badge.gold { background: var(--gold-dim); color: var(--gold); }
.card-actions { display: flex; gap: 8px; margin-top: 10px; }
.act {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}
.act-gold { background: var(--gold-dim); color: var(--gold); border-color: transparent; }

.fab {
  position: fixed; right: 16px; bottom: calc(18px + var(--safe-bot));
  height: 52px; padding: 0 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, #f8e39a, #c9a227);
  color: #1a1204; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 10px 28px rgba(201, 162, 39, 0.28);
  z-index: 6;
}

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.72); display: none; z-index: 40; }
.overlay.show { display: block; }
.sheet {
  position: fixed;
  inset: 0;
  max-height: none;
  width: 100%;
  background: var(--bg-2);
  border: none;
  border-radius: 0;
  z-index: 41;
  display: none;
  flex-direction: column;
  padding-top: calc(var(--safe-top) + 22px);
  padding-bottom: calc(var(--safe-bot) + 10px);
}
.sheet.show { display: flex; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  position: sticky;
  top: 0;
  z-index: 2;
}
.sheet-head h2 { font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-head .icon-btn {
  width: 48px; height: 48px; flex: 0 0 48px;
  font-size: 22px;
  background: #2a2418;
  border: 1px solid var(--gold);
  color: var(--gold);
}
.sheet-body { overflow: auto; -webkit-overflow-scrolling: touch; padding: 14px 16px 16px; flex: 1; }
.sheet-actions { display: flex; gap: 8px; padding: 10px 16px 12px; border-top: 1px solid var(--line); flex-shrink: 0; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 7px 10px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { word-break: break-word; }

.nav {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  padding: 6px 8px calc(8px + var(--safe-bot));
  border-top: 1px solid var(--line);
  background: rgba(7,6,4,.94);
}
.nav button {
  padding: 8px 4px 6px;
  border-radius: 12px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.nav button.active { color: var(--gold); background: var(--gold-dim); }
.list { padding-bottom: calc(18px + var(--safe-bot)); }
.fab { bottom: calc(64px + var(--safe-bot)); }
.gap-neg { color: var(--danger); }
.gap-pos { color: var(--warn); }
.gap-ok { color: var(--ok); }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.sync-dot.on { background: var(--ok); }
.sync-dot.err { background: var(--danger); }
.bar-row { display: grid; grid-template-columns: 88px 1fr 64px; gap: 8px; align-items: center; margin: 7px 0; font-size: 12px; }
.bar-row span { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row b { text-align: right; font-family: var(--mono); font-size: 11px; color: var(--gold); }
.bar-track { height: 10px; background: #1b1710; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg,#c9a227,#f5d76e); border-radius: 99px; }
.pie { width: 160px; height: 160px; border-radius: 50%; margin: 12px auto 8px; box-shadow: inset 0 0 0 18px #17140e; }
.swatch { display: inline-block; width: 8px; height: 8px; border-radius: 99px; margin-right: 4px; }
.sheet-table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
table.glance { width: max(920px, 100%); border-collapse: collapse; font-size: 11px; }
table.glance th, table.glance td { padding: 8px 7px; border-bottom: 1px solid rgba(0,0,0,.25); text-align: left; white-space: nowrap; }
table.glance th { color: var(--muted); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; position: sticky; top: 0; background: var(--bg); z-index: 2; }
table.glance td.num { text-align: right; font-family: var(--mono); }
table.glance tr:active { filter: brightness(1.08); }
table.glance tr.tone-ordered td { background: #3b6eb5 !important; color: #fff; }
table.glance tr.tone-expected td { background: #c47a22 !important; color: #fff; }
table.glance tr.tone-landed td { background: #2a8a4a !important; color: #fff; }
table.glance tr.tone-disbursed td { background: #c9a227 !important; color: #1a1406; }
table.glance tr.tone-sold td { background: #7a4cb0 !important; color: #fff; }
table.glance tr.tone-other td { background: #2a2418 !important; color: #f6edd2; }
table.glance tr.tone-ordered td:first-child,
table.glance tr.tone-landed td:first-child,
table.glance tr.tone-disbursed td:first-child,
table.glance tr.tone-sold td:first-child { border-left: 0; }
table.glance .badge { white-space: nowrap; }

@media (min-width: 1100px) and (min-height: 700px) {
  .sheet {
    left: auto; right: 24px; top: 24px; bottom: 24px; width: 480px;
    border-radius: 24px; max-height: none; inset: auto;
    padding-top: 0;
  }
  .list, .stats, .search-bar, .filters, .topbar, .nav { max-width: 980px; margin-left: auto; margin-right: auto; width: 100%; }
}
