/* Ruvique workspace stylesheet. Hand written, no framework. */

@font-face {
    font-family: "Fraunces";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/fraunces-latin-opsz-normal.woff2") format("woff2-variations"), url("../fonts/fraunces-latin-opsz-normal.woff2") format("woff2");
}
@font-face {
    font-family: "Fraunces";
    font-style: italic;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/fraunces-latin-opsz-italic.woff2") format("woff2-variations"), url("../fonts/fraunces-latin-opsz-italic.woff2") format("woff2");
}
@font-face {
    font-family: "Instrument Sans";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/instrument-sans-latin-wght-normal.woff2") format("woff2-variations"), url("../fonts/instrument-sans-latin-wght-normal.woff2") format("woff2");
}
@font-face {
    font-family: "Instrument Sans";
    font-style: italic;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/instrument-sans-latin-wght-italic.woff2") format("woff2-variations"), url("../fonts/instrument-sans-latin-wght-italic.woff2") format("woff2");
}

/* ---------- Tokens ---------- */
:root {
    /* Brand */
    --cream: #EEDFC7;
    --amber: #CE7F20;
    --olive: #607938;
    --brown: #533416;
    --paper: #FAF5EC;
    --white: #FFFFFF;
    --clay: #9B2C1A;              /* errors and destructive actions only */

    /* Tints made from the brand colours and white */
    --ink: var(--brown);
    --ink-muted: #6D5239;         /* brown 85% + white */
    --rule: #DCD2C5;              /* brown 18% on paper */
    --rule-strong: #B9A58F;       /* brown 40% on paper, decorative borders */
    --field-border: #8C7660;      /* brown 67% + white, form field borders (3:1 on white) */
    --cream-deep: #E2D1B9;        /* cream + brown 8% */
    --cream-soft: #F4EADA;        /* cream + white 50% */
    --amber-tint: #F7EADB;        /* amber 16% + white */
    --olive-tint: #E9ECE3;        /* olive 14% + white */
    --clay-tint: #F5EAE8;         /* clay 10% + white */
    --brown-tint: #EEE9E4;        /* brown 10% + white */

    --font-display: "Fraunces", Georgia, "Times New Roman", serif;
    --font-ui: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;

    --radius-lg: 22px;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-pill: 999px;
    --shadow: 0 1px 0 rgba(83, 52, 22, .06), 0 10px 30px -18px rgba(83, 52, 22, .35);
    --sidebar-w: 268px;
    --topbar-h: 68px;
    --gap: 24px;
    --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.55;
    font-feature-settings: "kern";
    -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.2; font-weight: 600; }
