/* C2 — minimal baseline. Plain CSS; no build step. Colours via variables so
   [data-theme="dark"] can override the whole palette in one place. */
:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #fafbfc;     /* table headers, subtle fills */
    --input-bg: #ffffff;
    --text: #1f2430;
    --muted: #6b7280;
    --border: #e3e6ea;
    --border-strong: #cfd4da;
    --accent: #2f6feb;
    --accent-ink: #ffffff;
    --code-bg: #eef0f3;
    --ok-bg: #e7f6ec;  --ok-border: #bfe3cb;  --ok-text: #1c6b38;
    --err-bg: #fdecec; --err-border: #f3c2c2; --err-text: #9b1c1c;
    --warn-bg: #fff4e0; --warn-border: #f0d9a8; --warn-text: #8a5a00;
    --danger: #e5484d;
    --shadow: 0 1px 3px rgba(0,0,0,.05);
    --radius: 10px;
    --topbar-h: 56px;
    --sidebar-w: 220px;
    --sidebar-w-collapsed: 60px;
    color-scheme: light;
}
[data-theme="dark"] {
    --bg: #14161b;
    --surface: #1c1f26;
    --surface-2: #242832;
    --input-bg: #1c1f26;
    --text: #e6e8ec;
    --muted: #9aa3b2;
    --border: #2d323c;
    --border-strong: #3a414d;
    --accent: #5b8cff;
    --accent-ink: #0b1020;
    --code-bg: #242832;
    --ok-bg: #10301d;  --ok-border: #1f5e38;  --ok-text: #7fdca0;
    --err-bg: #3a1b1b; --err-border: #6e2d2d; --err-text: #f3a8a8;
    --warn-bg: #3a2f12; --warn-border: #6e5a23; --warn-text: #e8c879;
    --danger: #f3686d;
    --shadow: 0 1px 3px rgba(0,0,0,.45);
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 15px/1.55 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* All text-like controls follow the theme (covers inline/filter inputs too). */
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=datetime-local], input[type=number], input[type=search], input[type=time],
select, textarea {
    background: var(--input-bg); color: var(--text);
}

/* ===== App shell: top bar + left sidebar ===== */
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 1rem;
    padding: 0 1rem; height: var(--topbar-h);
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.2rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.clock-logo { width: 40px; height: 40px; display: block; }
/* Workspace name sits beside the C2 brand as a quieter subtitle, set off by a thin divider. */
.brand-sep { width: 1px; height: 1.3rem; background: var(--border); flex: 0 0 auto; }
.brand-workspace { font-weight: 500; font-size: 1.05rem; color: var(--muted); white-space: nowrap;
    max-width: 16rem; overflow: hidden; text-overflow: ellipsis; }
.topbar-spacer { flex: 1; }
.topbar-user { display: flex; align-items: center; gap: .5rem; }
.who { color: var(--muted); font-size: .9rem; white-space: nowrap; }

/* Gravatar avatars: round, never distorted, with a subtle ring that suits both themes. */
.avatar { border-radius: 50%; display: block; object-fit: cover; background: var(--input-bg); border: 1px solid var(--border); }
.topbar-avatar { width: 30px; height: 30px; }
.col-avatar { width: 44px; text-align: center; }
.col-avatar .avatar { margin: 0 auto; }
.avatar-card { display: flex; align-items: flex-start; gap: 1.25rem; }
.avatar-card .avatar { width: 72px; height: 72px; flex-shrink: 0; margin-top: .15rem; }
.avatar-card h2 { margin-top: 0; }
.avatar-card-body p { margin: .35rem 0 0; max-width: 52ch; }
.avatar-card-body .btn { margin-top: .9rem; }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; padding: 0; border-radius: 8px;
    background: transparent; border: 1px solid transparent; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); }
.logout-btn { color: var(--danger); }

/* theme toggle: one glyph per theme */
.theme-toggle .theme-moon, [data-theme="dark"] .theme-toggle .theme-sun { display: none; }
.theme-toggle .theme-sun, [data-theme="dark"] .theme-toggle .theme-moon { display: inline-flex; }

/* body = sidebar + content row, filling the viewport under the topbar */
.app-body { display: flex; align-items: flex-start; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
    flex: 0 0 var(--sidebar-w); width: var(--sidebar-w);
    background: var(--surface); border-right: 1px solid var(--border);
    position: sticky; top: var(--topbar-h); align-self: flex-start;
    height: calc(100vh - var(--topbar-h)); overflow-y: auto;
    transition: width .15s ease, flex-basis .15s ease;
}
.side-nav { display: flex; flex-direction: column; padding: .5rem; gap: 2px; }
.side-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .55rem .7rem; border-radius: 8px; color: var(--text); white-space: nowrap;
}
.side-link:hover { background: var(--surface-2); text-decoration: none; }
.side-link.is-active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 600; }
.side-ico { display: inline-flex; flex: 0 0 auto; color: var(--muted); }
.side-link.is-active .side-ico { color: var(--accent); }
.side-label { overflow: hidden; }

