/* ==========================================================================
   VELCREST PORTAL — THEME & LAYOUT
   ==========================================================================
   The portal runs on the SAME design system as velcrestwebdev.com: the
   "Nocturne" language locked in on 2026-09-14/15. Every token below is copied
   verbatim from the @theme block in site/src/css/tailwind.css — do not
   approximate them, and do not add colours that are not here.

   The three rules this sheet exists to hold:

   1. BUTTONS ARE TRANSPARENT. No solid fills anywhere, ever. .btn-primary and
      .btn-secondary differ only in the weight of a 1px border; hover brings
      the signal amber to the border and the label with at most an 8% wash.
      Flat 2px-radius rectangles — no pills, gradients, glows, shimmer or
      bounce. (The login screen used to have a solid amber "Sign In" button.)

   2. THE AMBER IS A SIGNAL, NOT A THEME. On the marketing site it appears
      only on the logo's massif, one small label per section, the field focus
      underline and button hover. In here that budget is spent on: the logo,
      the active sidebar item, the current phase in a stepper, field focus and
      validation, button hover, and the progress line. Nothing else.

   3. FONTS ARE SELF-HOSTED. css/fonts.css, pulled in on the first line below.
      Never a Google Fonts (or any CDN) link — the published privacy policy
      says no third party is involved beyond the host and the mail provider.

   Contrast floors that were audited and must not be softened:
     --color-line-strong  control borders   ~4.0:1 on void, ~4.1:1 on surface
     --color-line-field   field underlines  ~4.4:1 on void
     --color-line         DECORATIVE 1px rules only (1.5:1 — never a control)
     --color-text-3       DECORATIVE only — never used for text
   ========================================================================== */

@import url("fonts.css");

:root {
    color-scheme: dark;

    /* --- Nocturne tokens (site/src/css/tailwind.css @theme) --------------- */
    --color-void: #050505;          /* page canvas */
    --color-surface: #111111;       /* panels, cards, sidebar */
    --color-surface-2: #1c1c1c;     /* cells inside panels */
    --color-line: rgba(255, 255, 255, 0.14);        /* decorative rules ONLY */
    --color-line-strong: rgba(255, 255, 255, 0.42); /* control borders */
    --color-line-field: rgba(255, 255, 255, 0.45);  /* form underlines */
    --color-text: #f4f4f2;
    --color-text-2: #a6a6a3;        /* reading text, labels (8.3:1 on void) */
    --color-text-3: #6f6f6c;        /* DECORATIVE only — fails AA for text */
    --color-signal: #e8992c;        /* Velcrest amber, tiny doses only */
    --color-signal-hover: #ffc96b;
    --signal-wash: rgba(232, 153, 44, 0.08);
    --signal-wash-soft: rgba(232, 153, 44, 0.06);

    --font-display: 'Outfit', ui-sans-serif, system-ui, sans-serif;
    --font-sans: 'Manrope', ui-sans-serif, system-ui, sans-serif;

    --ease-brand: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out-brand: cubic-bezier(0.16, 1, 0.3, 1);

    /* --- legacy aliases ---------------------------------------------------
       The portal's markup and its older rules were written against these
       names. They now resolve to the system above so nothing can render
       off-palette. NOTE --ink-faint: it is deliberately the SAME value as
       --ink-soft. It used to be a dim grey and it is applied to real reading
       text (timestamps, hints, meta rows, file facts); --color-text-3 would
       fail AA for every one of them. Hierarchy comes from size and tracking
       in this system, not from a third grey. ---------------------------- */
    --bg: var(--color-void);
    --surface: var(--color-surface);
    --surface2: var(--color-surface-2);
    --card-bg: var(--color-surface);
    --dark: var(--color-void);
    --ink: var(--color-text);
    --ink-soft: var(--color-text-2);
    --ink-faint: var(--color-text-2);
    --border: var(--color-line);          /* decorative hairlines */
    --border-control: var(--color-line-strong); /* anything you can click */
    --accent: var(--color-signal);
    --accent-light: var(--color-signal-hover);
    --accent-dark: #9a5f0f;

    /* --- state palette ----------------------------------------------------
       The system has no status colours, but a portal has to say "failed",
       "clean", "pending". Kept to three, all measured on --color-surface:
       amber carries pending/warning (it is already the attention colour, and
       this is the only place a state is allowed to borrow it), one muted
       brick for danger, one muted jade for success. No blue: "info" resolves
       to plain white text so it adds no fourth hue. ---------------------- */
    --status-success: #6fbf9a;  /* 8.6:1 on surface */
    --status-warning: var(--color-signal); /* 8.1:1 on surface */
    --status-error: #e2675c;    /* 5.7:1 on surface */
    --status-info: var(--color-text);

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;

    /* Radius — the brand is flat 2px rectangles. Circles stay circles. */
    --radius: 2px;

    /* Transitions */
    --transition: 0.25s ease;
    --transition-slow: 0.3s var(--ease-brand);
}

