/*
 * Tiny House Village design system (thv.css)
 * One stylesheet for the resident portal, partner portal, sign-in pages, legal pages and
 * print views. Filament admin loads it too (resources/views/filament/styles.blade.php) so the
 * same thv-* classes work inside custom admin pages.
 *
 * Rules: zinc neutrals, Inter, 6px radius (4px for badges), 1px borders, color only for meaning
 * (green = paid / Green level / done, amber = open / due soon / Yellow level, red = overdue /
 * Red level / errors). Reference: docs/DESIGN.md. Keep class names stable.
 *
 * Every page that is not Filament puts class="thv" on <body>. Element defaults (type, links,
 * form controls) only apply inside .thv, so nothing here leaks into Filament.
 */

/* ------------------------------------------------------------------ */
/* 1. Tokens                                                           */
/* ------------------------------------------------------------------ */
:root {
    --thv-bg: #fafafa;
    --thv-surface: #ffffff;
    --thv-surface-muted: #f4f4f5;
    --thv-hover: #f4f4f5;
    --thv-ink: #18181b;
    --thv-ink-soft: #3f3f46;
    --thv-muted: #71717a;
    --thv-faint: #a1a1aa;
    --thv-line: #e4e4e7;
    --thv-line-strong: #d4d4d8;

    --thv-primary: #18181b;
    --thv-primary-hover: #27272a;
    --thv-primary-ink: #ffffff;
    --thv-ring: 0 0 0 3px rgba(24, 24, 27, 0.12);

    --thv-green: #15803d;
    --thv-green-bg: #f0fdf4;
    --thv-green-line: #bbf7d0;
    --thv-amber: #b45309;
    --thv-amber-bg: #fffbeb;
    --thv-amber-line: #fde68a;
    --thv-red: #b91c1c;
    --thv-red-bg: #fef2f2;
    --thv-red-line: #fecaca;

    --thv-radius: 6px;
    --thv-radius-sm: 4px;
    --thv-shadow: 0 1px 2px rgba(24, 24, 27, 0.04);
    --thv-shadow-pop: 0 8px 24px rgba(24, 24, 27, 0.10);

    --thv-font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --thv-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --thv-sidebar-w: 240px;
    --thv-content-w: 1080px;
    --thv-topbar-h: 56px;

    /* Older names still used by a few admin page blades. */
    --thv-page: var(--thv-bg);
    --thv-card: var(--thv-surface);
    --thv-sidebar: var(--thv-surface);
    --thv-leaf: var(--thv-green);

    color-scheme: light;
}

/* Dark tokens. Portal pages follow the device setting; Filament follows its own toggle (html.fi.dark). */
@media (prefers-color-scheme: dark) {
    :root:not(.fi):not([data-theme="light"]) {
        --thv-bg: #09090b;
        --thv-surface: #18181b;
        --thv-surface-muted: #27272a;
        --thv-hover: #27272a;
        --thv-ink: #fafafa;
        --thv-ink-soft: #d4d4d8;
        --thv-muted: #a1a1aa;
        --thv-faint: #71717a;
        --thv-line: #27272a;
        --thv-line-strong: #3f3f46;
        --thv-primary: #fafafa;
        --thv-primary-hover: #e4e4e7;
        --thv-primary-ink: #18181b;
        --thv-ring: 0 0 0 3px rgba(250, 250, 250, 0.16);
        --thv-green: #4ade80;
        --thv-green-bg: rgba(34, 197, 94, 0.12);
        --thv-green-line: rgba(34, 197, 94, 0.30);
        --thv-amber: #fbbf24;
        --thv-amber-bg: rgba(245, 158, 11, 0.12);
        --thv-amber-line: rgba(245, 158, 11, 0.30);
        --thv-red: #f87171;
        --thv-red-bg: rgba(239, 68, 68, 0.12);
        --thv-red-line: rgba(239, 68, 68, 0.30);
        --thv-shadow: 0 0 #0000;
        --thv-shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.5);
        color-scheme: dark;
    }
}

:root[data-theme="dark"],
html.fi.dark {
    --thv-bg: #09090b;
    --thv-surface: #18181b;
    --thv-surface-muted: #27272a;
    --thv-hover: #27272a;
    --thv-ink: #fafafa;
    --thv-ink-soft: #d4d4d8;
    --thv-muted: #a1a1aa;
    --thv-faint: #71717a;
    --thv-line: #27272a;
    --thv-line-strong: #3f3f46;
    --thv-primary: #fafafa;
    --thv-primary-hover: #e4e4e7;
    --thv-primary-ink: #18181b;
    --thv-ring: 0 0 0 3px rgba(250, 250, 250, 0.16);
    --thv-green: #4ade80;
    --thv-green-bg: rgba(34, 197, 94, 0.12);
    --thv-green-line: rgba(34, 197, 94, 0.30);
    --thv-amber: #fbbf24;
    --thv-amber-bg: rgba(245, 158, 11, 0.12);
    --thv-amber-line: rgba(245, 158, 11, 0.30);
    --thv-red: #f87171;
    --thv-red-bg: rgba(239, 68, 68, 0.12);
    --thv-red-line: rgba(239, 68, 68, 0.30);
    --thv-shadow: 0 0 #0000;
    --thv-shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
}

/* ------------------------------------------------------------------ */
/* 2. Base (only inside <body class="thv">)                            */
/* ------------------------------------------------------------------ */
:where(.thv),
:where(.thv) *,
:where(.thv) *::before,
:where(.thv) *::after {
    box-sizing: border-box;
}

:where(.thv) {
    margin: 0;
    min-height: 100vh;
    font-family: var(--thv-font);
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: -0.006em;
    color: var(--thv-ink);
    background: var(--thv-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

:where(.thv) :where(h1, h2, h3, h4) {
    margin: 0;
    color: var(--thv-ink);
    font-weight: 600;
    line-height: 1.3;
}
:where(.thv) h1 { font-size: 24px; letter-spacing: -0.015em; }
:where(.thv) h2 { font-size: 16px; letter-spacing: -0.005em; }
:where(.thv) h3 { font-size: 15px; }
:where(.thv) h4 { font-size: 14px; }

:where(.thv) a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--thv-line-strong);
    text-underline-offset: 2px;
}
:where(.thv) a:hover { text-decoration-color: currentColor; }
:where(.thv) :where(img, svg) { max-width: 100%; }
:where(.thv) :where(strong, b) { font-weight: 600; }
:where(.thv) code {
    font-family: var(--thv-font-mono);
    font-size: 0.9em;
    padding: 1px 4px;
    border-radius: var(--thv-radius-sm);
    background: var(--thv-surface-muted);
}
:where(.thv) hr { border: 0; border-top: 1px solid var(--thv-line); margin: 24px 0; }
:where(.thv) :focus-visible { outline: 2px solid var(--thv-ink); outline-offset: 2px; }
:where(.thv) [hidden] { display: none !important; }