/* Fill the available width (forms/cards self-constrain via their own max-width);
   wide tables — esp. with the audit columns on — use the whole monitor. */
.content { flex: 1 1 auto; min-width: 0; padding: 1.75rem 2rem; }

/* Mini audit trail: Created/Updated columns, hidden until the global "Audit trail"
   switch is on (persisted per-browser in localStorage as c2-audit). */
.col-audit { display: none; }
html.audit-on .col-audit { display: table-cell; }
.col-audit { white-space: nowrap; color: var(--muted); font-size: .82rem; vertical-align: top; }
.col-audit .audit-who { display: block; color: var(--muted); }
.audit-toggle { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; color: var(--muted); cursor: pointer; white-space: nowrap; user-select: none; }
.audit-toggle input { margin: 0; }
.page-head-tools { display: flex; align-items: center; gap: 1rem; }

/* collapsed sidebar: icons only */
.sidebar-collapsed .sidebar { flex-basis: var(--sidebar-w-collapsed); width: var(--sidebar-w-collapsed); }
.sidebar-collapsed .side-label { display: none; }
.sidebar-collapsed .side-link { justify-content: center; gap: 0; }

/* centered container kept for bare/auth pages */
.container { max-width: 980px; margin: 2rem auto; padding: 0 1.25rem; }

/* off-canvas drawer backdrop (mobile only) */
.sidebar-backdrop { display: none; }

@media (max-width: 760px) {
    /* Sidebar becomes an off-canvas drawer: hidden by default, slid in when open. */
    .sidebar {
        position: fixed; z-index: 45; left: 0; top: var(--topbar-h);
        width: var(--sidebar-w); flex-basis: var(--sidebar-w);
        height: calc(100vh - var(--topbar-h));
        transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow);
    }
    .sidebar-open .sidebar { transform: translateX(0); }
    /* the desktop icon-rail state doesn't apply on mobile — always show full labels */
    .sidebar-collapsed .side-label { display: inline; }
    .sidebar-collapsed .side-link { justify-content: flex-start; gap: .75rem; }

    .sidebar-backdrop {
        display: block; position: fixed; inset: var(--topbar-h) 0 0 0;
        background: rgba(0,0,0,.45); z-index: 44;
        opacity: 0; visibility: hidden; transition: opacity .2s ease;
    }
    .sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }

    .content { padding: 1.25rem; overflow-x: auto; }   /* wide tables scroll instead of breaking layout */
    .brand-name { display: none; }
    /* Keep the workspace name visible on mobile (it's the company identity), but drop the
       now-orphaned divider that sat between it and the hidden "C2" wordmark. */
    .brand-sep { display: none; }
    .brand-workspace { max-width: 9rem; }
}

/* ===== Accessibility polish (Phase 7) ===== */
.skip-link { position: absolute; left: .5rem; top: -3rem; z-index: 60; padding: .5rem .9rem;
    background: var(--accent); color: var(--accent-ink); border-radius: 8px; transition: top .15s ease; }