/* ========================================
   BASE
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: var(--font-sans);
    font-size: 15px;
    background-color: var(--color-void);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

@media (min-width: 64rem) {
    body { font-size: 16px; }
}

img, svg { display: block; max-width: 100%; }

::selection {
    background: var(--color-signal);
    color: var(--color-void);
}

/* Thin, unobtrusive scrollbars on the panes that actually scroll. */
.content-wrapper,
.sidebar,
.sidebar-nav,
.thread-list,
.modal,
.table-container {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

/* ========================================
   TYPOGRAPHY
   Display type is Outfit, uppercase, wide tracking (the .t-h* recipes from
   the site). Reading type is Manrope. Micro-labels are the site's .lbl:
   11px / 600 / 0.2em / uppercase.
   ======================================== */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 500;
    text-transform: uppercase;
    line-height: 1.1;
    color: var(--color-text);
    overflow-wrap: anywhere;
}

h1 { font-size: clamp(1.5rem, 2.6vw, 2rem); letter-spacing: 0.05em; line-height: 1.05; }
h2 { font-size: clamp(1.25rem, 1.9vw, 1.5rem); letter-spacing: 0.06em; }
h3 { font-size: 1.0625rem; letter-spacing: 0.07em; }
h4 { font-size: 0.9375rem; letter-spacing: 0.08em; }
h5 { font-size: 0.8125rem; letter-spacing: 0.1em; }
h6 { font-size: 0.75rem; letter-spacing: 0.12em; }

p { margin-bottom: var(--spacing-md); }
small { font-size: 0.8125rem; color: var(--color-text-2); }

a { color: inherit; }

/* ========================================
   BUTTONS
   Copied from the .btn / .btn-primary / .btn-outline / .btn-sm rules in
   site/src/css/tailwind.css. BACKGROUND IS TRANSPARENT ON EVERY VARIANT.
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-height: 44px;
    padding: 0.9rem 1.6rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    position: relative;
    transition:
        background-color var(--transition),
        border-color var(--transition),
        color var(--transition);
}

/* Disabled controls are exempt from 1.4.11, but they still have to read as
   present. An opacity fade was dropping the border below anything visible. */
.btn:disabled,
.btn[aria-disabled="true"] {
    color: var(--color-text-3);
    border-color: var(--color-line);
    background: transparent;
    cursor: not-allowed;
}

.btn-primary {
    color: var(--color-text);
    border-color: var(--color-text);
}

.btn-primary:hover:not(:disabled) {
    background: var(--signal-wash);
    border-color: var(--color-signal);
    color: var(--color-signal);
}

.btn-secondary {
    color: var(--color-text);
    border-color: var(--color-line-strong);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--signal-wash-soft);
    border-color: var(--color-signal);
    color: var(--color-signal);
}

/* The quietest of the three: a dim label until you reach for it. */
.btn-tertiary {
    color: var(--color-text-2);
    border-color: var(--color-line-strong);
}

.btn-tertiary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--color-text);
    color: var(--color-text);
}

/* Destructive. Still transparent — the colour is in the border and label. */
.btn-danger {
    color: var(--status-error);
    border-color: var(--status-error);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(226, 103, 92, 0.08);
    border-color: var(--status-error);
    color: var(--status-error);
}

.btn-small {
    min-height: 40px;
    padding: 0.7rem 1.2rem;
    font-size: 11px;
    letter-spacing: 0.14em;
}

