/* WordTenance Cloud: self-hosted, no third-party assets (constitution VI). App shell with a left sidebar (spec 007). */
:root {
    --canvas: #eceef4; --bg: #f6f7fb; --surface: #ffffff; --fg: #17181c; --muted: #575c69; --border: #e2e4eb;
    --accent: #bf400b; --dark: #17181c; --on-dark: #ffffff; --error: #b91c1c;
    --tint-rose: #fbe8ec; --tint-violet: #ecebfb; --tint-blue: #e5eefc; --tint-mint: #e2f4ec;
    --solid-blue: #2563eb; --solid-violet: #7c3aed; --solid-rose: #e11d48; --solid-mint: #059669;
    --tone-blue: #1d4ed8; --tone-violet: #6d28d9; --tone-rose: #be123c; --tone-mint: #047857;
    --shadow: 0 1px 2px rgba(23, 24, 28, .05), 0 2px 8px rgba(23, 24, 28, .06);
    --radius: 14px; --radius-sm: 10px;
    color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
    :root {
        --canvas: #0f1013; --bg: #15161a; --surface: #1d1f25; --fg: #f2f3f6; --muted: #b3b8c4; --border: #2e313a;
        --accent: #fb923c; --dark: #f2f3f6; --on-dark: #15161a; --error: #fca5a5;
        --tint-rose: #3a2329; --tint-violet: #2b2a45; --tint-blue: #1f2c44; --tint-mint: #1d3329;
        --tone-blue: #93c5fd; --tone-violet: #c4b5fd; --tone-rose: #fda4af; --tone-mint: #6ee7b7;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--fg); font: 1rem/1.6 system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; }
a { color: inherit; }
.skip-link { position: absolute; left: -999px; z-index: 10; } .skip-link:focus { left: 1rem; top: 1rem; background: var(--surface); padding: .5rem; }
.icon { width: 1.15rem; height: 1.15rem; flex: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* App shell: sidebar + workspace. */
.app { display: grid; grid-template-columns: 16.5rem minmax(0, 1fr); min-height: 100vh; max-width: 100rem; margin: 0 auto; background: var(--bg); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 1.25rem 1rem 1rem; border-right: 1px solid var(--border); }
.sidebar__top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: 0 .5rem 1.25rem; }
.sidebar__body { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; }
.sidebar__toggle { display: none; }
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.05rem; color: var(--fg); text-decoration: none; min-height: 44px; }
.brand__mark { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 9px; background: var(--dark); color: var(--on-dark); font-size: 1rem; }
.brand__logo { display: block; max-height: 2.5rem; max-width: 12rem; width: auto; }
.nav__label { margin: 1rem .75rem .35rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: .8rem; font-weight: 600; color: var(--muted); }
.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: .15rem; }
.nav a { display: flex; align-items: center; gap: .7rem; min-height: 42px; padding: .45rem .75rem; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500; text-decoration: none; }
.nav a:hover { color: var(--fg); background: rgba(127, 127, 140, .08); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--fg); font-weight: 600; box-shadow: var(--shadow); }
.nav a[aria-current="page"] .icon { color: var(--accent); }
.user-card { display: flex; align-items: center; gap: .65rem; margin-top: auto; padding: 1rem .5rem 0; border-top: 1px solid var(--border); }
.user-card__text { display: grid; min-width: 0; font-size: .875rem; line-height: 1.35; }
.user-card__text strong, .user-card__text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card form { margin-left: auto; }
.avatar { display: grid; place-items: center; flex: none; width: 2.4rem; height: 2.4rem; border-radius: 50%; background: var(--tint-violet); color: var(--fg); font-weight: 700; font-size: .875rem; }
.icon-button { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg); }
.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 1.5rem 2rem .5rem; }
.topbar__greeting { margin: 0; font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
.container { width: 100%; max-width: 72rem; padding: 1rem 2rem 3rem; }

/* Guest pages (sign in): a centred card. */
.guest { min-height: 100vh; display: grid; place-content: center; gap: 1.5rem; padding: 2rem 1rem; }
.guest__brand { justify-self: center; }
.guest__card { width: min(28rem, calc(100vw - 2rem)); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; }
.guest__card .stack { max-width: none; }

/* Surfaces. */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.5rem; margin: 1rem 0; box-shadow: var(--shadow); }
.notice { padding: .75rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.notice p { margin: .25rem 0; }
.notice--error { border-color: var(--error); color: var(--error); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1rem; margin: 0 0 1.5rem; }
/* Stat cards: white card, solid icon square with the label, big figure with a note in the card's colour, optional ring. */
.tile { --solid: var(--solid-blue); --tone: var(--tone-blue); display: grid; align-content: space-between; gap: .9rem; height: 100%; padding: 1rem 1.1rem 1.1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); color: var(--fg); text-decoration: none; }
.tile--violet { --solid: var(--solid-violet); --tone: var(--tone-violet); } .tile--rose { --solid: var(--solid-rose); --tone: var(--tone-rose); } .tile--mint { --solid: var(--solid-mint); --tone: var(--tone-mint); }
.tile__head { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.tile__icon { display: grid; place-items: center; flex: none; width: 2rem; height: 2rem; border-radius: 8px; background: var(--solid); color: #fff; }
.tile__icon .icon { width: 1.1rem; height: 1.1rem; }
.tile__label { font-size: .875rem; font-weight: 600; }
.tile__body { display: flex; align-items: flex-end; justify-content: space-between; gap: .75rem; }
.tile__main { display: grid; gap: .15rem; min-width: 0; }
.tile__value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; letter-spacing: -.01em; }
.tile__note { font-size: .78rem; font-weight: 600; color: var(--tone); }
.tile__ring { display: grid; place-items: center; flex: none; width: 2.9rem; height: 2.9rem; border-radius: 50%; background: radial-gradient(closest-side, var(--surface) 76%, transparent 78%), conic-gradient(var(--solid) calc(var(--p) * 1%), var(--border) 0); font-size: .7rem; font-weight: 600; color: var(--muted); }
a.tile:hover { border-color: var(--solid); } a.tile:hover .tile__value { text-decoration: underline; }
.facts, .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .75rem; margin: 0; }
.facts dt, .stats dt { color: var(--muted); font-size: .875rem; } .facts dd, .stats dd { margin: 0; font-weight: 600; }
.stats dd { font-size: 1.75rem; }
.stats--compact { grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); }
.ledger__hours { font-weight: 600; } .ledger__hours--in { color: var(--tone-mint); }
.tiles--five { grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); }
.ledger { min-width: 40rem; } .ledger__date { white-space: nowrap; }
.list { padding-left: 1.2rem; }
.data-list { padding-left: 1.2rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.contract { border-top: 1px solid var(--border); padding-top: .5rem; }
.contract details { margin-bottom: .5rem; }
.subnav { margin: 0 0 1rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border); }