/* Form controls get the input look by default inside .thv pages. */
:where(.thv) :where(button, input, select, textarea) { font: inherit; color: inherit; }
:where(.thv) :where(
    input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):not([type="submit"]):not([type="button"]):not([type="range"]):not([type="color"]),
    select,
    textarea
) {
    display: block;
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    font-size: 15px;
    line-height: 1.4;
    color: var(--thv-ink);
    background: var(--thv-surface);
    border: 1px solid var(--thv-line-strong);
    border-radius: var(--thv-radius);
    box-shadow: var(--thv-shadow);
    transition: border-color 0.1s ease, box-shadow 0.1s ease;
}
:where(.thv) :where(textarea) { min-height: 96px; resize: vertical; }
:where(.thv) :where(input, select, textarea):focus { outline: none; border-color: var(--thv-ink); box-shadow: var(--thv-ring); }
:where(.thv) :where(input, select, textarea)::placeholder { color: var(--thv-faint); }
:where(.thv) :where(input[type="checkbox"], input[type="radio"]) { width: 16px; height: 16px; margin: 0; accent-color: var(--thv-primary); }
:where(.thv) :where(input[type="file"]) {
    display: block;
    width: 100%;
    font-size: 14px;
    color: var(--thv-muted);
    padding: 6px;
    border: 1px dashed var(--thv-line-strong);
    border-radius: var(--thv-radius);
    background: var(--thv-surface);
}
:where(.thv) :where(input[type="file"])::file-selector-button {
    font: inherit;
    font-weight: 500;
    color: var(--thv-ink);
    margin-right: 10px;
    padding: 6px 12px;
    border: 1px solid var(--thv-line-strong);
    border-radius: var(--thv-radius);
    background: var(--thv-surface);
    cursor: pointer;
}

/* ------------------------------------------------------------------ */
/* 3. App shell (portal + partner portal)                              */
/* ------------------------------------------------------------------ */
.thv-shell {
    display: grid;
    grid-template-columns: var(--thv-sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
}

.thv-topbar { display: none; }

.thv-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 20px 12px 16px;
    background: var(--thv-surface);
    border-right: 1px solid var(--thv-line);
}

.thv-brand {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px 16px;
    text-decoration: none;
}
.thv-brand img, .thv-logo { display: block; height: 40px; width: auto; }

.thv-sidebar-label {
    padding: 0 8px 8px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--thv-muted);
}

.thv-nav { display: flex; flex-direction: column; gap: 2px; margin: 0; }
.thv-nav form { margin: 0; }
.thv-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 36px;
    padding: 7px 10px;
    border: 0;
    border-radius: var(--thv-radius);
    background: transparent;
    color: var(--thv-ink-soft);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.1s ease, color 0.1s ease;
}
.thv-nav-item:hover { background: var(--thv-hover); color: var(--thv-ink); }
.thv-nav-item.is-active,
.thv-nav-item[aria-current="page"] {
    background: var(--thv-surface-muted);
    color: var(--thv-ink);
    font-weight: 600;
}
.thv-nav-icon {
    width: 18px;
    height: 18px;
    flex: none;
    color: var(--thv-muted);
}
.thv-nav-item.is-active .thv-nav-icon,
.thv-nav-item[aria-current="page"] .thv-nav-icon { color: var(--thv-ink); }

.thv-count {
    margin-left: auto;
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--thv-primary);
    color: var(--thv-primary-ink);
    font-size: 11px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.thv-sidebar-foot {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--thv-line);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.thv-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 8px;
    min-width: 0;
}
.thv-user > div { min-width: 0; }
.thv-user-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.thv-user-meta { display: block; font-size: 12px; color: var(--thv-muted); }

.thv-avatar {
    width: 32px;
    height: 32px;
    flex: none;
    border-radius: 999px;
    object-fit: cover;
    background: var(--thv-surface-muted);
    color: var(--thv-ink-soft);
    display: inline-grid;
    place-items: center;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.thv-avatar-lg { width: 64px; height: 64px; font-size: 18px; }

.thv-legal-links {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    padding: 8px 10px 0;
    font-size: 12px;
}
.thv-legal-links a { color: var(--thv-muted); text-decoration: none; }
.thv-legal-links a:hover { color: var(--thv-ink); }

.thv-main { min-width: 0; }
.thv-container {
    width: 100%;
    max-width: var(--thv-content-w);
    padding: 32px 40px 64px;
}
.thv-container-wide { max-width: 1280px; }

.thv-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 6px 12px;
    border: 1px solid var(--thv-line-strong);
    border-radius: var(--thv-radius);
    background: var(--thv-surface);
    color: var(--thv-ink);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}
.thv-menu-btn svg { width: 18px; height: 18px; }

@media (max-width: 900px) {
    .thv-shell { display: block; }
    .thv-topbar {
        position: sticky;
        top: 0;
        z-index: 40;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        height: var(--thv-topbar-h);
        padding: 0 16px;
        background: var(--thv-surface);
        border-bottom: 1px solid var(--thv-line);
    }
    .thv-topbar .thv-brand { padding: 0; }
    .thv-topbar .thv-brand img, .thv-topbar .thv-logo { height: 32px; }
    .thv-sidebar {
        display: none;
        position: fixed;
        z-index: 39;
        top: var(--thv-topbar-h);
        left: 0;
        right: 0;
        bottom: 0;
        height: auto;
        padding: 12px 16px 24px;
        border-right: 0;
    }
    .thv-sidebar > .thv-brand { display: none; }
    .thv-shell.is-open .thv-sidebar { display: flex; }
    .thv-nav-item { min-height: 44px; font-size: 15px; }
    .thv-container { padding: 20px 16px 48px; }
}

/* Impersonation (staff viewing the portal as a resident) */
.thv-impersonation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin: 0 0 24px;
    padding: 10px 12px 10px 16px;
    border-radius: var(--thv-radius);
    background: var(--thv-primary);
    color: var(--thv-primary-ink);
    font-size: 14px;
}
.thv-impersonation form { margin: 0; }
.thv-impersonation .thv-btn {
    background: var(--thv-primary-ink);
    color: var(--thv-primary);
    border-color: transparent;
}

/* ------------------------------------------------------------------ */
/* 4. Simple pages: sign-in, home, legal                               */
/* ------------------------------------------------------------------ */
.thv-auth {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 40px 16px;
}
.thv-auth-card {
    width: 100%;
    max-width: 400px;
    padding: 32px;
    background: var(--thv-surface);
    border: 1px solid var(--thv-line);
    border-radius: var(--thv-radius);
    box-shadow: var(--thv-shadow);
}
/* A wider card for step-by-step pages (secure links). */
.thv-auth-card-wide { max-width: 560px; }
.thv-auth-logo { display: block; height: 56px; width: auto; margin: 0 auto 24px; }
.thv-auth-head { text-align: center; margin: 0 0 24px; }
.thv-auth-title { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.015em; }
.thv-auth-desc { margin: 6px 0 0; color: var(--thv-muted); font-size: 14px; line-height: 1.5; }
.thv-auth-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 16px;
    margin: 20px 0 0;
    font-size: 13px;
}
.thv-auth-links a { color: var(--thv-muted); text-decoration: none; }
.thv-auth-links a:hover { color: var(--thv-ink); text-decoration: underline; }
@media (max-width: 480px) {
    .thv-auth { justify-content: flex-start; padding-top: 32px; }
    .thv-auth-card { padding: 24px 20px; }
}