.btn-large {
    width: 100%;
    min-height: 48px;
    padding: 1rem 1.6rem;
    font-size: 12px;
}

/* The loader span carries real text ("Loading…", "Verifying…", "Sending…").
   It used to be styled as a 16px circle, which cropped that text to nothing.
   It is now the label plus a small spinner drawn in ::before. */
.btn-loader {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
}

.btn-loader::before {
    content: "";
    width: 13px;
    height: 13px;
    border: 1.5px solid var(--color-line-strong);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   FORMS — underline-only fields, the site's .field
   ======================================== */

.form-group {
    margin-bottom: var(--spacing-lg);
    display: flex;
    flex-direction: column;
}

/* The site's .field-label. */
label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--color-text-2);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
input[type="url"],
input[type="search"],
textarea,
select {
    width: 100%;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--color-line-field);
    border-radius: 0;
    padding: 0.7rem 0;
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.4;
    color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-bottom-color: var(--color-signal);
    box-shadow: 0 1px 0 0 var(--color-signal);
}

input::placeholder,
textarea::placeholder {
    color: var(--color-text-2);
}

/* Chrome paints its own blue-on-cream block over autofilled fields. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--color-text);
    caret-color: var(--color-text);
    -webkit-box-shadow: 0 0 0 1000px var(--color-void) inset;
    transition: background-color 9999s ease-in-out 0s;
}

textarea {
    resize: vertical;
    min-height: 6.5rem;
    font-family: var(--font-sans);
}

select {
    appearance: none;
    padding-right: 2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%23a6a6a3' stroke-width='1.5'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.25rem center;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.form-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--color-signal);
    flex-shrink: 0;
}

/* Inline with a control, so this one stays sentence-case reading text. */
.form-checkbox label {
    margin-bottom: 0;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--color-text-2);
    cursor: pointer;
}

.form-hint {
    display: block;
    margin-top: 0.5rem;
    font-size: 12px;
    line-height: 1.5;
    color: var(--color-text-2);
}

/* Validation uses the SIGNAL, exactly as the marketing site's .field-error and
   .field[aria-invalid] do. The brick red is kept for destructive actions and
   hard failures (a rejected upload, a delete confirmation), not for a typo. */
.error-message {
    display: block;
    margin-top: 0.5rem;
    font-size: 12px;
    line-height: 1.5;
    color: var(--color-signal);
    min-height: 1.2em;
}

.form-group.error input,
.form-group.error textarea,
.form-group.error select,
input[aria-invalid="true"],
textarea[aria-invalid="true"],
select[aria-invalid="true"] {
    border-bottom-color: var(--color-signal);
    box-shadow: 0 1px 0 0 var(--color-signal);
    background-color: transparent;
}

/* ========================================
   CARDS & CONTAINERS
   ======================================== */

.card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: var(--radius);
    padding: var(--spacing-lg);
    transition: border-color var(--transition), background-color var(--transition);
}

.card:hover {
    border-color: var(--color-line-strong);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--color-line);
}

.card-title {
    font-size: 1rem;
    letter-spacing: 0.07em;
    margin: 0;
    color: var(--color-text);
}

.card-subtitle {
    color: var(--color-text-2);
    font-size: 0.9rem;
}

/* ========================================
   GRID
   ======================================== */

.grid { display: grid; gap: var(--spacing-lg); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ========================================
   AUTH SCREENS
   ======================================== */

.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--color-void);
    padding: var(--spacing-xl) var(--spacing-md);
}

.auth-container.hidden { display: none; }

.auth-screen { width: 100%; max-width: 420px; }
.auth-screen.hidden { display: none; }

.auth-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: var(--radius);
    padding: var(--spacing-2xl) var(--spacing-xl);
}

/* THE LOCKUP. Drawn as a decorative background on the card rather than an
   <img>, because portal/index.html is owned by someone else this pass — the
   <img> markup is written out in portal/BRANDING_NOTES.md. The <h1> under it
   supplies the accessible name, so nothing is lost by this being decorative.
   Never recolour the file: the snow cap on the massif is snow, and is always
   white. */
