:root {
    --stone-50: #f6f3ec;
    --stone-100: #ece6da;
    --stone-200: #ddd4c2;
    --stone-300: #c7bba3;
    --ink: #2e2e2e;
    --ink-soft: #4a4a4a;
    --ink-faint: #6f6f6f;
    --green-900: #17380f;
    --green-800: #245417;
    --green-700: #2c5a1a;
    --green-600: #3a7522;
    --green-500: #4a8f2e;
    --brass: #9c8a52;
    --brass-soft: #bda86e;
    --paper: #fbf9f4;
    --line: rgba(32, 36, 31, 0.12);
    --shadow-sm: 0 1px 2px rgba(16, 37, 28, 0.06);
    --shadow-md: 0 18px 40px -24px rgba(16, 37, 28, 0.55);
    --rail-w: 288px;
    --topbar-h: 60px;
    --radius: 14px;
    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: "Spline Sans", ui-sans-serif, system-ui, sans-serif;
    color: var(--ink);
    background-color: var(--paper);
    background-image:
        radial-gradient(120% 90% at 12% -10%, rgba(47, 125, 91, 0.10), transparent 55%),
        radial-gradient(120% 100% at 100% 0%, rgba(176, 138, 62, 0.10), transparent 45%),
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
    background-attachment: fixed;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

.wordmark {
    font-family: "Fraunces", Georgia, serif;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 0.95;
    color: var(--green-900);
}

.wordmark span {
    color: var(--brass);
}

.brand-logo {
    display: block;
    height: 38px;
    width: auto;
    mix-blend-mode: multiply;
}

.login-brand .brand-logo {
    height: clamp(56px, 12vw, 88px);
    width: auto;
    margin: 0 auto;
}

/* ---------- Login ---------- */

.login-page {
    display: grid;
    place-items: center;
    padding: 32px;
}

.login-shell {
    width: min(420px, 100%);
    display: grid;
    gap: 30px;
    animation: rise 0.7s var(--ease) both;
}

.login-brand {
    text-align: center;
}

.login-eyebrow {
    margin: 0 0 12px;
    font-size: 0.72rem;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--green-600);
}

.login-shell .wordmark {
    font-size: clamp(2.8rem, 9vw, 3.9rem);
    margin: 0;
}

.login-card {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(6px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 28px;
    display: grid;
    gap: 14px;
}

.field-label {
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--ink-soft);
}

.field-input {
    width: 100%;
    padding: 13px 15px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--stone-300);
    border-radius: 10px;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.field-input:focus {
    outline: none;
    border-color: var(--green-500);
    box-shadow: 0 0 0 3px rgba(47, 125, 91, 0.18);
}

.field-error {
    margin: 0;
    font-size: 0.85rem;
    color: #9a2f2f;
}

.btn-primary {
    margin-top: 4px;
    padding: 13px 18px;
    font: inherit;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--stone-50);
    background: linear-gradient(180deg, var(--green-600), var(--green-700));
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px -12px rgba(28, 69, 53, 0.8);
}

.btn-secondary {
    display: inline-block;
    margin-top: 18px;
    padding: 11px 18px;
    font-weight: 500;
    color: var(--green-700);
    border: 1px solid var(--green-600);
    border-radius: 10px;
    transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.btn-secondary:hover {
    background: var(--green-700);
    color: var(--stone-50);
}

/* ---------- App shell ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 22px;
    background: rgba(251, 249, 244, 0.86);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.wordmark-sm {
    font-size: 1.35rem;
}

.topbar-brand {
    display: flex;
    align-items: center;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-user {
    font-size: 0.82rem;
    color: var(--ink-faint);
}

.topbar-user strong {
    font-weight: 500;
    color: var(--ink-soft);
}

.topbar-link {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--green-700);
    padding: 6px 12px;
    border: 1px solid var(--green-600);
    border-radius: 999px;
    transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.topbar-link:hover,
.topbar-link.is-active {
    background: var(--green-700);
    color: var(--stone-50);
}

.topbar-logout {
    font-size: 0.85rem;
    color: var(--ink-faint);
    transition: color 0.2s var(--ease);
}

.topbar-logout:hover {
    color: var(--green-700);
}

@media (max-width: 640px) {
    .topbar-user {
        display: none;
    }
}

.rail-toggle {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font: inherit;
    font-size: 0.85rem;
    color: var(--green-800, var(--green-700));
    background: var(--stone-100);
    border: 1px solid var(--line);
    border-radius: 999px;
    cursor: pointer;
}

.layout {
    display: grid;
    grid-template-columns: var(--rail-w) 1fr;
    align-items: start;
    min-height: calc(100vh - var(--topbar-h));
}

/* ---------- Left rail: Thesis Search ---------- */

.rail {
    position: sticky;
    top: var(--topbar-h);
    align-self: start;
    height: calc(100vh - var(--topbar-h));
    padding: 22px 16px;
    border-right: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(236, 230, 218, 0.55), rgba(251, 249, 244, 0.2));
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.rail-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    font: inherit;
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    color: var(--green-900);
}

