:root {
  --bg: #faf8f5; --panel: #ffffff; --ink: #222120; --muted: #6b635d; --line: #ebe5df; --soft: #f5f0eb;
  --brand: #c4510f; --brand-ink: #ffffff; --brand-soft: #fdeee4; --accent: #f36a20; --gold: #c9954c; --charcoal: #222120;
  --danger: #b3261e; --warn: #8a5a00; --ok: #2f7d4a;
  --danger-soft: #fbeaea; --warn-soft: #fff4dc; --ok-soft: #e7f4ec; --radius: 10px; --shadow: 0 1px 2px rgba(34,33,32,.06);
  color-scheme: light;
}
/* Display: follows the device (system) unless the person picked light or dark on My account. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --bg: #171514; --panel: #211e1c; --ink: #f1ece7; --muted: #a89f97; --line: #3a3430; --soft: #2a2623;
  --brand: #f58a4b; --brand-ink: #1c1a19; --brand-soft: #3a2518; --accent: #f36a20; --gold: #d8a865; --charcoal: #f1ece7;
  --danger: #ef8a83; --warn: #e7b85a; --ok: #7ccb97;
  --danger-soft: #3a1f1d; --warn-soft: #3a2f17; --ok-soft: #1b3324;
  color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171514; --panel: #211e1c; --ink: #f1ece7; --muted: #a89f97; --line: #3a3430; --soft: #2a2623;
  --brand: #f58a4b; --brand-ink: #1c1a19; --brand-soft: #3a2518; --accent: #f36a20; --gold: #d8a865; --charcoal: #f1ece7;
  --danger: #ef8a83; --warn: #e7b85a; --ok: #7ccb97;
  --danger-soft: #3a1f1d; --warn-soft: #3a2f17; --ok-soft: #1b3324;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; color: var(--charcoal); letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 1.25rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.money { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* layout */
.app { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 4px 8px 14px; color: var(--ink); }
.brand img { width: 28px; height: 28px; }
.brand.logo { justify-content: center; padding: 6px 8px 14px; }
.brand.logo img { width: 100%; max-width: 170px; height: auto; }
.brand.logo.big { margin-bottom: 10px; }
.brand.logo.big img { max-width: 240px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand.logo img { background: #fff; border-radius: 10px; padding: 8px; } }
:root[data-theme="dark"] .brand.logo img { background: #fff; border-radius: 10px; padding: 8px; }
.nav a { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; border-radius: 8px; color: var(--ink); }
.nav a:hover { background: var(--soft); text-decoration: none; }
.nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.nav .sec { margin-top: 8px; }
.nav .sec > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600;
  padding: 8px 10px 4px; border-radius: 8px; user-select: none; }
.nav .sec > summary::-webkit-details-marker { display: none; }
.nav .sec > summary::after { content: "▾"; font-size: .9rem; transition: transform .15s; }
.nav .sec:not([open]) > summary::after { transform: rotate(-90deg); }
.nav .sec > summary:hover { color: var(--ink); background: var(--soft); }
.nav .sec .items { margin-left: 12px; padding-left: 8px; border-left: 1px solid color-mix(in srgb, var(--gold) 45%, transparent); }
.nav .sec .items a { padding: 6px 10px; }
.nav .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 10px 4px; }
.nav .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 8px; flex: none; }
.nav .cl { display: flex; align-items: center; min-width: 0; }
.nav .cl span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { background: var(--brand); color: var(--brand-ink); border-radius: 999px; font-size: .72rem; padding: 0 7px; font-weight: 600; }
.main { padding: 22px 28px 60px; min-width: 0; max-width: 1280px; }
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.topbar .menu-btn { display: none; }
.sandbox { background: var(--warn); color: #fff; text-align: center; font-weight: 700; padding: 3px; font-size: .8rem; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 20; left: 0; top: 0; width: 260px; transform: translateX(-105%); transition: transform .2s; box-shadow: 0 0 20px rgba(0,0,0,.2); }
  .side.open { transform: none; }
  .topbar .menu-btn { display: inline-flex; }
  .main { padding: 14px 16px 60px; }
}

/* pieces */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .v { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .k { color: var(--muted); font-size: .85rem; }
.stat.bad .v { color: var(--danger); }
.flash { padding: 9px 12px; border-radius: 8px; margin-bottom: 10px; background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--danger-soft); color: var(--danger); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }
.pill { display: inline-block; font-size: .75rem; padding: 1px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.chip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 6px 0 14px; overflow-x: auto; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--brand); border-color: var(--accent); font-weight: 600; }
.empty { color: var(--muted); padding: 10px 0; }

