/* ===========================================================================
 * VoxFlow — application stylesheet
 *
 * Translates the design_spec/ Carbon-inspired language into handwritten
 * CSS so the app runs fully offline behind Caddy: no Tailwind CDN,
 * no Google Fonts call-out, no Material Symbols font. Colors, spacing,
 * and typographic rhythm follow the design; we substitute the system
 * font stack for Inter/Manrope so first paint never blocks on a font
 * fetch.
 *
 * Layout:
 *   .app-shell { display: flex }
 *     .app-shell__sidebar (280px, fixed left)
 *     .app-shell__main
 *       .app-shell__header (64px, sticky top)
 *       .app-shell__content (the page content block)
 *
 * Login is a separate split-screen shell: .login-shell.
 * =========================================================================== */

:root {
    /* Carbon-derived palette. Naming follows the design's intent (primary
     * for the deep navy brand colour, secondary for the IBM-blue accent
     * used by interactive elements). */
    --color-primary: #031636;
    --color-primary-container: #1a2b4c;
    --color-secondary: #0051d5;
    --color-secondary-hover: #003ea8;
    --color-surface: #ffffff;
    --color-surface-bright: #f7f9fb;
    --color-surface-container: #eceef0;
    --color-surface-container-low: #f2f4f6;
    --color-surface-container-high: #e6e8ea;
    --color-on-surface: #191c1e;
    --color-on-surface-variant: #44474e;
    --color-outline: #75777f;
    --color-outline-variant: #c5c6cf;
    --color-error: #ba1a1a;
    --color-error-container: #ffdad6;
    --color-on-error-container: #93000a;
    --color-success: #00a774;
    --color-success-container: #d8f1e3;
    --color-on-success-container: #006c45;
    --color-warning-container: #fff3cd;
    --color-on-warning-container: #8a6d3b;

    /* 4px / 8px grid. */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-6: 24px;
    --space-8: 32px;
    --space-12: 48px;
    --space-16: 64px;

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;

    /* System font stack — fast, offline, close in spirit to Inter. */
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    --font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
        "Liberation Mono", monospace;

    --sidebar-width: 280px;
    --header-height: 64px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-body);
    color: var(--color-on-surface);
    background-color: var(--color-surface-bright);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--color-secondary);
    text-decoration: none;
    transition: color 150ms ease;
}
a:hover { color: var(--color-secondary-hover); text-decoration: underline; }

code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--color-surface-container);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
}

pre {
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--color-surface-bright);
    padding: var(--space-4);
    border-radius: var(--radius-sm);
    overflow: auto;
    margin: 0 0 var(--space-4) 0;
}

p { margin: 0 0 var(--space-3) 0; }

/* ---------------------------------------------------------------------------
 * App shell
 * ------------------------------------------------------------------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-shell__sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-outline-variant);
    display: flex;
    flex-direction: column;
    z-index: 40;
}

.app-shell__sidebar-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--color-outline-variant);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
}

/* Brand lockup — the 3Wolf wordmark image. Wrapped in an anchor that
 * routes back to the dashboard so a click on the logo behaves the way
 * users expect from every other SaaS shell. Sized against the sidebar's
 * inner width (280 - 24*2 = 232px) so the logo fits without a layout
 * shift, with object-fit: contain to preserve the wordmark's aspect
 * ratio if a wider or taller variant is dropped in later. */
.app-shell__brand-link {
    display: block;
    line-height: 0;        /* avoid the inline-image baseline gap */
}
.app-shell__brand-link:hover {
    text-decoration: none;
}
.app-shell__brand-logo {
    display: block;
    width: 100%;
    max-width: 232px;
    max-height: 48px;
    object-fit: contain;
    object-position: left center;
}

.app-shell__brand-subtitle {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-on-surface-variant);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.app-shell__nav {
    flex: 1;
    padding: var(--space-3) var(--space-2);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    overflow-y: auto;
}

.app-shell__nav a {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    color: var(--color-on-surface-variant);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: background-color 150ms ease, color 150ms ease;
}

