:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-soft: #475569;
  --muted: #94a3b8;
  --line: #e2e8f0;
  --brand: #0f172a;
  --accent: #0284c7;
  --accent-soft: #e0f2fe;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--ink-soft); }
.tiny { font-size: 12px; }
code { background: #f1f5f9; padding: 1px 5px; border-radius: 5px; font-size: 13px; }

/* ---------- Sign-in ---------- */
.signin-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1e293b, #0f172a);
  padding: 24px;
}
.signin-card {
  background: var(--panel); border-radius: 20px; padding: 36px 30px; max-width: 380px; width: 100%;
  text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.signin-card h1 { font-size: 22px; margin: 14px 0 6px; }
.brand-mark {
  width: 60px; height: 60px; border-radius: 16px; margin: 0 auto;
  background: var(--brand); color: #e2e8f0; font-weight: 800; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
}
.config-warning {
  margin-top: 18px; background: #fef3c7; color: #92400e; border-radius: 10px;
  padding: 12px; font-size: 13px; text-align: left;
}

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 10px; padding: 9px 14px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: .15s; font-family: inherit;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #0369a1; }
.btn-lg { padding: 12px 18px; font-size: 15px; width: 100%; margin-top: 10px; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.icon-btn {
  border: none; background: transparent; color: #cbd5e1; font-size: 18px;
  cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

/* ---------- Topbar ---------- */
.topbar { position: sticky; top: 0; z-index: 40; background: var(--brand); color: #e2e8f0; }
.topbar-inner {
  max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 16px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
}
.topbar-brand { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: #38bdf8; box-shadow: 0 0 0 4px rgba(56,189,248,.18); }
.greeting { white-space: nowrap; }
.topnav { display: flex; gap: 2px; margin-left: 8px; flex: 1; overflow-x: auto; }
.navlink {
  background: transparent; border: none; color: #94a3b8; font-weight: 600; font-size: 14px;
  padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; font-family: inherit;
}
.navlink:hover { color: #e2e8f0; background: rgba(255,255,255,.06); }
.navlink.active { color: #fff; background: rgba(56,189,248,.18); }
.topbar-user { display: flex; align-items: center; gap: 6px; }
.user-name { font-size: 13px; color: #cbd5e1; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Screen layout ---------- */
.screen {
  max-width: 1100px; margin: 0 auto; padding: 18px 16px 96px;
}
.page-title { font-size: 20px; font-weight: 700; margin: 4px 0 16px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ---------- Cards ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 14px; font-weight: 700; margin: 0; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.card-body { padding: 8px 16px 14px; }
.card-body.tight { padding: 4px 8px 8px; }

/* ---------- List rows ---------- */
.row {
  display: flex; align-items: flex-start; gap: 12px; padding: 11px 8px;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 14.5px; }
.row-sub { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.row-time { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13px; color: var(--ink); white-space: nowrap; }
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }

.dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.dot.green { background: var(--green); }
.dot.amber { background: var(--amber); }
.dot.red { background: var(--red); }
.dot.blue { background: var(--accent); }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: #f1f5f9; color: var(--ink-soft);
}
.badge.high { background: #fee2e2; color: #b91c1c; }
.badge.med  { background: #ffedd5; color: #c2410c; }
.badge.low  { background: #ecfccb; color: #4d7c0f; }
.badge.blue { background: var(--accent-soft); color: #075985; }
.badge.unread { background: var(--accent); color: #fff; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink-soft);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Stat tiles ---------- */
.stat { text-align: center; padding: 14px 8px; }
.stat-num { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Today gaps timeline ---------- */
.gap { color: var(--green); font-weight: 600; font-size: 13px; }
.empty {
  text-align: center; color: var(--muted); padding: 22px 12px; font-size: 14px;
}

/* ---------- Forms ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; }

/* ---------- Timer ---------- */
.timer-display { font-size: 46px; font-weight: 800; font-variant-numeric: tabular-nums; text-align: center; letter-spacing: .02em; }
.timer-active-label { text-align: center; color: var(--accent); font-weight: 700; margin-top: 2px; }
.activity-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.activity-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 6px;
  font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--ink-soft);
}
.activity-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.bar-row { display: flex; align-items: center; gap: 10px; margin: 7px 0; }
.bar-label { width: 80px; font-size: 13px; font-weight: 600; }
.bar-track { flex: 1; background: #f1f5f9; border-radius: 999px; height: 12px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.bar-val { width: 52px; text-align: right; font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink-soft); }

/* ---------- News ---------- */
.news-item { padding: 12px 8px; border-bottom: 1px solid var(--line); }
.news-item:last-child { border-bottom: none; }
.news-head { font-weight: 700; font-size: 14.5px; }
.news-head a { color: var(--ink); text-decoration: none; }
.news-head a:hover { color: var(--accent); }
.news-sum { color: var(--ink-soft); font-size: 13px; margin: 3px 0 5px; }
.news-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 88px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 14px; z-index: 80; box-shadow: 0 8px 30px rgba(0,0,0,.3); max-width: 90%;
}

/* ---------- Bottom nav (mobile) ---------- */
.bottomnav { display: none; }

@media (max-width: 760px) {
  .topnav { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .activity-grid { grid-template-columns: repeat(4, 1fr); }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: #fff; border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bnav {
    flex: 1; border: none; background: transparent; font-size: 11px; font-weight: 600;
    color: var(--muted); padding: 8px 2px 7px; display: flex; flex-direction: column;
    align-items: center; gap: 3px; cursor: pointer; font-family: inherit;
  }
  .bnav span { font-size: 17px; }
  .bnav.active { color: var(--accent); }
  .user-name { display: none; }
}

@media (min-width: 761px) {
  .span-2 { grid-column: span 2; }
}