.auth-card::before {
    content: "";
    display: block;
    width: clamp(148px, 46%, 184px);
    aspect-ratio: 1548 / 1169;
    margin: 0 auto var(--spacing-lg);
    background: url(../brand/velcrest-logo-fullname.svg) center / contain no-repeat;
}

.auth-title {
    font-size: 1.125rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    margin-bottom: var(--spacing-xs);
    text-align: center;
    color: var(--color-text);
}

.auth-subtitle {
    text-align: center;
    color: var(--color-text-2);
    font-size: 0.9375rem;
    margin-bottom: var(--spacing-xl);
}

.auth-form {
    display: flex;
    flex-direction: column;
}

.auth-form .btn + .btn {
    margin-top: var(--spacing-md);
}

.auth-link {
    display: inline-block;
    width: 100%;
    margin-top: var(--spacing-lg);
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--color-text-2);
    transition: color var(--transition);
}

.auth-link:hover { color: var(--color-text); }

.auth-link-bold {
    color: var(--color-text);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--color-line-strong);
    font-weight: 600;
    transition: text-decoration-color var(--transition);
}

.auth-link-bold:hover { text-decoration-color: var(--color-signal); }

.auth-divider {
    text-align: center;
    color: var(--color-text-2);
    margin: var(--spacing-xl) 0;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.auth-footer {
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--color-line);
    text-align: center;
    color: var(--color-text-2);
    font-size: 0.875rem;
    line-height: 1.7;
}

.auth-footer .auth-link { margin-top: 0; }

/* ========================================
   APP LAYOUT
   ======================================== */

.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    background-color: var(--color-void);
}

.app-container.hidden { display: none; }

/* Sidebar */
.sidebar {
    width: 280px;
    flex: none;
    background-color: var(--color-surface);
    border-right: 1px solid var(--color-line);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
    z-index: 100;
}

.sidebar-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--color-line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
    color: var(--color-text);
    text-transform: none;
}

/* THE MARK. index.html still contains a literal "V" inside this span — it was
   a rounded amber square with a letter in it. The real mountain mark is drawn
   here as a background and the glyph is collapsed to nothing. Replace the span
   with the <img> in BRANDING_NOTES.md when index.html is next touched; that
   also stops screen readers announcing a stray "V" before "Velcrest". */
.brand-mark {
    display: block;
    width: 60px;
    height: 28px;
    flex: none;
    background: url(../brand/velcrest-mark-color.svg) left center / contain no-repeat;
    border-radius: 0;
    font-size: 0;
    line-height: 0;
    color: transparent;
    overflow: hidden;
}

.brand-text {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    white-space: nowrap;
}

.sidebar-close {
    display: none;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--color-text-2);
    font-size: 1.125rem;
    line-height: 1;
    cursor: pointer;
    width: 40px;
    height: 40px;
    flex: none;
    align-items: center;
    justify-content: center;
    transition: color var(--transition), border-color var(--transition);
}

.sidebar-close:hover {
    color: var(--color-text);
    border-color: var(--color-line-strong);
}

.sidebar-nav {
    flex: 1;
    padding: var(--spacing-lg) 0;
    overflow-y: auto;
}

.sidebar-nav nav {
    display: flex;
    flex-direction: column;
}

/* Navigation labels use the site nav's .lbl treatment. */
.nav-item {
    display: block;
    padding: 14px var(--spacing-lg);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--color-text-2);
    text-decoration: none;
    cursor: pointer;
    border-left: 2px solid transparent;
    transition: color var(--transition), background-color var(--transition), border-color var(--transition);
}

.nav-item:hover {
    color: var(--color-text);
    background-color: rgba(255, 255, 255, 0.04);
}

/* The one amber in this column besides the logo: where you are. */
.nav-item.active {
    color: var(--color-text);
    background-color: transparent;
    border-left-color: var(--color-signal);
}

.nav-section {
    padding: var(--spacing-lg) var(--spacing-lg) var(--spacing-sm);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--color-text-2);
}

.sidebar-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--color-line);
}

.user-info {
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-md);
    background-color: var(--color-surface-2);
    border: 1px solid var(--color-line);
    border-radius: var(--radius);
}

.user-info-name {
    display: block;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 2px;
    word-break: break-word;
}