h1, .display { font-family: var(--font-display); font-weight: 560; font-variation-settings: "opsz" 96, "SOFT" 50; letter-spacing: -.01em; }
h2 { font-family: var(--font-display); font-weight: 560; font-size: 1.35rem; font-variation-settings: "opsz" 48; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 1em; }
small, .small { font-size: .85rem; }
.muted { color: var(--ink-muted); }
.num, td.num, .tabular { font-variant-numeric: tabular-nums lining-nums; }
hr { border: 0; border-top: 1px solid var(--rule); margin: var(--gap) 0; }
code, kbd { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .85em; }
kbd { border: 1px solid var(--rule-strong); border-bottom-width: 2px; border-radius: 6px; padding: 0 .4em; background: var(--white); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

:focus-visible {
    outline: 3px solid var(--brown);
    outline-offset: 2px;
    border-radius: 6px;
}
.skip-link {
    position: absolute; left: 12px; top: -60px; z-index: 100;
    background: var(--brown); color: var(--cream); padding: 10px 16px; border-radius: var(--radius-sm);
}
.skip-link:focus { top: 12px; }

/* ---------- Icons and brand mark ---------- */
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 24px; height: 24px; }
.wave-mark { display: inline-flex; align-items: center; gap: 3px; height: 26px; }
.wave-mark span { display: block; width: 4px; border-radius: 4px; background: var(--brown); }
.wave-mark span:nth-child(1) { height: 40%; background: var(--olive); }
.wave-mark span:nth-child(2) { height: 75%; }
.wave-mark span:nth-child(3) { height: 100%; background: var(--amber); }
.wave-mark span:nth-child(4) { height: 65%; }
.wave-mark span:nth-child(5) { height: 35%; background: var(--olive); }
.wave-mark.is-lg { height: 56px; gap: 6px; }
.wave-mark.is-lg span { width: 9px; border-radius: 9px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-name { font-family: var(--font-display); font-size: 1.45rem; font-weight: 600; letter-spacing: -.01em; font-variation-settings: "opsz" 72, "SOFT" 80; }

/* Loader: the wave bars breathe */
.loader { display: inline-flex; gap: 3px; align-items: center; height: 18px; vertical-align: middle; }
.loader span { width: 3px; height: 100%; border-radius: 3px; background: currentColor; animation: wave 1s var(--ease) infinite; }
.loader span:nth-child(2) { animation-delay: .1s; }
.loader span:nth-child(3) { animation-delay: .2s; }
.loader span:nth-child(4) { animation-delay: .3s; }
.loader span:nth-child(5) { animation-delay: .4s; }
@keyframes wave { 0%, 100% { transform: scaleY(.35); } 50% { transform: scaleY(1); } }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    background: var(--cream);
    border-right: 1px solid var(--rule-strong);
    padding: 22px 16px 28px;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    display: flex; flex-direction: column; gap: 18px;
}
.sidebar .brand { padding: 4px 10px 10px; }
.org-chip { margin: 0 10px; padding: 10px 12px; border: 1px solid var(--rule-strong); border-radius: var(--radius); background: var(--cream-soft); font-size: .85rem; }
.org-chip strong { display: block; font-size: .95rem; }
.nav-group h2 {
    font-family: var(--font-ui); font-size: .72rem; font-weight: 650; letter-spacing: .12em; text-transform: uppercase;
    color: var(--ink-muted); margin: 0 10px 6px;
}
.nav-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-link {
    display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 12px;
    text-decoration: none; color: var(--ink); font-weight: 520;
}
.nav-link:hover { background: var(--cream-deep); }
.nav-link[aria-current="page"] { background: var(--brown); color: var(--cream); }
.nav-link[aria-current="page"] .icon { color: var(--cream); }
.sidebar-foot { margin-top: auto; padding: 0 10px; font-size: .8rem; color: var(--ink-muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 16px; min-height: var(--topbar-h);
    padding: 12px clamp(16px, 3vw, 40px);
    background: rgba(250, 245, 236, .94);
    border-bottom: 1px solid var(--rule);
    backdrop-filter: blur(6px);
}
.menu-toggle { display: none; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .88rem; color: var(--ink-muted); min-width: 0; }
.breadcrumb ol { display: contents; list-style: none; }
.breadcrumb li { display: inline-flex; align-items: center; gap: 6px; }
.breadcrumb li + li::before { content: "/"; color: var(--rule-strong); }
.breadcrumb a { color: var(--ink-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--ink); text-decoration: underline; }
.breadcrumb [aria-current] { color: var(--ink); font-weight: 600; }
.global-search { margin-left: auto; position: relative; width: min(420px, 40vw); }
.global-search input { padding-left: 40px; border-radius: var(--radius-pill); background: var(--white); }
.global-search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-muted); pointer-events: none; }
.user-menu { position: relative; }
.user-menu > summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
    padding: 4px 10px 4px 4px; border-radius: var(--radius-pill); border: 1px solid var(--rule);
    background: var(--white);
}
.user-menu > summary::-webkit-details-marker { display: none; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
    background: var(--olive); color: var(--white); font-weight: 650; font-size: .8rem;
}
.user-menu .menu {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; z-index: 30;
    background: var(--white); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 8px;
}
.menu a, .menu button {
    display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px;
    text-decoration: none; color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer; text-align: left;
}
.menu a:hover, .menu button:hover { background: var(--cream-soft); }
.menu .menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--rule); margin-bottom: 6px; }