.rail-header:hover {
    background: rgba(255, 255, 255, 0.5);
}

.rail-title {
    font-family: "Fraunces", Georgia, serif;
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: 0.01em;
}

.rail-caret {
    width: 9px;
    height: 9px;
    border-right: 2px solid var(--ink-faint);
    border-bottom: 2px solid var(--ink-faint);
    transform: rotate(45deg);
    transition: transform 0.25s var(--ease);
}

.rail-header[aria-expanded="false"] .rail-caret {
    transform: rotate(-45deg);
}

.rail-list {
    display: grid;
    gap: 6px;
    margin-top: 10px;
    overflow: hidden;
    transition: max-height 0.3s var(--ease), opacity 0.25s var(--ease);
}

.rail-list[hidden] {
    display: grid;
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

.rail-item {
    display: grid;
    gap: 3px;
    padding: 11px 13px;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: background 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.18s var(--ease);
}

.rail-item:hover {
    background: rgba(255, 255, 255, 0.65);
    border-color: var(--line);
    transform: translateX(2px);
}

.rail-item.is-active {
    background: var(--green-700);
    border-color: var(--green-700);
}

.rail-item.is-active .rail-item-title {
    color: var(--stone-50);
}

.rail-item.is-active .rail-item-tag {
    color: var(--brass-soft);
}

.rail-item-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--ink);
}

.rail-item-tag {
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

/* Nested pages beneath a thesis (e.g. Industry Data under Home Inspections) */
.rail-children {
    display: grid;
    gap: 4px;
    margin: 2px 0 2px 12px;
    padding-left: 12px;
    border-left: 1px solid var(--line);
}

.rail-child {
    display: block;
    padding: 8px 12px;
    border-radius: 9px;
    border: 1px solid transparent;
    transition: background 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.18s var(--ease);
}

.rail-child:hover {
    background: rgba(255, 255, 255, 0.65);
    border-color: var(--line);
    transform: translateX(2px);
}

.rail-child.is-active {
    background: var(--green-700);
    border-color: var(--green-700);
}

.rail-child.is-active .rail-child-title {
    color: var(--stone-50);
}

.rail-child-title {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--ink-soft);
}

/* Admin entry pinned to the bottom of the rail */
.rail-admin {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 13px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.5);
    color: var(--green-900);
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.18s var(--ease);
}

.rail-admin:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: var(--green-600);
    transform: translateX(2px);
}

.rail-admin.is-active {
    background: var(--green-700);
    border-color: var(--green-700);
    color: var(--stone-50);
}

.rail-admin-icon {
    width: 18px;
    height: 18px;
    flex: none;
}

.rail-admin-label {
    line-height: 1;
}

/* ---------- Main pane ---------- */

.main {
    padding: clamp(28px, 5vw, 56px);
    max-width: 1080px;
}

.section-eyebrow,
.home-hero .section-eyebrow {
    margin: 0 0 12px;
    font-size: 0.72rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--green-600);
}

.home-hero {
    animation: rise 0.6s var(--ease) both;
}

.home-title {
    font-family: "Fraunces", Georgia, serif;
    font-weight: 600;
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 1.05;
    letter-spacing: -0.02em;
    color: var(--green-900);
    margin: 0 0 16px;
    max-width: 16ch;
}