/* forms */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time], input[type=datetime-local],
input[type=number], input[type=url], input[type=search], input[type=tel], input:not([type]), select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; width: 100%; max-width: 100%;
}
input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: .85rem; color: var(--muted); margin: 8px 0 3px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); margin: 4px 12px 4px 0; font-size: .95rem; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 160px; min-width: 0; }
.row > .shrink { flex: 0 0 auto; }
.btn, button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover, button:hover { background: var(--soft); text-decoration: none; }
.btn.primary, button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
.btn.primary:hover, button.primary:hover { filter: brightness(1.07); }
.btn.danger, button.danger { color: var(--danger); }
.btn.sm, button.sm { padding: 3px 9px; font-size: .85rem; }
.btn.link, button.link { border: 0; background: none; color: var(--brand); padding: 0; }
form.inline { display: inline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
details > summary { cursor: pointer; color: var(--brand); }
.quick { display: flex; gap: 8px; }
.quick input { flex: 1; font-size: 1rem; padding: 10px 12px; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }

/* tables and lists */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.table-wrap { overflow-x: auto; }
.list { list-style: none; margin: 0; padding: 0; }
.task { display: flex; gap: 10px; align-items: flex-start; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task .check { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--muted); background: none; padding: 0; margin-top: 2px; }
.task .check:hover { background: var(--ok-soft); border-color: var(--ok); }
.task .check.p1 { border-color: #d1453b; } .task .check.p2 { border-color: #eb8909; } .task .check.p3 { border-color: #246fe0; }
.task .body { flex: 1; min-width: 0; }
.task .title { font-weight: 500; color: var(--ink); }
.task .next { font-size: .85rem; color: var(--muted); }
.task .meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; font-size: .8rem; color: var(--muted); }
.task .meta .late { color: var(--danger); font-weight: 600; }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.task .side-actions { display: flex; gap: 4px; }
.group-h { display: flex; justify-content: space-between; align-items: baseline; margin: 16px 0 2px; }
.group-h h3 { margin: 0; }
.group-h.late h3 { color: var(--danger); }
.msg { display: flex; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.msg .ico { flex: none; width: 34px; height: 34px; border-radius: 8px; background: var(--soft); display: grid; place-items: center; font-size: .7rem; font-weight: 700; color: var(--muted); }
.msg .body { flex: 1; min-width: 0; }
.msg .subject { font-weight: 600; }
.msg .snippet { color: var(--muted); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.msg .tools { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.msg .tools select { width: auto; padding: 3px 6px; font-size: .85rem; }
.timeline .ev { display: grid; grid-template-columns: 64px 4px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.timeline .ev .t { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
.timeline .ev .bar { border-radius: 4px; }
.timeline .ev .what { min-width: 0; }
.clients-grid .c { display: block; color: var(--ink); border-left: 5px solid var(--brand); }
.clients-grid .c:hover { text-decoration: none; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.shortcuts { display: flex; flex-wrap: wrap; gap: 8px; }
.shortcuts a { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--panel); color: var(--ink); font-size: .9rem; }
.shortcuts a:hover { border-color: var(--brand); text-decoration: none; }
.kanban { display: grid; grid-template-columns: repeat(6, minmax(200px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.kanban .col { background: var(--soft); border-radius: var(--radius); padding: 8px; min-height: 120px; }
.kanban .col h3 { margin: 2px 4px 8px; font-size: .9rem; display: flex; justify-content: space-between; }
.kanban .item { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; color: var(--ink); font-size: .9rem; }
.kanban .item:hover { border-color: var(--brand); text-decoration: none; }
.month { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.month .d { min-height: 104px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; background: var(--panel); font-size: .8rem; }
.month .d.out { background: var(--soft); color: var(--muted); }
.month .d .n { display: flex; justify-content: space-between; color: var(--muted); }
.month .d a.p { display: block; margin-top: 3px; padding: 2px 5px; border-radius: 5px; background: var(--brand-soft); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.month .d a.p.s-approved { background: var(--ok-soft); } .month .d a.p.s-review { background: var(--warn-soft); }
.month .d a.p.s-posted { background: var(--soft); color: var(--muted); }
.month .hd { font-size: .75rem; color: var(--muted); text-align: center; padding: 4px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--panel); }
@media (max-width: 700px) { .month { grid-template-columns: 1fr; } .month .hd, .month .d.out { display: none; } .month .d { min-height: 0; } }
.cal-day { margin-bottom: 10px; }
.cal-day h3 { margin: 10px 0 4px; font-size: .95rem; }
.cal-day.today h3 { color: var(--brand); }
.auth { max-width: 400px; margin: 8vh auto; padding: 0 16px; }
.auth .card { padding: 22px; }
.qr svg { width: 200px; height: 200px; background: #fff; border-radius: 8px; }
code, .code { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; background: var(--soft); padding: 1px 5px; border-radius: 5px; word-break: break-all; }
.lines td input { min-width: 70px; }

/* top bar: search + notifications */
.topbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.topbar .search { flex: 1; max-width: 560px; }
.topbar .search input { border-radius: 999px; padding: 8px 14px; }
.topbar .bell { position: relative; font-size: 1.15rem; text-decoration: none; padding: 4px 6px; }
.topbar .bell .count { position: absolute; top: -4px; right: -8px; }
.count { background: var(--accent); color: #1c1a19; }
/* My Day panels */
.panel-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.panel-h h2 { margin: 0 0 6px; }
.panel-h .n { background: var(--soft); border-radius: 999px; padding: 0 9px; font-size: .8rem; color: var(--muted); }
.card.alert { border-left: 4px solid var(--danger); }
.card.attn { border-left: 4px solid var(--accent); }
.card.gold { border-left: 4px solid var(--gold); }
.mini { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.mini:last-child { border-bottom: 0; }
.status-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.status-btns button.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.update { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.checklist label { display: flex; gap: 8px; align-items: center; padding: 5px 0; color: var(--ink); font-size: .95rem; margin: 0; }
.checklist .done span { text-decoration: line-through; color: var(--muted); }
.notif { display: flex; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.notif.unread { font-weight: 600; }
.notif.unread::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 7px; flex: none; }