.content { padding: clamp(18px, 3vw, 40px); max-width: 1320px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.page-head h1 { font-size: clamp(1.9rem, 3vw, 2.6rem); margin: 0; }
.page-head .lede { margin: 6px 0 0; color: var(--ink-muted); max-width: 64ch; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 10px; }
.eyebrow { font-size: .74rem; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-muted); margin: 0 0 6px; }

.drawer-backdrop { display: none; }

/* ---------- Cards and grids ---------- */
.card {
    background: var(--white); border: 1px solid var(--rule); border-radius: var(--radius-lg);
    padding: clamp(18px, 2.2vw, 26px); box-shadow: var(--shadow); min-width: 0;
}
.card + .card { margin-top: var(--gap); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 1.2rem; }
.card.is-cream { background: var(--cream-soft); }
.card.is-flat { box-shadow: none; }
.grid { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); gap: var(--gap); align-items: start; }
.stack { display: grid; gap: var(--gap); }
.stack-sm { display: grid; gap: 12px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.row-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }

/* Stat tiles */
.stat { padding: 20px 22px; border-radius: var(--radius-lg); background: var(--white); border: 1px solid var(--rule); }
.stat .label { font-size: .82rem; color: var(--ink-muted); font-weight: 560; display: flex; align-items: center; gap: 8px; }
.stat .value { font-family: var(--font-display); font-size: 2.2rem; font-weight: 560; line-height: 1.1; margin-top: 8px; font-variant-numeric: tabular-nums lining-nums; }
.stat .delta { margin-top: 6px; font-size: .84rem; display: inline-flex; align-items: center; gap: 6px; }
.stat.is-accent { background: var(--brown); color: var(--cream); border-color: var(--brown); }
.stat.is-accent .label, .stat.is-accent .delta { color: var(--cream); }