.skip-link:focus { top: .5rem; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.side-link.is-active:focus-visible { outline-offset: -2px; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }

.facts { list-style: none; padding: 0; margin: 1.25rem 0; display: grid; gap: .5rem; }
.facts li {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .6rem .9rem;
}

/* Forms / buttons */
.inline { display: inline; margin: 0; }
.linkbtn {
    background: none; border: none; padding: 0;
    color: var(--accent); cursor: pointer; font: inherit;
}
.linkbtn:hover { text-decoration: underline; }

.btn {
    display: inline-block;
    padding: .6rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font: inherit;
}
.btn:hover { text-decoration: none; border-color: var(--border-strong); }
.btn-small { padding: .35rem .7rem; font-size: .85rem; }
.btn-google { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-dev { margin-top: .5rem; }

/* Bare layout (auth + public share pages) */
body.bare { background: var(--bg); }
.bare-topbar {
    display: flex; align-items: center; justify-content: space-between;
    height: 52px; padding: 0 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.centered { min-height: calc(100vh - 52px); display: grid; place-items: center; padding: 1.25rem; }
/* A public share renders a full-width report (not a centered card). */
.share-page { width: 100%; max-width: 1100px; }
.share-page h1 { margin-top: 0; }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}
/* The narrow 380px cap is only for the centered auth/login card. */
.card.auth { text-align: center; width: 100%; max-width: 380px; margin: 0 auto; }
.card.auth .btn { display: block; width: 100%; }
.card.auth .btn + .btn { margin-top: .6rem; }
code { background: var(--code-bg); padding: .1em .35em; border-radius: 4px; }

/* Flash / feedback messages */
/* Pinned just under the (sticky) topbar so action feedback — including snap notices
   from inline edits deep in a long list — stays visible as the page scrolls. Empty
   container collapses to zero height, so it costs nothing when there's nothing to show. */
.feedback { position: sticky; top: calc(var(--topbar-h) + .5rem); z-index: 20; }
.flash {
    position: relative; padding: .6rem 2.2rem .6rem .9rem; border-radius: var(--radius);
    margin-bottom: 1rem; border: 1px solid transparent;
    transition: opacity .2s ease, transform .2s ease;
}
.flash-success { background: var(--ok-bg); border-color: var(--ok-border); color: var(--ok-text); }
.flash-error   { background: var(--err-bg); border-color: var(--err-border); color: var(--err-text); }
.flash-warn    { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
/* Per-message close button (added by JS) + the fade-out it triggers. */
.flash-close {
    position: absolute; top: 50%; right: .5rem; transform: translateY(-50%);
    width: 1.5rem; height: 1.5rem; padding: 0; line-height: 1; font-size: 1.15rem;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: 0; border-radius: 4px; cursor: pointer;
    color: inherit; opacity: .6;
}
.flash-close:hover { opacity: 1; background: rgba(127, 127, 127, .18); }
.flash-out { opacity: 0; transform: translateY(-4px); }

/* Page header with an action on the right */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }

/* Buttons */
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Data grid */
table.grid { width: 100%; border-collapse: collapse; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.grid th, table.grid td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--border); }
table.grid th { background: var(--surface-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.grid tr:last-child td { border-bottom: none; }
.th-sort { color: inherit; text-decoration: none; cursor: pointer; white-space: nowrap; }
.th-sort:hover { text-decoration: underline; }
.th-sort.is-active { color: var(--text); font-weight: 700; }
table.grid tr.is-archived td { color: var(--muted); background: var(--surface-2); }
table.grid .col-actions { width: 1%; white-space: nowrap; }
table.grid .actions { white-space: nowrap; }
table.grid .actions a, table.grid .actions .linkbtn { margin-right: .75rem; }

/* Forms */
.form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.5rem; max-width: 560px; display: grid; gap: .35rem; }
/* Edit page (form + embedded "Team & permissions" card): give both the same
   comfortable width and space them out, instead of a narrow form abutting a
   full-width card. */
.edit-stack { max-width: 860px; }
.edit-stack > .form { max-width: none; }
.edit-stack > .card { margin-top: 1.5rem; }
.form label { display: block; font-weight: 600; margin-top: .5rem; }
.form label.checkbox, .form label.radio { font-weight: 400; display: flex; align-items: center; gap: .5rem; }
.form input[type=text], .form input[type=email], .form select, .form textarea {
    width: 100%; padding: .5rem .6rem; margin-top: .25rem; font: inherit; color: var(--text);
    border: 1px solid var(--border); border-radius: 8px; background: var(--input-bg); }
.form label.checkbox input, .form label.radio input { width: auto; margin: 0; }
.form .scope { border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; margin-top: .5rem; }
.form .scope legend { font-weight: 600; padding: 0 .35rem; }
.form fieldset.setting { border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; margin-top: .75rem; }
.form fieldset.setting legend { font-weight: 600; padding: 0 .35rem; }
.setting-help { margin: .1rem 0 .5rem; font-size: .85rem; }
.setting-options { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-top: .35rem; }
/* Multi-select setting (e.g. quick-select periods): a tidy wrapped checkbox grid. */
.setting-options.setting-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .35rem 1rem; }
.setting-checks .checkbox { font-weight: 400; }
.field-error { color: var(--err-text); font-size: .85rem; margin: .1rem 0 .25rem; }
.access-help { margin: .15rem 0 .25rem; padding-left: 1.15rem; font-size: .82rem; line-height: 1.5; }
.access-help li { margin: .2rem 0; }
.access-help strong { color: var(--text); }
.form-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }

.card + .card, .grid + .card, table.grid + .card { margin-top: 1.5rem; }
.card h2 { margin-top: 0; font-size: 1.15rem; }
.card.bulk { max-width: 560px; }
/* Data Imports edit: the top form spans full width like the cards below it,
   and gets the same gap so the panes don't touch. */
.import-form { max-width: none; }
.import-form + .card { margin-top: 1.5rem; }