/* Single sign-on block (shared by resident, partner and staff sign-in) */
.thv-sso { margin: 0 0 4px; }
.thv-sso-copy { margin: 0 0 12px; color: var(--thv-muted); font-size: 14px; text-align: center; }
.thv-sso-error { margin: 0 0 12px; color: var(--thv-red); font-size: 14px; text-align: center; }
/* Google and Apple are both outlined (secondary) 40px buttons, so "Sign in" is the only primary. */
.thv-sso-google { display: flex; justify-content: center; min-height: 40px; }
.thv-sso-apple {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 40px;
    margin-top: 10px;
    padding: 8px 14px;
    border: 1px solid var(--thv-line-strong);
    border-radius: var(--thv-radius);
    background: var(--thv-surface);
    color: var(--thv-ink);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    box-shadow: var(--thv-shadow);
}
.thv-sso-apple:hover { background: var(--thv-hover); color: var(--thv-ink); }
.thv-sso-apple svg { width: 16px; height: 16px; }
.thv-sso-rule {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0 4px;
    color: var(--thv-muted);
    font-size: 13px;
}
.thv-sso-rule::before, .thv-sso-rule::after { content: ""; flex: 1; height: 1px; background: var(--thv-line); }

/* Public site pages (legal, support) */
.thv-site-header {
    border-bottom: 1px solid var(--thv-line);
    background: var(--thv-surface);
}
.thv-site-inner {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 0 16px;
}
.thv-site-header .thv-site-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
    min-height: 64px;
    padding-top: 10px;
    padding-bottom: 10px;
}
.thv-site-header .thv-brand { padding: 0; }
.thv-site-header .thv-brand img { height: 36px; }
.thv-site-nav { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 14px; }
.thv-site-nav a { color: var(--thv-muted); text-decoration: none; font-weight: 500; }
.thv-site-nav a:hover { color: var(--thv-ink); }
.thv-site-main { padding-top: 32px; padding-bottom: 32px; }
.thv-site-footer { padding-bottom: 40px; color: var(--thv-muted); font-size: 13px; }

/* Long-form text (legal pages, lesson text, notice letters) */
.thv-prose { color: var(--thv-ink-soft); font-size: 15px; line-height: 1.65; }
.thv-prose > :first-child { margin-top: 0; }
.thv-prose > :last-child { margin-bottom: 0; }
.thv-prose h1 { margin: 0 0 16px; color: var(--thv-ink); font-size: 24px; }
.thv-prose h2 { margin: 32px 0 8px; color: var(--thv-ink); font-size: 17px; }
.thv-prose h3 { margin: 24px 0 8px; color: var(--thv-ink); font-size: 15px; }
.thv-prose p { margin: 0 0 14px; }
.thv-prose :is(ul, ol) { margin: 0 0 14px; padding-left: 22px; }
.thv-prose li { margin: 0 0 6px; }
.thv-prose a { color: var(--thv-ink); text-decoration-color: var(--thv-faint); }
.thv-prose strong { color: var(--thv-ink); }

/* ------------------------------------------------------------------ */
/* 5. Page header                                                      */
/* ------------------------------------------------------------------ */
.thv-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 24px;
    margin: 0 0 24px;
}
.thv-page-header > :first-child { min-width: 0; flex: 1 1 320px; }
.thv-page-title { margin: 0; font-size: 24px; font-weight: 600; line-height: 1.25; letter-spacing: -0.015em; color: var(--thv-ink); }
.thv-page-desc { margin: 6px 0 0; max-width: 680px; color: var(--thv-muted); font-size: 15px; line-height: 1.5; }
.thv-page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.thv-eyebrow {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--thv-muted);
}
.thv-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0 0 12px;
    color: var(--thv-muted);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}
.thv-back:hover { color: var(--thv-ink); }
.thv-back::before { content: "\2039"; font-size: 18px; line-height: 1; }

.thv-section-title { margin: 0 0 12px; font-size: 16px; font-weight: 600; color: var(--thv-ink); }

/* ------------------------------------------------------------------ */
/* 6. Cards                                                            */
/* ------------------------------------------------------------------ */
.thv-card {
    background: var(--thv-surface);
    border: 1px solid var(--thv-line);
    border-radius: var(--thv-radius);
    box-shadow: var(--thv-shadow);
    margin: 0 0 16px;
    min-width: 0;
}
.thv-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--thv-line);
}
.thv-card-header > :first-child { min-width: 0; }
.thv-card-title { margin: 0; font-size: 15px; font-weight: 600; line-height: 1.4; color: var(--thv-ink); }
.thv-card-desc { margin: 2px 0 0; font-size: 13px; color: var(--thv-muted); line-height: 1.45; }
.thv-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; }
.thv-card-body { padding: 20px; }
.thv-card-body > :first-child { margin-top: 0; }
.thv-card-body > :last-child { margin-bottom: 0; }
.thv-card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--thv-line);
    background: var(--thv-surface-muted);
    border-radius: 0 0 var(--thv-radius) var(--thv-radius);
}
.thv-card > .thv-table-wrap { border: 0; border-radius: 0 0 var(--thv-radius) var(--thv-radius); box-shadow: none; margin: 0; }
.thv-card > .thv-table-wrap:first-child { border-radius: var(--thv-radius); }
.thv-card > .thv-list:last-child > :last-child { border-radius: 0 0 var(--thv-radius) var(--thv-radius); }

/* Layout helpers */
.thv-stack { display: flex; flex-direction: column; gap: 16px; }
.thv-stack > * { margin-top: 0; margin-bottom: 0; }
.thv-stack-sm { gap: 8px; }
.thv-stack-lg { gap: 24px; }
.thv-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); margin: 0 0 16px; }
.thv-grid > * { margin: 0; }
@media (min-width: 768px) {
    .thv-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .thv-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .thv-span-2 { grid-column: span 2; }
    .thv-span-all { grid-column: 1 / -1; }
}
.thv-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; }
.thv-inline { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.thv-divider { border: 0; border-top: 1px solid var(--thv-line); margin: 20px 0; }

/* ------------------------------------------------------------------ */
/* 7. Stat tiles                                                       */
/* ------------------------------------------------------------------ */
.thv-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin: 0 0 24px;
}
.thv-stats-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.thv-stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.thv-stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
    .thv-stats-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
    .thv-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .thv-stats:not(.thv-stats-3) > :last-child:nth-child(odd) { grid-column: 1 / -1; }
    /* Three tiles stay on one row on phones (no lopsided orphan tile); one or two share the row. */
    .thv-stats.thv-stats-3 { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
    .thv-stats-3 > .thv-stat { padding: 12px; }
    .thv-stats-3 .thv-stat-value { font-size: 18px; }
    .thv-stats-3 .thv-stat-label, .thv-stats-3 .thv-stat-hint { font-size: 12px; }
}

.thv-stat-grid { /* older name, same look */
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0 0 24px;
}
@media (min-width: 1024px) {
    .thv-stat-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .thv-stat-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .thv-stat-grid.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.thv-stat {
    display: block;
    min-width: 0;
    padding: 16px 20px;
    background: var(--thv-surface);
    border: 1px solid var(--thv-line);
    border-radius: var(--thv-radius);
    box-shadow: var(--thv-shadow);
    color: inherit;
    text-decoration: none;
}
a.thv-stat:hover { border-color: var(--thv-line-strong); }
.thv-stat-label {
    display: block;
    margin: 0;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--thv-muted);
}
.thv-stat-value {
    display: block;
    margin: 6px 0 0;
    font-size: 24px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--thv-ink);
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.thv-stat-hint { display: block; margin: 4px 0 0; font-size: 13px; line-height: 1.4; color: var(--thv-muted); }
.thv-stat-label .thv-inline { flex-wrap: nowrap; gap: 6px; } /* a dot + label stays on one line */
.thv-stat-hint a { color: inherit; font-weight: 500; }
.thv-stat.is-green .thv-stat-value { color: var(--thv-green); }
.thv-stat.is-amber .thv-stat-value { color: var(--thv-amber); }
.thv-stat.is-red .thv-stat-value { color: var(--thv-red); }

