:root {
  --bg: #f1f5f9; --surface: #fff; --text: #0f172a; --muted: #64748b; --border: #e2e8f0;
  --brand: #1e3a8a; --accent: #2563eb; --accent-soft: #dbeafe;
  --ok: #16a34a; --warn: #d97706; --danger: #dc2626; --danger-soft: #fee2e2;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 14px; }

/* Buttons */
.btn { border: 1px solid transparent; border-radius: 10px; padding: 10px 16px; font-weight: 600; cursor: pointer; background: var(--surface); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:disabled { opacity: .6; }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.icon-btn { border: 0; background: transparent; color: var(--muted); padding: 4px 8px; cursor: pointer; font-size: 15px; border-radius: 8px; flex-shrink: 0; }
.icon-btn:hover { background: var(--bg); }

/* Screens */
.screen.center { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; gap: 24px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.auth { width: 100%; max-width: 360px; padding: 28px 24px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.auth h1 { margin: 0; font-size: 24px; color: var(--brand); }
.auth p.muted { margin: -8px 0 6px; }
.auth-logo { width: 72px; height: 72px; margin: 0 auto; border-radius: 18px; }
label { display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: 16px; color: var(--text); }
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* App shell */
#app { min-height: 100vh; padding-bottom: calc(68px + var(--safe-b)); }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; background: var(--brand); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 500; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.me { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.me .btn.ghost { color: #fff; border-color: rgba(255,255,255,.35); white-space: nowrap; }
#meName { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
#meName small { opacity: .75; font-size: 11px; }
.countdown { background: #fff; border-bottom: 1px solid var(--border); padding: 10px 16px; display: flex; align-items: center; gap: 14px; }
.countdown .num { font-size: 26px; font-weight: 800; color: var(--accent); line-height: 1; min-width: 44px; text-align: center; }
.countdown .txt { font-size: 13px; color: var(--muted); line-height: 1.35; }
.countdown .txt b { color: var(--text); }
main { max-width: 900px; margin: 0 auto; padding: 16px; }
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; background: var(--surface);
  border-top: 1px solid var(--border); padding-bottom: var(--safe-b);
}
.tabs button { flex: 1; border: 0; background: none; padding: 8px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs svg { width: 24px; height: 24px; fill: currentColor; }
.tabs button.on { color: var(--accent); }

/* Sections */
.head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 12px; }
.head h2 { margin: 0; font-size: 18px; }
h3.sub { font-size: 15px; margin: 22px 0 10px; }
.install { display: flex; align-items: center; gap: 10px; background: var(--accent-soft); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }
.install span { flex: 1; }
.stats { padding: 14px 16px; margin-bottom: 12px; }
.stats-row { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; }
.stat b { display: block; font-size: 22px; line-height: 1; }
.stat small { color: var(--muted); font-size: 12px; }
.bar { flex: 1 1 160px; }
.bar i { display: block; height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; }
.bar i::after { content: ""; display: block; height: 100%; width: var(--pct); background: var(--ok); }
.bar small { color: var(--muted); font-size: 12px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.filters select { width: auto; padding: 6px 10px; font-size: 13px; border-radius: 99px; }

.phase { overflow: hidden; margin-bottom: 12px; }
.phase-title { padding: 10px 16px; background: var(--accent-soft); color: var(--brand); font-weight: 700; font-size: 14px; }
.week { padding: 6px 16px 8px; }
.week-title { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; margin: 8px 0 4px; }
.task { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.task input[type=checkbox] { width: 20px; height: 20px; margin: 1px 0 0; flex-shrink: 0; accent-color: var(--ok); cursor: pointer; }
.task .body { flex: 1; min-width: 0; }
.task .t { font-size: 14.5px; }
.task.done .t { text-decoration: line-through; color: var(--muted); }
.task .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; align-items: center; }
.task .by { font-size: 12px; color: var(--muted); }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: #e0f2fe; color: #0369a1; white-space: nowrap; }
.badge.due { background: #eef2ff; color: #3730a3; }
.badge.late { background: var(--danger-soft); color: #991b1b; }
.badge.amber { background: #fef3c7; color: #92400e; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.link { display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin-bottom: 10px; }
.link .ic { font-size: 22px; }
.link .body { flex: 1; min-width: 0; }
.link .body b { display: block; font-size: 14.5px; }
.link .body small { color: var(--muted); }
.link a.btn { text-decoration: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.soon { padding: 16px; }
.soon b { display: block; margin-bottom: 4px; }
.soon p { margin: 0 0 10px; font-size: 13px; color: var(--muted); }

.user { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
.user:first-child { border-top: 0; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; }
.user .body { flex: 1; }
.user small { color: var(--muted); display: block; font-size: 12px; }
.note { font-size: 13px; color: var(--muted); padding: 12px 16px; margin-top: 12px; }
.note code { background: var(--bg); padding: 1px 5px; border-radius: 4px; word-break: break-all; }

/* Bottom sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; background: rgba(15,23,42,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; background: var(--surface); border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; max-height: 90vh; overflow: auto; }
.sheet h3 { margin: 0 0 4px; }
.sheet .row { display: flex; gap: 10px; }
.sheet .row > * { flex: 1; }
.sheet .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 18px; } }

.toast { position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%); z-index: 30; background: var(--text); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px); }

/* Prime Computers credit */
.footer-credit { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 18px 16px; color: var(--muted); font-size: 12px; }
.footer-credit .credit { display: inline-flex; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; }
.footer-credit .credit-logo { height: 22px; display: block; }
