/* Theme matches RC Tracker */
:root {
  --bg: #0A0C0F;
  --surface: #111418;
  --card: #181D24;
  --border: #252B35;
  --accent: #E8FF00;
  --accent2: #00D4FF;
  --accent3: #FF6B35;
  --muted: #5A6478;
  --text: #E8EDF5;
  --text-dim: #8A94A8;
  --good: #34D399;
  --warn: #FF6B35;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--text); }
body {
  font: 14px/1.45 'Inter', 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent2); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }
.mono { font-family: var(--mono); }

/* ---------- header + top menu ---------- */
.header {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: env(safe-area-inset-top) 16px 0;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 48px; max-width: 1200px; margin: 0 auto; gap: 12px; }
.brand-row { display: flex; align-items: center; gap: 7px; min-width: 0; padding: 8px 0; }
.logo {
  width: 22px; height: 22px; border-radius: 5px; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); color: var(--bg); font-size: 12px; font-weight: 900;
}
.logo svg { width: 14px; height: 14px; }
.app-name { font-weight: 800; font-size: 13px; white-space: nowrap; }
.divider-group { display: flex; align-items: center; gap: 6px; margin-left: 6px; padding-left: 8px; border-left: 1px solid var(--border); min-width: 0; }
.hh-select {
  background: var(--card); border: 1px solid var(--border); color: var(--text); border-radius: 5px;
  padding: 3px 6px; font-size: 11px; font-weight: 600; max-width: 170px;
}
.hh-name { font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.logout { background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: 4px; font-size: 10px; padding: 2px 6px; }
.logout:hover { color: var(--text); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.live-dot.on { background: var(--good); box-shadow: 0 0 6px var(--good); }

.tabs { display: flex; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--text-dim);
  padding: 14px 10px 12px; font-size: 12px; white-space: nowrap; flex: 0 0 auto; position: relative;
}
.tab:hover { color: var(--text); }
.tab.on { border-bottom-color: var(--accent); color: var(--accent); font-weight: 700; }
.tab .count {
  font-family: var(--mono); font-size: 9px; font-weight: 800; background: var(--border); color: var(--text);
  border-radius: 8px; padding: 1px 5px; margin-left: 5px; vertical-align: 1px;
}
.tab.on .count { background: var(--accent); color: var(--bg); }

@media (max-width: 820px) {
  .header { padding: env(safe-area-inset-top) 0 0; }
  .header-inner { flex-wrap: wrap; gap: 0; }
  .brand-row { padding: 8px 14px; width: 100%; }
  .tabs { width: 100%; border-top: 1px solid var(--border); -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .tabs.at-end { -webkit-mask-image: none; mask-image: none; }
  .tab { flex: 1 0 auto; padding: 13px 12px 11px; font-size: 13px; }
  .acct-name { display: none; }
}

/* ---------- page ---------- */
main { max-width: 1200px; margin: 0 auto; padding: 18px 16px calc(40px + env(safe-area-inset-bottom)); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
h2 { font-size: 17px; font-weight: 800; }
.label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.section-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; font-weight: 700; margin: 18px 2px 6px; }
.section-label:first-child { margin-top: 0; }
.muted { color: var(--muted); }
.dim { color: var(--text-dim); }
.small { font-size: 11px; }
.error { color: var(--warn); font-size: 12px; margin: 8px 0; }
.note { font-size: 12px; color: var(--text-dim); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 11px; }
.pad { padding: 13px; }
.grid { display: grid; gap: 12px; }
.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }

/* stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: 11px; padding: 11px 13px;
  border-top: 3px solid var(--c, var(--accent)); text-align: left; color: inherit;
}
button.stat:hover { border-color: var(--c, var(--accent)); }
.stat .label { font-size: 9px; }
.stat .val { font-family: var(--mono); font-size: 24px; font-weight: 800; color: var(--c, var(--accent)); margin-top: 2px; }
.stat .sub { font-size: 10px; color: var(--text-dim); }

/* rows */
.list { list-style: none; }
.row {
  display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--border);
  border-radius: 7px; padding: 9px 11px; margin-bottom: 5px; min-height: 44px;
}
.row.click { cursor: pointer; }
.row.click:hover { border-color: #353d4a; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.row .meta { font-size: 11px; color: var(--text-dim); display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 1px; }
.row.done .title { color: var(--muted); text-decoration: line-through; font-weight: 400; }
.row .qty { color: var(--text-dim); font-weight: 400; font-family: var(--mono); font-size: 12px; }
.overdue { color: var(--accent3); font-weight: 700; }
.today-tag { color: var(--accent); font-weight: 700; }
.bar { width: 3px; align-self: stretch; border-radius: 2px; flex: none; }
.time { font-family: var(--mono); font-size: 12px; color: var(--accent2); min-width: 64px; flex: none; }
.time.allday { color: var(--text-dim); font-size: 10px; text-transform: uppercase; letter-spacing: .5px; }

.check {
  width: 22px; height: 22px; flex: none; border-radius: 5px; border: 2px solid var(--muted); background: none;
  display: grid; place-items: center; padding: 0;
}
.check svg { width: 14px; height: 14px; opacity: 0; color: var(--bg); }
.check.on { background: var(--accent); border-color: var(--accent); }
.check.on svg { opacity: 1; }
.check:disabled { opacity: .45; cursor: default; }

.icon-btn { border: 0; background: none; color: var(--muted); padding: 5px; border-radius: 6px; display: grid; place-items: center; }
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

.avatar {
  width: 24px; height: 24px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  color: var(--bg); font-size: 10px; font-weight: 900;
}
.avatar.lg { width: 32px; height: 32px; font-size: 13px; }
.avatars { display: inline-flex; }
.avatars .avatar { border: 2px solid var(--card); margin-left: -6px; }
.avatars .avatar:first-child { margin-left: 0; }
.pill {
  display: inline-block; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  padding: 2px 7px; border-radius: 4px; background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--c);
}

