/* Keystone — styles. Nearly every visual choice is a CSS variable set by js/theme.js from the user's Appearance settings. */
:root {
  --accent: #1d5fd6; --accent-soft: #e8f0fe; --accent-ink: #ffffff; --accent-text: #1a4fb3;
  --bg: #f5f7fa; --surface: #ffffff; --surface-2: #f8fafc; --border: #e4e8ee; --border-strong: #cfd6e0;
  --text: #1b2433; --text-2: #4b5567; --text-3: #7b8597;
  --ok: #12804a; --ok-soft: #e5f6ec; --warn: #a15c00; --warn-soft: #fff3e0; --bad: #c62f3a; --bad-soft: #fdebed; --info-soft: #eaf2ff;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --fs: 14.5px; --radius: 12px; --btn-radius: 999px; --pad: 1; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 2px 8px rgba(16,24,40,.04);
  --sidebar-w: 248px; --sidebar-bg: #ffffff; --sidebar-text: #3b4659; --sidebar-muted: #8a93a3; --sidebar-hover: #f1f4f8;
  --sidebar-active-bg: var(--accent-soft); --sidebar-active-text: var(--accent-text); --sidebar-border: var(--border);
  --content-max: 1280px; --row-stripe: transparent;
  --series-1: #2a78d6; --series-2: #eb6834;
}
[data-mode="dark"] {
  --bg: #12151b; --surface: #1a1e26; --surface-2: #20252f; --border: #2b313c; --border-strong: #3a4250;
  --text: #e9edf3; --text-2: #b4bccb; --text-3: #8690a2; --accent-soft: color-mix(in srgb, var(--accent) 22%, transparent);
  --accent-text: color-mix(in srgb, var(--accent) 55%, white);
  --ok: #4cc38a; --ok-soft: #173a2a; --warn: #f0a849; --warn-soft: #3b2b14; --bad: #f2737c; --bad-soft: #3d1c20; --info-soft: #1b2a45;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --sidebar-hover: #222833;
  --series-1: #3987e5; --series-2: #d95926;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: var(--fs); color: var(--text); background: var(--bg); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.app.collapsed { --sidebar-w: 72px; }
.sidebar { background: var(--sidebar-bg); color: var(--sidebar-text); border-right: 1px solid var(--sidebar-border); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.sb-top { padding: 16px 14px 10px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; padding: 4px 6px 14px; letter-spacing: -.02em; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.co-switch { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--sidebar-border); background: transparent; cursor: pointer; text-align: left; color: inherit; }
.co-switch:hover { background: var(--sidebar-hover); }
.co-dot { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; flex: none; }
.co-name { font-weight: 650; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.co-sub { font-size: 11.5px; color: var(--sidebar-muted); }
.nav { flex: 1; overflow-y: auto; padding: 6px 10px 16px; }
.nav-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-muted); padding: 10px 10px 4px; font-weight: 650; white-space: nowrap; }
.nav a { display: flex; align-items: center; gap: 11px; padding: calc(7px * var(--pad) + 1px) 10px; border-radius: 9px; color: var(--sidebar-text); font-weight: 550; white-space: nowrap; margin: 1px 0; }
.nav a:hover { background: var(--sidebar-hover); text-decoration: none; }
.nav a.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.nav a svg { flex: none; opacity: .85; }
.nav .count { margin-left: auto; background: var(--bad); color: #fff; font-size: 11px; border-radius: 99px; padding: 0 7px; font-weight: 700; }
.collapsed .nav-sec, .collapsed .nav a span, .collapsed .co-name, .collapsed .co-sub, .collapsed .brand span, .collapsed .co-switch .chev { display: none; }
.collapsed .nav a { justify-content: center; }
.sb-foot { padding: 10px; border-top: 1px solid var(--sidebar-border); display: flex; gap: 6px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); }
.searchbox { flex: 1; max-width: 640px; display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 8px 16px; color: var(--text-3); cursor: text; box-shadow: var(--shadow); }
.searchbox kbd { margin-left: auto; font-size: 11.5px; border: 1px solid var(--border); border-radius: 6px; padding: 0 6px; background: var(--surface-2); }
.content { padding: 8px 28px 48px; width: 100%; max-width: var(--content-max); margin: 0 auto; }

/* ---------- page header ---------- */
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 10px 0 22px; flex-wrap: wrap; }
.ph h1 { font-size: 28px; font-weight: 800; }
.ph .sub { color: var(--text-3); margin-top: 4px; }
.crumbs { font-size: 13px; color: var(--text-3); margin-bottom: 6px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 18px; } .mb { margin-bottom: 18px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid transparent; background: var(--accent); color: var(--accent-ink); padding: calc(8px * var(--pad) + 1px) 18px; border-radius: var(--btn-radius); font-weight: 650; cursor: pointer; white-space: nowrap; line-height: 1.3; transition: filter .12s, background .12s; }
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--surface-2); filter: none; }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); filter: none; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.sm { padding: 5px 12px; font-size: 13px; }
.btn.icon { padding: 7px; border-radius: 10px; }
.btn:disabled { opacity: .55; cursor: default; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: calc(20px * var(--pad)); }
.card-h { display: flex; align-items: center; justify-content: space-between; padding: calc(16px * var(--pad)) calc(20px * var(--pad)) 0; gap: 10px; }
.card-h h3 { font-size: 16px; font-weight: 750; }
.grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-side { grid-template-columns: minmax(0, 1fr) 340px; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g-side, .g3 { grid-template-columns: 1fr; } }
/* hidden on desktop */
@media (max-width: 720px) { .desk-only { display: none !important; } }
.mob-only { display: none !important; } .tabbar, .nav-scrim { display: none; }
@media (max-width: 720px) { .g2, .g4 { grid-template-columns: 1fr; } .app { grid-template-columns: 1fr; } .sidebar { display: none; } .content, .topbar { padding-left: 14px; padding-right: 14px; } }