/* ------------------------------------------------------------------ */
/* 8. Tables                                                           */
/* ------------------------------------------------------------------ */
.thv-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--thv-surface);
    border: 1px solid var(--thv-line);
    border-radius: var(--thv-radius);
    box-shadow: var(--thv-shadow);
    margin: 0 0 16px;
}
.thv-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 14px;
    line-height: 1.45;
    color: var(--thv-ink);
}
.thv-table th,
.thv-table td {
    padding: 10px 16px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--thv-line);
}
.thv-table thead th {
    padding-top: 9px;
    padding-bottom: 9px;
    background: var(--thv-surface-muted);
    color: var(--thv-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}
.thv-table tbody tr:last-child > * { border-bottom: 0; }
.thv-table tbody tr:hover > * { background: var(--thv-hover); }
.thv-table tfoot td, .thv-table tfoot th { font-weight: 600; border-top: 1px solid var(--thv-line-strong); border-bottom: 0; }
.thv-table a { color: var(--thv-ink); font-weight: 500; }
.thv-table .thv-num, .thv-table td.num, .thv-table th.num { text-align: right; }
.thv-table-compact th, .thv-table-compact td { padding: 6px 12px; }
.thv-table-bordered th, .thv-table-bordered td { border: 1px solid var(--thv-line); }
.thv-table-empty { padding: 24px 16px !important; text-align: center !important; color: var(--thv-muted); }

/* ------------------------------------------------------------------ */
/* 9. List rows                                                        */
/* ------------------------------------------------------------------ */
.thv-list { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.thv-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 56px;
    padding: 12px 20px;
    border-top: 1px solid var(--thv-line);
    color: inherit;
    text-decoration: none;
    font-size: 14px;
}
.thv-list > .thv-list-item:first-child,
.thv-card-header + .thv-list-item,
.thv-card-header + .thv-list > .thv-list-item:first-child { border-top: 0; }
a.thv-list-item { cursor: pointer; transition: background-color 0.1s ease; }
a.thv-list-item:hover { background: var(--thv-hover); }
a.thv-list-item::after {
    content: "";
    flex: none;
    width: 7px;
    height: 7px;
    margin-left: 4px;
    border-right: 1.5px solid var(--thv-faint);
    border-bottom: 1.5px solid var(--thv-faint);
    transform: rotate(-45deg);
}
.thv-list-item.is-unread { box-shadow: inset 3px 0 0 var(--thv-primary); }
.thv-list-main { min-width: 0; flex: 1 1 auto; }
.thv-list-title { display: block; font-size: 15px; font-weight: 500; color: var(--thv-ink); line-height: 1.4; }
.thv-list-item.is-unread .thv-list-title { font-weight: 600; }
.thv-list-meta { display: block; margin-top: 2px; font-size: 13px; color: var(--thv-muted); line-height: 1.4; }
.thv-list-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex: none;
    text-align: right;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}
@media (max-width: 480px) {
    .thv-list-item { padding: 12px 16px; gap: 12px; }
}

/* ------------------------------------------------------------------ */
/* 10. Badges                                                          */
/* ------------------------------------------------------------------ */
.thv-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 7px;
    border: 1px solid var(--thv-line);
    border-radius: var(--thv-radius-sm);
    background: var(--thv-surface-muted);
    color: var(--thv-ink-soft);
    font-size: 12px;
    font-weight: 500;
    line-height: 18px;
    white-space: nowrap;
    vertical-align: middle;
}
.thv-badge-neutral { /* default look, named for clarity */ }
.thv-badge-green { background: var(--thv-green-bg); border-color: var(--thv-green-line); color: var(--thv-green); }
.thv-badge-amber { background: var(--thv-amber-bg); border-color: var(--thv-amber-line); color: var(--thv-amber); }
.thv-badge-red { background: var(--thv-red-bg); border-color: var(--thv-red-line); color: var(--thv-red); }
.thv-badge-solid { background: var(--thv-primary); border-color: var(--thv-primary); color: var(--thv-primary-ink); }
/* In dark mode a solid white chip outshines everything else; use a raised grey chip instead. */
:root[data-theme="dark"] .thv-badge-solid,
html.fi.dark .thv-badge-solid { background: var(--thv-surface-muted); border-color: var(--thv-line-strong); color: var(--thv-ink); }
@media (prefers-color-scheme: dark) {
    :root:not(.fi):not([data-theme="light"]) .thv-badge-solid { background: var(--thv-surface-muted); border-color: var(--thv-line-strong); color: var(--thv-ink); }
}
.thv-badge-outline { background: transparent; }
.thv-dot { display: inline-block; box-sizing: border-box; width: 8px; height: 8px; border-radius: 999px; background: var(--thv-faint); flex: none; }
.thv-dot-green { background: var(--thv-green); }
.thv-dot-amber { background: var(--thv-amber); }
.thv-dot-red { background: var(--thv-red); }
.thv-dot-empty { background: transparent; border: 1.5px solid var(--thv-faint); } /* a strike not used yet: ●○○ */