/* Time page */
.card.timer { padding: 1rem 1.25rem; }
.form-inline { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.form-inline select, .form-inline input[type=text] {
    padding: .5rem .6rem; font: inherit; border: 1px solid var(--border); border-radius: 8px; }
.form-inline input[type=text] { flex: 1; min-width: 220px; }
.timer-running { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.timer-clock { font-size: 2rem; font-variant-numeric: tabular-nums; font-weight: 700; }
.timer-actions { display: flex; align-items: center; gap: 1rem; }

.form .form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form .form-row label { flex: 1; min-width: 200px; }
/* Live duration readout on the edit-entry page. */
.form .entry-duration { margin: .25rem 0 .5rem; color: var(--muted); }
.form .entry-duration strong { color: var(--text); font-variant-numeric: tabular-nums; }
/* "Change date of both" helper on the edit-entry page. Everything centered on one
   row so the button lines up with the field beside it. */
.form .date-both { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin: .75rem 0 .25rem; }
.form .date-both .date-both-field { display: inline-flex; align-items: center; gap: .5rem; margin: 0; font-weight: 600; }
.form .date-both .date-both-field input[type=date] {
    font: inherit; font-weight: 400; padding: .55rem .6rem; color: var(--text);
    background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius);
}
.form .date-both .btn { padding: .55rem .9rem; }
.form .date-both .date-both-help { font-size: .85rem; }

.day-head { display: flex; justify-content: space-between; align-items: baseline;
    margin: 1.25rem 0 .35rem; padding-bottom: .25rem; border-bottom: 2px solid var(--border); }
.col-check { width: 1%; }
.col-time { width: 1%; white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.col-hours { width: 1%; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }

/* Reports */
.page-head .report-links { display: flex; align-items: center; gap: 1rem; }
.report-links { display: flex; align-items: center; gap: 1rem; margin: .75rem 0; }
.report-links .current { font-weight: 600; }
.report-links .btn { margin-left: auto; }
/* "Share" greyed out when the report is on a custom period (shared reports need a
   Quick Select Period); clicking warns instead of navigating (app.js). */
.report-links .share-link.is-disabled { color: var(--muted); opacity: .55; cursor: not-allowed; }
.report-links .share-link.is-disabled:hover { opacity: .75; }
.report-filters { padding: 1rem 1.25rem; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.filter-grid label { display: block; font-weight: 600; font-size: .85rem; }
.filter-grid select, .filter-grid input { width: 100%; padding: .45rem .5rem; margin-top: .2rem;
    font: inherit; border: 1px solid var(--border); border-radius: 8px; }
.group-by { margin-top: .9rem; border: 1px solid var(--border); border-radius: 8px; padding: .6rem .9rem; }
.group-by legend { font-weight: 600; padding: 0 .35rem; }
.group-by-hint { margin: .1rem 0 .6rem; font-size: .82rem; }
.group-by-levels { display: flex; flex-wrap: wrap; gap: .75rem; }
.group-by-levels label { display: inline-flex; align-items: center; gap: .4rem; font-weight: 400; }
.group-by-rank { display: inline-flex; align-items: center; justify-content: center; width: 1.4rem; height: 1.4rem;
    border-radius: 50%; background: var(--border); font-size: .8rem; font-weight: 600; }
.group-by-levels select { padding: .4rem .5rem; font: inherit; border: 1px solid var(--border); border-radius: 8px; }

.bar-cell { width: 30%; }
.hbar { height: 12px; background: var(--accent); border-radius: 6px; min-width: 2px; }

.chart .bars-vertical { display: flex; align-items: flex-end; gap: 3px; height: 160px; overflow-x: auto; padding-top: .5rem; }
.vbar { flex: 1 0 14px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.vbar-fill { width: 70%; min-height: 2px; background: var(--accent); border-radius: 3px 3px 0 0; }
.vbar-label { font-size: .6rem; color: var(--muted); margin-top: 2px; white-space: nowrap; }

.pager { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }

/* ===== Timer page (Phase 2) ===== */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.timer-bar-wrap { display: flex; align-items: stretch; gap: .6rem; margin-bottom: 1.5rem; }
.timer-bar {
    flex: 1 1 auto; display: flex; align-items: center; gap: 1.25rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: .6rem 1rem;
}
.timer-bar .tf-field { display: flex; flex-direction: column; gap: .15rem; }
.timer-bar .tf-desc { flex: 3 1 0; min-width: 0; }
.timer-bar .tf-proj { flex: 2 1 0; min-width: 0; }
.tf-field label { font-size: .72rem; color: var(--accent); font-weight: 600; }
.tf-field .req { color: var(--danger); }
.timer-bar .typeahead input[type=text] {
    width: 100%; border: none; border-bottom: 1px solid transparent; background: transparent;
    color: var(--text); font: inherit; padding: .25rem 0;
}
.timer-bar .typeahead input:focus { outline: none; border-bottom-color: var(--accent); }
.tf-clock { margin-left: auto; display: flex; align-items: center; gap: .9rem; }
.timer-bar .timer-clock { font-size: 1.7rem; font-variant-numeric: tabular-nums; font-weight: 700; }
/* Editable start time, left of the running clock */
.timer-start { display: flex; flex-direction: column; gap: .1rem; }
.timer-start-cap { font-size: .72rem; color: var(--accent); font-weight: 600; }
.timer-start-input {
    width: 4.2rem; font: inherit; color: var(--text); background: transparent;
    border: 1px solid transparent; border-bottom: 1px solid var(--border); border-radius: 6px;
    padding: .2rem .35rem; font-variant-numeric: tabular-nums;
}
.timer-start-input:hover { border-color: var(--border); }
.timer-start-input:focus { outline: none; border-color: var(--accent); background: var(--input-bg); }
.btn-start, .btn-stop { color: #fff; border: none; font-weight: 600; min-width: 92px; padding: .7rem 1.2rem; font-size: 1.05rem; }
.btn-start { background: #2fa45e; } .btn-start:hover { background: #289353; }
.btn-stop  { background: var(--danger); } .btn-stop:hover { filter: brightness(.95); }

/* "Shortcuts" help: a hint button in the timer bar with a hover/click popover */
.shortcuts-hint { position: relative; display: flex; align-items: center; }
.shortcuts-toggle { width: auto; gap: .4rem; padding: 0 .6rem; color: var(--muted); white-space: nowrap; }
.shortcuts-label { font-size: .85rem; }
.shortcuts-panel {
    position: absolute; z-index: 50; right: 0; top: calc(100% + 6px); width: 320px; max-width: 80vw;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: .85rem 1rem;
}
.shortcuts-panel h2 { margin: 0 0 .6rem; font-size: .95rem; }
.shortcuts-panel dl { margin: 0; display: grid; gap: .45rem; }
.shortcuts-panel dl > div { display: flex; align-items: baseline; gap: .6rem; }
.shortcuts-panel dt { flex: 0 0 auto; min-width: 3.2rem; }
.shortcuts-panel dd { margin: 0; font-size: .9rem; }
.shortcuts-panel p { margin: .7rem 0 0; font-size: .8rem; }
kbd {
    display: inline-block; min-width: 1.2em; text-align: center; padding: .1rem .4rem;
    font: 600 .8rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--text); background: var(--surface-2);
    border: 1px solid var(--border-strong); border-radius: 5px; box-shadow: 0 1px 0 var(--border-strong);
}
@media (max-width: 760px) { .shortcuts-label { display: none; } }

/* typeahead dropdown */
.typeahead { position: relative; }
.ta-results {
    position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px);
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: var(--shadow); max-height: 320px; overflow-y: auto; min-width: 280px;
}
.ta-item { padding: .5rem .75rem; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ta-item:hover, .ta-item.active { background: var(--surface-2); }

/* API key one-time reveal (Settings → API access) */
.api-key-reveal { border: 1px solid var(--accent); border-radius: 8px; padding: .8rem 1rem; margin: .5rem 0 1rem;
    background: var(--surface-2); display: grid; gap: .5rem; }
.api-key-value { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 1rem; word-break: break-all; padding: .5rem .6rem; border: 1px solid var(--border);
    border-radius: 6px; background: var(--surface); color: var(--text); }

/* API documentation page */
.api-docs { max-width: 880px; }
.api-docs h2 { margin-top: 2rem; }
.api-docs pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
    padding: 1rem; overflow-x: auto; font-size: .85rem; line-height: 1.5; }
.api-docs table.grid td code { white-space: nowrap; }

/* Scheduled services grid (Admin → Maintenance) */
.cron-reminder { background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 8px; padding: .8rem 1rem; margin-bottom: 1rem; font-size: .9rem; }
.cron-reminder pre { background: var(--code-bg); border: 1px solid var(--border);
    border-radius: 6px; padding: .6rem .8rem; margin: .5rem 0; overflow-x: auto;
    font-size: .82rem; }
.cron-reminder pre code { background: none; padding: 0; }
.svc-grid td { vertical-align: top; }
.svc-grid input[type=number], .svc-grid input[type=text] {
    padding: .4rem .5rem; font: inherit; border: 1px solid var(--border);
    border-radius: 6px; background: var(--input-bg); color: var(--text); }
.svc-grid .svc-var { display: block; margin-top: .4rem; font-size: .85rem; color: var(--muted); }
.svc-grid .svc-var input { display: block; margin-top: .15rem; }
.svc-run-now { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* Data Imports → project-mapping editor (source name → searchable local project) */
.map-add { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.map-add .map-source { flex: 1 1 200px; min-width: 180px; }
.map-add .map-arrow { color: var(--muted); font-weight: 700; }
.map-add .typeahead.map-target { flex: 1 1 240px; min-width: 200px; }
.map-add .map-source,
.map-add .typeahead.map-target input[type=text] {
    width: 100%; padding: .5rem .6rem; font: inherit;
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text);
}
.map-add .map-source:focus,
.map-add .typeahead.map-target input:focus { outline: none; border-color: var(--accent); }
.map-add .btn { flex: 0 0 auto; }

/* week / day subheadings */
.wk-head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin: 1.5rem 0 .25rem; padding-bottom: .3rem; border-bottom: 2px solid var(--border);
    font-size: 1.05rem;
}
.wk-total { font-weight: 700; font-variant-numeric: tabular-nums; }
.day-head2 {
    display: flex; justify-content: space-between; align-items: baseline;
    margin: .9rem 0 .2rem; font-weight: 600; color: var(--muted);
}

/* entry rows with inline edit */
table.grid.entries-grid { margin-bottom: .5rem; }
.entries-grid td { vertical-align: middle; }
.entries-grid .col-desc { width: 45%; }
.entries-grid .col-proj { width: 32%; }
.entries-grid .col-time { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.inline-desc, .inline-project {
    width: 100%; font: inherit; color: var(--text);
    background: transparent; border: 1px solid transparent; border-radius: 6px; padding: .3rem .4rem;
}
.inline-desc:hover, .inline-project:hover { border-color: var(--border); }
.inline-desc:focus, .inline-project:focus { outline: none; border-color: var(--accent); background: var(--input-bg); }
/* Resume-shortcut number (1..9) left of the description on the Timer page. */
.col-desc .desc-wrap { display: flex; align-items: center; gap: .45rem; }
.desc-wrap .inline-desc { width: auto; flex: 1 1 auto; min-width: 0; }
.resume-num {
    flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
    width: 1.4rem; height: 1.4rem; border-radius: 6px;
    font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums;
    color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); user-select: none;
}
tr.is-locked .resume-num { opacity: .6; }
.inline-project { background: var(--input-bg); border-color: var(--border); }
/* Inline start/end time inputs (HH:MM) */
.col-time .inline-time {
    width: 3.3rem; font: inherit; color: var(--muted); text-align: center;
    background: transparent; border: 1px solid transparent; border-radius: 6px;
    padding: .25rem .2rem; font-variant-numeric: tabular-nums;
}
.col-time .inline-time:hover { border-color: var(--border); }
.col-time .inline-time:focus { outline: none; color: var(--text); border-color: var(--accent); background: var(--input-bg); }
.col-time .time-sep { color: var(--muted); margin: 0 .1rem; }
/* Inline date shift (Time Entries): compact date input + the mirrored time/date text. */
.col-time .inline-date {
    font: inherit; color: var(--text); background: transparent;
    border: 1px solid transparent; border-radius: 6px; padding: .2rem .25rem;
    font-variant-numeric: tabular-nums;
}
.col-time .inline-date:hover { border-color: var(--border); }
.col-time .inline-date:focus { outline: none; border-color: var(--accent); background: var(--input-bg); }
.col-time .time-part, .col-time .date-part { color: var(--muted); margin-left: .15rem; }
/* Timer page: compact calendar button that opens a visually-hidden date input
   (kept rendered, 1px, so the native picker can anchor to it). */
.col-time .inline-date-wrap { position: relative; display: inline-flex; align-items: center; vertical-align: middle; margin-right: .1rem; }
.col-time .inline-date-btn { width: 1.7rem; height: 1.7rem; border-radius: 6px; color: var(--muted); }
.col-time .inline-date-btn:hover { color: var(--text); }
.col-time .inline-date-btn svg { width: 16px; height: 16px; }
.col-time .inline-date-wrap .inline-date {
    position: absolute; left: 0; bottom: 0; width: 1px; height: 1px;
    padding: 0; border: 0; opacity: 0; pointer-events: none;
}
.save-ok { border-color: #2fa45e !important; }
.save-err { border-color: var(--danger) !important; }
tr.is-locked .inline-desc { color: var(--muted); }
.entries-grid .actions { white-space: nowrap; text-align: right; width: 1%; }
.entries-grid .actions .icon-btn { width: 32px; height: 32px; vertical-align: middle; }
.icon-btn.danger { color: var(--danger); }

/* Time Entries (wide 8-column grid) — balance the columns */
.time-entries .col-desc { width: 24%; }
.time-entries .col-proj { width: 16%; }
.time-entries .col-client { width: 14%; }
.time-entries .inline-desc, .time-entries .inline-project { max-width: 100%; }
.time-entries td { vertical-align: middle; }

@media (max-width: 760px) {
    .timer-bar { flex-wrap: wrap; }
    .timer-bar .tf-desc, .timer-bar .tf-proj { flex: 1 1 100%; }
}

/* ===== Reports filter bar + charts + tree (Phase 3) ===== */
.report-bar {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: .75rem 1rem; margin-bottom: 1rem;
}
.report-bar .rb-date, .report-bar .rb-search { display: flex; flex-direction: column; font-size: .72rem; color: var(--muted); font-weight: 600; gap: .15rem; }
.report-bar .rb-date input, .report-bar .rb-date select, .report-bar .rb-search input {
    font: inherit; padding: .4rem .5rem; border: 1px solid var(--border); border-radius: 8px; background: var(--input-bg); color: var(--text); }
.report-bar .rb-search input { min-width: 14rem; }
.report-bar .rb-apply { margin-left: auto; }
.rb-export { display: inline-flex; align-items: center; gap: .35rem; }
.rb-export svg { width: 16px; height: 16px; }

/* Export: one button + dropdown of formats (native <details>). */
.export-menu { position: relative; display: inline-block; }
.export-menu > summary { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; list-style: none; }
.export-menu > summary::-webkit-details-marker { display: none; }
.export-menu > summary svg { width: 16px; height: 16px; }
.export-caret { font-size: .7rem; opacity: .8; }
.export-menu[open] > summary { border-color: var(--border-strong); }
.export-menu-list {
    position: absolute; z-index: 40; right: 0; top: calc(100% + 4px); min-width: 150px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: var(--shadow); padding: .3rem; display: flex; flex-direction: column;
}
.export-menu-list a { padding: .45rem .6rem; border-radius: 6px; color: var(--text); white-space: nowrap; }
.export-menu-list a:hover { background: var(--surface-2); text-decoration: none; }

/* multi-select */
.ms { position: relative; }
.ms-toggle {
    min-width: 130px; text-align: left; font: inherit; cursor: pointer;
    padding: .5rem .7rem; border: 1px solid var(--border); border-radius: 8px;
    background: var(--input-bg); color: var(--text);
}
.ms-toggle:hover { border-color: var(--border-strong); }
.ms-panel {
    position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; min-width: 240px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    box-shadow: var(--shadow); padding: .5rem;
}
.ms-search { width: 100%; padding: .4rem .5rem; border: 1px solid var(--border); border-radius: 6px; margin-bottom: .4rem; font: inherit; }
.ms-list { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; }
.ms-item { display: flex; align-items: center; gap: .5rem; padding: .35rem .4rem; border-radius: 6px; font-weight: 400; cursor: pointer; }
.ms-item:hover { background: var(--surface-2); }
.ms-hint { margin: .4rem 0 0; font-size: .75rem; color: var(--muted); }

/* filter tabs (segmented control) */
.filter-tabs { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 1rem; }
.filter-tab { padding: .4rem .9rem; color: var(--muted); font-size: .85rem; font-weight: 600; border-right: 1px solid var(--border); }
.filter-tab:last-child { border-right: none; }
.filter-tab:hover { background: var(--surface-2); text-decoration: none; }
.filter-tab.is-active { background: var(--accent); color: var(--accent-ink); }
.list-controls { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.list-controls .filter-tabs { margin-bottom: 0; }
.list-controls label { font-size: .85rem; color: var(--muted); display: inline-flex; align-items: center; gap: .4rem; }
.list-controls select { padding: .4rem .5rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; }

/* status / access pills */
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 600;
    background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge-ok     { background: var(--ok-bg);   color: var(--ok-text);   border-color: var(--ok-border); }
.badge-warn   { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-border); }
.badge-danger { background: var(--err-bg);  color: var(--err-text);  border-color: var(--err-border); }
.badge-info   { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); border-color: transparent; }

/* Colour-coded project names. --proj-h (the per-project hue) is set inline by
   proj_name(); saturation/lightness are fixed here per theme so any hue stays
   legible on both backgrounds (darker text on light, lighter text on dark). */
.proj-name { color: hsl(var(--proj-h, 220), 65%, 38%); font-weight: 600; }
[data-theme="dark"] .proj-name { color: hsl(var(--proj-h, 220), 70%, 72%); }

/* Editable project controls — the inline-edit <select>s and the timer typeahead.
   JS sets --proj-h from the chosen project's id and adds .proj-tinted (so untinted
   controls keep the default colour). The closed select / input shows the selected
   project's hue; each <option> / result row carries its own. */
.inline-project.proj-tinted,
.timer-bar .typeahead input[type=text].proj-tinted,
.inline-project.proj-tinted option,
.ta-item.proj-tinted { color: hsl(var(--proj-h, 220), 65%, 38%); font-weight: 600; }
[data-theme="dark"] .inline-project.proj-tinted,
[data-theme="dark"] .timer-bar .typeahead input[type=text].proj-tinted,
[data-theme="dark"] .inline-project.proj-tinted option,
[data-theme="dark"] .ta-item.proj-tinted { color: hsl(var(--proj-h, 220), 70%, 72%); }

/* Dashboard "What's new" card — reuses .card / .badge / .muted / palette vars. */
.changelog .changelog-release + .changelog-release {
    margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.changelog-head { display: flex; align-items: baseline; gap: .6rem; margin: 0 0 .35rem; }
.changelog ul { margin: 0; padding-left: 1.2rem; display: grid; gap: .3rem; }

.report-meta { display: flex; align-items: baseline; gap: 1rem; margin: .25rem 0 1rem; }
.report-total { font-size: 1.2rem; }

/* bar chart — responsive flex columns that always fill the width (no scroll) */
.chart-card { padding: 1.25rem 1.25rem .5rem; }
.bar-chart2 { display: flex; gap: .5rem; }
.bc-yaxis { display: flex; flex-direction: column; justify-content: space-between; height: 220px;
    font-size: 10px; color: var(--muted); text-align: right; padding-right: .25rem; }
.bc-plot {
    flex: 1 1 auto; min-width: 0; display: flex; align-items: flex-end; gap: 4px;
    height: 220px; margin-bottom: 1.4rem; border-bottom: 1px solid var(--border);
    background-image: linear-gradient(to top, var(--border) 1px, transparent 1px);
    background-size: 100% 25%;
}
.bc-col { position: relative; flex: 1 1 0; min-width: 0; height: 100%;
    display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.bc-bar { width: 72%; max-width: 48px; min-height: 2px; background: var(--accent); opacity: .85; border-radius: 3px 3px 0 0; }
.bc-col:hover .bc-bar { opacity: 1; }
.bc-val { font-size: 10px; font-weight: 600; color: var(--text); margin-bottom: 3px; white-space: nowrap; }
.bc-x { position: absolute; top: 100%; margin-top: 4px; font-size: 10px; color: var(--muted); white-space: nowrap; }

/* tree + donut layout */
.summary-grid { display: grid; grid-template-columns: 1fr 280px; gap: 1.5rem; align-items: start; margin-top: 1.25rem; }
.summary-tree { min-width: 0; }
.tree-head, .tree-row { display: flex; align-items: center; gap: .5rem; }
.tree-head { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted);
    border-bottom: 1px solid var(--border); padding: .4rem .2rem; }
.tree-head .tree-hours, .tree-row .tree-hours { margin-left: auto; font-variant-numeric: tabular-nums; }
.tree-row { padding: .5rem .2rem; border-bottom: 1px solid var(--border); }
.tree-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Drill-down: clicking a node filters+regroups the summary. Keep the node's own
   colour (incl. project tint); show it's clickable on hover. */
a.tree-link { color: inherit; text-decoration: none; cursor: pointer; }
a.tree-link:hover, a.tree-link:focus-visible { text-decoration: underline; }
.tree-toggle { background: none; border: none; cursor: pointer; color: var(--muted); font-size: .9rem;
    width: 1.2rem; transition: transform .12s ease; }
.tree-node.open > .tree-row > .tree-toggle { transform: rotate(90deg); }
.tree-spacer { display: inline-block; width: 1.2rem; }
.tree-row .tree-hours { font-weight: 600; }

.summary-donut { display: flex; justify-content: center; }
.donut-total { fill: var(--text); font-size: 22px; font-weight: 700; }
.donut-slice:hover { opacity: .8; }

@media (max-width: 860px) {
    .summary-grid { grid-template-columns: 1fr; }
    .summary-donut { order: -1; }
    .report-bar .rb-apply { margin-left: 0; }
}

/* ===== Print / PDF — the Summary "Save as PDF" page (layout_print) ===== */
.pdf-page { background: #fff; }
.pdf-content { max-width: 1080px; margin: 0 auto; padding: 1.5rem 1.75rem; }
.pdf-head { margin-bottom: 1rem; }
.pdf-head h1 { margin: 0 0 .25rem; }
.pdf-meta { color: var(--muted); margin: 0; }
.pdf-actions { max-width: 1080px; margin: .5rem auto 2rem; padding: 0 1.75rem;
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
    .pdf-content { max-width: none; padding: 0; }
    /* Stack tree + donut so nothing is clipped at the page edge. */
    .summary-grid { display: block; }
    .summary-donut { margin-top: 1rem; }
    /* Keep charts / tree rows from splitting across a page break. */
    .chart-card, .summary-donut, .tree-row { break-inside: avoid; }
    a { color: inherit; text-decoration: none; }
    /* Force the chart/donut/tag colours to print (also needs the browser's
       "Background graphics" option enabled in the print dialog). */
    .bar-chart2, .bc-bar, .summary-donut, .donut-slice, .badge, .proj-name {
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
    @page { margin: 12mm; }
}