.home-lede {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--ink-soft);
    max-width: 56ch;
}

.home-theses {
    display: grid;
    gap: 14px;
    margin-top: 40px;
}

.thesis-link {
    display: grid;
    gap: 8px;
    padding: 20px 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.55);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
    animation: rise 0.6s var(--ease) both;
}

.thesis-link:hover {
    transform: translateY(-2px);
    border-color: var(--green-600);
    box-shadow: var(--shadow-md);
}

.thesis-link-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.thesis-link-title {
    font-family: "Fraunces", Georgia, serif;
    font-weight: 600;
    font-size: 1.3rem;
    color: var(--green-900);
}

.thesis-link-blurb {
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--ink-soft);
    max-width: 62ch;
}

.status-pill {
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

.status-pill-live {
    color: var(--green-700);
    background: rgba(47, 125, 91, 0.14);
}

.status-pill-soon {
    color: var(--brass);
    background: rgba(176, 138, 62, 0.16);
}

.status-pill-off {
    color: #9a2f2f;
    background: rgba(154, 47, 47, 0.12);
}

.rail-empty {
    margin: 10px 12px 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--ink-faint);
}

.home-empty {
    padding: 40px 28px;
    border: 1px dashed var(--stone-300);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.4);
    text-align: center;
    display: grid;
    gap: 10px;
    justify-items: center;
}

/* ---------- Thesis detail ---------- */

.thesis {
    animation: rise 0.55s var(--ease) both;
}

.thesis-head-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.thesis-title {
    font-family: "Fraunces", Georgia, serif;
    font-weight: 600;
    font-size: clamp(1.9rem, 4vw, 2.6rem);
    letter-spacing: -0.02em;
    color: var(--green-900);
    margin: 0;
}

.thesis-blurb {
    margin: 14px 0 0;
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--ink-soft);
    max-width: 64ch;
}

.thesis-summary {
    margin-top: 26px;
    padding: 22px 24px;
    border-left: 3px solid var(--green-600);
    background: rgba(255, 255, 255, 0.5);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.thesis-summary p {
    margin: 0;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--ink-soft);
}

.thesis-map {
    margin-top: 30px;
}

.thesis-map-frame {
    width: min(1400px, calc(100vw - var(--rail-w) - 2 * clamp(28px, 5vw, 56px)));
    height: min(72vh, 760px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow-md);
}

.map-placeholder {
    display: grid;
    justify-items: center;
    text-align: center;
    gap: 12px;
    padding: 64px 28px;
    border: 1px dashed var(--stone-300);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.4);
}

.map-placeholder-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--brass);
    box-shadow: 0 0 0 0 rgba(176, 138, 62, 0.5);
    animation: pulse 2.2s var(--ease) infinite;
}

.map-placeholder-title {
    font-family: "Fraunces", Georgia, serif;
    font-weight: 600;
    font-size: 1.4rem;
    color: var(--green-900);
    margin: 0;
}

.map-placeholder-text {
    margin: 0;
    max-width: 44ch;
    color: var(--ink-faint);
    line-height: 1.6;
}

.thesis-missing {
    animation: rise 0.55s var(--ease) both;
}

/* ---------- Motion ---------- */

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(176, 138, 62, 0.45);
    }
    70% {
        box-shadow: 0 0 0 14px rgba(176, 138, 62, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(176, 138, 62, 0);
    }
}

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

/* ---------- Responsive: rail becomes a drawer ---------- */

@media (max-width: 820px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .thesis-map-frame {
        width: 100%;
    }

    .rail-toggle {
        display: inline-flex;
    }

    .rail {
        position: fixed;
        top: var(--topbar-h);
        left: 0;
        width: min(320px, 86vw);
        height: calc(100vh - var(--topbar-h));
        z-index: 40;
        transform: translateX(-102%);
        transition: transform 0.3s var(--ease);
        box-shadow: var(--shadow-md);
        background: var(--paper);
    }

    .rail[data-open="true"] {
        transform: translateX(0);
    }

    .rail-backdrop {
        position: fixed;
        inset: var(--topbar-h) 0 0;
        background: rgba(16, 37, 28, 0.32);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s var(--ease);
        z-index: 35;
    }

    .rail-backdrop[data-open="true"] {
        opacity: 1;
        pointer-events: auto;
    }
}

