/* ==========================================================================
   Hives HR — components
   Reusable building blocks. Page-specific styles go in pages/<page>.css.
   Class naming: .component, .component-part, state via .is-* / .has-*
   ========================================================================== */

@layer components {

    /* ---------- Icons ---------- */
    .i {
        width: 18px; height: 18px; flex: none;
        stroke: currentColor; fill: none; stroke-width: 1.75;
        stroke-linecap: round; stroke-linejoin: round;
    }
    .i-sm { width: 14px; height: 14px; }

    /* ---------- App shell ---------- */
    .app { max-width: var(--page-max); margin: 0 auto; padding: 18px var(--gutter) 64px; }

    .topbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
    .brand {
        display: flex; align-items: center; gap: 9px; margin-right: auto;
        color: var(--ink); text-decoration: none;
        font-size: 21px; font-weight: 700; letter-spacing: -.03em;
    }
    .brand-logo { width: auto; height: 36px; }
    .brand-tag {
        font-size: 11px; font-weight: 500; letter-spacing: .02em;
        padding: 2px 7px; border-radius: var(--radius-pill);
        background: var(--ink); color: var(--white);
    }
    .nav-wrap { display: flex; justify-content: center; flex: 1 1 auto; }
    .nav { display: flex; gap: 6px; }
    .topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

    /* ---------- Buttons (pills) ---------- */
    .pill {
        display: inline-flex; align-items: center; justify-content: center; gap: 8px;
        height: 38px; padding: 0 15px;
        border: 1px solid var(--line); border-radius: var(--radius-pill);
        background: var(--surface); color: var(--ink);
        font-size: 13.5px; font-weight: 500; text-decoration: none; white-space: nowrap;
        transition: background var(--fast) var(--ease), transform var(--fast) var(--ease);
    }
    .pill:hover { background: var(--white); }
    .pill:active { transform: scale(.97); }
    .pill:disabled { opacity: .5; transform: none; }
    .pill .i { width: 16px; height: 16px; }
    .pill.is-primary { background: var(--accent); border-color: var(--accent); color: var(--ink); font-weight: 600; }
    .pill.is-primary:hover { background: var(--accent-hover); }
    .pill.is-dark, .pill.is-active { background: var(--ink); border-color: var(--ink); color: var(--white); }
    .pill.is-dark:hover { background: var(--ink-hover); }
    .pill.is-active .i { color: var(--accent); }
    .pill.is-sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
    .pill.is-lg { height: 50px; padding: 0 24px; font-size: 15px; font-weight: 600; gap: 10px; }
    .pill.is-block { width: 100%; }

    .icon-btn {
        position: relative; width: 38px; height: 38px; flex: none;
        display: grid; place-items: center;
        border: 1px solid var(--line); border-radius: 50%;
        background: var(--surface); color: var(--ink);
    }
    .icon-btn:hover { background: var(--white); }
    .icon-btn.has-dot::after {
        content: ""; position: absolute; top: 9px; right: 10px;
        width: 7px; height: 7px; border-radius: 50%;
        background: var(--accent); box-shadow: 0 0 0 2px var(--surface);
    }

    .arrow-btn {
        width: 30px; height: 30px; flex: none;
        display: grid; place-items: center;
        border: 1px solid var(--line-2); border-radius: 50%;
        background: transparent; color: var(--ink);
        transition: background var(--fast), color var(--fast), transform var(--fast) var(--ease);
    }
    .arrow-btn:hover { background: var(--ink); color: var(--white); transform: rotate(45deg); }
    .arrow-btn .i { width: 14px; height: 14px; }

    .kbd, kbd { font: inherit; font-size: 11px; color: var(--ink-3); border: 1px solid var(--line-2); border-radius: 6px; padding: 0 5px; }

    /* ---------- Search button & command palette (Ctrl+K) ---------- */
    .search-btn {
        height: 38px; padding: 0 8px 0 14px; display: inline-flex; align-items: center; gap: 8px;
        border: 1px solid var(--line); border-radius: var(--radius-pill);
        background: var(--surface); color: var(--ink-3); font-size: 13px; cursor: pointer;
    }
    .search-btn:hover { background: var(--white); color: var(--ink); }
    .search-btn .i { width: 15px; height: 15px; }
    .palette { width: min(600px, calc(100vw - 32px)); margin-top: 12vh; }
    .palette-search { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
    .palette-search .i { width: 18px; height: 18px; color: var(--ink-3); }
    .palette-search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font: inherit; font-size: 16px; color: var(--ink); }
    .palette-results { max-height: min(420px, 60vh); overflow-y: auto; padding: 6px 8px 10px; }
    .palette-group { padding: 10px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
    .palette-results a { display: block; padding: 9px 10px; border-radius: 10px; color: var(--ink); text-decoration: none; font-size: 14px; }
    .palette-results [aria-selected="true"] a { background: var(--accent-soft); }
    .palette-empty { padding: 18px 10px; font-size: 13px; color: var(--ink-3); }

    /* ---------- Avatars ---------- */
    .avatar {
        width: 38px; height: 38px; flex: none; overflow: hidden;
        display: grid; place-items: center; border-radius: 50%;
        font-size: 12.5px; font-weight: 700; color: var(--ink);
        background: var(--avatar-1);
    }
    .avatar img { width: 100%; height: 100%; object-fit: cover; }
    .avatar.is-sm { width: 34px; height: 34px; font-size: 11.5px; }
    .avatar.is-lg { width: 64px; height: 64px; font-size: 20px; }
    .avatar[data-tone="2"] { background: var(--avatar-2); }
    .avatar[data-tone="3"] { background: var(--avatar-3); }
    .avatar[data-tone="4"] { background: var(--avatar-4); }
    .avatar[data-tone="5"] { background: var(--avatar-5); }
    .avatar[data-tone="6"] { background: var(--avatar-6); }

    .avatar-link { display: inline-flex; border-radius: 50%; text-decoration: none; }
    .avatar-link:hover .avatar { box-shadow: 0 0 0 3px var(--accent-soft); }

    /* ---------- Chips ---------- */
    .chip {
        display: inline-flex; align-items: center; gap: 5px;
        height: 24px; padding: 0 9px; white-space: nowrap;
        border: 1px solid var(--line); border-radius: var(--radius-pill);
        background: var(--surface-2); color: var(--ink-2);
        font-size: 11.5px; font-weight: 500;
    }
    .chip .i { width: 12px; height: 12px; }
    .chip.is-green { background: var(--green-soft); color: var(--green-ink); border-color: transparent; }
    .chip.is-amber { background: var(--amber-soft); color: var(--amber-ink); border-color: transparent; }
    .chip.is-red { background: var(--red-soft); color: var(--red-ink); border-color: transparent; }
    .chip.is-blue { background: var(--blue-tint); color: var(--blue-ink); border-color: transparent; }
    .chip.is-peach { background: var(--peach); color: #7A4F0C; border-color: transparent; }
    .chip.is-ink { background: var(--ink); color: var(--white); border-color: transparent; }

    /* ---------- Page header ---------- */
    .page-header {
        display: flex; align-items: flex-end; justify-content: space-between;
        gap: 16px; flex-wrap: wrap; margin: 30px 0 22px;
    }
    .page-title { font-size: clamp(26px, 3.2vw, 38px); font-weight: 400; letter-spacing: -.035em; line-height: 1.1; }
    .page-title b { font-weight: 700; }
    .page-subtitle { margin-top: 6px; font-size: 13.5px; color: var(--ink-3); }
    .page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

    /* ---------- Grid ---------- */
    .grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); }
    .span-2 { grid-column: span 2; }
    .span-3 { grid-column: span 3; }
    .span-4 { grid-column: span 4; }
    .span-5 { grid-column: span 5; }
    .span-6 { grid-column: span 6; }
    .span-7 { grid-column: span 7; }
    .span-8 { grid-column: span 8; }
    .span-12 { grid-column: span 12; }
    .stack { display: grid; gap: var(--gap); }

    /* ---------- Cards ---------- */
    .card {
        position: relative; min-width: 0;
        padding: 18px 20px;
        background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
        box-shadow: var(--shadow);
        animation: rise .6s var(--ease) both;
        animation-delay: calc(var(--i, 0) * 45ms);
    }
    .card.is-flush { padding: 0; overflow: hidden; }
    .card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
    .card.is-flush .card-head { padding: 18px 20px 14px; }
    .card-title { font-size: 17px; font-weight: 600; letter-spacing: -.015em; }
    .card-subtitle { margin-top: 2px; font-size: 12.5px; color: var(--ink-3); }
    .card-label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
    .card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
    .card-body { margin-top: 14px; }
    .card-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--ink-3); }

    /* ---------- KPI ---------- */
    .kpi-body { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; margin-top: 20px; }
    .kpi-value { font-size: 38px; font-weight: 400; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
    .kpi-value small { font-size: 16px; letter-spacing: -.01em; color: var(--ink-3); }
    .kpi-meta { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 12px; color: var(--ink-3); white-space: nowrap; }
    .delta { font-weight: 600; }
    .delta.is-up { color: var(--green); }
    .delta.is-down { color: var(--red); }

    /* ---------- Mini visuals ---------- */
    .gauge { display: grid; justify-items: center; }
    .gauge-label { margin-top: -14px; font-size: 10.5px; font-weight: 600; color: var(--ink-2); }
    .gauge-tick { stroke: var(--line-2); stroke-width: 2.4; stroke-linecap: round; }
    .gauge-tick.is-on { stroke: var(--peach); }
    .gauge-needle { fill: var(--accent); }

    .dots { display: grid; gap: 4px; grid-template-columns: repeat(var(--cols, 8), 6px); }
    .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-2); }
    .dots i.is-on { background: var(--accent); }

    .meter { width: 84px; }
    .meter-label { margin-bottom: 4px; text-align: right; font-size: 10.5px; font-weight: 600; color: var(--ink-2); }
    .meter-track { display: flex; height: 30px; overflow: hidden; border-radius: 8px; background: var(--hatch), var(--surface-2); }
    .meter-track i { border-radius: 8px; background: var(--accent); }

    .mini-bars { display: flex; align-items: flex-end; gap: 6px; height: 48px; }
    .mini-bars span { position: relative; width: 26px; height: 100%; overflow: hidden; border-radius: 7px; background: var(--hatch), var(--surface-2); }
    .mini-bars i { position: absolute; inset: auto 0 0 0; border-radius: 7px; }

    /* ---------- Progress ---------- */
    .progress { display: grid; gap: 6px; }
    .progress-top { display: flex; justify-content: space-between; font-size: 12.5px; }
    .progress-top b { font-weight: 600; }
    .progress-top span { color: var(--ink-3); }
    .progress-track { height: 12px; overflow: hidden; border-radius: var(--radius-pill); background: var(--hatch), var(--surface-2); }
    .progress-track i {
        display: block; height: 100%; border-radius: var(--radius-pill);
        background: var(--tone, var(--accent));
        transform-origin: left; animation: grow-x .9s var(--ease) both .2s;
    }

    /* ---------- Select-like pill & segmented control ---------- */
    .select {
        display: inline-flex; align-items: center; gap: 6px; flex: none;
        height: 30px; padding: 0 12px; white-space: nowrap;
        border: 1px solid var(--line-2); border-radius: var(--radius-pill);
        background: var(--surface); font-size: 12px; font-weight: 500;
    }
    .select .i { width: 14px; height: 14px; }

    .seg { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--surface-2); }
    .seg button, .seg a {
        height: 26px; padding: 0 11px; display: inline-flex; align-items: center;
        border: 0; border-radius: var(--radius-pill); background: transparent;
        font-size: 12px; font-weight: 500; color: var(--ink-2); text-decoration: none;
    }
    .seg [aria-pressed="true"], .seg [aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

    /* ---------- Lists ---------- */
    .list { margin-top: 12px; }
    .row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
    .row:first-child { border-top: 0; }
    .row-main { flex: 1; min-width: 0; display: grid; }
    .row-main b, .row-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .row-main b { font-size: 13.5px; font-weight: 600; }
    .row-main span { font-size: 12px; color: var(--ink-3); }
    .row-end { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
    .row-actions { display: flex; gap: 6px; }
    .row.is-leaving { animation: leave .35s var(--ease) forwards; }

    .list-icon {
        width: 34px; height: 34px; flex: none;
        display: grid; place-items: center; border-radius: 10px;
        background: var(--surface-2); color: var(--ink-2);
    }
    .list-icon.is-accent { background: var(--accent-soft); color: var(--accent-ink); }
    .list-icon .i { width: 16px; height: 16px; }

    .act {
        width: 30px; height: 30px; display: grid; place-items: center;
        border: 1px solid var(--line-2); border-radius: 50%; background: var(--surface);
        transition: background var(--fast) var(--ease), color var(--fast), border-color var(--fast);
    }
    .act .i { width: 15px; height: 15px; }
    .act.is-ok:hover { background: var(--green); border-color: var(--green); color: var(--white); }
    .act.is-no:hover { background: var(--red); border-color: var(--red); color: var(--white); }

    /* ---------- Bar chart ---------- */
    .barchart { display: grid; grid-template-columns: 34px 1fr; height: 230px; margin-top: 16px; }
    .barchart-y { display: flex; flex-direction: column; justify-content: space-between; padding-bottom: 26px; font-size: 11px; color: var(--ink-3); }
    .barchart-bars { display: flex; gap: 8px; }
    .bar { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
    .bar-track { position: relative; flex: 1; width: min(34px, 80%); border-radius: 9px; background: var(--hatch), var(--surface-2); }
    .bar-fill {
        position: absolute; inset: auto 0 0 0; border-radius: 9px; background: var(--green-soft);
        transform-origin: bottom; animation: grow-y .9s var(--ease) both;
        animation-delay: calc(var(--i, 0) * 50ms + 150ms);
    }
    .bar.is-current .bar-fill { background: var(--accent); }
    .bar-tip {
        position: absolute; left: 50%; top: -8px; transform: translate(-50%, -100%);
        padding: 3px 8px; border-radius: var(--radius-pill); white-space: nowrap; pointer-events: none;
        background: var(--ink); color: var(--white); font-size: 10.5px; font-weight: 600;
        opacity: 0; transition: opacity var(--fast);
    }
    .bar.is-current .bar-tip, .bar:hover .bar-tip { opacity: 1; }
    .bar-x { height: 18px; font-size: 11.5px; color: var(--ink-2); }

    /* ---------- Line chart ---------- */
    .linechart { position: relative; margin-top: 16px; }
    .linechart svg { display: block; width: 100%; height: 200px; overflow: visible; }
    .linechart-x { display: flex; justify-content: space-between; margin-top: 10px; font-size: 11.5px; color: var(--ink-2); }
    .line-marker {
        position: absolute; transform: translate(-50%, -50%);
        padding: 3px 8px; border-radius: var(--radius-pill);
        background: var(--accent); color: var(--ink); font-size: 10.5px; font-weight: 700;
        box-shadow: 0 0 0 4px rgba(245, 161, 27, .25);
    }

    /* ---------- Legend ---------- */
    .legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; font-size: 11.5px; color: var(--ink-2); }
    .legend span { display: inline-flex; align-items: center; gap: 6px; }
    .legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--tone); }

    /* ---------- Tables ---------- */
    .table-wrap { overflow-x: auto; }
    .table { width: 100%; font-size: 13.5px; }
    .table th {
        position: sticky; top: 0; z-index: 1;
        padding: 10px 16px; text-align: left; white-space: nowrap;
        background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 500;
    }
    .table td { height: 48px; padding: 8px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
    .table tbody tr:hover { background: rgba(245, 161, 27, .05); }
    .table th:first-child, .table td:first-child { padding-left: 20px; }
    .table th:last-child, .table td:last-child { padding-right: 20px; }
    .table .is-num { text-align: right; font-variant-numeric: tabular-nums; }
    .table .is-muted { color: var(--ink-3); }
    .cell-person { display: flex; align-items: center; gap: 10px; }
    .cell-person .row-main b { font-size: 13.5px; }

    .pagination { display: flex; align-items: center; gap: 6px; }
    .pagination a, .pagination span {
        min-width: 32px; height: 32px; padding: 0 10px;
        display: inline-grid; place-items: center;
        border: 1px solid var(--line); border-radius: var(--radius-pill);
        background: var(--surface); color: var(--ink); text-decoration: none; font-size: 12.5px;
    }
    .pagination [aria-current="page"] { background: var(--ink); border-color: var(--ink); color: var(--white); }
    .pagination [aria-disabled="true"] { color: var(--ink-3); }

    /* ---------- Forms ---------- */
    .form { display: grid; gap: 14px; }
    .field { display: grid; gap: 6px; }
    .field-label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
    .field-label .is-optional { font-weight: 400; color: var(--ink-3); }
    .field-hint { font-size: 12px; color: var(--ink-3); }
    .field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

    .input, .field input:not([type="checkbox"], [type="radio"]), .field select, .field textarea {
        width: 100%; height: 42px; padding: 0 12px;
        border: 1px solid var(--line-2); border-radius: var(--radius-sm);
        background: var(--white); outline: none;
        transition: border-color var(--fast), box-shadow var(--fast);
    }
    .field textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
    .input:focus, .field input:focus, .field select:focus, .field textarea:focus {
        border-color: var(--ink); box-shadow: 0 0 0 4px rgba(14, 13, 16, .06);
    }
    .field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); }
    .field-error { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--red-ink); }
    .field-error .i { width: 14px; height: 14px; }

    .input-unit { display: flex; align-items: center; gap: 8px; }
    .input-unit span { font-size: 12.5px; color: var(--ink-3); }

    .day-picker { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: 0; }
    .day { position: relative; cursor: pointer; }
    .day input { position: absolute; opacity: 0; pointer-events: none; }
    .day span {
        display: grid; place-items: center; width: 52px; height: 40px;
        border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--white);
        font-size: 13px; font-weight: 500; color: var(--ink-2);
    }
    .day input:checked + span { background: var(--hatch), var(--surface-2); border-color: var(--ink); color: var(--ink); }
    .day input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

    .check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
    .check input { width: 16px; height: 16px; accent-color: var(--ink); }

    .form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
    .form-inline { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

    .link { color: var(--accent-ink); font-weight: 500; text-decoration: none; }
    .link:hover { text-decoration: underline; }
    .link-button { padding: 0; border: 0; background: none; font: inherit; }

    .input-code { letter-spacing: .4em; font-size: 18px; font-variant-numeric: tabular-nums; }

    .disclosure summary { cursor: pointer; font-size: 13px; color: var(--accent-ink); font-weight: 500; list-style: none; }
    .disclosure summary::-webkit-details-marker { display: none; }
    .disclosure[open] summary { margin-bottom: 12px; }


    /* ---------- Profile & detail lists ---------- */
    .profile-head { display: flex; align-items: center; gap: 14px; }
    .profile-head .row-main b { font-size: 16px; }
    .details { display: grid; margin: 14px 0 0; }
    .details > div { display: grid; grid-template-columns: 140px 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
    .details dt { font-size: 12.5px; color: var(--ink-3); }
    .details dd { margin: 0; font-size: 13.5px; }

    /* ---------- Filters & chip groups ---------- */
    .filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
    .input-sm { height: 32px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--radius-pill); background: var(--white); font-size: 12.5px; outline: none; }
    .input-sm:focus { border-color: var(--ink); }
    .filters input.input-sm { width: 220px; max-width: 100%; }
    .chips { display: flex; flex-wrap: wrap; gap: 6px; }
    .tabs { flex-wrap: wrap; }
    .text-warning { color: var(--amber-ink) !important; }

    /* ---------- Option cards (radio choices) ---------- */
    .options { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; min-width: 0; }
    .option {
        display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 12px;
        padding: 14px 16px; cursor: pointer;
        border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface);
        transition: border-color var(--fast), background var(--fast), box-shadow var(--fast);
    }
    .option:hover { background: var(--white); }
    .option:has(input:checked) { border-color: var(--ink); background: var(--white); box-shadow: 0 0 0 3px rgba(14, 13, 16, .05); }
    .option input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }
    .option-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); }
    .option:has(input:checked) .option-icon { background: var(--accent-soft); color: var(--accent-ink); }
    .option-text { display: grid; gap: 2px; min-width: 0; }
    .option-text b { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; font-weight: 600; }
    .option-text > span { font-size: 12.5px; color: var(--ink-3); }

    /* ---------- Setup panels (authenticator, recovery codes) ---------- */
    .setup { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
    .setup-title { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
    .setup-steps { margin: 8px 0 14px; padding-left: 18px; list-style: decimal; font-size: 13px; color: var(--ink-2); }
    .setup-body { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: start; }
    .qr { padding: 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--white); }
    .qr svg { width: 168px; height: 168px; }
    .setup-key, .recovery-codes code {
        display: inline-block; padding: 6px 10px; border-radius: 8px;
        background: var(--surface-2); font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px;
        word-break: break-all;
    }
    .recovery-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; }
    .recovery-codes code { display: block; text-align: center; }
    .setup-actions { margin-top: 14px; }
    .page-alert { margin-bottom: var(--gap); }
    /* ---------- Alerts ---------- */
    .alert {
        display: flex; align-items: flex-start; gap: 10px;
        padding: 12px 14px; border-radius: var(--radius-sm);
        background: var(--surface-2); color: var(--ink-2); font-size: 13px;
    }
    .alert.is-green { background: var(--green-soft); color: var(--green-ink); }
    .alert.is-amber { background: var(--amber-soft); color: var(--amber-ink); }
    .alert.is-red { background: var(--red-soft); color: var(--red-ink); }
    .alert.is-blue { background: var(--blue-tint); color: var(--blue-ink); }

    /* ---------- Dialogs ---------- */
    .dialog {
        width: min(520px, calc(100vw - 32px)); padding: 0; border: 0;
        border-radius: var(--radius-lg); background: var(--surface); color: var(--ink);
        box-shadow: var(--shadow-float);
    }
    .dialog::backdrop { background: rgba(14, 13, 16, .25); backdrop-filter: blur(6px); }
    .dialog[open] { animation: pop .3s var(--ease); }
    .dialog-body { padding: 22px 24px 24px; }
    .dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
    .dialog-title { font-size: 20px; font-weight: 600; letter-spacing: -.02em; }

    /* ---------- Toast ---------- */
    .toast {
        position: fixed; right: 24px; bottom: 24px; z-index: 50;
        display: flex; align-items: center; gap: 14px;
        padding: 12px 14px 12px 18px; border-radius: 16px;
        background: var(--ink); color: var(--white); font-size: 13.5px;
        box-shadow: var(--shadow-toast);
        opacity: 0; visibility: hidden; transform: translateY(16px);
        transition: opacity .3s, visibility .3s, transform .35s var(--ease);
    }
    .toast.is-shown { opacity: 1; visibility: visible; transform: none; }
    .toast button {
        height: 30px; padding: 0 12px; border: 0; border-radius: var(--radius-pill);
        background: rgba(255, 255, 255, .14); color: var(--white); font-size: 12.5px; font-weight: 600;
    }

    /* ---------- Empty state ---------- */
    .empty { display: grid; justify-items: center; gap: 8px; padding: 32px 16px; text-align: center; }
    .empty-icon {
        width: 48px; height: 48px; display: grid; place-items: center;
        border-radius: 14px; background: var(--accent-soft); color: var(--accent-ink);
    }
    .empty-title { font-size: 15px; font-weight: 600; }
    .empty-text { max-width: 36ch; font-size: 13px; color: var(--ink-3); }
    .empty .pill { margin-top: 6px; }

    /* ---------- Guest (auth) layout ---------- */
    .guest { min-height: 100dvh; display: grid; place-items: center; align-content: center; padding: 32px var(--gutter); }
    .guest-card { width: min(420px, 100%); padding: 32px; }
    .guest-brand { margin: 0 auto 24px; justify-content: center; }
    .guest-brand .brand-logo { height: 64px; }
    .guest-foot { margin-top: 20px; text-align: center; font-size: 12px; color: var(--ink-3); }
    .error-card { text-align: center; }
    .error-code { font-size: 44px; font-weight: 500; letter-spacing: -.04em; color: var(--accent); line-height: 1; }
    .error-title { margin-top: 10px; font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
    .error-text { margin-top: 10px; font-size: 14px; line-height: 1.55; color: var(--ink-2); }
    .error-actions { justify-content: center; margin-top: 22px; }
    .auth-head { margin-bottom: 20px; }
    .auth-foot { margin-top: 18px; text-align: center; font-size: 13px; }
    .guest-card .alert { margin-bottom: 16px; }

    /* ---------- Motion ---------- */
    @keyframes rise { from { opacity: 0; transform: translateY(10px); } }
    @keyframes grow-y { from { transform: scaleY(0); } }
    @keyframes grow-x { from { transform: scaleX(0); } }
    @keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }
    @keyframes leave { to { opacity: 0; transform: translateX(24px); height: 0; padding: 0; } }

    /* ---------- Responsive ---------- */
    @media (max-width: 1180px) {
        .span-2 { grid-column: span 4; }
        .span-3 { grid-column: span 6; }
        .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
        .nav-wrap {
            order: 3; flex-basis: 100%; justify-content: flex-start;
            overflow-x: auto; scrollbar-width: none;
            margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter);
        }
        .hide-md { display: none; }
    }

    @media (max-width: 640px) {
        .search-btn { width: 38px; padding: 0; justify-content: center; }
        .search-btn span, .search-btn kbd { display: none; }
        .span-2 { grid-column: span 6; }
        .span-3 { grid-column: span 12; }
        .kpi-value { font-size: 34px; }
        .hide-sm { display: none; }
        .page-actions .pill.is-primary { flex: 1; }
        .toast { left: 16px; right: 16px; bottom: 16px; }
        .guest-card { padding: 24px 20px; }
        .setup-body { grid-template-columns: 1fr; justify-items: start; }
    }
}