/* ---------- Buttons ---------- */
.btn {
    --btn-bg: var(--brown); --btn-fg: var(--cream); --btn-border: var(--brown);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 42px; padding: 9px 18px; border-radius: var(--radius-pill);
    background: var(--btn-bg); color: var(--btn-fg); border: 1.5px solid var(--btn-border);
    font: inherit; font-weight: 600; font-size: .92rem; text-decoration: none; cursor: pointer; white-space: nowrap;
    transition: background-color .15s var(--ease), transform .15s var(--ease);
}
.btn:hover { background: #3F2710; border-color: #3F2710; }
.btn:active { transform: translateY(1px); }
.btn-secondary { --btn-bg: transparent; --btn-fg: var(--brown); --btn-border: var(--brown); }
.btn-secondary:hover { background: var(--cream-soft); border-color: var(--brown); }
.btn-quiet { --btn-bg: transparent; --btn-fg: var(--brown); --btn-border: transparent; }
.btn-quiet:hover { background: var(--cream-soft); border-color: transparent; }
.btn-danger { --btn-bg: var(--clay); --btn-fg: var(--white); --btn-border: var(--clay); }
.btn-danger:hover { background: #7E2314; border-color: #7E2314; }
.btn-danger-outline { --btn-bg: transparent; --btn-fg: var(--clay); --btn-border: var(--clay); }
.btn-danger-outline:hover { background: var(--clay-tint); border-color: var(--clay); }
.btn-sm { min-height: 34px; padding: 5px 13px; font-size: .85rem; }
.btn-icon { width: 42px; padding: 0; }
.btn-icon.btn-sm { width: 34px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 18px; min-width: 0; }
.field > label, .label { font-weight: 600; font-size: .9rem; }
.hint { font-size: .84rem; color: var(--ink-muted); margin: 0; }
.error-text { font-size: .86rem; color: var(--clay); display: flex; gap: 6px; align-items: center; margin: 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], input[type="date"], input[type="datetime-local"], input[type="file"], select, textarea {
    width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 12px;
    border: 1.5px solid var(--field-border); background: var(--white); color: var(--ink);
    font: inherit; font-size: .95rem;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23533416' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }
select[multiple] { background-image: none; padding-right: 14px; min-height: 130px; }
input:hover, select:hover, textarea:hover { border-color: var(--brown); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--brown); outline-offset: 1px; border-color: var(--brown); }
[aria-invalid="true"] { border-color: var(--clay) !important; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; accent-color: var(--brown); margin: 0; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; }
.checklist { display: grid; gap: 8px; max-height: 240px; overflow: auto; padding: 12px; border: 1.5px solid var(--field-border); border-radius: 12px; background: var(--white); }
.dropzone {
    border: 2px dashed var(--rule-strong); border-radius: var(--radius-lg); padding: 30px; text-align: center;
    background: var(--cream-soft); display: grid; gap: 10px; justify-items: center;
}
.dropzone.is-over { border-color: var(--brown); background: var(--amber-tint); }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.file-list li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 12px; background: var(--white); font-size: .9rem; }

/* Filters bar */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; }
.filters .field { margin: 0; }
.filters .field > label { font-size: .8rem; color: var(--ink-muted); }
.filters-actions { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th {
    text-align: left; font-weight: 650; font-size: .76rem; letter-spacing: .08em; text-transform: uppercase;
    color: var(--ink-muted); padding: 10px 12px; border-bottom: 1.5px solid var(--brown); white-space: nowrap;
}
.table td { padding: 13px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table tbody tr:hover { background: var(--paper); }
.table .num { text-align: right; }
.table .title-cell a { font-weight: 600; text-decoration: none; }
.table .title-cell a:hover { text-decoration: underline; }
.table .sub { display: block; font-size: .82rem; color: var(--ink-muted); }
.table .actions-cell { text-align: right; white-space: nowrap; }
.table tfoot td { font-weight: 650; border-top: 1.5px solid var(--brown); border-bottom: 0; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: var(--radius-pill);
    font-size: .8rem; font-weight: 600; color: var(--ink); background: var(--white); border: 1px solid var(--rule-strong);
    white-space: nowrap; line-height: 1.5;
}
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-muted); flex: none; }
.badge .icon { width: 14px; height: 14px; }
.badge.tone-olive { background: var(--olive-tint); border-color: #C5CEB4; }
.badge.tone-olive .dot { background: var(--olive); }
.badge.tone-amber { background: var(--amber-tint); border-color: #EBCCA5; }
.badge.tone-amber .dot { background: var(--amber); }
.badge.tone-clay { background: var(--clay-tint); border-color: #DDB6AF; }
.badge.tone-clay .dot { background: var(--clay); }
.badge.tone-brown { background: var(--brown-tint); }
.badge.tone-brown .dot { background: var(--brown); }
.badge.tone-solid-olive { background: var(--olive); color: var(--white); border-color: var(--olive); }
.badge.tone-solid-olive .dot { background: var(--white); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--radius-pill); border: 1px solid var(--rule-strong); font-size: .82rem; background: var(--paper); color: var(--ink); text-decoration: none; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Alerts, toasts, empty states ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--rule-strong); background: var(--cream-soft); margin-bottom: var(--gap); }
.alert .icon { margin-top: 2px; }
.alert p { margin: 0; }
.alert.is-error { background: var(--clay-tint); border-color: #DDB6AF; }
.alert.is-error .icon { color: var(--clay); }
.alert.is-success { background: var(--olive-tint); border-color: #C5CEB4; }
.alert.is-warning { background: var(--amber-tint); border-color: #EBCCA5; }
.link-box { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.link-box input { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: grid; gap: 10px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
    display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius);
    background: var(--brown); color: var(--cream); box-shadow: var(--shadow);
    animation: toast-in .25s var(--ease);
}
.toast .icon { color: var(--cream); margin-top: 2px; }
.toast.is-error { background: var(--clay); color: var(--white); }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; padding: 2px; border-radius: 6px; }
.toast button:focus-visible { outline-color: var(--cream); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.empty { text-align: center; padding: 48px 20px; display: grid; justify-items: center; gap: 10px; }
.empty .wave-mark { margin-bottom: 6px; opacity: .9; }
.empty h3 { font-family: var(--font-display); font-size: 1.3rem; font-weight: 560; margin: 0; }
.empty p { color: var(--ink-muted); max-width: 46ch; margin: 0; }

/* ---------- Dialog ---------- */
dialog.confirm {
    border: 1px solid var(--rule); border-radius: var(--radius-lg); padding: 26px; width: min(460px, calc(100vw - 32px));
    background: var(--white); color: var(--ink); box-shadow: 0 30px 60px -20px rgba(83, 52, 22, .45);
}
dialog.confirm::backdrop { background: rgba(83, 52, 22, .38); }
dialog.confirm h2 { display: flex; gap: 10px; align-items: center; }
dialog.confirm .icon { color: var(--clay); }

/* ---------- Tabs and pagination ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; border-bottom: 2.5px solid transparent; font-weight: 560; white-space: nowrap; }
.tabs a[aria-current="page"] { border-color: var(--brown); }
.pagination { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: space-between; margin-top: 18px; font-size: .9rem; }
.pagination ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.pagination a, .pagination span.page { display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--rule); text-decoration: none; background: var(--white); }
.pagination span.page[aria-current="page"] { background: var(--brown); color: var(--cream); border-color: var(--brown); }

/* ---------- Detail lists ---------- */
.dl { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 8px 16px; margin: 0; font-size: .92rem; }
.dl dt { color: var(--ink-muted); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.access-note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); background: var(--cream-soft); border: 1px solid var(--rule); font-size: .88rem; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; font-size: .88rem; }
.timeline li { display: grid; grid-template-columns: 10px 1fr; gap: 12px; }
.timeline li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--cream-deep); border: 2px solid var(--brown); margin-top: 5px; }

/* ---------- Audio player ---------- */
.player { background: var(--brown); color: var(--cream); border-radius: var(--radius-lg); padding: 20px 22px; display: grid; gap: 14px; }
.player .row { gap: 12px; }
.player-btn {
    display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
    background: transparent; color: var(--cream); border: 1.5px solid rgba(238, 223, 199, .55); cursor: pointer; font: inherit;
}
.player-btn:hover { background: rgba(238, 223, 199, .12); }
.player-btn.is-main { width: 56px; height: 56px; background: var(--cream); color: var(--brown); border-color: var(--cream); }
.player-btn:focus-visible { outline-color: var(--cream); }
.player .time { font-variant-numeric: tabular-nums; font-size: .92rem; min-width: 96px; }
.player select { width: auto; min-height: 38px; background-color: transparent; color: var(--cream); border-color: rgba(238, 223, 199, .55); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23EEDFC7' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); }
.player select option { color: var(--brown); background: var(--white); }
.player select:focus-visible { outline-color: var(--cream); }
.seek { width: 100%; accent-color: var(--amber); height: 28px; cursor: pointer; }
.seek:focus-visible { outline-color: var(--cream); }
.player-wave { display: flex; align-items: center; gap: 3px; height: 36px; overflow: hidden; }
.player-wave span { flex: 1; min-width: 2px; border-radius: 3px; background: rgba(238, 223, 199, .35); }
.player-wave span.is-played { background: var(--amber); }
.player .shortcuts { font-size: .8rem; color: var(--cream); opacity: .92; }
.player .shortcuts kbd { background: transparent; color: var(--cream); border-color: rgba(238, 223, 199, .55); }

/* ---------- Transcript ---------- */
.transcript { display: grid; gap: 4px; max-height: 70vh; overflow-y: auto; padding-right: 4px; }
.segment { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 12px; padding: 10px 12px; border-radius: var(--radius); border: 1px solid transparent; }
.segment:hover { background: var(--paper); }
.segment.is-current { background: var(--amber-tint); border-color: #EBCCA5; }
.segment .seek-btn { background: none; border: 0; padding: 0; text-align: left; font: inherit; color: var(--ink); cursor: pointer; font-variant-numeric: tabular-nums; font-size: .85rem; }
.segment .seek-btn:disabled { cursor: default; color: var(--ink-muted); }
.segment .speaker { font-weight: 650; font-size: .86rem; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.segment .text { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.segment textarea { min-height: 80px; margin-top: 6px; }
.segment .seg-tools { display: flex; gap: 4px; align-items: start; }
.save-state { font-size: .82rem; color: var(--ink-muted); display: inline-flex; gap: 6px; align-items: center; }
.save-state.is-saved { color: var(--olive); }

/* ---------- Charts (server rendered SVG) ---------- */
.chart { width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--ink); font-family: var(--font-ui); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .axis { stroke: var(--rule-strong); stroke-width: 1; }
.chart .grid-line { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .line { fill: none; stroke: var(--brown); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.is-prev { stroke: var(--amber); stroke-dasharray: 6 5; stroke-width: 2; }
.chart .area { fill: var(--amber-tint); }
.chart .pt { fill: var(--white); stroke: var(--brown); stroke-width: 2; }
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 34%) 1fr auto; gap: 12px; align-items: center; font-size: .9rem; }
.hbar .track { height: 12px; background: var(--cream-soft); border-radius: 12px; overflow: hidden; border: 1px solid var(--rule); }
.hbar .fill { height: 100%; border-radius: 12px; background: var(--brown); }
.hbar .fill.tone-olive { background: var(--olive); }
.hbar .fill.tone-amber { background: var(--amber); }
.hbar .fill.tone-clay { background: var(--clay); }
.hbar .val { font-variant-numeric: tabular-nums; min-width: 92px; text-align: right; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .84rem; margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 18px; height: 3px; border-radius: 2px; background: var(--brown); display: inline-block; }
.legend i.is-prev { background: var(--amber); }
.pipeline { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.pipeline .step { border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px; background: var(--paper); }
.pipeline .step .value { font-family: var(--font-display); font-size: 1.7rem; font-variant-numeric: tabular-nums; }
details.data-table summary { cursor: pointer; font-size: .86rem; color: var(--ink-muted); margin-top: 12px; }

/* Search results */
.result { padding: 14px 0; border-bottom: 1px solid var(--rule); }
.result:last-child { border-bottom: 0; }
.result mark { background: var(--amber-tint); color: var(--ink); border-radius: 3px; padding: 0 2px; outline: 1px solid #EBCCA5; }

/* Auth pages */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-art { background: var(--brown); color: var(--cream); padding: clamp(28px, 5vw, 64px); display: flex; flex-direction: column; justify-content: space-between; gap: 32px; position: relative; overflow: hidden; }
.auth-art .brand-name { color: var(--cream); }
.auth-art .wave-mark span { background: var(--cream); }
.auth-art .wave-mark span:nth-child(3) { background: var(--amber); }
.auth-art h1 { font-size: clamp(2rem, 4vw, 3.2rem); max-width: 14ch; }
.auth-art p { max-width: 42ch; }
.auth-bars { display: flex; align-items: flex-end; gap: 8px; height: 140px; }
.auth-bars span { flex: 1; border-radius: 8px 8px 0 0; background: rgba(238, 223, 199, .22); }
.auth-bars span:nth-child(3n) { background: rgba(206, 127, 32, .75); }
.auth-form { display: grid; place-items: center; padding: clamp(24px, 5vw, 64px); }
.auth-form .card { width: min(440px, 100%); }

/* Print helpers */
.print-only { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
    .app { grid-template-columns: minmax(0, 1fr); }
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; width: min(300px, 86vw);
        transform: translateX(-105%); transition: transform .25s var(--ease); box-shadow: var(--shadow);
        visibility: hidden;
    }
    body.drawer-open .sidebar { transform: none; visibility: visible; }
    body.drawer-open .drawer-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(83, 52, 22, .38); }
    .menu-toggle { display: inline-flex; }
    .global-search { width: auto; flex: 1; }
    .grid-3 { grid-template-columns: minmax(0, 1fr); }
    .pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .auth { grid-template-columns: minmax(0, 1fr); }
    .auth-art { min-height: auto; }
    .auth-bars { height: 60px; }
}
@media (max-width: 720px) {
    body { font-size: 15px; }
    .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
    .topbar .breadcrumb { order: 3; width: 100%; }
    .content { padding: 18px 16px 40px; }
    .grid-2, .grid-4, .form-grid { grid-template-columns: minmax(0, 1fr); }
    .user-menu .user-name { display: none; }
    .page-head { align-items: flex-start; }
    .dl { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
    .dl dd { margin-bottom: 8px; }
    .hbar { grid-template-columns: minmax(0, 1fr) auto; }
    .hbar .track { grid-column: 1 / -1; grid-row: 2; }
    .segment { grid-template-columns: minmax(0, 1fr) auto; }
    .segment .seek-btn { grid-column: 1 / -1; }
    .chart text { font-size: 24px; }

    /* Tables become stacked cards */
    table.table.stack-mobile thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    table.table.stack-mobile, .table.stack-mobile tbody, .table.stack-mobile tr, .table.stack-mobile td { display: block; width: 100%; }
    .table.stack-mobile tr { border: 1px solid var(--rule); border-radius: var(--radius); padding: 8px 14px; margin-bottom: 12px; background: var(--white); }
    .table.stack-mobile td { border: 0; padding: 6px 0; display: grid; grid-template-columns: 40% minmax(0, 1fr); gap: 10px; text-align: left; }
    .table.stack-mobile td::before { content: attr(data-label); font-size: .76rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); }
    .table.stack-mobile td.num, .table.stack-mobile .actions-cell { text-align: left; }
    .table.stack-mobile td[data-label=""]::before { content: none; }
    .table.stack-mobile td[data-label=""] { display: block; }
    .table.stack-mobile tfoot tr { background: var(--cream-soft); }
    .global-search { order: 2; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

@media print {
    .sidebar, .topbar, .toasts, .no-print, .skip-link { display: none !important; }
    .app { display: block; }
    body { background: var(--white); }
    .card { box-shadow: none; border-color: var(--rule-strong); break-inside: avoid; }
    .print-only { display: block; }
    a { text-decoration: none; }
}

/* ---------- Brand images and Google sign in ---------- */
.brand-logo { height: 44px; width: auto; }
.sidebar .brand { padding: 2px 8px 8px; }
.brand-mark { width: 56px; height: 56px; }
.or-rule { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--ink-muted); font-size: .85rem; }
.or-rule::before, .or-rule::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }
.btn-google { --btn-bg: var(--white); --btn-fg: var(--brown); --btn-border: var(--field-border); width: 100%; gap: 12px; }
.btn-google:hover { background: var(--cream-soft); border-color: var(--brown); }
.btn-google svg { width: 20px; height: 20px; flex: none; }
.btn-google[aria-busy="true"] { opacity: .7; cursor: progress; }

/* ---------- Specificity fixes ---------- */
[hidden] { display: none !important; }
.btn.menu-toggle { display: none; }
.global-search input[type="search"] { padding-left: 40px; }
@media (max-width: 960px) {
    .btn.menu-toggle { display: inline-flex; }
}

/* ---------- Compact sidebar on short screens (laptops, browser zoom) ---------- */
@media (max-height: 900px) and (min-width: 961px) {
    .sidebar { padding: 16px 14px 18px; gap: 12px; }
    .sidebar .brand { padding: 0 8px 4px; }
    .sidebar .brand-logo { height: 38px; }
    .org-chip { padding: 8px 12px; }
    .nav-group h2 { margin-bottom: 4px; }
    .nav-link { padding: 7px 12px; }
    .sidebar-foot { display: none; }
}
.sidebar { scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent; overscroll-behavior: contain; }

/* ---------- Responsive fixes found by the device checks ---------- */
/* Hidden screen reader labels inside wide tables must stay inside the scrolling wrapper. */
.table-wrap { position: relative; }
/* Status pipeline: as many columns as fit, badges may wrap. */
.pipeline { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }
.pipeline .badge { white-space: normal; text-align: left; }
@media (max-width: 400px) {
    .pipeline { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .pipeline .step { padding: 10px; }
}