/* ------------------------------------------------------------------ */
/* 11. Buttons                                                         */
/* ------------------------------------------------------------------ */
.thv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid var(--thv-line-strong);
    border-radius: var(--thv-radius);
    background: var(--thv-surface);
    color: var(--thv-ink);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: var(--thv-shadow);
    transition: background-color 0.1s ease, border-color 0.1s ease, color 0.1s ease;
}
.thv-btn:hover { background: var(--thv-hover); }
.thv-btn:focus-visible { outline: none; box-shadow: var(--thv-ring); }
.thv-btn:disabled, .thv-btn[aria-disabled="true"] { opacity: 0.55; pointer-events: none; }
.thv-btn svg { width: 16px; height: 16px; flex: none; }
.thv-btn-primary { background: var(--thv-primary); border-color: var(--thv-primary); color: var(--thv-primary-ink); }
.thv-btn-primary:hover { background: var(--thv-primary-hover); border-color: var(--thv-primary-hover); }
.thv-btn-secondary { /* default look, named for clarity */ }
.thv-btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--thv-ink-soft); }
.thv-btn-ghost:hover { background: var(--thv-hover); color: var(--thv-ink); }
.thv-btn-danger { background: var(--thv-red); border-color: var(--thv-red); color: #fff; }
.thv-btn-danger:hover { background: #991b1b; border-color: #991b1b; }
:root[data-theme="dark"] .thv-btn-danger, html.fi.dark .thv-btn-danger { color: #18181b; }
@media (prefers-color-scheme: dark) { :root:not(.fi):not([data-theme="light"]) .thv-btn-danger { color: #18181b; } }
.thv-btn-sm { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.thv-btn-lg { min-height: 44px; padding: 10px 18px; font-size: 15px; }
.thv-btn-block { display: flex; width: 100%; }
.thv-btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 16px; }
.thv-btn-row:last-child { margin-bottom: 0; }
.thv-link { color: var(--thv-ink); font-weight: 500; text-decoration: underline; text-decoration-color: var(--thv-line-strong); text-underline-offset: 2px; }
.thv-link:hover { text-decoration-color: currentColor; }

/* ------------------------------------------------------------------ */
/* 12. Callouts                                                        */
/* ------------------------------------------------------------------ */
.thv-callout {
    display: block;
    margin: 0 0 16px;
    padding: 12px 16px;
    border: 1px solid var(--thv-line);
    border-left-width: 3px;
    border-left-color: var(--thv-ink-soft);
    border-radius: var(--thv-radius);
    background: var(--thv-surface);
    color: var(--thv-ink-soft);
    font-size: 14px;
    line-height: 1.5;
}
.thv-callout > :first-child { margin-top: 0; }
.thv-callout > :last-child { margin-bottom: 0; }
.thv-callout-title { display: block; margin: 0 0 2px; font-weight: 600; color: var(--thv-ink); }
.thv-callout-info { /* default look */ }
.thv-callout-success { background: var(--thv-green-bg); border-color: var(--thv-green-line); border-left-color: var(--thv-green); }
.thv-callout-warning { background: var(--thv-amber-bg); border-color: var(--thv-amber-line); border-left-color: var(--thv-amber); }
.thv-callout-danger { background: var(--thv-red-bg); border-color: var(--thv-red-line); border-left-color: var(--thv-red); }
.thv-callout-success .thv-callout-title { color: var(--thv-green); }
.thv-callout-warning .thv-callout-title { color: var(--thv-amber); }
.thv-callout-danger .thv-callout-title { color: var(--thv-red); }

/* ------------------------------------------------------------------ */
/* 13. Empty state                                                     */
/* ------------------------------------------------------------------ */
.thv-empty {
    margin: 0;
    padding: 32px 20px;
    text-align: center;
    color: var(--thv-muted);
    font-size: 14px;
}
.thv-empty-title { display: block; margin: 0 0 4px; font-size: 15px; font-weight: 600; color: var(--thv-ink); }
.thv-empty-text { margin: 0 auto; max-width: 420px; }
.thv-empty .thv-btn { margin-top: 12px; }

/* ------------------------------------------------------------------ */
/* 14. Forms                                                           */
/* ------------------------------------------------------------------ */
.thv-form { display: flex; flex-direction: column; gap: 16px; margin: 0; }
.thv-field { display: flex; flex-direction: column; gap: 6px; margin: 0; min-width: 0; }
.thv-label { display: block; margin: 0; font-size: 14px; font-weight: 500; color: var(--thv-ink); }
.thv-input, .thv-select, .thv-textarea {
    display: block;
    width: 100%;
    min-height: 40px;
    margin: 0;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.4;
    color: var(--thv-ink);
    background: var(--thv-surface);
    border: 1px solid var(--thv-line-strong);
    border-radius: var(--thv-radius);
    box-shadow: var(--thv-shadow);
}
.thv-textarea { min-height: 96px; resize: vertical; }
.thv-select,
:where(.thv) :where(select:not([multiple]):not([size])) {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2371717a' stroke-width='1.6'%3E%3Cpath d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px 16px;
}
.thv-input:focus, .thv-select:focus, .thv-textarea:focus { outline: none; border-color: var(--thv-ink); box-shadow: var(--thv-ring); }
.thv-input.is-invalid, .thv-select.is-invalid, .thv-textarea.is-invalid { border-color: var(--thv-red); }
.thv-help { margin: 0; font-size: 13px; color: var(--thv-muted); }
.thv-error { margin: 0; font-size: 13px; color: var(--thv-red); }
.thv-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 14px;
    font-weight: 400;
    color: var(--thv-ink);
    cursor: pointer;
}
.thv-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--thv-primary); }
.thv-form-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) {
    .thv-form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .thv-form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.thv-form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 4px 0 0; }

/* Copy rows: one exact value (a URL, an event name, a message) and a small Copy button.
   Public pages: <button data-thv-copy="…">. Admin: filament.components.copy-row (Alpine). */
.thv-copy {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 5px 5px 5px 12px;
    background: var(--thv-surface-muted);
    border: 1px solid var(--thv-line);
    border-radius: var(--thv-radius);
}
.thv-copy + .thv-copy { margin-top: 8px; }
.thv-copy-value {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    padding: 0;
    border-radius: 0;
    background: none;
    font-family: var(--thv-font-mono);
    font-size: 13px;
    line-height: 1.45;
    color: var(--thv-ink);
    overflow-wrap: anywhere;
}
.thv-copy-block { align-items: flex-start; padding-top: 10px; padding-bottom: 10px; }
.thv-copy-block .thv-copy-value { font-family: var(--thv-font); font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.thv-copy > .thv-btn, .thv-copy > .fi-btn { flex: none; min-width: 68px; justify-content: center; }
.thv-copy .is-copied { color: var(--thv-green); }

/* Numbered how-to steps */
.thv-howto {
    list-style: none;
    counter-reset: thv-howto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 0;
    padding: 0;
}
.thv-howto > li {
    counter-increment: thv-howto;
    position: relative;
    min-width: 0;
    padding-left: 36px;
    font-size: 14px;
    line-height: 1.55;
    color: var(--thv-ink-soft);
}
.thv-howto > li::before {
    content: counter(thv-howto);
    position: absolute;
    top: -1px;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 1px solid var(--thv-line-strong);
    border-radius: 50%;
    background: var(--thv-surface);
    color: var(--thv-ink);
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.thv-howto-title { display: block; margin: 0 0 4px; color: var(--thv-ink); font-weight: 600; }
.thv-howto p { margin: 0 0 8px; }
.thv-howto p:last-child { margin-bottom: 0; }
.thv-howto .thv-copy { margin-top: 8px; }
.thv-howto .thv-copy + .thv-copy { margin-top: 8px; }
.thv-howto-action { margin: 8px 0 10px; }

/* A secret / password field with a Show button beside it. 16px text so phones don't zoom in. */
.thv-secret { display: flex; gap: 8px; }
.thv-secret > .thv-input {
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--thv-font-mono);
    font-size: 16px;
    letter-spacing: 0.01em;
}
.thv-secret > .thv-btn { flex: none; min-width: 72px; min-height: 40px; }
@media (max-width: 480px) {
    .thv-howto > li { padding-left: 32px; }
}
/* Finger-sized Copy buttons on touch screens and phones. */
@media (pointer: coarse), (max-width: 640px) {
    .thv-copy > .thv-btn, .thv-copy > .fi-btn { min-height: 40px; }
}

/* ------------------------------------------------------------------ */
/* 15. Key-value details                                               */
/* ------------------------------------------------------------------ */
.thv-dl {
    display: grid;
    grid-template-columns: minmax(120px, 200px) minmax(0, 1fr);
    align-content: start; /* a shorter list beside a longer one keeps its own row heights */
    margin: 0;
    font-size: 14px;
}
.thv-dl > dt, .thv-dl > dd {
    margin: 0;
    padding: 10px 0;
    border-top: 1px solid var(--thv-line);
}
.thv-dl > dt { padding-right: 16px; color: var(--thv-muted); }
.thv-dl > dd { color: var(--thv-ink); min-width: 0; overflow-wrap: anywhere; }
.thv-dl > dt:first-of-type, .thv-dl > dt:first-of-type + dd { border-top: 0; padding-top: 0; }
.thv-card-body > .thv-dl:only-child > dt:last-of-type,
.thv-card-body > .thv-dl:only-child > dd:last-of-type { padding-bottom: 0; }
/* Label column only as wide as the longest label (two lists side by side in a .thv-grid-2). */
.thv-dl-auto { grid-template-columns: max-content minmax(0, 1fr); }
@media (max-width: 480px) {
    .thv-dl, .thv-dl-auto { grid-template-columns: minmax(0, 1fr); }
    .thv-dl > dd { border-top: 0; padding-top: 0; }
    .thv-dl > dt { padding-bottom: 2px; }
}

/* ------------------------------------------------------------------ */
/* 16. Tabs and filter chips                                           */
/* ------------------------------------------------------------------ */
.thv-tabs {
    display: flex;
    gap: 4px;
    margin: 0 0 20px;
    border-bottom: 1px solid var(--thv-line);
    overflow-x: auto;
    scrollbar-width: none;
}
.thv-tabs::-webkit-scrollbar { display: none; }
.thv-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    color: var(--thv-muted);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    background: none;
    border: 0;
    cursor: pointer;
}
.thv-tab:hover { color: var(--thv-ink); }
.thv-tab.is-active, .thv-tab[aria-current="page"], .thv-tab[aria-selected="true"] { color: var(--thv-ink); }
.thv-tab.is-active::after, .thv-tab[aria-current="page"]::after, .thv-tab[aria-selected="true"]::after {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: -1px;
    height: 2px;
    background: var(--thv-ink);
}
.thv-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.thv-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 4px 10px;
    border: 1px solid var(--thv-line-strong);
    border-radius: var(--thv-radius);
    background: var(--thv-surface);
    color: var(--thv-ink-soft);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
}
.thv-chip:hover { background: var(--thv-hover); }
.thv-chip.is-active, .thv-chip[aria-current="page"], .thv-chip[aria-pressed="true"] {
    background: var(--thv-primary);
    border-color: var(--thv-primary);
    color: var(--thv-primary-ink);
}