/* ---------- Thesis workspace: tabs ---------- */

.tabbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 26px 0 18px;
    border-bottom: 1px solid var(--line);
}

.tab {
    appearance: none;
    font: inherit;
    font-size: 0.92rem;
    color: var(--ink-faint);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 14px;
    margin-bottom: -1px;
    cursor: pointer;
    transition: color 0.18s var(--ease), border-color 0.18s var(--ease);
}

.tab:hover {
    color: var(--green-700);
}

.tab.is-active {
    color: var(--green-900);
    border-bottom-color: var(--green-600);
    font-weight: 500;
}

.tab-panel {
    display: none;
    animation: rise 0.4s var(--ease) both;
}

.tab-panel.is-active {
    display: block;
}

.tab-status {
    font-size: 0.9rem;
    color: var(--ink-faint);
    padding: 8px 0;
}

.tab-status.is-error {
    color: #9a2f2f;
}

/* ---------- Overview ---------- */

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 30px;
}

.metric-card {
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.55);
    box-shadow: var(--shadow-sm);
}

.metric-value {
    font-family: "Fraunces", Georgia, serif;
    font-weight: 600;
    font-size: 1.7rem;
    color: var(--green-900);
    line-height: 1.1;
}

.metric-label {
    margin-top: 6px;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

/* ---------- Industry Data ---------- */

.industry {
    animation: rise 0.55s var(--ease) both;
}

.industry-breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-bottom: 8px;
    transition: color 0.18s var(--ease);
}

.industry-breadcrumb::before {
    content: "\2190";
    font-size: 0.9rem;
}

.industry-breadcrumb:hover {
    color: var(--green-700);
}

.industry-status {
    margin: 22px 0;
    font-size: 0.95rem;
    color: var(--ink-faint);
}

.industry-status.is-error {
    color: #b23b2e;
}

.industry-chart-card {
    margin-top: 4px;
    padding: 22px 24px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.6);
    box-shadow: var(--shadow-sm);
}

.industry-chart-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 20px;
    margin-bottom: 14px;
}

.industry-chart-title {
    font-family: "Fraunces", Georgia, serif;
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--green-900);
    margin: 0;
}

.industry-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.industry-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.86rem;
    color: var(--ink-soft);
}

.industry-legend-swatch {
    width: 14px;
    height: 3px;
    border-radius: 2px;
    display: inline-block;
}

.industry-legend-unit {
    color: var(--ink-faint);
}

.industry-controls {
    display: flex;
    align-items: center;
    margin-bottom: 14px;
}

.industry-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.industry-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.industry-toggle-track {
    position: relative;
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: var(--stone-200);
    border: 1px solid var(--line);
    transition: background 0.18s var(--ease);
    flex: none;
}

.industry-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s var(--ease);
}

.industry-toggle input:checked + .industry-toggle-track {
    background: var(--green-600);
    border-color: var(--green-600);
}

.industry-toggle input:checked + .industry-toggle-track .industry-toggle-thumb {
    transform: translateX(18px);
}

.industry-toggle input:focus-visible + .industry-toggle-track {
    outline: 2px solid var(--green-500);
    outline-offset: 2px;
}

.industry-toggle-text {
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.industry-chart-wrap {
    position: relative;
    height: clamp(320px, 52vh, 520px);
}

.industry-source {
    margin: 14px 0 0;
    font-size: 0.78rem;
    color: var(--ink-faint);
    line-height: 1.5;
}

.industry .tabbar {
    margin-top: 8px;
}

.grain-toggle {
    display: inline-flex;
    border: 1px solid var(--stone-300);
    border-radius: 8px;
    overflow: hidden;
    background: var(--paper);
}

.grain-btn {
    appearance: none;
    font: inherit;
    font-size: 0.86rem;
    padding: 7px 12px;
    border: none;
    background: transparent;
    color: var(--ink-soft);
    cursor: pointer;
}

.grain-btn + .grain-btn {
    border-left: 1px solid var(--stone-300);
}

.grain-btn.is-active {
    background: var(--green-700);
    color: #fff;
}

.muted {
    color: var(--ink-faint);
    font-style: italic;
}

.overview-cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 26px;
}

