:root {
  --bg: #0f1115; --panel: #171a21; --panel2: #1e222b; --line: #2a2f3a;
  --text: #e8eaf0; --muted: #9aa3b2; --accent: #4f8cff; --accent2: #7aa7ff;
  --good: #3ecf8e; --bad: #ff6b6b; --warn: #f5b84f;
  --radius: 12px; --navh: 60px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh; font-size: 16px;
}
h1 { font-size: 1.3rem; } h2 { font-size: 1.05rem; margin-bottom: .6rem; }
.muted { color: var(--muted); } .small { font-size: .82rem; }
.error { color: var(--bad); margin-top: .6rem; font-size: .9rem; }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem 1.5rem; margin-top: 10vh; }
.brand { text-align: center; margin-bottom: 1.5rem; }
.brand-mark { width: 52px; height: 52px; margin: 0 auto .6rem; border-radius: 14px; background: linear-gradient(135deg, var(--accent), #2b5fd9); display: flex; align-items: center; justify-content: center; font-size: 1.6rem; font-weight: 700; }
label { display: block; font-size: .85rem; color: var(--muted); margin: .8rem 0 .25rem; }
input, select, textarea {
  width: 100%; padding: .7rem .8rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); font-size: 1rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

/* buttons */
.btn { border: none; border-radius: 8px; padding: .65rem 1rem; font-size: .95rem; cursor: pointer; background: var(--panel2); color: var(--text); min-height: 44px; }
.btn-primary { background: var(--accent); color: #fff; font-weight: 600; }
.btn-block { width: 100%; margin-top: 1.2rem; }
.btn-done { background: transparent; border: 1px solid var(--good); color: var(--good); padding: .35rem .7rem; min-height: 36px; border-radius: 8px; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }

/* app shell */
.app-header {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 1rem; padding-top: calc(.8rem + env(safe-area-inset-top));
  background: rgba(15,17,21,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.app-header .title { display: flex; align-items: center; gap: .55rem; font-weight: 700; }
.app-header .title .dot { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #2b5fd9); display: inline-flex; align-items: center; justify-content: center; font-size: .85rem; font-weight: 700; }
main { padding: 1rem; padding-bottom: calc(var(--navh) + env(safe-area-inset-bottom) + 1rem); max-width: 1100px; margin: 0 auto; }
section[hidden] { display: none; }

/* bottom nav (mobile-first) */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: grid; grid-template-columns: repeat(6, 1fr);
  background: rgba(15,17,21,.95); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
  height: calc(var(--navh) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
}
.nav button { background: none; border: none; color: var(--muted); font-size: .68rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; min-height: 44px; }
.nav button .ico { font-size: 1.15rem; line-height: 1; }
.nav button.active { color: var(--accent2); }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.cards-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-bottom: 1rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; text-align: center; }
.stat .val { font-size: 1.15rem; font-weight: 700; } .stat .lbl { font-size: .72rem; color: var(--muted); margin-top: 2px; }
.pos { color: var(--good); } .neg { color: var(--bad); } .warn { color: var(--warn); }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { font-size: .78rem; padding: .3rem .6rem; border-radius: 999px; border: 1px solid var(--warn); color: var(--warn); background: rgba(245,184,79,.08); }
.chip.neutral { border-color: var(--line); color: var(--muted); background: none; }
.chip.done { border-color: var(--good); color: var(--good); background: rgba(62,207,142,.08); }

/* action items */
.item { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: none; }
.item .t { font-weight: 600; } .item .meta { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.item.overdue .meta { color: var(--bad); }

/* tables -> cards on phone */
.rowcard { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem; margin-bottom: .5rem; }
.rowcard .top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.rowcard .name { font-weight: 600; } .rowcard .amt { font-weight: 700; white-space: nowrap; }
.rowcard .sub { font-size: .78rem; color: var(--muted); margin-top: 3px; display: flex; flex-wrap: wrap; gap: .35rem .8rem; }

/* placeholder frames */
.ph { border: 1px dashed var(--line); border-radius: var(--radius); padding: 1rem; color: var(--muted); margin-bottom: 1rem; }
.ph .ph-title { color: var(--text); font-weight: 600; margin-bottom: .3rem; }
.ph .phase { display: inline-block; font-size: .7rem; border: 1px solid var(--line); border-radius: 999px; padding: .15rem .5rem; margin-left: .4rem; color: var(--muted); vertical-align: middle; }

/* forms inline */
.addform { display: grid; gap: .5rem; margin-top: .8rem; }
.addform .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }

/* section filters */
.seg { display: flex; gap: .4rem; margin-bottom: .8rem; flex-wrap: wrap; }
.seg button { border: 1px solid var(--line); background: none; color: var(--muted); border-radius: 999px; padding: .35rem .8rem; font-size: .82rem; cursor: pointer; }
.seg button.active { border-color: var(--accent); color: var(--accent2); }

/* desktop */
@media (min-width: 800px) {
  .nav { top: 57px; bottom: auto; left: 0; right: auto; width: 200px; height: calc(100vh - 57px); grid-template-columns: 1fr; align-content: start; border-top: none; border-right: 1px solid var(--line); padding: 1rem 0; }
  .nav button { flex-direction: row; justify-content: flex-start; gap: .6rem; padding: .7rem 1.2rem; font-size: .9rem; }
  main { margin-left: 200px; max-width: 1000px; padding: 1.5rem 2rem; }
  .cards-row { grid-template-columns: repeat(3, 220px); }
}