/* Tables: inside a white panel. */
.table-wrap { position: relative; max-width: 100%; overflow-x: auto; margin: .5rem 0 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); } /* Contains the absolutely positioned visually-hidden labels. */
.card .table-wrap { box-shadow: none; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .85rem; font-weight: 600; color: var(--muted); background: var(--bg); }
tbody tr:last-child td { border-bottom: 0; }

/* Forms and buttons. */
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem; max-width: 26rem; }
.stack--wide { max-width: 40rem; }
.stack select, .stack input { width: 100%; }
input, select, textarea { font: inherit; padding: .6rem .75rem; border: 1px solid #8a8f9c; border-radius: var(--radius-sm); background: var(--surface); color: inherit; max-width: 100%; }
input, select { min-height: 44px; }
textarea { width: 100%; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.inline-form input { flex: 1 1 10rem; min-width: 0; }
.check { display: flex; gap: .5rem; align-items: center; min-height: 44px; }
.check input { min-height: auto; width: 1.25rem; height: 1.25rem; flex: none; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem 1rem; margin: 0; min-width: 0; }
button, a.button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; font: inherit; font-weight: 600; padding: .6rem 1.1rem; border: 0; border-radius: var(--radius-sm); background: var(--accent); color: #fff; cursor: pointer; min-height: 44px; text-decoration: none; }
.button--secondary, a.button.button--secondary { background: var(--surface); color: var(--fg); border: 1px solid var(--border); }
a.button.button--dark { background: var(--dark); color: var(--on-dark); border-radius: 999px; padding-inline: 1.2rem; }
.link-button { background: none; color: var(--fg); text-decoration: underline; padding: .5rem; }
@media (prefers-color-scheme: dark) { a.button:not(.button--secondary):not(.button--dark), button:not(.button--secondary):not(.link-button):not(.icon-button) { color: #1c1917; } }
code { overflow-wrap: anywhere; }
.key summary { cursor: pointer; padding: .4rem 0; }
pre.code { overflow-x: auto; padding: .75rem; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .875rem; background: var(--surface); }

/* Badges. */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; border: 1px solid currentColor; font-size: .8rem; font-weight: 500; background: var(--surface); }
.badge--active, .badge--processed, .badge--delivered, .badge--good { color: #166534; } .badge--grace, .badge--pending, .badge--recommended { color: #92400e; }
.badge--expired, .badge--revoked, .badge--failed, .badge--critical { color: var(--error); }
.badge--open, .badge--in_progress { color: #1e40af; } .badge--waiting { color: #92400e; } .badge--resolved { color: #166534; } .badge--closed { color: var(--muted); }
@media (prefers-color-scheme: dark) {
    .badge--active, .badge--processed, .badge--delivered, .badge--good, .badge--resolved { color: #86efac; }
    .badge--grace, .badge--pending, .badge--recommended, .badge--waiting { color: #fcd34d; }
    .badge--open, .badge--in_progress { color: #93c5fd; }
}

/* Requests. */
.messages { list-style: none; padding: 0; margin: 0 0 1.5rem; display: grid; gap: .75rem; }
.message { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1.1rem; overflow-wrap: anywhere; }
.message--staff { border-left: 4px solid var(--accent); }
.message--internal { border-style: dashed; border-left: 4px dashed var(--muted); }
.message__meta { margin: 0 0 .25rem; }
.message__body { white-space: normal; }

/* Small screens: the sidebar becomes a top bar with a menu button (app.js); without JavaScript the menu stays open. */
@media (max-width: 56rem) {
    .app { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: static; height: auto; padding: .75rem 1rem; }
    .sidebar__top { padding: 0; }
    .sidebar__toggle { display: inline-grid; }
    .js .sidebar__body { display: none; }
    .js .sidebar__body.is-open { display: flex; padding-top: .75rem; }
    .topbar { padding: 1rem 1rem .25rem; }
    .topbar__greeting { font-size: 1.25rem; }
    .container { padding: .75rem 1rem 2.5rem; }
    .card { padding: 1rem; }
}
@media (prefers-reduced-motion: no-preference) { .nav a, .tile { transition: background-color .15s ease, color .15s ease, border-color .15s ease; } }
.tiles { list-style: none; padding: 0; }
.icon-button.sidebar__toggle { display: none; }
.brand__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .brand { min-width: 0; }
nav > .nav__label:first-child { margin-top: .25rem; padding-top: 0; border-top: 0; }
.card .stats dd { font-size: 1.25rem; }
@media (max-width: 56rem) { .icon-button.sidebar__toggle { display: inline-grid; } }
/* Users screen: role filters like WordPress; the switched-user banner. */
.filters ul { display: flex; flex-wrap: wrap; gap: .25rem .5rem; list-style: none; margin: 0 0 1rem; padding: 0; }
.filters a { display: inline-flex; align-items: center; min-height: 44px; padding: .25rem .75rem; border-radius: 999px; color: var(--muted); text-decoration: none; }
.filters a[aria-current="page"] { background: var(--surface); color: var(--fg); font-weight: 600; box-shadow: var(--shadow); }
.filters .count { margin-left: .25rem; font-weight: 400; }
.switched { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin: 1rem 2rem 0; padding: .75rem 1rem; border-radius: var(--radius); background: var(--tint-rose); }
.switched p { margin: 0; }
button.button--dark { background: var(--dark); color: var(--on-dark); border-radius: 999px; }
@media (max-width: 56rem) { .switched { margin: .75rem 1rem 0; } }
td form button { white-space: nowrap; }
/* Sidebar: the navigation scrolls, the account menu stays pinned to the bottom. */
.sidebar__body > nav { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -.25rem; padding: 0 .25rem .5rem; }
.user-menu { position: relative; flex: none; margin-top: .75rem; }
.user-menu > summary { list-style: none; }
.user-menu > summary::-webkit-details-marker { display: none; }
summary.user-card { display: flex; align-items: center; gap: .65rem; margin: 0; padding: .6rem .65rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); cursor: pointer; }
summary.user-card:hover { border-color: #b9bdc8; }
.user-card__role { font-size: .8rem; font-weight: 600; color: var(--muted); }
.user-card__chevron { margin-left: auto; color: var(--muted); }
.user-menu__panel { position: absolute; left: 0; right: 0; bottom: calc(100% + .5rem); z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(23, 24, 28, .16); overflow: hidden; }
.user-menu__head { display: grid; gap: .15rem; padding: .85rem 1rem; border-bottom: 1px solid var(--border); font-size: .875rem; overflow-wrap: anywhere; }
.chip { justify-self: start; margin-top: .35rem; padding: .1rem .5rem; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); font-size: .75rem; font-weight: 600; color: var(--muted); }
.user-menu__links { list-style: none; margin: 0; padding: .35rem; border-bottom: 1px solid var(--border); }
.user-menu__links a, .user-menu__action { display: flex; align-items: center; gap: .6rem; width: 100%; min-height: 40px; padding: .4rem .65rem; border: 0; border-radius: 8px; background: none; color: var(--fg); font: inherit; font-size: .9rem; font-weight: 500; text-decoration: none; justify-content: flex-start; }
.user-menu__links a:hover, .user-menu__action:hover { background: var(--bg); }
.user-menu__links a[aria-current="page"] { font-weight: 600; }
.user-menu__row { padding: .35rem; }
.user-menu__row + .user-menu__row { padding-top: 0; }
button.user-menu__action { color: var(--fg); }
button.user-menu__action--danger { color: var(--error); }
@media (prefers-color-scheme: dark) { button.user-menu__action { color: var(--fg); } button.user-menu__action--danger { color: var(--error); } .user-menu__panel { box-shadow: 0 8px 28px rgba(0, 0, 0, .5); } }
@media (max-width: 56rem) { .sidebar__body > nav { overflow: visible; } .user-menu__panel { position: static; margin-bottom: .5rem; } .user-menu[open] { display: flex; flex-direction: column-reverse; } }
/* Compact type, like the reference: 14 px base. */
body { font-size: .875rem; line-height: 1.55; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.05rem; } h3 { font-size: .95rem; }
.topbar__greeting { font-size: 1.25rem; }
.brand { font-size: .95rem; }
.nav a { min-height: 38px; padding: .4rem .7rem; }
.tile__value { font-size: 1.5rem; }
.tile { padding: .85rem 1rem 1rem; }
th { font-size: .8rem; } th, td { padding: .65rem .9rem; }
input, select, textarea { padding: .5rem .7rem; }
input, select, button, a.button { min-height: 40px; }
.badge { font-size: .75rem; }
.icon { width: 1.05rem; height: 1.05rem; }

/* No sideways scroll in the sidebar: only the link list scrolls (vertically); the account menu is never clipped. */
.sidebar__body { overflow: visible; }
.sidebar__body > nav { overflow-x: hidden; }
.user-card__text { min-width: 0; }

/* Collapse to icons (wide screens): the arrow at the top left of the top bar. */
.topbar__start { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.topbar__collapse { width: 36px; height: 36px; min-height: 36px; border-radius: 10px; }
.app { transition: grid-template-columns .2s ease; }
.app.is-collapsed { grid-template-columns: 4.75rem minmax(0, 1fr); }
.is-collapsed .sidebar { padding-inline: .75rem; }
.is-collapsed .sidebar__top { justify-content: center; padding-inline: 0; }
.is-collapsed .brand__name, .is-collapsed .nav__text, .is-collapsed .user-card__text, .is-collapsed .user-card__chevron { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.is-collapsed .brand__logo { max-width: 2.5rem; object-fit: contain; object-position: left; }
.is-collapsed .nav__label { height: 0; margin: .75rem .25rem; padding: 0; overflow: hidden; color: transparent; }
.is-collapsed .nav a { justify-content: center; padding-inline: 0; }
.is-collapsed summary.user-card { justify-content: center; padding: .5rem 0; }
.is-collapsed .user-menu__panel { right: auto; width: 16rem; }
@media (prefers-reduced-motion: reduce) { .app { transition: none; } }
@media (max-width: 56rem) {
    .topbar__collapse { display: none; }
    .app.is-collapsed { grid-template-columns: minmax(0, 1fr); }
    .is-collapsed .brand__name, .is-collapsed .nav__text, .is-collapsed .user-card__text, .is-collapsed .user-card__chevron { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
    .is-collapsed .nav a { justify-content: flex-start; padding-inline: .7rem; }
    .is-collapsed .nav__label { height: auto; color: var(--muted); }
}
.sidebar { z-index: 20; } /* The account menu may extend past a collapsed sidebar over the workspace. */
/* Drawers: right-hand panels (like Google Tag Manager) for details and forms. */
dialog.drawer { position: fixed; inset: 0 0 0 auto; margin: 0; width: min(32rem, 100vw); height: 100dvh; max-height: none; max-width: 100vw; padding: 0; border: 0; border-left: 1px solid var(--border); background: var(--surface); color: var(--fg); box-shadow: -16px 0 40px rgba(23, 24, 28, .18); overflow-y: auto; }
dialog.drawer::backdrop { background: rgba(15, 16, 20, .38); }
@media (prefers-reduced-motion: no-preference) {
    dialog.drawer[open] { animation: drawer-in .22s ease-out; }
    dialog.drawer[open]::backdrop { animation: drawer-fade .22s ease-out; }
}
@keyframes drawer-in { from { transform: translateX(100%); } }
@keyframes drawer-fade { from { opacity: 0; } }
.drawer__head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.drawer__head h2 { margin: 0; font-size: 1.1rem; }
.drawer__body { padding: 1.25rem; display: grid; gap: 1.25rem; }
.drawer__body .stack { max-width: none; }
.drawer__section h3 { margin: 0 0 .5rem; }
.drawer .facts { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }
.site-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.site-list li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .65rem .85rem; border-bottom: 1px solid var(--border); }
.site-list li:last-child { border-bottom: 0; }
.site-list__url { display: grid; min-width: 0; } .site-list__url strong { overflow-wrap: anywhere; font-weight: 600; }
.warning { padding: .75rem 1rem; border-radius: var(--radius-sm); background: var(--tint-rose); }
.warning p { margin: 0; }
.warning p + p { margin-top: .5rem; }
/* Saved logins: the sites a login is used on, each with its "Stop using here" button. */
.used-on { list-style: none; padding: 0; margin: 0 0 .75rem; }
.used-on li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .35rem 0; border-bottom: 1px solid var(--border); }
.used-on form { flex: none; }
.credential-host { display: block; max-width: 16rem; overflow-wrap: anywhere; white-space: normal; }
button.button--danger, .button--danger { background: var(--error); color: #fff; }
@media (prefers-color-scheme: dark) { button.button--danger { color: #1c1917; } }

/* Row actions: icon buttons on the right of a table row. */
.row-actions { display: flex; justify-content: flex-end; gap: .35rem; }
.row-actions .icon-button { width: 36px; height: 36px; min-height: 36px; }
.icon-button--danger { color: var(--error); }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.key-code { display: block; padding: .6rem .75rem; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--border); font-size: .85rem; }
.drawer__panel { min-height: 100%; }
.drawer dd, .drawer .facts div { min-width: 0; overflow-wrap: anywhere; }
code.nowrap { white-space: nowrap; }
.row-actions { flex-wrap: nowrap; }
/* Sites (spec 008): page tabs, connection badges, credentials, connect steps, work reports. */
[hidden] { display: none !important; }
.page-head__title { min-width: 0; }
.page-head__title h1 { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; overflow-wrap: anywhere; }
.page-head__title p { margin: .25rem 0 0; overflow-wrap: anywhere; }
.page-head .actions { margin: 0; }
.card > .page-head { margin-bottom: .5rem; }
.card > .page-head h2 { margin: 0; }
.tabs { margin: 0 0 1rem; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs ul { display: flex; gap: .25rem; list-style: none; margin: 0; padding: 0; }
.tabs a { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; padding: .25rem .85rem; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--muted); font-weight: 500; text-decoration: none; white-space: nowrap; }
.tabs a:hover { color: var(--fg); }
.tabs a[aria-current="page"] { color: var(--fg); font-weight: 600; border-bottom-color: var(--accent); }
.tabs .count, .nav__count { display: inline-grid; place-items: center; min-width: 1.35rem; height: 1.35rem; padding: 0 .35rem; border-radius: 999px; background: var(--tint-blue); color: var(--fg); font-size: .72rem; font-weight: 600; }
.nav__count { margin-left: auto; }
.is-collapsed .nav a { position: relative; }
.is-collapsed .nav__count { position: absolute; top: 2px; right: 6px; min-width: 1.1rem; height: 1.1rem; font-size: .65rem; }
.badge--not-connected { color: var(--muted); }
.badge--review { color: #6d28d9; }
.badge--report-draft { color: var(--muted); } .badge--report-submitted { color: #6d28d9; } .badge--report-returned { color: #92400e; } .badge--report-approved { color: #1e40af; } .badge--report-accepted { color: #166534; } .badge--report-questioned { color: #92400e; }
@media (prefers-color-scheme: dark) {
    .badge--review, .badge--report-submitted { color: #c4b5fd; }
    .badge--report-returned { color: #fcd34d; } .badge--report-approved { color: #93c5fd; } .badge--report-accepted { color: #86efac; } .badge--report-questioned { color: #fcd34d; }
}
.empty p { margin: .25rem 0; }
.icon--inline { width: 1em; height: 1em; vertical-align: -.125em; }
.wrap-anywhere { overflow-wrap: anywhere; }
.secret .key-code { overflow-wrap: anywhere; white-space: pre-wrap; }
.secret .actions { margin: .5rem 0 0; }
.secret p { margin: .5rem 0 0; }
.secret-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.plan-option { align-items: flex-start; padding: .65rem .85rem; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: .5rem; }
.plan-option input { margin-top: .3rem; }
.steps { display: grid; gap: .75rem; padding-left: 1.4rem; }
.steps a { margin-left: .25rem; }
.work-report { padding: .85rem 1rem; margin: .75rem 0; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); background: var(--bg); }
.work-report h3 { margin: .75rem 0 .25rem; font-size: .9rem; }
.work-report__meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .5rem; margin: 0; }
.work-report__group { margin-bottom: 1.25rem; }
.work-report__group > p { margin: 0; }
.badge { white-space: nowrap; }
/* Estimates (spec 009): form grid, task repeater, the estimate document, status badges. */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: .85rem 1.25rem; }
.field { display: grid; gap: .35rem; align-content: start; min-width: 0; }
.field input, .field select { width: 100%; }
.field p { margin: 0; }
.field--full { grid-column: 1 / -1; }
.estimate-form .card > label { display: block; margin: .85rem 0 .35rem; }
.estimate-form .card > h2 + label { margin-top: 0; }
.estimate-form .card > input { width: 100%; }
.item-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .75rem; }
.item-row { display: grid; grid-template-columns: minmax(0, 1fr) 9rem; gap: .75rem 1rem; padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); }
.item-row__main, .item-row__side { display: grid; gap: .35rem; align-content: start; min-width: 0; }
.item-row__side input { width: 100%; }
.item-row__tools { display: flex; gap: .35rem; margin-top: .5rem; }
.item-row__tools .icon-button { width: 36px; height: 36px; min-height: 36px; }
.estimate-form__rate { margin-top: 1.25rem; max-width: 32rem; }
.estimate-form__total { margin: 1rem 0 0; font-size: 1.1rem; font-weight: 600; }
.num, th.num { text-align: right; white-space: nowrap; }
tfoot th, tfoot td { border-top: 1px solid var(--border); border-bottom: 0; background: var(--bg); }
tfoot th { text-align: right; }
.estimate-doc__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.estimate-doc__company { margin: 0; font-size: 1.25rem; font-weight: 700; }
.estimate-doc__contact { margin: .25rem 0 0; font-size: .875rem; }
.estimate-doc__meta { display: grid; gap: .15rem; margin: 0; font-size: .875rem; min-width: 0; }
.estimate-doc__meta div { display: flex; gap: .5rem; }
.estimate-doc__meta dt { min-width: 6.5rem; color: var(--muted); }
.estimate-doc__meta dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.estimate-doc h2 { overflow-wrap: anywhere; }
.estimate-doc__bullets { margin: .35rem 0 0; padding-left: 1.1rem; color: var(--muted); }
.estimate-doc__cost { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .75rem; margin: 0 0 1.5rem; }
.estimate-doc__cost dt { color: var(--muted); font-size: .875rem; }
.estimate-doc__cost dd { margin: 0; font-size: 1.1rem; font-weight: 600; }
.estimate-doc__total dd { font-size: 1.5rem; }
.estimate-doc__disclaimer { padding: .75rem 1rem; border-radius: var(--radius-sm); background: var(--bg); font-size: .875rem; }
.estimate-doc__footer { margin: 1.5rem 0 0; font-size: .85rem; }
.badge--estimate-draft { color: var(--muted); } .badge--estimate-review { color: #6d28d9; } .badge--estimate-sent { color: #1e40af; }
.badge--estimate-accepted { color: #166534; } .badge--estimate-changes_requested { color: #92400e; }
@media (prefers-color-scheme: dark) {
    .badge--estimate-review { color: #c4b5fd; } .badge--estimate-sent { color: #93c5fd; }
    .badge--estimate-accepted { color: #86efac; } .badge--estimate-changes_requested { color: #fcd34d; }
}
@media (max-width: 40rem) {
    .item-row { grid-template-columns: minmax(0, 1fr); }
    .estimate-doc__meta div { display: grid; gap: 0; }
}
/* Client search (sites/partials/client-picker): a combobox with a list of matches under the field. */
.combobox { position: relative; display: grid; gap: .35rem; min-width: 0; }
.combobox input[type="text"] { width: 100%; }
.combobox__list { position: absolute; z-index: 5; top: calc(1.6em + 44px + .5rem); left: 0; right: 0; max-height: 16rem; overflow-y: auto; margin: 0; padding: .25rem; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.combobox__list li { padding: .55rem .75rem; border-radius: 8px; cursor: pointer; overflow-wrap: anywhere; }
.combobox__list [aria-selected="true"], .combobox__list [role="option"]:hover { background: var(--tint-blue); }
.combobox__list .combobox__empty { color: var(--muted); cursor: default; }
/* Maintenance (spec 010): site overview in two panels with health bars, due badges, change badges. */
.overview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 1rem; margin: 1rem 0; align-items: start; }
.overview-grid > .card { margin: 0; }
.panel__head { display: flex; gap: .85rem; align-items: flex-start; margin-bottom: 1rem; }
.panel__head h2 { margin: 0; }
.panel__head p { margin: .2rem 0 0; font-size: .875rem; }
.panel__icon { display: grid; place-items: center; flex: none; width: 2.5rem; height: 2.5rem; border-radius: var(--radius-sm); background: var(--tint-blue); color: var(--fg); }
.panel__icon--health { background: var(--tint-mint); }
.detail-list { display: grid; gap: 0; margin: 0; }
.detail-list div { display: grid; grid-template-columns: minmax(7rem, 38%) minmax(0, 1fr); gap: .75rem; padding: .55rem 0; border-top: 1px solid var(--border); }
.detail-list div:first-child { border-top: 0; }
.detail-list dt { color: var(--muted); font-size: .875rem; }
.detail-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.detail-list .link-button { padding: 0 .35rem; min-height: auto; font-weight: 600; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; margin-bottom: 1rem; }
.metric { display: grid; gap: .1rem; align-content: start; padding: .75rem .85rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); min-width: 0; }
.metric__label { color: var(--muted); font-size: .8rem; }
.metric__value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.metric__note { color: var(--muted); font-size: .8rem; }
.metric .badge { justify-self: start; }
.bar-block { margin-top: .85rem; }
.bar-block__label { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem .75rem; margin: 0 0 .35rem; font-size: .875rem; font-weight: 600; }
.bar-block__label .muted { font-weight: 400; }
.bar-block__status { margin: .5rem 0 0; }
.bar { display: block; width: 100%; height: 8px; border-radius: 4px; overflow: hidden; }
.bar__track { fill: var(--border); } .bar__fill { fill: #2563eb; } .bar__good { fill: #16a34a; } .bar__warn { fill: #d97706; } .bar__bad { fill: #dc2626; }
.badge--due { color: #1e40af; } .badge--overdue { color: var(--error); }
.badge--maintenance-in_progress { color: #1e40af; } .badge--maintenance-submitted { color: #6d28d9; } .badge--maintenance-returned { color: #92400e; } .badge--maintenance-approved { color: #166534; }
.badge--change-updated { color: #1e40af; } .badge--change-installed, .badge--change-activated { color: #166534; } .badge--change-removed, .badge--change-deactivated { color: #92400e; }
.schedule-form { max-width: 36rem; }
.schedule-form .actions { margin-top: 0; }
@media (prefers-color-scheme: dark) {
    .badge--due, .badge--maintenance-in_progress, .badge--change-updated { color: #93c5fd; } .badge--maintenance-submitted { color: #c4b5fd; }
    .badge--maintenance-returned, .badge--change-removed, .badge--change-deactivated { color: #fcd34d; }
    .badge--maintenance-approved, .badge--change-installed, .badge--change-activated { color: #86efac; }
    .bar__fill { fill: #60a5fa; }
}
@media (max-width: 30rem) {
    .metric-grid { grid-template-columns: minmax(0, 1fr); }
    .detail-list div { grid-template-columns: minmax(0, 1fr); gap: .1rem; }
}

/* List screens (sites, requests, reports, estimates, people, licences): quick filters, one line per row, the whole row opens it, cards on phones. */
.site-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0 0 .9rem; }
.site-chips a { display: inline-flex; gap: .35rem; align-items: baseline; padding: .35rem .8rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--fg); text-decoration: none; font-size: .9rem; }
.site-chips a:hover { border-color: var(--muted); }
.site-chips a[aria-current="true"] { background: var(--dark); border-color: var(--dark); color: var(--on-dark); }
.site-filters { margin-bottom: .25rem; }
.site-filters input[type="search"] { flex: 2 1 14rem; }
.list-table tbody tr { position: relative; }
.list-table tbody tr:hover { background: var(--bg); }
.list-table tbody th { background: transparent; color: var(--fg); font-size: inherit; font-weight: 500; border-bottom: 1px solid var(--border); }
.list-table tbody tr:last-child th { border-bottom: 0; }
.list-table td, .list-table th { vertical-align: middle; }
.site-cell { min-width: 13rem; }
.site-cell__inner { display: flex; gap: .65rem; align-items: center; }
.site-cell__inner > span:last-child { display: grid; min-width: 0; }
.site-bar { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; margin: 0 0 .9rem; }
.site-bar .site-chips { margin: 0; }
.site-sort { display: flex; gap: .5rem; align-items: center; }
.js .site-sort button { display: none; }
.site-filters select { flex: 0 1 auto; }
.site-cell__host { font-size: .82rem; font-weight: 400; overflow-wrap: anywhere; }
.row-link { color: var(--fg); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.row-link::after { content: ""; position: absolute; inset: 0; }
.row-link:focus-visible { outline: none; }
.site-cell__logins { position: relative; z-index: 1; justify-self: start; }
.row-link:focus-visible::after { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius-sm); }
.list-table tbody tr:hover .row-link { text-decoration: underline; }
.dot { flex: none; width: .6rem; height: .6rem; border-radius: 50%; }
.dot--on { background: #16a34a; } .dot--off { background: transparent; border: 2px solid var(--muted); }
.people { display: inline-flex; }
.avatar--sm { width: 1.8rem; height: 1.8rem; font-size: .7rem; border: 2px solid var(--surface); }
.people .avatar--sm + .avatar--sm { margin-left: -.4rem; background: var(--tint-mint); }
td.nowrap, th.nowrap { white-space: nowrap; }
@media (max-width: 45rem) {
    .list-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .list-table, .list-table tbody, .list-table tr { display: block; }
    .list-table tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .35rem 1rem; padding: .9rem 1rem; border-bottom: 1px solid var(--border); }
    .list-table tbody tr:last-child { border-bottom: 0; }
    .list-table tbody th, .list-table td { display: block; padding: 0; border: 0; }
    .list-table tbody th { grid-column: 1 / -1; }
    .site-cell { min-width: 0; }
    .list-table td::before { content: attr(data-label); display: block; color: var(--muted); font-size: .75rem; }
    .list-table td.num { text-align: left; }
}
.item-cell { min-width: 14rem; }
.item-cell .row-link { display: block; }
.item-cell__meta { display: block; margin-top: .1rem; font-size: .82rem; font-weight: 400; }
.item-cell__meta .badge { margin-left: .35rem; }
.person { display: inline-flex; gap: .5rem; align-items: center; white-space: nowrap; }
.person .avatar--sm { border: 0; }
.list-table .actions-cell { position: relative; z-index: 1; text-align: right; }
@media (max-width: 45rem) { .list-table .actions-cell { grid-column: 1 / -1; text-align: left; } }
.person-card { display: flex; gap: .65rem; align-items: center; min-width: 0; }
.person-card > span:last-child { display: grid; min-width: 0; overflow-wrap: anywhere; }
.person-card__name { color: var(--fg); font-weight: 600; }
.person-card .avatar--sm { width: 2.1rem; height: 2.1rem; border: 0; }
.list-table .actions-cell details { display: inline-block; text-align: left; }
button.row-link { display: block; padding: 0; min-height: 0; border: 0; background: none; font: inherit; font-weight: 600; text-align: left; color: var(--fg); cursor: pointer; }
.key__value { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.key__value code { overflow-wrap: anywhere; }
.list-table td { white-space: nowrap; }
.list-table td.wrap { white-space: normal; min-width: 10rem; }
.list-table .item-cell__meta { white-space: normal; }
@media (max-width: 45rem) { .list-table td { white-space: normal; } }
.list-table thead th { white-space: nowrap; }

/* Overview: panels below the cards, side by side on wide screens; counts as label-and-number rows. */
.overview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); gap: 1rem; align-items: start; margin: 0 0 1rem; }
.overview-grid > .card { margin: 0; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .25rem .75rem; margin-bottom: .75rem; }
.panel-head h2 { margin: 0; }
.panel-head a { font-size: .9rem; }
.panel-subhead { margin: 1.25rem 0 .5rem; }
.tally { margin: 0; }
.tally > div { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .45rem 0; border-bottom: 1px solid var(--border); }
.tally > div:last-child { border-bottom: 0; }
.tally dt { color: var(--muted); }
.tally dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.tally--cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); column-gap: 2rem; }
.tally--cols > div:last-child { border-bottom: 1px solid var(--border); }
.tally-group + .tally-group { margin-top: 1rem; }
.tally-group h3 { margin: 0 0 .1rem; font-size: .85rem; color: var(--muted); font-weight: 600; }
.meter-label { margin: 0 0 .35rem; font-size: .9rem; }
.meter { display: block; width: 100%; height: .5rem; margin: 0 0 .5rem; border-radius: 999px; }
.meter__track { fill: var(--border); } .meter__fill { fill: #16a34a; }
.card > .page-head .badge { font-size: .75rem; font-weight: 500; }
/* Store account (orders, subscriptions, payment methods, addresses): hand-off buttons sit in .actions as forms. */
.actions form { margin: 0; }
.actions button .icon, .actions-cell button .icon { width: .9rem; height: .9rem; margin-left: .15rem; vertical-align: -.1rem; }
h1 .badge { font-size: .8rem; font-weight: 600; vertical-align: middle; }
.store-address { font-style: normal; line-height: 1.6; }
.store-address-form { max-width: 40rem; gap: .25rem; }
.store-address-form p { margin: 0 0 .5rem; }
.store-address-form label { display: block; margin-bottom: .25rem; font-weight: 600; font-size: .9rem; }
.store-address-form input, .store-address-form select { width: 100%; }
.store-address-form__row { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0 .75rem; }
.store-cards { display: grid; gap: .5rem; margin: 0; padding: 0; list-style: none; }
.store-cards li { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.store-cards .icon { flex: none; width: 1.25rem; height: 1.25rem; color: var(--muted); }
.store-cards .badge { margin-left: auto; }
.store-cancel { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.store-cancel summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.store-cancel p { max-width: 40rem; }