.block-title {
    font-family: "Fraunces", Georgia, serif;
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--green-900);
    margin: 0 0 12px;
}

.block-note {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--ink-faint);
    margin: 12px 0 0;
    max-width: 70ch;
}

/* ---------- Data tables ---------- */

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px 18px;
    margin: 8px 0 16px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.5);
}

.filter-group {
    display: grid;
    gap: 6px;
}

.filter-group.grow {
    flex: 1;
    min-width: 160px;
}

.filter-label {
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.chk-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    align-items: center;
    min-height: 34px;
}

.chk {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--ink);
    cursor: pointer;
}

.filters select,
.filters input[type="text"],
.filters input[type="number"] {
    font: inherit;
    font-size: 0.9rem;
    padding: 8px 10px;
    border: 1px solid var(--stone-300);
    border-radius: 8px;
    background: var(--paper);
    color: var(--ink);
}

.filters input:focus,
.filters select:focus {
    outline: none;
    border-color: var(--green-500);
    box-shadow: 0 0 0 3px rgba(47, 125, 91, 0.15);
}

.f-minloc {
    width: 90px;
}

.btn-download {
    font: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 9px 16px;
    color: var(--stone-50);
    background: var(--green-700);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.18s var(--ease);
}

.btn-download:hover {
    background: var(--green-600);
}

.download-group {
    display: flex;
    gap: 6px;
    align-items: flex-end;
}

.btn-secondary-dl {
    background: transparent;
    color: var(--green-700);
    border: 1px solid var(--green-600);
}

.btn-secondary-dl:hover {
    background: var(--green-700);
    color: var(--stone-50);
}

.table-meta {
    font-size: 0.82rem;
    color: var(--ink-faint);
    margin-bottom: 8px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.6);
    max-height: 68vh;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.87rem;
}

.data-table.compact {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--stone-100);
    color: var(--ink-soft);
    text-align: left;
    font-weight: 500;
    font-size: 0.74rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 11px 12px;
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
}

.data-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.data-table th.sortable:hover {
    color: var(--green-700);
}

.data-table td {
    padding: 9px 12px;
    border-bottom: 1px solid rgba(32, 36, 31, 0.07);
    vertical-align: top;
}

.data-table tbody tr:hover {
    background: rgba(47, 125, 91, 0.06);
}

.data-table .num {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.pcc-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 7px;
    vertical-align: baseline;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.score-cell {
    position: relative;
    min-width: 74px;
}

.score-bar {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 20px;
    background: rgba(47, 125, 91, 0.16);
    border-radius: 4px;
    z-index: 0;
}

.score-num {
    position: relative;
    z-index: 1;
}

/* ---------- Company detail ---------- */

.company-picker {
    display: grid;
    gap: 6px;
    max-width: 460px;
    margin-bottom: 22px;
}

.company-picker select {
    font: inherit;
    font-size: 0.95rem;
    padding: 10px 12px;
    border: 1px solid var(--stone-300);
    border-radius: 8px;
    background: var(--paper);
}

.company-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.company-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
}

.company-metrics span {
    display: grid;
    font-family: "Fraunces", Georgia, serif;
    font-size: 1.05rem;
    color: var(--green-900);
}

.company-metrics em {
    font-family: "Spline Sans", sans-serif;
    font-style: normal;
    font-size: 0.68rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-bottom: 2px;
}

.verdict {
    margin: 18px 0;
    padding: 14px 16px;
    border-radius: 10px;
    font-size: 0.92rem;
    line-height: 1.5;
    border: 1px solid transparent;
}

.verdict-good {
    background: rgba(47, 125, 91, 0.12);
    border-color: rgba(47, 125, 91, 0.3);
    color: var(--green-700);
}

.verdict-warn {
    background: rgba(176, 138, 62, 0.14);
    border-color: rgba(176, 138, 62, 0.35);
    color: #8a6a24;
}