.app-shell__nav a:hover {
    background: var(--color-surface-container-low);
    color: var(--color-secondary);
    text-decoration: none;
}

.app-shell__nav a.is-active {
    background: var(--color-surface-container-low);
    color: var(--color-secondary);
    font-weight: 700;
}

/* Inline-SVG nav icons (Font Awesome Free 6.7.2 Solid, embedded via
 * the nav_icon() macro in admin/_macros.html). Fixed width keeps the
 * label column aligned even though the source viewBoxes have
 * different aspect ratios; flex-shrink keeps the icon at its native
 * size when the label wraps. */
.app-shell__nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    /* Align the SVG visually with the text x-height — the FA Solid
     * icons render slightly above the baseline by default. */
    display: inline-block;
    vertical-align: middle;
}

.app-shell__main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-shell__header {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    height: var(--header-height);
    padding: 0 var(--space-6);
    background: var(--color-surface-bright);
    border-bottom: 1px solid var(--color-outline-variant);
}

.app-shell__header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

/* ---------------------------------------------------------------------------
 * Profile dropdown (Change password + Log out)
 *
 * JS-free via <details>/<summary>. The native disclosure marker is hidden
 * with summary { list-style: none } plus the WebKit-specific
 * details-marker selector. The panel positions absolutely below the
 * trigger and lifts above the page via z-index 40 (the sticky header
 * is z-index 30; the sidebar is 40 so we match it to avoid stacking
 * surprises when the menu overlaps the sidebar's vertical seam).
 *
 * Caveat: closing on Escape needs JS; we accept that and rely on
 * click-outside to close (clicking the summary again, or anywhere
 * outside) since <details> toggles on summary click natively.
 * ------------------------------------------------------------------------- */
.profile-menu {
    position: relative;
}

.profile-menu summary {
    list-style: none;        /* Hide default disclosure triangle (FF, Chrome) */
    cursor: pointer;
}
.profile-menu summary::-webkit-details-marker {
    display: none;           /* Hide the same triangle on older Safari/WebKit */
}

.profile-menu__trigger {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 6px var(--space-3);
    border-radius: var(--radius-md);
    color: var(--color-on-surface);
    font-size: 13px;
    font-weight: 500;
    transition: background-color 150ms ease;
}
.profile-menu__trigger:hover {
    background: var(--color-surface-container-low);
}
.profile-menu[open] > .profile-menu__trigger {
    background: var(--color-surface-container-low);
}
.profile-menu__trigger:focus-visible {
    outline: 2px solid var(--color-secondary);
    outline-offset: 2px;
}

.profile-menu__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0;
    flex-shrink: 0;
}

.profile-menu__email {
    color: var(--color-on-surface);
    line-height: 1.2;
}

.profile-menu__chevron {
    color: var(--color-on-surface-variant);
    transition: transform 200ms ease;
    flex-shrink: 0;
}
.profile-menu[open] .profile-menu__chevron {
    transform: rotate(180deg);
}

.profile-menu__panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 240px;
    background: var(--color-surface);
    border: 1px solid var(--color-outline-variant);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: var(--space-1);
    z-index: 40;
}

.profile-menu__header {
    padding: var(--space-3) var(--space-4) var(--space-2);
    border-bottom: 1px solid var(--color-outline-variant);
    margin-bottom: var(--space-1);
}
.profile-menu__header-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 2px;
}
.profile-menu__header-email {
    font-size: 13px;
    color: var(--color-on-surface);
    overflow-wrap: anywhere;
    word-break: break-all;
}

/* Menu items: both the <a> and the <button> inside the logout <form> share
 * this class. Default button styling is overridden so the Log out option
 * reads like a menu row, not a CTA. */
.profile-menu__item,
button.profile-menu__item {
    display: block;
    width: 100%;
    text-align: left;
    padding: var(--space-3) var(--space-4);
    border: none;
    background: transparent;
    color: var(--color-on-surface);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    height: auto;        /* Reset the global button { height: 40px } */
    transition: background-color 150ms ease, color 150ms ease;
}
.profile-menu__item:hover,
button.profile-menu__item:hover {
    background: var(--color-surface-container-low);
    color: var(--color-secondary);
    text-decoration: none;
}
.profile-menu__item:focus-visible,
button.profile-menu__item:focus-visible {
    outline: 2px solid var(--color-secondary);
    outline-offset: -2px;
}

