:root {
  --navy: #1b2d4f; --bg: #f3f4f6; --card: #ffffff; --text: #16181d; --muted: #656b76;
  --line: #d9dde3; --ok: #2e7d32; --err: #b3261e; --warn: #9a6700; --accent: #1b2d4f; --accent-text: #ffffff;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111318; --card: #1b1e26; --text: #e9ebf0; --muted: #9aa1ad; --line: #2e333d; --accent: #4f7fd1; --ok: #5fbf66; --err: #ff6b61; --warn: #e3b341; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--navy); color: #fff; }
.brand { font-weight: 700; letter-spacing: .3px; }
.who { flex: 1; font-size: 13px; opacity: .9; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.net { width: 10px; height: 10px; border-radius: 50%; background: #5fbf66; flex: none; }
.net.off { background: #e3b341; }
main { max-width: 640px; margin: 0 auto; padding: 12px 16px; }
.pad { padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 14px 6px; margin: 12px 0; }
.card h2 { margin: 0 0 10px; font-size: 17px; }
.field { margin: 0 0 14px; }
.field.err > label { color: var(--err); }
label { display: block; font-weight: 600; margin-bottom: 6px; }
.help { display: block; font-weight: 400; color: var(--muted); font-size: 13px; margin-top: 2px; }
.errmsg { color: var(--err); font-size: 13px; margin-top: 4px; }
input[type=text], input[type=search], input[type=number], input[type=date], input[type=email], input[type=tel], input[type=password], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; -webkit-appearance: none; appearance: none;
}
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; min-width: 0; }
.row > .fix { flex: none; }
.unit { flex: none; color: var(--muted); font-size: 14px; min-width: 28px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { flex: 1 1 auto; min-height: 44px; padding: 8px 12px; font: inherit; border: 1px solid var(--line); background: var(--bg); color: var(--text); border-radius: 10px; }
.seg button[aria-pressed=true] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.seg.wrap button { flex: 0 1 auto; }
button.btn { min-height: 48px; padding: 10px 16px; font: inherit; font-weight: 600; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
button.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.btn.link { background: none; border: none; color: var(--accent); font-weight: 500; padding: 6px 0; min-height: 32px; }
button.btn.danger { color: var(--err); }
button:disabled { opacity: .5; }
.unknown-toggle { flex: none; min-height: 44px; padding: 0 12px; font: inherit; font-size: 14px; border: 1px dashed var(--line); background: transparent; color: var(--muted); border-radius: 10px; }
.unknown-toggle[aria-pressed=true] { border-style: solid; color: var(--text); background: var(--bg); }
.kc-row { display: grid; grid-template-columns: 1fr 88px 36px; gap: 8px; margin-bottom: 8px; align-items: center; }
.kc-row .x { min-height: 44px; border: none; background: transparent; color: var(--muted); font-size: 20px; }
.hidden { display: none !important; }
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); }
.bar > * { flex: 1; }
.bar .status { flex: 2; font-size: 13px; color: var(--muted); align-self: center; }
.banner { padding: 10px 12px; border-radius: 10px; margin: 10px 0; font-size: 14px; }
.banner.warn { background: rgba(227,179,65,.18); color: var(--text); border: 1px solid var(--warn); }
.banner.err { background: rgba(179,38,30,.1); border: 1px solid var(--err); }
.banner.ok { background: rgba(46,125,50,.12); border: 1px solid var(--ok); }
.results { list-style: none; margin: 6px 0 0; padding: 0; }
.results li { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px; background: var(--bg); }
.results li .small { display: block; }
.picked { padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); margin-bottom: 10px; }
pre.summary { white-space: pre-wrap; word-break: break-word; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font: 15px/1.5 inherit; }
.code input { font-size: 24px; letter-spacing: 6px; text-align: center; }
footer.meta { color: var(--muted); font-size: 12px; text-align: center; padding: 16px 0 4px; }
footer.meta a { color: var(--muted); }

/* ---- CRM screens (Files, File page) */
.tabs { display: flex; gap: 6px; padding: 8px 16px 0; max-width: 640px; margin: 0 auto; }
.tabs button { flex: 1; min-height: 40px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--text); font-weight: 600; font-size: 15px; }
.tabs button[aria-pressed=true] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.count { margin-left: 8px; font-size: 13px; color: var(--muted); font-weight: 400; }
.kv { display: flex; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.kv:first-of-type { border-top: 0; }
.kv .k { flex: none; width: 96px; color: var(--muted); text-transform: capitalize; }
.kv .v { flex: 1; word-break: break-word; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--line); font-size: 12px; text-transform: capitalize; }
.row.between { justify-content: space-between; align-items: center; }
.row.actions { flex-wrap: wrap; gap: 8px; margin: 10px 0 6px; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; min-width: 72px; }
h2.title { font-size: 20px; margin: 6px 0 2px; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
details.insp { padding: 8px 0; border-top: 1px solid var(--line); }
details.insp summary { cursor: pointer; font-size: 14px; }
.logbar { display: flex; gap: 8px; margin-bottom: 10px; }
.logbar .btn { flex: 1; }
.logform { padding: 10px; border: 1px dashed var(--line); border-radius: var(--radius); margin-bottom: 10px; }
.timeline .act { padding: 8px 0; border-top: 1px solid var(--line); }
.act .body { white-space: pre-wrap; margin-top: 2px; font-size: 15px; }
.act.queued { opacity: .7; }
.field.owner { margin-top: 10px; padding-top: 8px; border-top: 2px solid var(--line); }
/* ---- Home */
.doors { display: flex; gap: 8px; margin: 8px 0 12px; }
.doors .btn { flex: 1; min-height: 48px; font-size: 16px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 4px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.tile .n { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.tile .l { font-size: 13px; color: var(--muted); }
.tap { cursor: pointer; }
ul.plain li.tap:active, .tile.tap:active, .act.tap:active { opacity: .7; }
.chip { border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--text); padding: 2px 10px; font-size: 13px; }
.linklike { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-decoration: underline; }
/* ---- outcome sheet + week table */
.sheetwrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.card.sheet { border-color: var(--accent); box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.pill.app { margin-left: 4px; background: var(--accent); color: var(--accent-text); }
.outcome { color: var(--ok); margin-top: 2px; }
table.week { width: 100%; border-collapse: collapse; font-size: 14px; }
table.week th { text-align: right; font-weight: 600; color: var(--muted); padding: 4px 6px; }
table.week td { text-align: right; padding: 6px; border-top: 1px solid var(--line); }
table.week th:first-child, table.week td:first-child { text-align: left; }
/* ---- calendar */
.dim { opacity: .6; }
.appt { padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.appt .pill { margin-left: 6px; }