/* block, not inline: the role label below is a sibling <span> and the two ran
   together on one line ("info@… ADMINISTRATOR") when this was inline. */
.user-info-email {
    display: block;
    font-size: 0.8125rem;
    color: var(--color-text-2);
    word-break: break-all;
}

.user-info-role {
    display: inline-block;
    margin-top: var(--spacing-sm);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--color-text-2);
}

/* Mobile header */
.mobile-header {
    display: none;
    position: sticky;
    top: 0;
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-line);
    padding: var(--spacing-sm) var(--spacing-md);
    z-index: 50;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
}

.menu-toggle {
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--color-text);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 44px;
    height: 44px;
    flex: none;
    align-items: center;
    justify-content: center;
    transition: border-color var(--transition);
}

.menu-toggle:hover { border-color: var(--color-line-strong); }

.menu-toggle span {
    width: 22px;
    height: 1px;
    background-color: currentColor;
    transition: transform var(--transition), opacity var(--transition);
}

.menu-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.menu-toggle.active span:nth-child(2) { opacity: 0; }
.menu-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

.header-title {
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.22em;
    margin: 0;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Main content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-xl);
}

.content-wrapper > * {
    max-width: 1200px;
    margin: 0 auto;
}

/* ========================================
   DASHBOARD COMPONENTS
   ======================================== */

.dashboard-title { margin-bottom: var(--spacing-xl); }
.dashboard-title h1 { margin: 0 0 var(--spacing-sm) 0; }

.dashboard-subtitle {
    color: var(--color-text-2);
    font-size: 0.9375rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.stat-card {
    background-color: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: var(--radius);
    padding: var(--spacing-lg);
}

.stat-value {
    font-family: var(--font-display);
    font-size: 2.25rem;
    font-weight: 400;
    line-height: 1;
    letter-spacing: 0.02em;
    color: var(--color-text);
    margin: var(--spacing-md) 0 var(--spacing-sm);
}

.stat-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--color-text-2);
}

/* Status badge — copied from the site's .status-badge (2px, surface-2 cell,
   decorative hairline, 11px tracked label). The state colour is carried by
   the dot and the label, never by a filled background. */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0.55rem 0.9rem;
    border: 1px solid var(--color-line);
    border-radius: var(--radius);
    background-color: var(--color-surface-2);
    width: fit-content;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--color-text-2);
}

.status-badge.active { color: var(--status-success); }
.status-badge.building { color: var(--status-warning); }
.status-badge.error { color: var(--status-error); }
.status-badge.inactive { color: var(--color-text-2); }

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    flex: none;
    background-color: var(--color-text-3);
    animation: pulse 2s ease-in-out infinite;
}

.status-dot.active { background-color: var(--status-success); }
.status-dot.building { background-color: var(--status-warning); }
.status-dot.error { background-color: var(--status-error); }
.status-dot.inactive { background-color: var(--color-text-3); animation: none; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

/* Progress — the portal's answer to the site's 1px amber scroll line. */
.progress-bar {
    width: 100%;
    height: 2px;
    background-color: var(--color-line);
    overflow: hidden;
    margin: var(--spacing-md) 0;
}

.progress-fill {
    height: 100%;
    background: var(--color-signal);
    transition: width 0.4s var(--ease-out-brand);
}

/* Timeline */
.timeline { position: relative; padding: var(--spacing-lg) 0; }

.timeline-item {
    display: grid;
    grid-template-columns: 24px 1fr;
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
    position: relative;
}

.timeline-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.timeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: transparent;
    border: 1px solid var(--color-line-strong);
    flex-shrink: 0;
    margin-top: 6px;
}

.timeline-item.active .timeline-dot {
    background-color: var(--color-signal);
    border-color: var(--color-signal);
}

.timeline-line {
    width: 1px;
    flex: 1;
    background-color: var(--color-line);
    margin: var(--spacing-sm) 0;
}

.timeline-item.active .timeline-line { background-color: var(--color-line-strong); }
.timeline-item:last-child .timeline-line { display: none; }

.timeline-content h4 { margin: 0 0 var(--spacing-sm) 0; }

.timeline-date {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--color-text-2);
}

.timeline-description {
    color: var(--color-text-2);
    font-size: 0.9375rem;
    margin-top: var(--spacing-sm);
}