.profile-menu__item--danger,
button.profile-menu__item--danger {
    color: var(--color-on-error-container);
}
.profile-menu__item--danger:hover,
button.profile-menu__item--danger:hover {
    background: var(--color-error-container);
    color: var(--color-on-error-container);
}

.profile-menu__form {
    margin: 0;
    display: block;
}

/* Hide the email text on very narrow screens — the avatar + chevron
 * carry enough affordance. */
@media (max-width: 480px) {
    .profile-menu__email { display: none; }
    .profile-menu__panel { right: 0; min-width: 200px; }
}

.app-shell__content {
    flex: 1;
    padding: var(--space-8);
    max-width: 1280px;
    width: 100%;
}

@media (max-width: 1023px) {
    .app-shell__sidebar {
        position: relative;
        width: 100%;
        height: auto;
    }
    .app-shell__main { margin-left: 0; }
    .app-shell__content { padding: var(--space-4); }
}

/* ---------------------------------------------------------------------------
 * Typography
 * ------------------------------------------------------------------------- */
h1 {
    font-family: var(--font-heading);
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--color-primary);
    margin: 0 0 var(--space-6) 0;
    line-height: 1.2;
}

h2 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--color-primary);
    margin: var(--space-8) 0 var(--space-4) 0;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

h3 {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 600;
    color: var(--color-on-surface);
    margin: var(--space-6) 0 var(--space-3) 0;
}

small { font-size: 12px; color: var(--color-on-surface-variant); }

/* ---------------------------------------------------------------------------
 * Cards
 * ------------------------------------------------------------------------- */
.card,
section {
    background: var(--color-surface);
    border: 1px solid var(--color-outline-variant);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
}

section:first-of-type { margin-top: 0; }
section h2:first-child { margin-top: 0; }

/* ---------------------------------------------------------------------------
 * Forms
 * ------------------------------------------------------------------------- */
label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-on-surface);
    letter-spacing: 0.02em;
    margin-bottom: var(--space-1);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="search"],
input[type="url"],
select,
textarea {
    display: block;
    width: 100%;
    max-width: 480px;
    height: 40px;
    padding: 0 var(--space-4);
    background: var(--color-surface-container-low);
    border: none;
    border-bottom: 1px solid var(--color-outline);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-family: inherit;
    font-size: 14px;
    color: var(--color-on-surface);
    transition: outline 100ms ease;
    margin-bottom: var(--space-3);
}

textarea {
    height: auto;
    min-height: 120px;
    padding: var(--space-3) var(--space-4);
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--color-secondary);
    outline-offset: -2px;
    border-bottom-color: transparent;
}

input[type="checkbox"],
input[type="radio"] {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin: 0 var(--space-2) 0 0;
    accent-color: var(--color-secondary);
    vertical-align: middle;
}

fieldset {
    border: 1px solid var(--color-outline-variant);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-6);
    margin: 0 0 var(--space-4) 0;
    background: var(--color-surface-bright);
}

fieldset legend {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-on-surface-variant);
    padding: 0 var(--space-2);
}

p.errors,
.error,
p.error,
ul.errors li,
span.error {
    color: var(--color-on-error-container);
    font-size: 13px;
    font-weight: 600;
}

ul.errors { list-style: none; padding: 0; margin: var(--space-2) 0; }

/* ---------------------------------------------------------------------------
 * Buttons
 * ------------------------------------------------------------------------- */
button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 var(--space-4);
    border: none;
    border-radius: var(--radius-sm);
    background: var(--color-secondary);
    color: white;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease,
        border-color 150ms ease;
    text-decoration: none;
}

button:hover,
.button:hover {
    background: var(--color-secondary-hover);
    color: white;
    text-decoration: none;
}