/* ------------------------------------------------------------------ */
/* 17. Progress bar                                                    */
/* ------------------------------------------------------------------ */
.thv-progress {
    height: 6px;
    margin: 6px 0 0;
    border-radius: 999px;
    background: var(--thv-surface-muted);
    overflow: hidden;
}
.thv-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--thv-primary); }
.thv-progress.is-green > span { background: var(--thv-green); }
.thv-progress.is-amber > span { background: var(--thv-amber); }
.thv-progress.is-red > span { background: var(--thv-red); }

/* ------------------------------------------------------------------ */
/* 18. Text utilities                                                  */
/* ------------------------------------------------------------------ */
.thv-muted { color: var(--thv-muted); }
.thv-small { font-size: 13px; }
.thv-strong { font-weight: 600; color: var(--thv-ink); }
.thv-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.thv-right { text-align: right; }
.thv-center { text-align: center; }
.thv-nowrap { white-space: nowrap; }
.thv-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thv-text-green { color: var(--thv-green); }
.thv-text-amber { color: var(--thv-amber); }
.thv-text-red { color: var(--thv-red); }
.thv-mt-0 { margin-top: 0 !important; }
.thv-mb-0 { margin-bottom: 0 !important; }
/* Hide a less important table column on phones (screen only: paper always shows it). */
@media screen and (max-width: 700px) {
    .thv-hide-sm { display: none !important; }
}
/* Admin tables at Filament's sm breakpoint (640px), to pair with visibleFrom('sm') columns:
   .thv-phone-only shows what a hidden column said; .thv-no-phone drops a button phones don't need. */
