:root {
  --bg: #14161a; --surface: #1d2026; --surface2: #262a31; --line: #30353d;
  --text: #f4f4f5; --muted: #9aa1ab; --accent: #7cdea0; --accent-ink: #0d2116;
  --danger: #ff7a7a; --warn: #f5c26b; --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.err { color: var(--danger); min-height: 1.4em; font-size: 14px; }

/* Lock */
.lock { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.lock-card { width: 100%; max-width: 360px; text-align: center; }
.logo { font-size: 44px; font-weight: 800; letter-spacing: -1px; }
.logo span { color: var(--accent); }
.lock-card form { display: grid; gap: 10px; margin-top: 16px; }

/* Layout */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + var(--safe-t)) 16px 10px; background: rgba(20, 22, 26, .92); backdrop-filter: blur(10px); }
.top h1 { margin: 0; font-size: 28px; letter-spacing: -.5px; }
.top-actions { display: flex; gap: 4px; }
main { padding: 4px 16px calc(96px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
.section { margin: 18px 4px 8px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.list { display: grid; gap: 8px; }

/* Controls */
input, select, textarea { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }
.btn { padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface2); font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { background: transparent; color: var(--danger); border-color: transparent; }
.btn:disabled { opacity: .5; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; font-size: 18px; cursor: pointer; color: var(--muted); }
.icon-btn:active { background: var(--surface2); }
.search { margin: 4px 0 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; font-size: 14px; cursor: pointer; color: var(--muted); }
.chip.on { background: var(--text); color: var(--bg); border-color: transparent; }
.chip input { width: auto; margin: 0; }
.filters { display: flex; gap: 8px; margin: 10px 0 4px; flex-wrap: wrap; }
.quick { display: flex; gap: 8px; margin-top: 4px; }
.quick input { flex: 1; }

/* Cards */
.card { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); text-align: left; transition: opacity .2s; }
button.card { cursor: pointer; }
.card.busy { opacity: .5; pointer-events: none; }
.site-main, .task-main { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 0; cursor: pointer; }
.site-name { font-weight: 600; }
.site-main .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.go { border: 0; border-radius: 10px; padding: 10px 12px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap; }
.go:active { transform: scale(.96); }

.tick { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); background: none; color: var(--accent-ink); font-weight: 800; cursor: pointer; }
.task.done .tick { background: var(--accent); border-color: var(--accent); }
.task.done .task-main > div:first-child { text-decoration: line-through; color: var(--muted); }
.task.pri-high { border-left: 3px solid var(--danger); }
.task.pri-low { opacity: .8; }
.overdue { color: var(--danger); }

.appt .time { flex: none; width: 58px; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }
.issue { flex-direction: column; align-items: flex-start; gap: 2px; }

.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.form label.check { display: flex; align-items: center; gap: 8px; }
.form label.check input { width: auto; }
.form details { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.form details[open] { display: grid; gap: 12px; }
.form summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.row .btn { flex: none; }
.card.form { display: grid; align-items: stretch; padding: 16px; margin-top: 4px; }
.label-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.label-picks .chip { color: var(--text); }

.empty { text-align: center; padding: 48px 16px; }
.empty-title { font-weight: 600; margin-bottom: 4px; }

/* FAB + tabs */
.fab { position: fixed; right: 18px; bottom: calc(84px + var(--safe-b)); width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-ink); font-size: 28px; font-weight: 700; box-shadow: 0 8px 24px rgba(0,0,0,.4); cursor: pointer; z-index: 6; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; padding: 6px 8px calc(6px + var(--safe-b));
  background: rgba(29, 32, 38, .95); backdrop-filter: blur(10px); border-top: 1px solid var(--line); z-index: 6; }
.tabs button { flex: 1; display: grid; justify-items: center; gap: 2px; border: 0; background: none; color: var(--muted); font-size: 11px; padding: 6px 0; cursor: pointer; }
.tabs button span { font-size: 20px; line-height: 1; filter: grayscale(1); opacity: .7; }
.tabs button.on { color: var(--text); }
.tabs button.on span { filter: none; opacity: 1; }

/* Sheet */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-body { width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; background: var(--bg); border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(24px + var(--safe-b)); animation: up .22s ease-out; }
.sheet-head { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; background: var(--bg); padding: 8px 0; z-index: 1; }
.sheet-head h2 { margin: 0; font-size: 20px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

.toast { position: fixed; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px;
  transition: .2s; pointer-events: none; z-index: 30; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--danger); color: #2a0b0b; }

/* ---- iPhone width fixes ---- */
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: hidden; max-width: 100%; }
input, select, textarea { min-width: 0; max-width: 100%; }
input[type="date"], input[type="time"] {
  -webkit-appearance: none; appearance: none; display: block; min-height: 48px; text-align: left;
}
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
.row > *, .quick > *, .form label { min-width: 0; }
.card > div, .appt > div:last-child { min-width: 0; }
.card, .site-name, .task-main, .appt, .issue { overflow-wrap: anywhere; }
.sheet-body { overflow-x: hidden; }
.label-picks .chip { max-width: 100%; }

/* Connection banner */
.offline { position: fixed; top: 0; left: 0; right: 0; z-index: 40; padding: calc(8px + var(--safe-t)) 16px 8px;
  background: var(--danger); color: #2a0b0b; font-weight: 600; font-size: 14px; text-align: center; }

/* ---- Inbox / assistant ---- */
.tabs button { position: relative; }
.badge { position: absolute; top: 2px; left: 50%; margin-left: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #2a0b0b; font: 700 11px/18px -apple-system, system-ui, sans-serif; font-style: normal; }
.gtag { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--surface2); color: var(--muted); vertical-align: 1px; }
.mail { flex-direction: column; align-items: stretch; gap: 6px; }
.mail.done { opacity: .55; }
.mail.urg-high { border-left: 3px solid var(--danger); }
.mail-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.mail-head b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-head .small { flex: none; }
.mail-subj { font-weight: 600; }
.meet { font-size: 14px; background: var(--surface2); border-radius: 10px; padding: 8px 10px; }
.mail-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.mail-actions .btn { padding: 8px 12px; font-size: 14px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
#inbox-status { margin: 6px 4px 2px; }
code { font-size: 12px; overflow-wrap: anywhere; }
.sticky-save { position: sticky; bottom: 0; box-shadow: 0 -8px 16px var(--bg); }
.form p { margin: 0; }

/* ---- More / Projects / Invoices / Time ---- */
.title-wrap { display: flex; align-items: center; gap: 6px; min-width: 0; }
.title-wrap h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { font-size: 30px; width: 32px; margin-left: -8px; color: var(--text); }
.timer-chip { border: 0; border-radius: 999px; padding: 4px 10px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13px;
  white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; vertical-align: 2px; background: var(--muted); }
.dot.up { background: var(--accent); } .dot.down { background: var(--danger); box-shadow: 0 0 0 3px rgba(255,122,122,.25); }
.dot.warn { background: var(--warn); } .dot.off { background: transparent; border: 1px solid var(--muted); }
#monitor-summary { align-self: center; }
.menu-item { gap: 14px; cursor: pointer; padding: 16px 14px; }
.menu-item > span { font-size: 26px; width: 34px; text-align: center; }
.proj, .inv { cursor: pointer; }
.inv-main, .entry-main { flex: 1; min-width: 0; }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.timer-card { flex-direction: column; align-items: stretch; gap: 12px; padding: 16px; margin-top: 4px; }
.timer-card label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.elapsed { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -1px; text-align: center; }
.btn.big { padding: 16px; font-size: 18px; }
.btn.danger-fill { background: var(--danger); color: #2a0b0b; border-color: transparent; padding: 14px; font-size: 17px; }
.week { justify-content: space-between; padding: 10px 14px; }
.week b, .entry b { font-variant-numeric: tabular-nums; }
.entry { padding: 10px 6px 10px 14px; }
.brief { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 15px; line-height: 1.5; }
.row label.narrow { flex: 0 0 72px; }
.title-wrap h1 { flex: none; max-width: 70vw; } .timer-chip { flex: none; }
.crm-task { cursor: pointer; }
.crm-mark { flex: none; font-size: 10px; font-weight: 800; letter-spacing: .05em; padding: 3px 6px; border-radius: 6px; background: var(--surface2); color: var(--accent); }
a.gtag { color: var(--accent); }

/* ---- Never wider than the phone ----
   Grid lists sized their column to the longest unwrapped line (a long site
   address or username), pushing cards off-screen. Pin the column to the
   screen width and let long text shorten with "…" instead. */
.list { grid-template-columns: minmax(0, 1fr); }
.card, .site-main, .task-main, .inv-main, .entry-main { min-width: 0; }
.site-main .muted, .site-name { overflow: hidden; text-overflow: ellipsis; }
main, .sheet-body { overflow-x: clip; }
body { overscroll-behavior-x: none; }
.icon-btn.view { flex: none; font-size: 20px; }
@media (max-width: 360px) { .go { padding: 10px 9px; font-size: 13px; } .site .icon-btn { width: 34px; } }
.help-list { margin: 0; padding-left: 18px; display: grid; gap: 4px; }
.icon-btn.edit { flex: none; font-size: 18px; }