button:focus-visible,
.button:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.button--secondary,
button.button--secondary {
    background: transparent;
    color: var(--color-secondary);
    border: 1px solid var(--color-secondary);
}
.button--secondary:hover,
button.button--secondary:hover {
    background: var(--color-secondary);
    color: white;
}

.button--ghost,
button.button--ghost {
    background: transparent;
    color: var(--color-secondary);
}
.button--ghost:hover,
button.button--ghost:hover {
    background: var(--color-surface-container);
    color: var(--color-secondary);
}

.button--danger,
button.button--danger {
    background: var(--color-error);
    color: white;
}
.button--danger:hover,
button.button--danger:hover {
    background: var(--color-on-error-container);
}

/* Inline button used inside table rows / action lists. */
form[style*="display:inline"] button {
    height: 32px;
    padding: 0 var(--space-3);
    font-size: 13px;
}

/* ---------------------------------------------------------------------------
 * Tables
 * ------------------------------------------------------------------------- */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border: 1px solid var(--color-outline-variant);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin: 0 0 var(--space-6) 0;
}

thead {
    background: var(--color-surface-container);
}

th, td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-size: 14px;
    border-bottom: 1px solid var(--color-outline-variant);
    vertical-align: middle;
}

th {
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-on-surface-variant);
}

tbody tr:nth-child(even) {
    background: var(--color-surface-container-low);
}

tbody tr:last-child td { border-bottom: none; }

/* ---------------------------------------------------------------------------
 * Clickable table rows (voicemails list).
 *
 * Each cell holds an <a> that fills the cell's full area — clicking anywhere
 * on the row navigates to the linked page. The td loses its padding and
 * hands it to the <a> so the click target reaches all the way to the cell
 * border. Tab navigation only stops on the first link per row (others are
 * tabindex="-1" in the template) so keyboard users walk rows, not cells.
 *
 * Hover lifts the whole row to a higher surface tone so the operator sees
 * the click target clearly. nth-child(even) zebra-striping is overridden
 * on hover so the highlight wins regardless of row parity.
 * ------------------------------------------------------------------------- */
table.rows-clickable tbody tr.row-link td {
    padding: 0;
}
table.rows-clickable tbody tr.row-link td > a {
    display: block;
    padding: var(--space-3) var(--space-4);
    color: inherit;
    text-decoration: none;
}
table.rows-clickable tbody tr.row-link:hover {
    background: var(--color-surface-container);
    cursor: pointer;
}
table.rows-clickable tbody tr.row-link:hover td > a {
    color: var(--color-on-surface);
    text-decoration: none;
}
table.rows-clickable tbody tr.row-link td > a:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
}

/* ---------------------------------------------------------------------------
 * Status badges (VM-3.16 contract)
 * ------------------------------------------------------------------------- */
.status-badge {
    display: inline-block;
    padding: 2px var(--space-2);
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--color-surface-container);
    color: var(--color-on-surface-variant);
    vertical-align: middle;
}
.status-badge--pending {
    background: var(--color-surface-container);
    color: var(--color-on-surface-variant);
}
.status-badge--running {
    background: rgba(0, 81, 213, 0.12);
    color: var(--color-secondary);
}
.status-badge--ready {
    background: var(--color-success-container);
    color: var(--color-on-success-container);
}
.status-badge--failed {
    background: var(--color-error-container);
    color: var(--color-on-error-container);
}
.status-badge--skipped {
    background: var(--color-warning-container);
    color: var(--color-on-warning-container);
}

/* ---------------------------------------------------------------------------
 * Flash messages
 * ------------------------------------------------------------------------- */
.flash {
    padding: var(--space-3) var(--space-4);
    margin: 0 0 var(--space-3) 0;
    border-radius: var(--radius-sm);
    border-left: 4px solid;
    font-size: 14px;
    line-height: 1.4;
}
.flash-success {
    background: var(--color-success-container);
    color: var(--color-on-success-container);
    border-color: var(--color-success);
}
.flash-error {
    background: var(--color-error-container);
    color: var(--color-on-error-container);
    border-color: var(--color-error);
}
.flash-info {
    background: rgba(0, 81, 213, 0.08);
    color: var(--color-secondary);
    border-color: var(--color-secondary);
}

