:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-soft: #475569;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-ink: #1d4ed8;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --shadow: 0 1px 3px rgba(15, 23, 42, .12), 0 1px 2px rgba(15, 23, 42, .08);
  --radius: 16px;
  font-size: 17px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f1f5f9;
  color: var(--ink);
  overscroll-behavior: none;
}

#app { display: flex; flex-direction: column; min-height: 100%; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--bg);
  color: #fff;
  padding: env(safe-area-inset-top) 20px 0;
  position: sticky; top: 0; z-index: 20;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 14px; padding: 14px 0 10px; }
.brand .logo { font-size: 30px; }
.brand h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: .2px; }
.net-pill {
  font-size: 12px; color: #cbd5e1; display: inline-block; margin-top: 2px;
}
.net-pill.online { color: #4ade80; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 0; }
.tab {
  appearance: none; border: 0; background: transparent; color: #94a3b8;
  font-size: 16px; font-weight: 600; padding: 12px 16px; cursor: pointer;
  border-bottom: 3px solid transparent; white-space: nowrap; min-height: 48px;
}
.tab.active { color: #fff; border-bottom-color: var(--brand); }

/* ---------- Main / views ---------- */
#main { flex: 1; padding: 18px 16px 120px; max-width: 1100px; width: 100%; margin: 0 auto; }
.view-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 16px; gap: 12px; }
.view-head h2 { margin: 0; font-size: 22px; }
.view-head .sub { color: var(--ink-soft); font-size: 14px; margin-top: 3px; }

/* ---------- Filter chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  padding: 9px 14px; border-radius: 999px; font-size: 14px; font-weight: 600;
  cursor: pointer; min-height: 40px;
}
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 12px;
}
.task {
  display: flex; align-items: flex-start; gap: 14px;
}
.task .check {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px;
  border: 2px solid var(--line); background: #fff; cursor: pointer;
  display: grid; place-items: center; font-size: 20px; color: transparent; margin-top: 2px;
}
.task.done .check { background: var(--ok); border-color: var(--ok); color: #fff; }
.task .body { flex: 1; min-width: 0; }
.task .title { font-size: 17px; font-weight: 650; line-height: 1.3; }
.task.done .title { text-decoration: line-through; color: var(--ink-soft); }
.task .meta { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 7px; font-size: 13px; color: var(--ink-soft); }
.task .meta b { color: var(--ink); font-weight: 600; }
.task .row-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: #166534; }
.badge.warn { background: var(--warn-soft); color: #92400e; }
.badge.bad { background: var(--bad-soft); color: #991b1b; }
.badge.muted { background: #f1f5f9; color: var(--ink-soft); }
.badge.prio-high { background: var(--bad-soft); color: #991b1b; }
.badge.prio-med { background: var(--warn-soft); color: #92400e; }
.badge.prio-low { background: #f1f5f9; color: var(--ink-soft); }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 15px; font-weight: 600; padding: 11px 16px; border-radius: 12px;
  cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; gap: 8px;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 8px 12px; font-size: 14px; min-height: 38px; }
.btn:active { transform: translateY(1px); }

/* ---------- Dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
  border-left: 5px solid var(--line);
}
.stat.bad { border-left-color: var(--bad); }
.stat.warn { border-left-color: var(--warn); }
.stat.ok { border-left-color: var(--ok); }
.stat.brand { border-left-color: var(--brand); }
.stat .num { font-size: 34px; font-weight: 800; line-height: 1; }
.stat .lbl { color: var(--ink-soft); font-size: 13px; margin-top: 6px; font-weight: 600; }

.section-title { font-size: 15px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .5px; margin: 22px 2px 10px; }

.list-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .t { font-weight: 600; }
.list-row .s { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

.empty { text-align: center; color: var(--ink-soft); padding: 40px 20px; }
.empty .big { font-size: 40px; }

/* ---------- Forms / modal ---------- */
.modal-host { position: fixed; inset: 0; z-index: 50; display: grid; place-items: end center; }
.modal-host.hidden { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,23,42,.5); }
.modal-card {
  position: relative; background: #fff; width: 100%; max-width: 560px;
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto; box-shadow: 0 -10px 40px rgba(0,0,0,.3);
  animation: slideUp .18s ease-out;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-card h3 { margin: 0 0 16px; font-size: 20px; }
@media (min-width: 700px) {
  .modal-host { place-items: center; }
  .modal-card { border-radius: 20px; }
}

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; font-size: 16px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; color: var(--ink); font-family: inherit;
}
.field textarea { min-height: 80px; resize: vertical; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn { flex: 1; justify-content: center; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: 20px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 30;
  width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--brand); color: #fff;
  font-size: 32px; line-height: 1; box-shadow: 0 6px 20px rgba(37,99,235,.45); cursor: pointer;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; z-index: 60;
  font-size: 15px; font-weight: 600; box-shadow: var(--shadow); max-width: 90vw;
}
.toast.hidden { display: none; }

.hidden { display: none !important; }
.muted-text { color: var(--ink-soft); }
hr.soft { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