/* Table */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--color-line);
    border-radius: var(--radius);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--color-surface);
}

.table thead {
    background-color: var(--color-surface-2);
    border-bottom: 1px solid var(--color-line);
}

.table th {
    padding: var(--spacing-md) var(--spacing-lg);
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--color-text-2);
    white-space: nowrap;
}

.table td {
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--color-line);
    color: var(--color-text-2);
    font-size: 0.9375rem;
}

.table tbody tr { transition: background-color var(--transition); }
.table tbody tr:hover { background-color: var(--color-surface-2); }
.table tbody tr:last-child td { border-bottom: none; }

/* ========================================
   MODAL
   ======================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(5, 5, 5, 0.86);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--spacing-md);
}

.modal {
    background-color: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: var(--radius);
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    padding: var(--spacing-lg) var(--spacing-xl);
    border-bottom: 1px solid var(--color-line);
}

.modal-title {
    font-size: 1.0625rem;
    letter-spacing: 0.07em;
    margin: 0;
}

.modal-close {
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--color-text-2);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    width: 40px;
    height: 40px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition), border-color var(--transition);
}

.modal-close:hover {
    color: var(--color-text);
    border-color: var(--color-line-strong);
}

.modal-body { padding: var(--spacing-xl); }
.modal-body p { color: var(--color-text-2); }

.modal-footer {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-lg) var(--spacing-xl) var(--spacing-xl);
    border-top: 1px solid var(--color-line);
}

.modal-footer .btn { flex: 1; }

/* ========================================
   TOASTS
   Solid surface panel, 1px border and label in the state colour. No filled
   washes of colour — the text sits on --color-surface so its contrast is the
   same every time (white 15.9:1; the three state hues 5.7:1 or better).
   ======================================== */

.toast-container {
    position: fixed;
    top: var(--spacing-lg);
    right: var(--spacing-lg);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    min-width: 300px;
    max-width: 380px;
    background-color: var(--color-surface);
    border: 1px solid var(--color-line-strong);
    border-left-width: 2px;
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 0.9375rem;
    pointer-events: all;
    animation: slideIn 0.3s var(--ease-out-brand);
}

@keyframes slideIn {
    from { transform: translateX(24px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left-color: var(--status-success); }
.toast.error { border-left-color: var(--status-error); }
.toast.warning { border-left-color: var(--status-warning); }
.toast.info { border-left-color: var(--color-text); }

.toast-icon { font-size: 1rem; flex-shrink: 0; line-height: 1; }
.toast.success .toast-icon { color: var(--status-success); }
.toast.error .toast-icon { color: var(--status-error); }
.toast.warning .toast-icon { color: var(--status-warning); }
.toast.info .toast-icon { color: var(--color-text); }

.toast-message { flex: 1; font-weight: 500; }

.toast-close {
    background: none;
    border: none;
    color: var(--color-text-2);
    cursor: pointer;
    font-size: 1.125rem;
    line-height: 1;
    padding: 0;
    width: 24px;
    height: 24px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--transition);
}

.toast-close:hover { color: var(--color-text); }

/* ========================================
   LOADING
   ======================================== */

.loading-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(5, 5, 5, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-overlay.hidden { display: none; }

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 1px solid var(--color-line);
    border-top-color: var(--color-text);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.skeleton {
    background: linear-gradient(90deg, var(--color-surface) 0%, var(--color-surface-2) 50%, var(--color-surface) 100%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================
   CLIENT PORTAL SPECIFIC
   ======================================== */

/* Was a full amber gradient block with black text — the single largest flood
   of orange in the portal. It is now a panel with one hairline of signal. */
.project-hero {
    position: relative;
    background-color: var(--color-surface);
    border: 1px solid var(--color-line);
    border-top: 1px solid var(--color-signal);
    border-radius: var(--radius);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    color: var(--color-text);
}

.project-hero h1 {
    color: var(--color-text);
    margin: 0 0 var(--spacing-md) 0;
}

.project-meta {
    display: flex;
    gap: var(--spacing-xl);
    flex-wrap: wrap;
}

.project-meta-item {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.project-meta-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--color-text-2);
}

.project-meta-value {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text);
}

.revision-bar {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin: var(--spacing-lg) 0;
}

.revision-text {
    min-width: 120px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--color-text-2);
}

.revision-used { color: var(--color-text); }
.revision-total { color: var(--color-text-2); }

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: var(--radius);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.chat-message { display: flex; flex-direction: column; gap: var(--spacing-xs); }
.chat-message.sent { align-items: flex-end; }
.chat-message.received { align-items: flex-start; }

.chat-bubble {
    max-width: 70%;
    padding: var(--spacing-md);
    border: 1px solid var(--color-line);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    line-height: 1.5;
}

/* Ours vs theirs is told by the border and the alignment, not by a fill. */
.chat-message.sent .chat-bubble {
    background-color: var(--color-surface-2);
    border-color: var(--color-line-strong);
    color: var(--color-text);
}

.chat-message.received .chat-bubble {
    background-color: transparent;
    color: var(--color-text-2);
}

.chat-time {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-2);
}