/* ---------------------------------------------------------------------------
 * Metadata description list
 * ------------------------------------------------------------------------- */
dl.metadata {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--space-2) var(--space-6);
    margin: 0 0 var(--space-4) 0;
}
dl.metadata dt {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding-top: 2px;
}
dl.metadata dd {
    margin: 0;
    font-size: 14px;
    color: var(--color-on-surface);
}

/* Generic dl (token issued page) */
dl:not(.metadata) dt {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-on-surface-variant);
    margin-bottom: 2px;
}
dl:not(.metadata) dd {
    margin: 0 0 var(--space-3) 0;
    font-size: 14px;
}

/* ---------------------------------------------------------------------------
 * Transcript / summary text
 * ------------------------------------------------------------------------- */
.transcript-text {
    background: var(--color-surface-bright);
    padding: var(--space-4);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-secondary);
    white-space: pre-wrap;
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 var(--space-3) 0;
}

.summary-text {
    background: var(--color-surface-bright);
    padding: var(--space-4);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--color-success);
    font-style: italic;
    font-size: 16px;
    line-height: 1.55;
    margin: 0 0 var(--space-3) 0;
}

.placeholder {
    color: var(--color-on-surface-variant);
    font-style: italic;
    font-size: 14px;
}

.retry-form {
    margin-top: var(--space-3);
}

/* ---------------------------------------------------------------------------
 * Status controls — segmented pill group on the voicemail detail page.
 *
 * Three buttons (New / Heard / Archived) joined into a single capsule so the
 * operator perceives them as one control. Each button is a separate form
 * (so the existing POST shape stays unchanged), but display: contents on the
 * form removes its block-level wrapper from layout — the buttons sit flush
 * against one another and share rounded outer corners only on the ends.
 *
 * The button matching the voicemail's current status carries .--active and
 * the `disabled` attribute. That serves two roles: it visually marks the
 * current state (no separate badge needed), and it short-circuits the
 * pointless "change to current status" click. aria-pressed reflects the
 * same state for screen readers.
 * ------------------------------------------------------------------------- */
.status-controls {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin: 0 0 var(--space-6) 0;
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface-bright);
    border: 1px solid var(--color-outline-variant);
    border-radius: var(--radius-md);
}
.status-controls__label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-on-surface-variant);
}
.status-controls__group {
    display: inline-flex;
    border: 1px solid var(--color-outline-variant);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--color-surface);
}
.status-controls__form {
    display: contents;
}

button.status-pill {
    height: 36px;
    padding: 0 var(--space-4);
    border: 0;
    border-right: 1px solid var(--color-outline-variant);
    border-radius: 0;
    background: var(--color-surface);
    color: var(--color-on-surface-variant);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
}
.status-controls__form:last-child button.status-pill {
    border-right: 0;
}
button.status-pill:hover {
    background: var(--color-surface-container-low);
    color: var(--color-on-surface);
}
button.status-pill:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
}
button.status-pill.status-pill--active,
button.status-pill.status-pill--active:hover {
    background: var(--color-secondary);
    color: white;
    cursor: default;
}

/* ---------------------------------------------------------------------------
 * Data handling banner (VM-3.18)
 * ------------------------------------------------------------------------- */
.data-handling-banner {
    background: var(--color-surface-bright);
    border: 1px solid var(--color-outline-variant);
    border-left: 4px solid var(--color-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-6);
    margin: 0 0 var(--space-6) 0;
}
.data-handling-banner h2 {
    margin-top: 0;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-secondary);
}

/* ---------------------------------------------------------------------------
 * Filters bar + pagination
 * ------------------------------------------------------------------------- */