.verdict-bad {
    background: rgba(215, 48, 39, 0.1);
    border-color: rgba(215, 48, 39, 0.3);
    color: #a12a22;
}

.company-cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-top: 8px;
}

.company-block h3 {
    font-size: 0.78rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin: 0 0 10px;
}

table.kv {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

table.kv th {
    text-align: left;
    font-weight: 500;
    color: var(--ink-soft);
    padding: 7px 12px 7px 0;
    white-space: nowrap;
    vertical-align: top;
    width: 34%;
}

table.kv td {
    padding: 7px 0;
    color: var(--ink);
    border-bottom: 1px solid rgba(32, 36, 31, 0.06);
    word-break: break-word;
}

/* ---------- Documentation ---------- */

.docs {
    max-width: 78ch;
    line-height: 1.65;
    color: var(--ink-soft);
}

.docs h1,
.docs h2,
.docs h3 {
    font-family: "Fraunces", Georgia, serif;
    color: var(--green-900);
    line-height: 1.2;
    margin: 1.6em 0 0.5em;
}

.docs h1 { font-size: 1.7rem; }
.docs h2 { font-size: 1.3rem; }
.docs h3 { font-size: 1.08rem; }

.docs p { margin: 0.7em 0; }

.docs a { color: var(--green-700); text-decoration: underline; }

.docs code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.88em;
    background: rgba(32, 36, 31, 0.07);
    padding: 1px 5px;
    border-radius: 4px;
}

.docs pre {
    background: var(--green-900);
    color: var(--stone-50);
    padding: 14px 16px;
    border-radius: 10px;
    overflow-x: auto;
    font-size: 0.82rem;
}

.docs pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.docs table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
    font-size: 0.88rem;
}

.docs th,
.docs td {
    border: 1px solid var(--line);
    padding: 8px 10px;
    text-align: left;
    vertical-align: top;
}

.docs th {
    background: var(--stone-100);
}

.docs hr {
    border: none;
    border-top: 1px solid var(--line);
    margin: 1.8em 0;
}

.docs blockquote {
    border-left: 3px solid var(--green-600);
    margin: 1em 0;
    padding: 0.2em 1em;
    color: var(--ink-faint);
}

@media (max-width: 820px) {
    .tabbar { gap: 0; }
    .tab { padding: 9px 10px; font-size: 0.86rem; }
}

/* ---------- Admin: Goodturn-style user access (scoped to .gt) ---------- */
/*
 * A self-contained slate design system that mirrors the Goodturn portal's
 * /admin page (Tailwind slate/rose/emerald vocabulary), reproduced as plain
 * CSS so it ships through the normal asset pipeline. Everything is scoped
 * under .gt so it never touches the rest of the Palm Court branding.
 */

.gt {
    width: 100%;
    max-width: 64rem;
    margin: 0 auto;
    color: #0f172a;
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    animation: rise 0.5s var(--ease) both;
}

.gt *,
.gt *::before,
.gt *::after {
    box-sizing: border-box;
}

/* Header */
.gt-head {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}

.gt-title {
    margin: 0;
    font-size: 24px;
    line-height: 1.2;
    font-weight: 600;
    color: #0f172a;
}

.gt-sub {
    margin: 4px 0 0;
    font-size: 14px;
    color: #64748b;
}

.gt-head-right {
    font-size: 12px;
    color: #64748b;
}

.gt-head-right strong {
    font-weight: 600;
    color: #334155;
}

@media (min-width: 768px) {
    .gt-head {
        flex-direction: row;
        align-items: flex-end;
        justify-content: space-between;
    }
}

/* Tabs */
.gt-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 1px solid #e2e8f0;
}

.gt-tab {
    position: relative;
    margin-bottom: -1px;
    padding: 8px 12px;
    border-bottom: 2px solid transparent;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    text-decoration: none;
    transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.gt-tab:hover {
    color: #334155;
}

.gt-tab.is-active {
    border-bottom-color: #0f172a;
    color: #0f172a;
}

/* Banners */
.gt-banner {
    margin-bottom: 24px;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-size: 14px;
}

.gt-banner-ok {
    border-color: #a7f3d0;
    background: #ecfdf5;
    color: #065f46;
}

.gt-banner-err {
    border-color: #fecdd3;
    background: #fff1f2;
    color: #881337;
}

/* Cards */
.gt-card {
    padding: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
}

.gt-card-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
}