.stat { padding: calc(18px * var(--pad)) calc(20px * var(--pad)); }
.stat .label { font-size: 13px; color: var(--text-3); font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .foot { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.stat.link { cursor: pointer; } .stat.link:hover { border-color: var(--accent); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 650; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
table.t th.sortable { cursor: pointer; user-select: none; }
table.t th.sortable:hover { color: var(--text); }
table.t td { padding: calc(11px * var(--pad)) 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tbody tr:nth-child(even) td { background: var(--row-stripe); }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.click:hover td { background: var(--surface-2); }
table.t tr:last-child td { border-bottom: 0; }
.t-name { font-weight: 650; }
.empty { text-align: center; padding: 46px 20px; color: var(--text-3); }
.empty .big { font-size: 17px; color: var(--text); font-weight: 700; margin-bottom: 4px; }

/* ---------- tabs / pills ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a, .tabs button { padding: 9px 14px; color: var(--text-2); font-weight: 600; border: 0; background: none; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; margin-bottom: -1px; }
.tabs a:hover, .tabs button:hover { color: var(--text); text-decoration: none; }
.tabs .active { color: var(--accent-text); border-bottom-color: var(--accent); }
.tabs .n { font-size: 11.5px; background: var(--surface-2); border-radius: 99px; padding: 1px 7px; margin-left: 5px; color: var(--text-3); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 13px; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--text-2); font-size: 13px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; padding: 2px 10px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; text-transform: capitalize; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.info { background: var(--info-soft); color: var(--accent-text); }
.co-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.co-tag i { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }

/* ---------- forms ---------- */
.form { display: grid; gap: 14px; }
.form .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 650; color: var(--text-2); margin-bottom: 5px; }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.input, select.input, textarea.input { width: 100%; padding: calc(8px * var(--pad) + 1px) 12px; border: 1px solid var(--border-strong); border-radius: calc(var(--radius) * .7); background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 80px; }
.check, .field label.check { display: flex; align-items: center; gap: 9px; cursor: pointer; font-size: inherit; font-weight: 500; color: inherit; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
input[type=range] { accent-color: var(--accent); width: 100%; }
input[type=color] { width: 42px; height: 34px; border: 1px solid var(--border-strong); border-radius: 9px; padding: 2px; background: var(--surface); cursor: pointer; }

/* ---------- modal / drawer / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15,20,30,.42); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; animation: fade .12s; }
.modal { background: var(--surface); border-radius: calc(var(--radius) + 4px); width: 100%; max-width: 620px; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: pop .16s; }
.modal.wide { max-width: 900px; }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-h h2 { font-size: 18px; }
.modal-b { padding: 20px 22px; }
.modal-f { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 calc(var(--radius) + 4px) calc(var(--radius) + 4px); }
@keyframes fade { from { opacity: 0; } } @keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; }
.toast { background: #1b2433; color: #fff; padding: 11px 18px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.25); font-weight: 550; animation: pop .16s; }
.toast.err { background: var(--bad); }

/* ---------- command palette search ---------- */
.palette { max-width: 720px; }
.palette .pin { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.palette .pin input { flex: 1; border: 0; outline: 0; font-size: 17px; background: transparent; }
.results { max-height: 60vh; overflow-y: auto; padding: 6px; }
.result { display: flex; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; align-items: flex-start; }
.result:hover, .result.sel { background: var(--accent-soft); }
.result .ico { width: 34px; height: 34px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; flex: none; color: var(--text-2); }
.result .rt { font-weight: 650; }
.result .rs { font-size: 13px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.result mark, .snip mark { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.rgroup { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); padding: 10px 12px 4px; font-weight: 650; }

/* ---------- document editor ---------- */
.doc-paper { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: calc(30px * var(--pad)); }
.items { width: 100%; border-collapse: collapse; }
.items th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); text-align: left; padding: 8px 6px; border-bottom: 2px solid var(--border); }
.items td { padding: 6px 4px; border-bottom: 1px solid var(--border); vertical-align: top; }
.items tr:has(+ tr.desc) td { border-bottom: 0; padding-bottom: 2px; }
.items .input[type=number] { padding-right: 4px; }
@media (max-width: 1200px) { .doc-grid { grid-template-columns: 1fr !important; } }
.items .input { padding: 7px 9px; }
.items tr.section td { background: var(--surface-2); }
.items tr.section .input { font-weight: 750; color: var(--accent-text); text-transform: uppercase; letter-spacing: .04em; font-size: 13px; }
.items .drag { cursor: grab; color: var(--text-3); padding-top: 12px; }
.totals { margin-left: auto; width: 320px; margin-top: 14px; }
.totals div { display: flex; justify-content: space-between; padding: 5px 0; }
.totals .grand { font-size: 19px; font-weight: 800; border-top: 2px solid var(--text); margin-top: 6px; padding-top: 10px; }
.status-steps { display: flex; gap: 0; margin: 0 0 18px; }
.status-steps div { flex: 1; text-align: center; font-size: 12.5px; font-weight: 650; color: var(--text-3); padding: 8px 4px; border-bottom: 3px solid var(--border); }
.status-steps div.done { color: var(--accent-text); border-color: var(--accent); }

/* ---------- kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; min-height: 200px; }
.kcol h4 { font-size: 13px; display: flex; justify-content: space-between; padding: 4px 6px 10px; color: var(--text-2); text-transform: capitalize; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: calc(var(--radius) * .8); padding: 11px 12px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow); }
.kcard:hover { border-color: var(--accent); }
.kcol.drop { outline: 2px dashed var(--accent); }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.cal .dow { font-size: 12px; font-weight: 650; color: var(--text-3); padding: 8px 10px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-transform: uppercase; letter-spacing: .05em; }
.cal .day { min-height: 116px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 6px; cursor: pointer; overflow: hidden; }
.cal .day:hover { background: var(--surface-2); }
.cal .day.other { background: var(--surface-2); color: var(--text-3); }
.cal .day .dn { font-size: 13px; font-weight: 650; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.cal .day.today .dn { background: var(--accent); color: var(--accent-ink); }
.ev { font-size: 12px; padding: 2px 7px; border-radius: 6px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; font-weight: 600; cursor: pointer; }
.agenda .a-day { font-weight: 750; margin: 16px 0 6px; }
.agenda .a-ev { display: flex; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 6px; cursor: pointer; }

/* ---------- misc ---------- */
.list-item { display: flex; gap: 12px; align-items: flex-start; padding: 11px 20px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; background: var(--accent-soft); color: var(--accent-text); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--text-3); } .kv dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; box-shadow: 0 6px 24px rgba(0,0,0,.14); font-size: 13px; white-space: nowrap; z-index: 5; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.msg-bubble { padding: 10px 14px; border-radius: 14px; background: var(--surface-2); max-width: 80%; margin: 6px 0; white-space: pre-wrap; }
.msg-bubble.out { background: var(--accent-soft); margin-left: auto; }
.theme-preview { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 2px var(--text); }
.preset { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; cursor: pointer; background: var(--surface); text-align: left; }
.preset:hover { border-color: var(--accent); }
.preset .pv { height: 46px; border-radius: 8px; display: flex; overflow: hidden; margin-bottom: 8px; }
.setting-row { display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: 0; }
.setting-row .sl { font-weight: 650; } .setting-row .sd { font-size: 12.5px; color: var(--text-3); }
@media (max-width: 720px) { .setting-row { grid-template-columns: 1fr; } }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; white-space: pre; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 30px 16px; background: linear-gradient(160deg, var(--accent-soft), var(--bg) 55%); }
.auth { width: 100%; max-width: 460px; }
.dropdown { position: absolute; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.18); padding: 6px; z-index: 120; min-width: 240px; }
.dropdown button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left; }
.dropdown button:hover { background: var(--surface-2); }
.dropdown hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
@media print { .sidebar, .topbar, .no-print { display: none !important; } .app { display: block; } body { background: #fff; } }

/* ---------- roles & permissions ---------- */
.roles-wrap { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 900px) { .roles-wrap { grid-template-columns: minmax(0, 1fr); } }
.roles-list { position: sticky; top: 16px; overflow: hidden; }
.role-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 16px; background: none; border: none; border-top: 1px solid var(--border); cursor: pointer; color: inherit; font: inherit; }
.role-item:hover { background: var(--surface-2); }
.role-item.on { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.role-name { font-size: 20px; font-weight: 750; border-color: transparent; padding: 4px 8px; margin-left: -8px; }
.role-name:hover:not(:disabled), .role-name:focus { border-color: var(--border-strong); }
.role-name:disabled, #rDesc:disabled { background: transparent; color: inherit; border-color: transparent; }
.perm-group { border-top: 1px solid var(--border); }
.perm-gh { display: flex; align-items: center; gap: 4px; padding: 12px 20px 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }
.perm-t th.c, .perm-t td.c { text-align: center; width: 72px; }
.perm-t td { padding-top: 9px; padding-bottom: 9px; }
.sm-sel { padding: 5px 8px; font-size: 12.5px; height: auto; min-width: 96px; }
.tick { display: inline-grid; place-items: center; cursor: pointer; }
.tick input { position: absolute; opacity: 0; pointer-events: none; }
.tick span { width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--border-strong); display: grid; place-items: center; transition: .12s; background: var(--surface); }
.tick input:checked + span { background: var(--accent); border-color: var(--accent); }
.tick input:checked + span::after { content: ''; width: 6px; height: 11px; border: solid var(--accent-ink); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) translate(-1px, -1px); }
.tick input:disabled + span { opacity: .55; cursor: default; }
.switch { position: relative; display: inline-block; width: 40px; height: 23px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--border-strong); transition: .15s; cursor: pointer; }
.switch i::after { content: ''; position: absolute; width: 17px; height: 17px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(17px); }
.switch input:disabled + i { opacity: .55; }
.role-save { position: sticky; bottom: 0; display: none; align-items: center; gap: 8px; padding: 12px 20px; background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -6px 18px rgba(0,0,0,.06); border-radius: 0 0 var(--radius, 12px) var(--radius, 12px); }
.role-save.show { display: flex; }
.pick-list { max-height: 190px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; background: var(--surface-2); }
.pick-list .check { display: flex; padding: 4px 0; }
.ov-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.seg.sm button { padding: 3px 9px; font-size: 12px; }
.preview-bar { position: sticky; top: 0; z-index: 60; display: flex; align-items: center; gap: 10px; padding: 9px 18px; background: #2b2f3a; color: #fff; font-size: 14px; }
.preview-bar .btn.secondary { background: rgba(255,255,255,.12); color: #fff; border-color: transparent; }
body.no-costs .costcol, body.no-costs .cost-only { display: none !important; }
.pin-btn span { display: inline; }
@media (max-width: 1100px) { .pin-btn span { display: none; } }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #2fb344; box-shadow: 0 0 0 3px rgba(47,179,68,.22); display: inline-block; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(47,179,68,.08); } }
#clockBtn.on-clock { border-color: #2fb344; color: #1f7a33; }
a.card.link:hover { border-color: var(--border-strong); box-shadow: var(--shadow, 0 2px 10px rgba(0,0,0,.06)); }
/* ---------- menu editor ---------- */
.menu-sec { margin: 0 14px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.menu-sec-h { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.menu-sec-name { font-weight: 700; text-transform: uppercase; letter-spacing: .04em; font-size: 12.5px; border-color: transparent; background: transparent; padding: 4px 6px; flex: 1; }
.menu-sec-name:focus, .menu-sec-name:hover { border-color: var(--border-strong); background: var(--surface); }
.menu-items { padding: 0 8px 8px; min-height: 12px; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; margin-top: 4px; border-radius: 9px; background: var(--surface); border: 1px solid var(--border); cursor: grab; font-size: 14px; }
.menu-item.off { opacity: .5; }
.menu-item.dragging { opacity: .35; }
.menu-item .pin { opacity: .35; } .menu-item .pin.on { opacity: 1; color: var(--accent); }
.grip { color: var(--text-3); display: inline-flex; cursor: grab; }
.drop-line { height: 3px; border-radius: 3px; background: var(--accent); margin: 3px 4px; }
a.card.link, a.card.link:hover, a.card.link * { text-decoration: none; }
/* ---------- Google-style calendar ---------- */
.gcal { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 18px; margin-top: -6px; }
@media (max-width: 900px) { .gcal { grid-template-columns: minmax(0, 1fr); } .gc-side { display: none; } }
.gc-side { padding-top: 4px; }
.gc-create { display: inline-flex; align-items: center; gap: 12px; padding: 10px 24px 10px 14px; border-radius: 16px; border: none; background: var(--surface); box-shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15); font-family: inherit; font-weight: 600; font-size: 15px; line-height: 1; color: var(--text); cursor: pointer; margin: 0 0 18px; transition: box-shadow .15s; }
.gc-create:hover { box-shadow: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15); background: color-mix(in srgb, var(--accent) 4%, var(--surface)); }
.mm { padding: 0 4px; }
.mm-h { display: flex; align-items: center; padding: 0 0 6px 6px; font-size: 14px; }
.mm-h .btn { padding: 4px; }
.mm-g { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11px; row-gap: 2px; }
.mm-dow { color: var(--text-3); font-weight: 600; padding: 4px 0; }
.mm-g a { width: 26px; height: 26px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%; color: var(--text); font-weight: 500; }
.mm-g a.o { color: var(--text-3); }
.mm-g a:hover { background: var(--surface-2); }
.mm-g a.sel { background: var(--accent-soft); color: var(--accent-text); }
.mm-g a.today { background: var(--accent); color: var(--accent-ink); }
.gc-cals { margin-top: 22px; }
.gc-cals-h { font-weight: 600; font-size: 14px; padding: 0 8px 6px; }
.gc-cal { display: flex; align-items: center; gap: 12px; padding: 5px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.gc-cal:hover { background: var(--surface-2); }
.gc-cal input { position: absolute; opacity: 0; pointer-events: none; }
.gc-box { width: 18px; height: 18px; border-radius: 3px; border: 2px solid var(--c); display: grid; place-items: center; flex: none; }
.gc-cal input:checked + .gc-box { background: var(--c); }
.gc-cal input:checked + .gc-box::after { content: ''; width: 4px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.gc-main { min-width: 0; }
.gc-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.gc-today { border-radius: 6px !important; }
.gc-title { font-size: 22px; font-weight: 400; margin: 0 0 0 10px; letter-spacing: 0; }
.gc-body { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.gc-dn { width: 46px; height: 46px; border-radius: 50%; border: none; background: none; font-family: inherit; font-weight: 400; font-size: 24px; line-height: 1; color: var(--text); cursor: pointer; display: inline-grid; place-items: center; }
.gc-dn:hover { background: var(--surface-2); }
.gc-dn.today, .today > .gc-dn { background: var(--accent); color: var(--accent-ink); }
/* time grid */
.tg-head, .tg-allday { display: grid; grid-template-columns: 58px minmax(0, 1fr); }
.tg-head { grid-template-columns: 58px repeat(var(--days), minmax(0, 1fr)); padding-top: 8px; }
.tg-gutter { display: flex; align-items: flex-end; justify-content: center; padding-bottom: 4px; font-size: 10px; }
.tg-dh { text-align: center; padding-bottom: 6px; }
.tg-dow { font-size: 11px; font-weight: 600; color: var(--text-2); letter-spacing: .04em; }
.tg-dh.today .tg-dow { color: var(--accent-text); }
.tg-allday { border-bottom: 1px solid var(--border); }
.tg-ad-cells { position: relative; display: grid; grid-template-columns: repeat(var(--days), minmax(0, 1fr)); }
.tg-ad-cells > div[data-day] { border-left: 1px solid var(--border); cursor: pointer; }
.tg-scroll { height: calc(100vh - 290px); min-height: 420px; overflow-y: auto; position: relative; }
.tg-grid { position: relative; display: grid; grid-template-columns: 58px minmax(0, 1fr); }
.tg-hours { position: relative; }
.tg-hours div { position: absolute; right: 8px; transform: translateY(-50%); font-size: 10px; color: var(--text-3); }
.tg-cols { position: relative; display: grid; grid-template-columns: repeat(var(--days), minmax(0, 1fr)); }
.tg-col { position: relative; border-left: 1px solid var(--border); cursor: default; user-select: none; }
.tg-slot { position: absolute; left: 0; right: 0; height: 48px; border-top: 1px solid var(--border); }
.gc-ev { position: absolute; border-radius: 6px; padding: 3px 7px; color: #fff; font-size: 12px; line-height: 1.3; overflow: hidden; cursor: pointer; box-shadow: 0 0 0 1px var(--surface); z-index: 2; }
.gc-ev b { font-weight: 600; } .gc-ev.short { display: flex; white-space: nowrap; align-items: center; padding-top: 0; padding-bottom: 0; }
.gc-ev .loc { opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gc-ev.ghost { background: var(--accent); opacity: .85; left: 1px; width: calc(100% - 8px); pointer-events: none; }
.gc-ev.dragging { opacity: .8; box-shadow: 0 6px 16px rgba(0,0,0,.25); z-index: 5; }
.gc-ev .rs { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; }
.now-line { position: absolute; left: -1px; right: 0; height: 2px; background: #ea4335; z-index: 3; pointer-events: none; }
.now-line::before { content: ''; position: absolute; left: -6px; top: -5px; width: 12px; height: 12px; border-radius: 50%; background: #ea4335; }
/* month */
.mg-dows { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 11px; font-weight: 600; color: var(--text-2); padding: 8px 0 0; }
.mg-week { position: relative; min-height: calc((100vh - 270px) / 6); min-height: max(112px, calc((100vh - 270px) / 6)); border-top: 1px solid var(--border); }
.mg-cells { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(7, 1fr); }
.mg-cell { border-left: 1px solid var(--border); text-align: center; padding-top: 4px; cursor: pointer; }
.mg-cell:first-child { border-left: none; }
.mg-cell .gc-dn { width: auto; min-width: 24px; height: 24px; font-size: 12px; font-weight: 500; padding: 0 6px; border-radius: 12px; }
.mg-cell.other .gc-dn { color: var(--text-3); }
.mg-more { position: absolute; margin-left: 4px; border: none; background: none; font-family: inherit; font-weight: 600; font-size: 12px; color: var(--text); cursor: pointer; padding: 2px 6px; border-radius: 4px; transform: translateX(0); }
.mg-cell { position: relative; } .mg-more { left: 0; }
.mg-more:hover { background: var(--surface-2); }
.gc-chip { position: absolute; height: 20px; line-height: 20px; border-radius: 4px; padding: 0 6px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; color: var(--text); z-index: 2; display: flex; align-items: center; gap: 5px; }
.gc-chip:hover { background: var(--surface-2); }
.gc-chip.solid { color: #fff; font-weight: 500; }
.gc-chip.solid:hover { filter: brightness(.95); }
.gc-chip i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.gc-chip .t { color: var(--text-2); flex: none; }
/* schedule */
.ag-day { display: grid; grid-template-columns: 130px minmax(0, 1fr); border-bottom: 1px solid var(--border); padding: 8px 14px; }
.ag-date { display: flex; align-items: flex-start; gap: 8px; font-size: 11px; font-weight: 600; color: var(--text-2); }
.ag-date .gc-dn { width: 34px; height: 34px; font-size: 18px; margin-top: -6px; }
.ag-ev { display: flex; align-items: center; gap: 14px; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.ag-ev:hover { background: var(--surface-2); }
.ag-ev i { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.ag-t { width: 150px; flex: none; color: var(--text-2); }
.ag-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* popovers */
.gc-pop { position: absolute; z-index: 90; width: 420px; max-width: calc(100vw - 20px); background: var(--surface); border-radius: 12px; box-shadow: 0 24px 38px 3px rgba(0,0,0,.14), 0 9px 46px 8px rgba(0,0,0,.12), 0 11px 15px -7px rgba(0,0,0,.2); padding: 8px 18px 18px; }
.gc-pop.center { position: fixed; top: 120px !important; left: 50% !important; transform: translateX(-50%); width: 480px; }
.gc-pop-tools { display: flex; justify-content: flex-end; gap: 2px; margin-right: -10px; }
.gc-pop-row { display: flex; gap: 16px; align-items: flex-start; padding: 7px 0; color: var(--text-2); }
.gc-pop-row > svg { flex: none; margin-top: 2px; }
.gc-pop-row .sq { width: 14px; height: 14px; border-radius: 4px; flex: none; margin: 6px 2px 0; }
.gc-pop-title { font-size: 22px; color: var(--text); line-height: 1.25; }
.gc-qtitle { width: 100%; border: none; border-bottom: 1px solid var(--border-strong); font-family: inherit; font-weight: 400; font-size: 22px; padding: 6px 2px 8px; margin: 0 0 14px; background: transparent; color: var(--text); outline: none; }
.gc-qtitle:focus { border-bottom: 2px solid var(--accent); }
/* ---------- maps ---------- */
.gmap-embed { width: 100%; border: 0; display: block; }
.map-wrap { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; height: calc(100vh - 210px); min-height: 480px; }
@media (max-width: 900px) { .map-wrap { grid-template-columns: minmax(0, 1fr); height: auto; } .map-card { height: 60vh; } }
.map-list { overflow: auto; }
.map-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; border: none; border-top: 1px solid var(--border); background: none; cursor: pointer; color: inherit; font: inherit; }
.map-row:hover { background: var(--surface-2); } .map-row.on { background: var(--accent-soft); }
.sdot { width: 11px; height: 11px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px var(--surface); }
.map-card { position: relative; overflow: hidden; }
.map-legend { position: absolute; left: 12px; bottom: 12px; z-index: 500; display: flex; flex-wrap: wrap; gap: 10px; background: var(--surface); padding: 6px 10px; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.15); font-size: 12px; }
.map-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
/* ---------- cost groups & templates ---------- */
tr.grp td { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); border-top: 2px solid color-mix(in srgb, var(--accent) 25%, var(--border)); }
.grp-name { font-weight: 700; } .grp-desc { margin-top: 6px; font-size: 13px; }
.grp-sub { font-weight: 750; padding-top: 14px !important; }
.tpl-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--accent-soft); border-color: transparent; }
.cg-pick { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; margin-bottom: 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; color: inherit; font: inherit; }
.cg-pick:hover { border-color: var(--accent); background: var(--accent-soft); }
.tpl-card { display: flex; flex-direction: column; gap: 6px; }
.mini-items td { padding: 4px 6px !important; } .mini-items .input { padding: 6px 8px; font-size: 13px; }
/* ---------- time & daily logs ---------- */
.ts-day { text-align: center; padding: 12px 6px; }
.ts-day.today { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.ts-h { margin-top: 6px; font-weight: 700; color: var(--accent-text); }
.dlog { display: flex; gap: 18px; padding: 16px 20px; cursor: pointer; }
.dlog:hover { border-color: var(--border-strong); }
.dlog-date { width: 54px; text-align: center; flex: none; }
.dlog-ph { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.dlog-ph img { width: 92px; height: 70px; object-fit: cover; border-radius: 8px; display: block; }
/* ---------- gantt ---------- */
.gantt { overflow: hidden; }
.gantt-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.gantt-body { display: grid; grid-template-columns: 300px minmax(0, 1fr); }
@media (max-width: 800px) { .gantt-body { grid-template-columns: 150px minmax(0, 1fr); } }
.g-left { border-right: 1px solid var(--border); }
.g-lh { display: flex; height: 52px; align-items: flex-end; padding: 0 12px 6px; font-size: 11px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); }
.g-row { height: 38px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; cursor: pointer; }
.g-row:hover { background: var(--surface-2); }
.g-head { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); background: var(--surface-2); cursor: default; }
.g-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.g-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-right { overflow-x: auto; position: relative; }
.g-months { height: 24px; position: relative; border-bottom: 1px solid var(--border); }
.g-months div { position: absolute; top: 0; height: 24px; line-height: 24px; padding-left: 8px; font-size: 12px; font-weight: 700; border-left: 1px solid var(--border); white-space: nowrap; overflow: hidden; }
.g-days { display: flex; height: 28px; border-bottom: 1px solid var(--border); position: relative; }
.g-days div { flex: none; text-align: center; font-size: 11px; color: var(--text-2); line-height: 1.1; padding-top: 3px; }
.g-days small { display: block; font-size: 9px; color: var(--text-3); }
.g-days .we { color: var(--text-3); } .g-days .td { color: var(--accent-text); font-weight: 800; }
.g-grid { position: relative; background-image: repeating-linear-gradient(to bottom, transparent 0 37px, var(--border) 37px 38px); }
.g-we { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--text) 3.5%, transparent); }
.g-today { position: absolute; top: 0; bottom: 0; width: 2px; background: #ea4335; opacity: .8; z-index: 1; }
.g-links { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 1; }
.g-bar { position: absolute; height: 24px; border-radius: 6px; background: color-mix(in srgb, var(--c) 30%, var(--surface)); border: 1px solid var(--c); overflow: hidden; cursor: grab; z-index: 2; user-select: none; }
.g-bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--c); opacity: .85; }
.g-bar span { position: relative; padding: 0 8px; font-size: 12px; line-height: 22px; font-weight: 600; white-space: nowrap; color: var(--text); }
.g-bar.done { opacity: .6; }
.g-h { position: absolute; right: 0; top: 0; bottom: 0; width: 8px; cursor: ew-resize; }
.g-h:hover { background: color-mix(in srgb, var(--c) 60%, transparent); }
.grp-desc, tr.section .grp-desc { text-transform: none !important; letter-spacing: 0 !important; font-weight: 400 !important; }
/* ---------- checks ---------- */
.ck-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 520px); gap: 18px; align-items: start; }
@media (max-width: 1200px) { .ck-wrap { grid-template-columns: minmax(0, 1fr); } }
.ck-form .field { margin-bottom: 12px; }
.cols3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 700px) { .cols3 { grid-template-columns: minmax(0, 1fr); } }
.big-in { font-size: 17px; padding: 11px 12px; }
.money-in { display: flex; align-items: center; gap: 6px; } .money-in span { font-size: 20px; font-weight: 700; color: var(--text-2); }
.ck-link { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 14px 4px; margin: 4px 0 14px; }
.posts { font-size: 13px; color: var(--text-2); padding: 0 0 10px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ck-prev { position: sticky; top: 16px; }
.ck-frame { width: 100%; aspect-ratio: 8.5 / 7; overflow: hidden; border-radius: 10px; border: 1px solid var(--border); background: #fff; position: relative; }
.ck-frame iframe { position: absolute; left: 0; top: 0; width: 8.5in; height: 11in; border: 0; transform-origin: 0 0; transform: scale(var(--s, .6)); }
.ck-bank { background: color-mix(in srgb, var(--warn) 7%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 30%, var(--border)); border-radius: 12px; padding: 12px 14px 4px; margin-top: 4px; }
.ck-form .cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } @media (max-width: 700px) { .ck-form .cols { grid-template-columns: minmax(0, 1fr); } }

/* ================= Phones ================= */
@media (max-width: 720px) {
  html { -webkit-text-size-adjust: 100%; }
  body { overscroll-behavior-y: none; }
  .mob-only { display: inline-flex !important; }
  /* slide-out menu */
  .app .sidebar { display: flex; position: fixed; z-index: 60; top: 0; bottom: 0; left: 0; width: min(300px, 84vw); height: 100%; transform: translateX(-105%); transition: transform .22s ease; box-shadow: 0 10px 40px rgba(0,0,0,.25); padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
  .app.collapsed .sidebar { width: min(300px, 84vw); }
  .app.collapsed .sidebar .nav a span, .app.collapsed .sidebar .brand span, .app.collapsed .co-switch > span { display: revert; }
  .app.mobile-nav .sidebar { transform: none; }
  .nav-scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(15,20,30,.4); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .app.mobile-nav .nav-scrim { opacity: 1; pointer-events: auto; }
  .sidebar .nav a { padding-top: 11px; padding-bottom: 11px; font-size: 15.5px; }
  .sidebar #collapse { display: none; }
  /* bottom tab bar */
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 7px; color: var(--text-3); font-size: 11px; font-weight: 650; background: none; border: 0; text-decoration: none !important; cursor: pointer; min-height: 54px; justify-content: center; }
  .tabbar a.on { color: var(--accent-text); }
  .tabbar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .content { padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
  .toasts { bottom: calc(72px + env(safe-area-inset-bottom)); width: calc(100% - 28px); }
  /* compact top bar */
  .topbar { gap: 6px; padding-top: calc(8px + env(safe-area-inset-top)); padding-bottom: 8px; flex-wrap: nowrap; }
  .searchbox { flex: 1; min-width: 0; padding: 8px 12px; box-shadow: none; }
  .searchbox span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; font-size: 14.5px; }
  .searchbox kbd, #pins { display: none !important; }
  .topbar > .spacer { display: none; }
  #quick { gap: 6px; flex-wrap: nowrap; flex-shrink: 0; }
  #clockBtn { padding: 7px 9px; max-width: 120px; overflow: hidden; white-space: nowrap; }
  #clockBtn:not(:has(.live-dot)) { font-size: 0; gap: 0; } #clockBtn:not(:has(.live-dot)) svg { width: 18px; height: 18px; }
  #newBtn { font-size: 0; gap: 0; width: 36px; height: 36px; padding: 0; justify-content: center; border-radius: 50%; } #newBtn svg { width: 20px; height: 20px; }
  /* page headers */
  .ph { margin: 6px 0 16px; gap: 12px; align-items: flex-start; }
  .ph > div:first-child { min-width: 0; flex: 1 1 100%; }
  .ph h1 { font-size: 24px; }
  .ph > .row { flex-wrap: wrap; gap: 8px; width: 100%; }
  .ph > .row:empty { display: none; }
  .ph .sub { font-size: 14px; }
  /* touch-sized controls, no iOS zoom on focus */
  .input, select.input, textarea.input, input, select, textarea { font-size: 16px !important; }
  .btn { min-height: 40px; } .btn.sm { min-height: 34px; } .btn.icon { min-width: 40px; }
  .row { flex-wrap: wrap; }
  .topbar .row, #quick { flex-wrap: nowrap; }
  /* stat tiles: two across, smaller */
  .grid { gap: 12px; }
  .g4:has(> .stat), .g3:has(> .stat), .g2:has(> .stat), .grid:has(> .stat:nth-child(2)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 13px 14px; }
  .stat .value { font-size: 20px; overflow-wrap: anywhere; }
  .stat .label { font-size: 12.5px; }
  .card-pad { padding: 14px; }
  .card-h { padding: 12px 14px 0; }
  .list-item { padding: 11px 14px; }
  /* tabs scroll sideways with a fade */
  .tabs { scrollbar-width: none; -webkit-overflow-scrolling: touch; margin-left: -14px; margin-right: -14px; padding: 0 14px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a, .tabs button { padding: 10px 12px; }
  .seg { max-width: 100%; overflow-x: auto; }
  /* forms: one column */
  .cols, .cols3, .setting-row, .form-grid, .fgrid { grid-template-columns: minmax(0, 1fr) !important; }
  [style*="grid-template-columns"]:not(.gcal *):not(.gantt-body):not(.gantt *):not(.kanban):not(.week7) { grid-template-columns: minmax(0, 1fr) !important; }
  /* dialogs become full-height sheets */
  .overlay { padding: 0; align-items: flex-end; }
  .modal, .modal.wide { max-width: none; border-radius: 18px 18px 0 0; max-height: 94vh; display: flex; flex-direction: column; }
  .modal-b { overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }
  .modal-h { padding: 14px 16px; }
  .modal-f { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); flex-wrap: wrap; border-radius: 0; }
  .modal-f .btn { flex: 1 1 auto; justify-content: center; }
  .palette { border-radius: 0 0 18px 18px; }
  .overlay:has(.palette) { align-items: flex-start; }
  /* kanban: one column at a time, swipe */
  .kanban { grid-auto-columns: 84vw; scroll-snap-type: x mandatory; margin: 0 -14px; padding: 0 14px 8px; scroll-padding: 0 14px; }
  .kanban > * { scroll-snap-align: start; }
  /* tables → cards */
  table.t.mcard, table.items.mcard { display: block; }
  table.mcard thead { display: none; }
  table.mcard tbody { display: block; }
  table.mcard tr { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); position: relative; }
  table.mcard tbody tr:nth-child(even) td { background: none; }
  table.mcard tbody tr:nth-child(even) { background: var(--row-stripe); }
  table.mcard tr:last-child { border-bottom: 0; }
  table.mcard td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 3px 0 !important; border: 0 !important; text-align: right !important; min-height: 0; width: auto !important; white-space: normal !important; }
  table.mcard td::before { content: attr(data-label); color: var(--text-3); font-size: 12.5px; font-weight: 600; text-align: left; flex-shrink: 0; max-width: 45%; }
  table.mcard td[data-label=""]::before { display: none; }
  table.mcard td[data-label=""] { justify-content: flex-end; }
  table.mcard td:empty { display: none; }
  table.mcard td:first-child { font-weight: 650; font-size: 15px; justify-content: flex-start; text-align: left !important; }
  table.mcard td:first-child::before { display: none; }
  table.mcard td > * { min-width: 0; }
  table.mcard tfoot { display: block; } table.mcard tfoot tr { display: flex; justify-content: space-between; flex-wrap: wrap; } table.mcard tfoot td { display: block; }
  /* proposal / invoice line items: label-above mini form per line */
  table.items.mcard tbody tr, table.items.mcard tbody tr:nth-child(even) { background: none; }
  table.items.mcard tr[data-i]:not(.desc):not(.grp) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 10px; padding: 14px 0 6px; border-bottom: 0; border-top: 1px solid var(--border-strong); position: relative; }
  table.items.mcard tr[data-i]:not(.desc):not(.grp) td { display: block; text-align: left !important; padding: 0 !important; }
  table.items.mcard tr[data-i]:not(.desc):not(.grp) td::before { display: block; margin-bottom: 3px; max-width: none; }
  table.items.mcard tr[data-i]:not(.desc):not(.grp) td.drag { grid-column: 1 / -1; display: flex; gap: 4px; order: -1; font-size: 0; }
  table.items.mcard tr[data-i]:not(.desc):not(.grp) td:nth-child(2) { grid-column: 1 / -1; font-size: 15px; }
  table.items.mcard tr[data-i]:not(.desc):not(.grp) td:nth-child(2)::before { display: none; }
  table.items.mcard tr[data-i]:not(.desc):not(.grp) td:last-child { position: absolute; top: 8px; right: 0; }
  table.items.mcard tr[data-i]:not(.desc):not(.grp) td.num { font-size: 16px; padding-top: 0 !important; }
  table.items.mcard tr[data-i]:not(.desc):not(.grp) td input[type=checkbox] { width: 22px; height: 22px; }
  table.items.mcard .input { max-width: none; text-align: left; width: 100%; }
  table.items.mcard tr.desc { padding: 0 0 12px; border: 0; }
  table.items.mcard tr.desc td { display: block; padding: 0 !important; }
  table.items.mcard tr.desc .row { flex-wrap: wrap !important; gap: 8px; }
  table.items.mcard tr.desc textarea { flex: 1 1 100% !important; }
  table.items.mcard tr.desc select { width: auto !important; flex: 1; }
  table.items.mcard tr.grp { display: grid; grid-template-columns: auto 1fr auto auto; gap: 6px 8px; align-items: center; padding: 12px 10px; margin-top: 10px; border-radius: 10px; background: var(--accent-soft) !important; border: 0; }
  table.items.mcard tr.grp td { display: block; padding: 0 !important; text-align: left !important; }
  table.items.mcard tr.grp td::before { display: none; }
  table.items.mcard tr.grp td[colspan] { grid-column: 1 / -1; order: -1; display: grid; gap: 6px; }
  .table-wrap { margin: 0; }
  table.no-mcard td, table.no-mcard th { white-space: nowrap; }
  /* calendar */
  .gc-bar { flex-wrap: wrap; row-gap: 8px; }
  .gc-title { font-size: 19px; margin-left: 4px; flex: 1; min-width: 0; }
  .gc-bar .seg { order: 9; width: 100%; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
  .gc-bar .seg button { padding: 7px 4px; }
  /* time clock week strip */
  .week7 { gap: 4px !important; }
  .week7 > .card { padding: 8px 2px; text-align: center; border-radius: 10px; }
  .week7 > .card > div:nth-child(2) { font-size: 17px !important; }
  .week7 .ts-h { font-size: 11px; }
  /* misc */
  .preview-bar { flex-wrap: wrap; font-size: 13px; }
  .empty { padding: 36px 14px; }
  img, video, iframe { max-width: 100%; }
}
@media (max-width: 720px) and (display-mode: standalone) { .topbar { padding-top: calc(10px + env(safe-area-inset-top)); } }