.filters {
    display: flex;
    align-items: end;
    gap: var(--space-3);
    flex-wrap: wrap;
    padding: var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-outline-variant);
    border-radius: var(--radius-md);
    margin: 0 0 var(--space-6) 0;
}
.filters label {
    margin-bottom: 0;
    flex: 1 1 160px;
    min-width: 140px;
}
.filters input,
.filters select {
    margin-bottom: 0;
    max-width: none;
}
.filters button {
    margin-top: 0;
    align-self: end;
}

.pagination {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    justify-content: center;
    margin: var(--space-6) 0;
}
.pagination span { color: var(--color-on-surface-variant); font-size: 13px; }

/* ---------------------------------------------------------------------------
 * Voicemail detail actions (status change + delete forms in same row)
 * ------------------------------------------------------------------------- */
section.actions {
    display: flex;
    gap: var(--space-4);
    flex-wrap: wrap;
    align-items: end;
}
section.actions form {
    display: flex;
    align-items: end;
    gap: var(--space-3);
    margin: 0;
}
section.actions form label { margin-bottom: 0; }
section.actions form select { max-width: 200px; margin-bottom: 0; }

/* ---------------------------------------------------------------------------
 * Audio player
 * ------------------------------------------------------------------------- */
audio {
    width: 100%;
    max-width: 600px;
    display: block;
    margin: var(--space-3) 0;
}

/* ---------------------------------------------------------------------------
 * Tokens / one-time secret display
 * ------------------------------------------------------------------------- */
pre.token-plaintext {
    background: var(--color-primary);
    color: var(--color-surface-bright);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    font-size: 16px;
    overflow-wrap: anywhere;
    word-break: break-all;
    white-space: pre-wrap;
}

/* ---------------------------------------------------------------------------
 * Dashboard counts
 * ------------------------------------------------------------------------- */
section.counts {
    display: flex;
    gap: var(--space-4);
    flex-wrap: wrap;
}
section.counts p {
    flex: 1 1 160px;
    background: var(--color-surface-bright);
    padding: var(--space-4) var(--space-6);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-outline-variant);
    margin: 0;
    font-size: 18px;
    color: var(--color-primary);
    font-weight: 700;
}
section.counts p strong {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--color-on-surface-variant);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

ul.recent-list,
section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
section ul li {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-outline-variant);
}
section ul li:last-child { border-bottom: none; }

/* ---------------------------------------------------------------------------
 * Logs viewer
 * ------------------------------------------------------------------------- */
.log-filters {
    display: flex;
    gap: var(--space-3);
    align-items: end;
    flex-wrap: wrap;
    padding: var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-outline-variant);
    border-radius: var(--radius-md);
    margin: 0 0 var(--space-4) 0;
}
.log-filters label { margin-bottom: 0; }
.log-filters input,
.log-filters select { margin-bottom: 0; max-width: none; }

table.logs td {
    font-family: var(--font-mono);
    font-size: 12px;
    vertical-align: top;
    line-height: 1.45;
}
table.logs th { font-size: 11px; }
table.logs details summary {
    cursor: pointer;
    color: var(--color-secondary);
    font-size: 12px;
}

/* Raw-row expander.
 *
 * Each log entry renders two <tr>s — the data row and a follow-up
 * "raw" row that's hidden by default. Clicking the <summary> in the
 * data row toggles its <details> to [open]; the :has() selector on
 * the data row then targets the next-sibling raw row and reveals it.
 * Pure CSS, no JS, full-table-width payload instead of being shoved
 * into the rightmost Details cell.
 *
 * :has() is supported in every browser the admin UI targets (Chrome
 * 105+, Safari 15.4+, Firefox 121+); this is an internal tool so
 * older browsers are not in scope. */
table.logs .log-row__raw-row { display: none; }
table.logs .log-row:has(details[open]) + .log-row__raw-row,
table.logs .log-row--malformed:has(details[open]) + .log-row__raw-row {
    display: table-row;
}
table.logs .log-row__raw-row td {
    background: var(--color-surface-container);
    padding: var(--space-3) var(--space-4);
}
table.logs .log-row__raw-row pre {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-all;
    background: transparent;
    padding: 0;
}