@media (min-width: 640px) {
    .thv-phone-only { display: none !important; }
}
@media (max-width: 639px) {
    .thv-no-phone { display: none !important; }
}
.thv-sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------------ */
/* 19. Pagination (Laravel's default paginator markup inside .thv)     */
/* ------------------------------------------------------------------ */
:where(.thv) nav[role="navigation"][aria-label] { margin: 16px 0 0; font-size: 14px; }
:where(.thv) nav[role="navigation"][aria-label] > div:first-child { display: flex; justify-content: space-between; gap: 8px; }
:where(.thv) nav[role="navigation"][aria-label] > div:last-child { display: none; }
:where(.thv) nav[role="navigation"][aria-label] p { margin: 0; color: var(--thv-muted); }
:where(.thv) nav[role="navigation"][aria-label] > div:last-child > div:last-child > span { display: inline-flex; gap: 4px; }
:where(.thv) nav[role="navigation"][aria-label] a,
:where(.thv) nav[role="navigation"][aria-label] span[aria-current] > span,
:where(.thv) nav[role="navigation"][aria-label] span[aria-disabled] > span,
:where(.thv) nav[role="navigation"][aria-label] > div:first-child > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    min-height: 34px;
    padding: 4px 10px;
    border: 1px solid var(--thv-line-strong);
    border-radius: var(--thv-radius);
    background: var(--thv-surface);
    color: var(--thv-ink);
    text-decoration: none;
    font-weight: 500;
}
:where(.thv) nav[role="navigation"][aria-label] a:hover { background: var(--thv-hover); }
:where(.thv) nav[role="navigation"][aria-label] span[aria-current] > span { background: var(--thv-primary); border-color: var(--thv-primary); color: var(--thv-primary-ink); }
:where(.thv) nav[role="navigation"][aria-label] span[aria-disabled] > span,
:where(.thv) nav[role="navigation"][aria-label] > div:first-child > span { color: var(--thv-faint); }
:where(.thv) nav[role="navigation"][aria-label] svg { width: 16px; height: 16px; }
@media (min-width: 640px) {
    :where(.thv) nav[role="navigation"][aria-label] > div:first-child { display: none; }
    :where(.thv) nav[role="navigation"][aria-label] > div:last-child { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
}

/* ------------------------------------------------------------------ */
/* 20. Printed documents (notices, fee schedules, report cards)        */
/* ------------------------------------------------------------------ */
.thv-print-page { background: var(--thv-surface-muted); }
.thv-doc-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 8.5in;
    margin: 0 auto;
    padding: 16px 16px 0;
}
.thv-doc {
    /* A printed sheet is always light, even when the screen is dark. */
    --thv-bg: #ffffff;
    --thv-surface: #ffffff;
    --thv-surface-muted: #f4f4f5;
    --thv-hover: #f4f4f5;
    --thv-ink: #18181b;
    --thv-ink-soft: #3f3f46;
    --thv-muted: #52525b;
    --thv-faint: #a1a1aa;
    --thv-line: #e4e4e7;
    --thv-line-strong: #d4d4d8;
    --thv-primary: #18181b;
    --thv-primary-ink: #ffffff;
    --thv-green: #15803d;
    --thv-green-bg: #f0fdf4;
    --thv-green-line: #bbf7d0;
    --thv-amber: #b45309;
    --thv-amber-bg: #fffbeb;
    --thv-amber-line: #fde68a;
    --thv-red: #b91c1c;
    --thv-red-bg: #fef2f2;
    --thv-red-line: #fecaca;
    --thv-shadow: 0 0 #0000;
    color-scheme: light;
    max-width: 8.5in;
    margin: 16px auto 40px;
    padding: 0.6in;
    background: #fff;
    color: #18181b;
    border: 1px solid var(--thv-line);
    border-radius: var(--thv-radius);
    font-size: 14px;
    line-height: 1.55;
}
@media (max-width: 700px) {
    .thv-doc { margin: 12px 0 24px; padding: 24px 16px; border-left: 0; border-right: 0; border-radius: 0; }
}
.thv-letterhead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 0 16px;
    margin: 0 0 24px;
    border-bottom: 1px solid #d4d4d8;
}
.thv-letterhead img { height: 44px; width: auto; display: block; }
.thv-letterhead-meta { text-align: right; font-size: 12px; line-height: 1.5; color: #52525b; }
.thv-doc-title { margin: 0 0 4px; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; color: #18181b; }
.thv-doc-subtitle { margin: 0 0 20px; font-size: 14px; color: #52525b; }
.thv-doc-section { margin: 24px 0 0; }
.thv-doc-section > h2, .thv-doc-heading {
    margin: 0 0 8px;
    padding: 0 0 6px;
    border-bottom: 1px solid #e4e4e7;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #3f3f46;
}
.thv-doc p { margin: 0 0 10px; }
.thv-doc .thv-table tbody tr:hover > * { background: none; }
.thv-signatures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; margin: 40px 0 0; }
.thv-sign-line { padding: 6px 0 0; margin-top: 40px; border-top: 1px solid #18181b; font-size: 12px; color: #52525b; }
.thv-doc-footer { margin: 32px 0 0; padding: 12px 0 0; border-top: 1px solid #e4e4e7; font-size: 12px; color: #71717a; }
.thv-print-only { display: none !important; }

@media print {
    @page { size: letter; margin: 0.6in; }

    /*
     * Paper is always light. The list repeats every dark-token selector (same specificity) so
     * this block, coming later in the file, wins even on a phone or computer in dark mode.
     */
    :root,
    :root:not(.fi):not([data-theme="light"]),
    :root[data-theme="dark"],
    html.fi.dark {
        --thv-bg: #ffffff;
        --thv-surface: #ffffff;
        --thv-surface-muted: #f4f4f5;
        --thv-hover: transparent;
        --thv-ink: #000000;
        --thv-ink-soft: #18181b;
        --thv-muted: #3f3f46;
        --thv-faint: #71717a;
        --thv-line: #d4d4d8;
        --thv-line-strong: #a1a1aa;
        --thv-primary: #18181b;
        --thv-primary-hover: #27272a;
        --thv-primary-ink: #ffffff;
        --thv-ring: 0 0 #0000;
        --thv-shadow: 0 0 #0000;
        --thv-shadow-pop: 0 0 #0000;
        --thv-green: #000000;
        --thv-amber: #000000;
        --thv-red: #000000;
        --thv-green-bg: transparent;
        --thv-amber-bg: transparent;
        --thv-red-bg: transparent;
        --thv-green-line: #a1a1aa;
        --thv-amber-line: #a1a1aa;
        --thv-red-line: #a1a1aa;
        color-scheme: light !important;
    }

    html, body, .thv, .thv-print-page {
        background: #fff !important;
        color: #000 !important;
    }
    .thv { font-size: 11pt; min-height: 0; }

    .thv-topbar,
    .thv-sidebar,
    .thv-menu-btn,
    .thv-impersonation,
    .thv-doc-toolbar,
    .thv-no-print,
    .thv-btn,
    .thv-btn-row,
    .thv-page-actions,
    .thv-card-actions,
    .thv-legal-links,
    .thv-site-header,
    .thv-site-footer,
    .thv-back,
    .thv-tabs,
    .thv-chips,
    .thv-card-footer,
    .thv-form-actions,
    :where(.thv) nav[role="navigation"][aria-label] { display: none !important; }

    .thv-print-only { display: block !important; }
    .thv-shell { display: block; }
    .thv-container, .thv-container-wide { max-width: none; padding: 0; }
    .thv-doc { max-width: none; margin: 0; padding: 0; border: 0; border-radius: 0; font-size: 11pt; }

    .thv-card, .thv-stat, .thv-table-wrap, .thv-callout {
        box-shadow: none !important;
        border-color: #a1a1aa !important;
        break-inside: avoid;
    }
    /* Keep the colored left edge of a level callout on paper (the rule above greys every border). */
    .thv-callout-success { border-left-color: var(--thv-green) !important; }
    .thv-callout-warning { border-left-color: var(--thv-amber) !important; }
    .thv-callout-danger { border-left-color: var(--thv-red) !important; }
    .thv-table-wrap { overflow: visible; }
    .thv-table thead { display: table-header-group; }
    .thv-table tr, .thv-list-item, .thv-dl > dt, .thv-dl > dd { break-inside: avoid; }
    .thv-table tbody tr:hover > * { background: none; }
    .thv-badge { background: none !important; border-color: #71717a !important; color: #000 !important; }
    /* Level badges on printed documents keep their level color (outline + text), like the notice callout. */
    .thv-doc .thv-badge-green { background: #fff !important; border-color: var(--thv-green) !important; color: var(--thv-green) !important; }
    .thv-doc .thv-badge-amber { background: #fff !important; border-color: var(--thv-amber) !important; color: var(--thv-amber) !important; }
    .thv-doc .thv-badge-red { background: #fff !important; border-color: var(--thv-red) !important; color: var(--thv-red) !important; }
    a { color: #000 !important; text-decoration: none !important; }
    a.thv-list-item::after { display: none; }
    h1, h2, h3, .thv-doc-heading { break-after: avoid; }
    .thv-signatures, .thv-sign-line { break-inside: avoid; }
    .thv-keep-together { break-inside: avoid; }
    .thv-page-break { break-before: page; }
    /* Two short lists side by side on paper too (the sheet is narrower than the 768px breakpoint). */
    .thv-doc .thv-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    /* Notices and report cards: tighter type and spacing so a notice fits one Letter page. */
    .thv-doc-compact { font-size: 10pt; line-height: 1.4; }
    .thv-doc-compact .thv-letterhead { margin-bottom: 12px; padding-bottom: 8px; }
    .thv-doc-compact .thv-letterhead img { height: 32px; }
    .thv-doc-compact .thv-doc-title { font-size: 16pt; }
    .thv-doc-compact .thv-doc-subtitle { margin-bottom: 10px; }
    .thv-doc-compact .thv-doc-section { margin-top: 12px; }
    .thv-doc-compact .thv-doc-section > h2 { font-size: 8.5pt; margin-bottom: 4px; padding-bottom: 3px; }
    .thv-doc-compact p { margin-bottom: 6px; }
    .thv-doc-compact .thv-dl { font-size: 10pt; }
    /* Only the vertical padding: labels keep their 16px gap before the value. */
    .thv-doc-compact .thv-dl > dt, .thv-doc-compact .thv-dl > dd { padding-top: 3px; padding-bottom: 3px; }
    .thv-doc-compact .thv-dl > dt:first-of-type,
    .thv-doc-compact .thv-dl > dt:first-of-type + dd { padding-top: 0; }
    .thv-doc-compact .thv-callout { font-size: 10pt; padding: 8px 12px; margin-bottom: 10px; }
    .thv-doc-compact .thv-grid { gap: 0 24px; margin-bottom: 0; }
    .thv-doc-compact .thv-table { font-size: 9.5pt; }
    .thv-doc-compact .thv-signatures { margin-top: 18px; }
    .thv-doc-compact .thv-sign-line { margin-top: 22px; }
    .thv-doc-compact .thv-doc-footer { margin-top: 14px; }
}

/* ------------------------------------------------------------------ */
/* 22. Older admin page block (.thv-panel). New admin pages use        */
/* x-filament::section or .thv-card (see docs/DESIGN.md).              */
/* ------------------------------------------------------------------ */
.thv-panel {
    background: var(--thv-surface);
    border: 1px solid var(--thv-line);
    border-radius: var(--thv-radius);
    box-shadow: var(--thv-shadow);
    margin: 0 0 16px;
    padding-bottom: 14px;
    overflow: hidden;
    font-size: 14px;
    color: var(--thv-ink);
}
.thv-panel:has(> :last-child:is(table, .overflow-x-auto, .thv-table-wrap)) { padding-bottom: 0; }
.thv-panel > h2 {
    margin: 0 0 14px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--thv-line);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--thv-ink);
}
.thv-panel > h2 + :is(table, .overflow-x-auto, .thv-table-wrap) { margin-top: -14px; }
.thv-panel > :not(h2):not(table):not(.overflow-x-auto):not(.thv-table-wrap) { padding-left: 20px; padding-right: 20px; }
.thv-panel table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.thv-panel th {
    padding: 9px 20px;
    text-align: left;
    background: var(--thv-surface-muted);
    border-bottom: 1px solid var(--thv-line);
    color: var(--thv-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}
.thv-panel td { padding: 10px 20px; border-bottom: 1px solid var(--thv-line); color: var(--thv-ink); }
.thv-panel tbody tr:last-child > td { border-bottom: 0; }
.thv-panel tbody tr:hover > td { background: var(--thv-hover); }

/* ------------------------------------------------------------------ */
/* 23. Admin custom pages (Filament): toolbars, month calendar,        */
/* attendance roster, fee steps, survey bars, printing.                */
/* Used by resources/views/filament/pages/*. See docs/DESIGN.md.       */
/* ------------------------------------------------------------------ */
.thv-stat-grid.cols-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 1024px) {
    .thv-stat-grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
.thv-stat-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* A row with a title on the left and controls on the right (calendar month, staff week). */
.thv-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 16px;
    margin: 0;
}
.thv-toolbar-title { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; color: var(--thv-ink); }
.thv-toolbar-group { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.thv-toolbar-note { font-size: 13px; color: var(--thv-muted); }

/* Wide number tables: let header labels wrap onto two lines. */
.thv-table-wrap-head thead th { white-space: normal; vertical-align: bottom; line-height: 1.35; }

/* Small badge for tight spots (calendar chips). */
.thv-badge-xs { padding: 0 5px; font-size: 11px; line-height: 16px; }

/* Month calendar */
.thv-cal {
    background: var(--thv-surface);
    border: 1px solid var(--thv-line);
    border-radius: var(--thv-radius);
    box-shadow: var(--thv-shadow);
    overflow: hidden;
}
.thv-cal-head,
.thv-cal-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.thv-cal-head > div {
    padding: 8px 10px;
    background: var(--thv-surface-muted);
    border-bottom: 1px solid var(--thv-line);
    color: var(--thv-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.thv-cal-day {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    min-height: 124px;
    padding: 6px;
    border-right: 1px solid var(--thv-line);
    border-bottom: 1px solid var(--thv-line);
}
.thv-cal-days > .thv-cal-day:nth-child(7n) { border-right: 0; }
.thv-cal-days > .thv-cal-day:nth-last-child(-n + 7) { border-bottom: 0; }
.thv-cal-day.is-out { background: var(--thv-bg); }
.thv-cal-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: flex-start;
    min-width: 24px;
    height: 24px;
    padding: 0 5px;
    border-radius: var(--thv-radius-sm);
    color: var(--thv-ink-soft);
    font-size: 13px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}
.thv-cal-day.is-out .thv-cal-num { color: var(--thv-faint); }
.thv-cal-day.is-today { box-shadow: inset 0 2px 0 var(--thv-ink); }
.thv-cal-day.is-today .thv-cal-num { background: var(--thv-primary); color: var(--thv-primary-ink); font-weight: 600; }
.thv-cal-event {
    display: block;
    padding: 5px 7px;
    border: 1px solid var(--thv-line);
    border-left: 3px solid var(--thv-line-strong);
    border-radius: var(--thv-radius-sm);
    background: var(--thv-surface);
    color: var(--thv-ink);
    font-size: 12px;
    line-height: 1.35;
    text-decoration: none;
    transition: background-color 0.1s ease, border-color 0.1s ease;
}
.thv-cal-event:hover { background: var(--thv-hover); border-color: var(--thv-line-strong); }
.thv-cal-event.is-required { border-left-color: var(--thv-ink); }
.thv-cal-event-time { display: block; color: var(--thv-muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.thv-cal-event-title { display: block; font-weight: 600; overflow-wrap: anywhere; }
.thv-cal-event-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.thv-cal-agenda { display: none; }
.thv-cal-agenda .thv-list-item { padding-top: 10px; padding-bottom: 10px; }
.thv-cal-agenda-date {
    margin: 0;
    padding: 8px 16px;
    background: var(--thv-surface-muted);
    border-bottom: 1px solid var(--thv-line);
    color: var(--thv-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.thv-cal-agenda .thv-list + .thv-cal-agenda-date { border-top: 1px solid var(--thv-line); }
@media (max-width: 767px) {
    .thv-cal-month { display: none; }
    .thv-cal-agenda { display: block; }
}

/* Attendance roster: one row per resident, name left, status buttons right. */
html.fi .thv-roster .fi-section-content { padding-top: 4px; padding-bottom: 4px; }
html.fi .thv-roster .fi-section-content > .grid { row-gap: 0; }
html.fi .thv-roster .fi-fo-field-wrp { padding: 12px 0; border-top: 1px solid var(--thv-line); }
html.fi .thv-roster .fi-section-content > .grid > :first-child .fi-fo-field-wrp { border-top: 0; }
html.fi .thv-roster .fi-fo-field-wrp > .grid { align-items: center; }
html.fi .thv-roster .fi-fo-field-wrp-label { padding-top: 0; }
html.fi .thv-roster .fi-btn-group > .fi-btn { min-height: 40px; min-width: 88px; justify-content: center; }
html.fi .thv-roster .fi-btn-group > .fi-btn:not(.fi-color-custom):not(.fi-btn-outlined) { box-shadow: none; }
/* Phones: the four buttons share the row instead of running off the right edge. */
@media (max-width: 639px) {
    html.fi .thv-roster .fi-btn-group { width: 100%; grid-auto-columns: minmax(0, 1fr); }
    html.fi .thv-roster .fi-btn-group > .fi-btn { min-width: 0; padding-left: 4px; padding-right: 4px; }
}

/* Program fee steps (repeater): one compact row per step, delete button on the right. */
html.fi .thv-steps .fi-fo-repeater-item { display: flex; align-items: center; }
html.fi .thv-steps .fi-fo-repeater-item-content { order: 0; flex: 1 1 auto; min-width: 0; padding: 12px 0 12px 16px; border-top: 0; }
html.fi .thv-steps .fi-fo-repeater-item-header { order: 1; flex: none; padding: 12px 12px 12px 8px; }
html.fi .thv-steps .fi-fo-repeater-item-header-label { display: none; }

/* Survey results: answer, bar, count */
.thv-pre-wrap { white-space: pre-wrap; }
.thv-bar-cell { width: 45%; }
.thv-bar-cell .thv-progress { margin: 0; }

/* Printing admin pages (report cards): drop the Filament chrome. */
@media print {
    html.fi :is(.fi-sidebar, .fi-sidebar-close-overlay, .fi-topbar, .fi-breadcrumbs, .fi-header .fi-ac, .fi-form-actions) { display: none !important; }
    html.fi .fi-layout, html.fi .fi-main-ctn { display: block !important; padding: 0 !important; }
    html.fi .fi-main { max-width: none !important; padding: 0 !important; }
    html.fi .fi-body { background: #fff !important; }
    html.fi .fi-page > section { padding-top: 0 !important; }
}