/* Add-user form grid */
.gt-add-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 12px;
}

@media (min-width: 768px) {
    .gt-add-grid {
        grid-template-columns: 1fr 1fr 140px 120px;
    }
}

/* Form controls */
.gt-input,
.gt-select {
    width: 100%;
    font: inherit;
    font-size: 14px;
    padding: 8px 12px;
    color: #0f172a;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.gt-input:focus,
.gt-select:focus {
    outline: none;
    border-color: #64748b;
    box-shadow: 0 0 0 1px #64748b;
}

/* Buttons */
.gt-btn {
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    border: 1px solid transparent;
    transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}

.gt-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.gt-btn-primary {
    font-size: 14px;
    padding: 8px 16px;
    color: #ffffff;
    background: #0f172a;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.gt-btn-primary:hover:not(:disabled) {
    background: #1e293b;
}

.gt-btn-outline {
    font-size: 12px;
    padding: 4px 10px;
    color: #334155;
    background: #ffffff;
    border-color: #cbd5e1;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.gt-btn-outline:hover:not(:disabled) {
    background: #f8fafc;
}

.gt-btn-danger {
    font-size: 12px;
    padding: 4px 10px;
    color: #be123c;
    background: #fff1f2;
    border-color: #fecdd3;
}

.gt-btn-danger:hover:not(:disabled) {
    background: #ffe4e6;
}

/* Table */
.gt-table-wrap {
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.gt-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
}

.gt-table thead {
    background: #f8fafc;
}

.gt-table th {
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
}

.gt-table td {
    padding: 10px 16px;
    vertical-align: middle;
    color: #334155;
}

.gt-table tbody tr:not(:first-child) td {
    border-top: 1px solid #f1f5f9;
}

.gt-table .gt-empty {
    padding: 24px 16px;
    text-align: center;
    color: #64748b;
}

.gt-cell-right {
    text-align: right;
}

/* Username cell */
.gt-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: #334155;
}

.gt-you {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 6px;
    border-radius: 4px;
    background: #f1f5f9;
    font-size: 10px;
    font-family: ui-sans-serif, system-ui, sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
}

/* Small inline selects (row role + "+ access") */
.gt-select-sm {
    font: inherit;
    font-size: 12px;
    padding: 4px 8px;
    color: #0f172a;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.gt-select-sm:focus {
    outline: none;
    border-color: #64748b;
    box-shadow: 0 0 0 1px #64748b;
}

.gt-select-sm:disabled {
    opacity: 0.5;
}

.gt-add-chip {
    border-style: dashed;
    color: #64748b;
    padding: 2px 6px;
    font-size: 11px;
}

/* Chips */
.gt-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.gt-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 9999px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    font-size: 11px;
    color: #334155;
}

.gt-chip-x {
    font: inherit;
    font-size: 11px;
    line-height: 1;
    margin-left: 2px;
    padding: 0 4px;
    border: 0;
    border-radius: 9999px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.gt-chip-x:hover {
    background: #e2e8f0;
    color: #334155;
}

/* Pills (all-admin hint + status) */
.gt-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    background: #f1f5f9;
    font-size: 11px;
    color: #64748b;
}

.gt-pill-ok {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.gt-pill-off {
    background: #fff1f2;
    color: #9f1239;
    border: 1px solid #fecdd3;
}

/* Actions cell */
.gt-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.gt-inline {
    display: inline;
    margin: 0;
}

.gt-meta {
    font-size: 12px;
    color: #64748b;
}

.btn-danger {
    font: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 9px 16px;
    color: #9a2f2f;
    background: transparent;
    border: 1px solid rgba(154, 47, 47, 0.5);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.18s var(--ease), color 0.18s var(--ease);
}

.btn-danger:hover {
    background: #9a2f2f;
    color: var(--stone-50);
    border-color: #9a2f2f;
}