.log-level--error,
.log-level--critical {
    background: rgba(186, 26, 26, 0.06) !important;
}
.log-level--warning {
    background: rgba(255, 200, 0, 0.06) !important;
}
.log-row--malformed {
    background: var(--color-error-container) !important;
}

/* ---------------------------------------------------------------------------
 * Tenant-settings tab strip (Manage tenant page — VM-3.18 follow-up)
 * Renders the unified-page tab navigation across Overview / Users /
 * API tokens / AI settings. Each tab is a link to its own URL so deep
 * links work, but visually the operator perceives one cohesive page.
 * ------------------------------------------------------------------------- */
.tenant-page__header {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
}
.tenant-page__header h1 { margin: 0; }
.tenant-page__breadcrumbs {
    font-size: 13px;
    color: var(--color-on-surface-variant);
}

.tenant-tabs {
    display: flex;
    gap: var(--space-1);
    border-bottom: 1px solid var(--color-outline-variant);
    margin-bottom: var(--space-8);
    overflow-x: auto;
}
.tenant-tabs__tab {
    display: inline-flex;
    align-items: center;
    height: 44px;
    padding: 0 var(--space-4);
    color: var(--color-on-surface-variant);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.01em;
    border-bottom: 2px solid transparent;
    transition: color 150ms ease, border-color 150ms ease,
        background-color 150ms ease;
    white-space: nowrap;
}
.tenant-tabs__tab:hover {
    color: var(--color-secondary);
    background: var(--color-surface-container-low);
    text-decoration: none;
}
.tenant-tabs__tab--active {
    color: var(--color-secondary);
    border-bottom-color: var(--color-secondary);
}
.tenant-tabs__tab--active:hover {
    background: transparent;
}

/* ---------------------------------------------------------------------------
 * Login page (split-screen)
 * ------------------------------------------------------------------------- */
.login-shell {
    display: flex;
    min-height: 100vh;
    background: var(--color-surface);
}

.login-shell__brand-panel {
    display: none;
    flex-direction: column;
    justify-content: flex-end;
    flex: 1;
    background: linear-gradient(
        135deg,
        var(--color-primary) 0%,
        var(--color-primary-container) 100%
    );
    color: white;
    padding: var(--space-12);
    position: relative;
    overflow: hidden;
}

/* Decorative geometric lines to echo the design's abstract-blue image
 * without needing a remote asset. */
.login-shell__brand-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 70% 20%, rgba(0, 81, 213, 0.35), transparent 50%),
        radial-gradient(circle at 20% 80%, rgba(120, 169, 255, 0.20), transparent 50%);
    pointer-events: none;
}

.login-shell__brand-content {
    position: relative;
    z-index: 1;
    max-width: 480px;
}

.login-shell__brand-logo {
    display: block;
    max-width: 160px;
    width: 100%;
    height: auto;
    margin-bottom: var(--space-6);
}

.login-shell__brand-title {
    font-family: var(--font-heading);
    font-size: 36px;
    font-weight: 700;
    margin: 0 0 var(--space-3) 0;
    color: white;
}
.login-shell__brand-tagline {
    font-size: 18px;
    font-weight: 300;
    opacity: 0.92;
    margin: 0;
}
.login-shell__brand-rule {
    width: 48px;
    height: 4px;
    background: var(--color-secondary);
    margin-top: var(--space-6);
}

.login-shell__form-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--space-8);
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
}

.login-shell__form-header {
    margin-bottom: var(--space-12);
}
.login-shell__form-title {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 700;
    color: var(--color-on-surface);
    margin: 0 0 var(--space-2) 0;
}
.login-shell__form-subtitle {
    font-size: 13px;
    color: var(--color-on-surface-variant);
    margin: 0;
}

.login-shell__form-panel form { display: block; }
.login-shell__form-panel form p { margin: 0 0 var(--space-4) 0; }
.login-shell__form-panel input { max-width: none; }
.login-shell__form-panel button { width: 100%; height: 48px; }

.login-shell__footer {
    margin-top: var(--space-12);
    font-size: 12px;
    color: var(--color-on-surface-variant);
}