.chat-input-area {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    border-top: 1px solid var(--color-line);
}

.chat-input-area textarea {
    flex: 1;
    resize: none;
    min-height: 44px;
    max-height: 120px;
}

.chat-send-btn { align-self: flex-end; }

/* ========================================
   FOCUS — visible on everything focusable, in both themes of surface.
   The site's rule: 2px solid --color-text, offset 3px.
   ======================================== */

:focus-visible {
    outline: 2px solid var(--color-text);
    outline-offset: 3px;
}

/* The sidebar slides off-canvas below 1024px rather than unmounting, so
   without this a keyboard user tabs into links they cannot see. Handled in
   the responsive block below with visibility. */

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 1024px) {
    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        height: 100%;
        width: 280px;
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform var(--transition-slow), visibility 0s linear var(--transition-slow);
        z-index: 200;
    }

    .sidebar.open {
        transform: translateX(0);
        visibility: visible;
        transition: transform var(--transition-slow), visibility 0s;
    }

    .sidebar-close { display: flex; }
    .mobile-header { display: flex; }

    .content-wrapper { padding: var(--spacing-lg); }

    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

    .modal { max-width: 90vw; }
}

@media (max-width: 768px) {
    .auth-card { padding: var(--spacing-xl) var(--spacing-lg); }
    .content-wrapper { padding: var(--spacing-md); }
    .stat-grid { grid-template-columns: 1fr; }
    .toast { min-width: 0; max-width: none; }
    .table { font-size: 0.875rem; }
    .table th, .table td { padding: var(--spacing-sm) var(--spacing-md); }
    .project-hero { padding: var(--spacing-lg); }
    .project-meta { flex-direction: column; gap: var(--spacing-md); }
    .modal-header { padding: var(--spacing-md) var(--spacing-lg); }
    .modal-body { padding: var(--spacing-lg); }
    .modal-footer { padding: var(--spacing-md) var(--spacing-lg) var(--spacing-lg); }
}

@media (max-width: 480px) {
    .sidebar { width: 100%; }

    .toast-container {
        right: var(--spacing-sm);
        left: var(--spacing-sm);
        top: var(--spacing-sm);
    }

    .toast { align-items: flex-start; }

    .modal-footer { flex-direction: column; }
    .chat-bubble { max-width: 88%; }

    /* Tracked uppercase labels are already at their floor; the button
       padding is what gives, not the type size. */
    .btn { padding: 0.9rem 1.1rem; }
    .btn-large { padding: 1rem 1.1rem; }
}

/* ========================================
   MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0s !important;
        scroll-behavior: auto !important;
    }

    .loading-spinner,
    .btn-loader::before,
    .status-dot,
    .skeleton {
        animation: none !important;
    }
}

/* ========================================
   UTILITIES
   ======================================== */

.hidden { display: none !important; }
.invisible { visibility: hidden; }
.opacity-50 { opacity: 0.5; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--color-text-2); }
.text-accent { color: var(--color-signal); }
.text-danger { color: var(--status-error); }
.text-success { color: var(--status-success); }

.mt-md { margin-top: var(--spacing-md); }
.mb-md { margin-bottom: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mb-lg { margin-bottom: var(--spacing-lg); }