/* ---------- forms ---------- */
.add-bar { display: flex; gap: 6px; margin-bottom: 8px; }
.add-bar > input { flex: 1; min-width: 0; }
.add-extra { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.add-extra > * { flex: 1 1 140px; min-width: 0; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], select, textarea {
  width: 100%; background: var(--card); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 8px 10px; font-size: 13px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent2); }
input[type=date], input[type=time] { color-scheme: dark; }
@media (max-width: 820px) { input, select, textarea { font-size: 16px !important; } } /* stops iOS zoom */
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 9px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.field-row { display: flex; gap: 8px; flex-wrap: wrap; }
.field-row > * { flex: 1 1 130px; min-width: 0; }

.btn {
  border: 0; border-radius: 6px; padding: 8px 16px; font-size: 12px; font-weight: 700;
  background: var(--accent); color: var(--bg); white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
}
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; }
.btn.secondary { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn.ghost { background: none; color: var(--text-dim); padding: 6px 8px; }
.btn.ghost:hover { color: var(--text); }
.btn.danger { background: none; color: var(--accent3); border: 1px solid var(--border); }
.btn.block { width: 100%; }
.btn.sm { padding: 5px 10px; font-size: 11px; }

.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 2px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 5px; font-size: 11px; font-weight: 600; color: var(--text-dim); }
.seg button.on { background: var(--card); color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 3px 10px 3px 3px; font-size: 12px; color: var(--text-dim);
}
.chip-btn.on { border-color: var(--c); color: var(--text); background: color-mix(in srgb, var(--c) 12%, var(--surface)); }
.chip-btn.plain { padding: 5px 12px; }

.toggle { display: flex; align-items: center; gap: 12px; padding: 10px 13px; border-top: 1px solid var(--border); }
.toggle:first-child { border-top: 0; }
.toggle .main { flex: 1; }
.toggle .title { font-size: 13px; font-weight: 600; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 11px; background: var(--border); transition: .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-dim); transition: .15s; }
.switch input:checked + span { background: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.switch input:checked + span::after { transform: translateX(16px); background: var(--accent); }

.empty { text-align: center; color: var(--muted); padding: 28px 16px; font-size: 12px; background: var(--card); border: 1px dashed var(--border); border-radius: 11px; }
.code-box { font-family: var(--mono); font-size: 11px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; overflow-wrap: anywhere; color: var(--accent2); }
.stack > * + * { margin-top: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ---------- calendar ---------- */
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-title { font-size: 17px; font-weight: 800; min-width: 150px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal-dow { font-size: 9px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; text-align: center; padding: 4px 0; font-weight: 700; }
.cal-day {
  background: var(--card); border: 1px solid var(--border); border-radius: 6px; min-height: 92px; padding: 4px;
  text-align: left; display: flex; flex-direction: column; gap: 2px; overflow: hidden; color: inherit;
}
.cal-day:hover { border-color: #353d4a; }
.cal-day.out { background: var(--surface); opacity: .55; }
.cal-day.sel { border-color: var(--accent2); box-shadow: inset 0 0 0 1px var(--accent2); }
.cal-num { font-family: var(--mono); font-size: 11px; font-weight: 700; color: var(--text-dim); padding: 1px 3px; align-self: flex-start; border-radius: 4px; }
.cal-day.today .cal-num { background: var(--accent); color: var(--bg); }
.cal-ev {
  font-size: 10px; line-height: 1.25; padding: 1px 4px; border-radius: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: color-mix(in srgb, var(--c) 20%, transparent); color: var(--text); border-left: 2px solid var(--c);
}
.cal-ev .t { font-family: var(--mono); color: var(--text-dim); margin-right: 3px; }
.cal-more { font-size: 9px; color: var(--text-dim); padding-left: 4px; }
.cal-dots { display: none; gap: 3px; flex-wrap: wrap; padding: 2px 3px; }
.cal-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--c); display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 10px; color: var(--text-dim); margin-top: 8px; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--c); margin-right: 4px; vertical-align: 0; }
.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 980px) { .cal-layout { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .cal-day { min-height: 54px; padding: 3px; }
  .cal-ev, .cal-more { display: none; }
  .cal-dots { display: flex; }
  .cal-title { min-width: 0; font-size: 15px; }
}

/* ---------- auth ---------- */
.auth { max-width: 380px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 10vh) 20px 40px; }
.auth .hero { text-align: center; margin-bottom: 22px; }
.auth .hero .logo { width: 48px; height: 48px; border-radius: 11px; margin: 0 auto 10px; font-size: 24px; }
.auth .hero .logo svg { width: 28px; height: 28px; }
.auth .hero h1 { font-size: 24px; font-weight: 900; letter-spacing: -.02em; }
.auth .hero p { color: var(--text-dim); font-size: 13px; }
.banner { background: color-mix(in srgb, var(--accent2) 10%, var(--card)); border: 1px solid color-mix(in srgb, var(--accent2) 35%, var(--border)); border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; font-size: 13px; }

/* ---------- modal ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .7); z-index: 1000; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 520px; padding: 18px; animation: pop .15s ease-out; }
@media (max-width: 640px) { .scrim { padding: 12px 8px; } .modal { padding: 14px; } }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.modal h3 { font-size: 16px; font-weight: 800; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--card); color: var(--text); border: 1px solid var(--accent); padding: 9px 16px; border-radius: 8px;
  font-size: 12px; font-weight: 600; z-index: 2000; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