@media (min-width: 1024px) {
    .login-shell__brand-panel { display: flex; }
    .login-shell__form-panel { max-width: none; padding: var(--space-12) 96px; }
}

/* ---------------------------------------------------------------------------
 * Settings (global admin user management — VM-52)
 *
 * The list page uses a flex header so the page title sits on the left and
 * the primary CTA ("New global admin") on the right. Per-row actions are
 * grouped right-aligned with consistent spacing; the destructive Delete
 * button is rendered with .button--danger and gated behind a confirm in
 * the template. Form pages re-use .tenant-page__header for the breadcrumb
 * and stick to a narrow column so single-purpose forms read at a glance.
 * ------------------------------------------------------------------------- */
.settings-page__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-6);
    margin-bottom: var(--space-6);
}
.settings-page__header h1 {
    margin: var(--space-1) 0 var(--space-2) 0;
}
.settings-page__header > div {
    max-width: 720px;
}

.settings-users__actions-col {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}
.settings-users__actions {
    display: flex;
    gap: var(--space-2);
    justify-content: flex-end;
    align-items: center;
}
.settings-users__actions .button {
    height: 32px;
    padding: 0 var(--space-3);
    font-size: 13px;
}
.settings-users__delete-form { margin: 0; }

.settings-form {
    max-width: 480px;
    background: var(--color-surface);
    border: 1px solid var(--color-outline-variant);
    border-radius: var(--radius-md);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
}
.settings-form label {
    display: block;
    margin-bottom: var(--space-4);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-on-surface-variant);
}
.settings-form input {
    display: block;
    width: 100%;
    margin-top: var(--space-1);
    height: 40px;
    padding: 0 var(--space-3);
    border: 1px solid var(--color-outline-variant);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-on-surface);
    font: inherit;
    font-size: 14px;
}
.settings-form input:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
    border-color: var(--color-secondary);
}
.settings-form__hint {
    margin: calc(-1 * var(--space-3)) 0 var(--space-4) 0;
    font-size: 12px;
}
.settings-form__actions {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    margin-top: var(--space-6);
}
.settings-form__aside {
    max-width: 480px;
    font-size: 13px;
}

/* ---------------------------------------------------------------------------
 * Tenant Users page — side-by-side add-flow cards (VM-53)
 *
 * Two cards (Create + Assign) sit side by side at wider viewports and
 * stack vertically below 720px so each card keeps a usable input width.
 * Inputs inside the cards are full-width to keep alignment consistent
 * with the .settings-form pattern; spacing matches the 4/8px grid.
 * ------------------------------------------------------------------------- */
.tenant-users__forms {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
@media (min-width: 720px) {
    .tenant-users__forms {
        grid-template-columns: 1fr 1fr;
    }
}
.tenant-users__form-card {
    background: var(--color-surface);
    border: 1px solid var(--color-outline-variant);
    border-radius: var(--radius-md);
    padding: var(--space-6);
}
.tenant-users__form-card h2 {
    margin-top: 0;
}
.tenant-users__form-card label {
    display: block;
    margin-bottom: var(--space-3);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-on-surface-variant);
}
.tenant-users__form-card input {
    display: block;
    width: 100%;
    margin-top: var(--space-1);
    height: 40px;
    padding: 0 var(--space-3);
    border: 1px solid var(--color-outline-variant);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-on-surface);
    font: inherit;
    font-size: 14px;
}
.tenant-users__form-card input:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
    border-color: var(--color-secondary);
}
.tenant-users__hint {
    margin: calc(-1 * var(--space-2)) 0 var(--space-3) 0;
    font-size: 12px;
}

/* Row-level actions in the Current members table. Right-aligned button
 * group with consistent spacing; uses the inline-button size shared
 * with the existing per-row Remove form. */
.tenant-users__row-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}
.tenant-users__row-actions .button,
.tenant-users__row-actions button {
    height: 32px;
    padding: 0 var(--space-3);
    font-size: 13px;
    margin-left: var(--space-2);
}
.tenant-users__row-actions > :first-child {
    margin-left: 0;
}
