/* =========================================================
   portal.css · prefire · access terminal
   User + admin shared design system
   ========================================================= */

:root {
    /* Surface scale -------------------------------------- */
    --bg:         #0a0a0c;
    --bg-deep:    #050507;
    --bg-1:       #111114;
    --bg-2:       #16161a;
    --bg-3:       #1d1d22;
    --bg-4:       #25252c;

    /* Lines / borders (hard, high-contrast) ------------- */
    --line:           rgba(255, 255, 255, 0.06);
    --line-bright:    rgba(255, 255, 255, 0.10);
    --line-emphasis:  rgba(255, 255, 255, 0.18);
    --line-red:       rgba(239, 68, 68, 0.40);

    /* Foreground / text -------------------------------- */
    --fg:        #f4f4f5;
    --fg-soft:   #d4d4d8;
    --fg-mute:   #a1a1aa;
    --fg-dim:    #71717a;
    --fg-faint:  #52525b;
    --fg-ghost:  #3f3f46;

    /* Brand red --------------------------------------- */
    --red:        #ef4444;
    --red-bright: #f87171;
    --red-dim:    #dc2626;
    --red-deep:   #991b1b;
    --red-soft:   rgba(239, 68, 68, 0.10);
    --red-mid:    rgba(239, 68, 68, 0.18);
    --red-edge:   rgba(239, 68, 68, 0.32);
    --red-glow:   rgba(239, 68, 68, 0.55);

    /* Status colors (deliberately neutral so red stays the accent) */
    --ok:        #4ade80;
    --ok-soft:   rgba(74, 222, 128, 0.10);
    --ok-edge:   rgba(74, 222, 128, 0.30);
    --warn:      #f5b542;
    --warn-soft: rgba(245, 181, 66, 0.10);
    --warn-edge: rgba(245, 181, 66, 0.32);
    --alert:     #ff6b6b;
    --alert-soft:rgba(255, 107, 107, 0.10);
    --alert-edge:rgba(255, 107, 107, 0.36);

    /* Radii (sharp by default) ------------------------ */
    --r-0: 0;
    --r-1: 2px;
    --r-2: 3px;
    --r-3: 6px;
    --r-4: 10px;

    /* Spacing 4px scale ------------------------------- */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 20px;
    --s-6: 24px;
    --s-7: 32px;
    --s-8: 40px;
    --s-9: 56px;
    --s-10: 72px;
    --s-11: 96px;

    /* Typography ------------------------------------- */
    --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono:  'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --font-zh:    'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', 'Heiti TC', sans-serif;

    /* Motion ----------------------------------------- */
    --ease:       cubic-bezier(0.16, 1, 0.3, 1);
    --ease-snap:  cubic-bezier(0.32, 0.72, 0.18, 1);
    --t-fast:     120ms;
    --t-base:     200ms;
    --t-slow:     400ms;
}

/* =========================================================
   Reset · Base
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: dark; background: var(--bg-deep); }

body {
    font-family: var(--font-sans);
    font-feature-settings: 'cv11', 'ss01';
    font-size: 14px;
    line-height: 1.55;
    color: var(--fg);
    background: var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    letter-spacing: -0.005em;
    position: relative;
}
body.lang-zh {
    font-family: var(--font-zh), var(--font-sans);
    letter-spacing: 0;
}

img, svg { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; background: transparent; }
button { border: none; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* =========================================================
   Background — dot grid + corner red glow
   ========================================================= */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -3;
    background-image:
        radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 28px 28px;
    background-position: 0 0;
    mask-image: radial-gradient(ellipse 100% 70% at 50% 30%, #000 50%, transparent 95%);
    -webkit-mask-image: radial-gradient(ellipse 100% 70% at 50% 30%, #000 50%, transparent 95%);
    pointer-events: none;
    opacity: 0.7;
}

body::after {
    content: "";
    position: fixed;
    z-index: -2;
    top: -220px;
    right: -180px;
    width: 720px;
    height: 720px;
    background: radial-gradient(circle, rgba(239, 68, 68, 0.16), transparent 65%);
    filter: blur(40px);
    pointer-events: none;
    animation: glow-drift 22s ease-in-out infinite;
}

@keyframes glow-drift {
    0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.85; }
    50%      { transform: translate(-40px, 60px) scale(1.08); opacity: 1; }
}

/* Hide any leftover particle canvas if reused */
.particle-canvas { display: none !important; }

/* Scrollbars ------------------------------------------ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb {
    background: var(--line-bright);
    border: 2px solid var(--bg);
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: var(--line-emphasis); }
* { scrollbar-color: var(--line-emphasis) transparent; scrollbar-width: thin; }

::selection { background: var(--red-edge); color: #fff; }

/* =========================================================
   Typography utilities
   ========================================================= */
h1, h2, h3, h4 {
    margin: 0;
    font-weight: 500;
    line-height: 1.18;
    color: var(--fg);
    letter-spacing: -0.02em;
}
.lang-zh h1, .lang-zh h2, .lang-zh h3 {
    font-family: var(--font-zh), var(--font-sans);
    letter-spacing: -0.005em;
    font-weight: 500;
}
p { margin: 0; }

.mono {
    font-family: var(--font-mono);
    font-feature-settings: 'zero', 'ss02';
    letter-spacing: -0.01em;
}
.upper {
    text-transform: uppercase;
    letter-spacing: 0.14em;
}
.text-soft { color: var(--fg-soft); }
.text-mute { color: var(--fg-mute); }
.text-dim  { color: var(--fg-dim); }
.text-red  { color: var(--red); }

/* =========================================================
   Brand mark — Prefire seal logo (rendered as inline SVG via CSS bg)
   ========================================================= */
.brand-mono {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 3px;
    background-color: var(--red);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'><g fill='%23fff'><rect x='17' y='12' width='7' height='40'/><rect x='17' y='12' width='22' height='7'/><rect x='32' y='12' width='7' height='22'/><rect x='17' y='27' width='22' height='7'/></g><rect x='42' y='46' width='6' height='6' fill='%23fff' fill-opacity='0.55'/></svg>");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    position: relative;
    box-shadow:
        0 0 0 1px rgba(239, 68, 68, 0.5),
        0 6px 16px -6px rgba(239, 68, 68, 0.7);
}
.brand-mono::after {
    content: "";
    position: absolute;
    top: -2px;
    right: -2px;
    width: 7px;
    height: 7px;
    background: var(--red-bright);
    border-radius: 50%;
    box-shadow: 0 0 6px var(--red-bright);
    animation: brand-pulse 2.2s ease-in-out infinite;
}
@keyframes brand-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.5;  transform: scale(0.8); }
}
.brand-mono-sm { width: 26px; height: 26px; }
.brand-mono-sm::after { width: 6px; height: 6px; top: -2px; right: -2px; }

/* =========================================================
   Buttons
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 20px;
    border: 1px solid var(--line-bright);
    background: transparent;
    color: var(--fg);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    border-radius: var(--r-1);
    cursor: pointer;
    transition: background var(--t-base) var(--ease),
                border-color var(--t-base) var(--ease),
                color var(--t-base) var(--ease),
                box-shadow var(--t-base) var(--ease),
                transform var(--t-fast) var(--ease);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    user-select: none;
    line-height: 1;
}
.lang-zh .btn { letter-spacing: 0.16em; }
.btn:hover:not(:disabled) {
    background: var(--bg-2);
    border-color: var(--line-emphasis);
    color: var(--fg);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: 3px;
}

.btn-primary {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}
.btn-primary:hover:not(:disabled) {
    background: var(--red-bright);
    border-color: var(--red-bright);
    color: #fff;
    box-shadow: 0 0 0 1px var(--red-bright), 0 8px 24px -8px var(--red-glow);
}
.btn-primary::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
    transform: translateX(-100%);
    transition: transform 0.7s var(--ease);
    pointer-events: none;
}
.btn-primary:hover::after { transform: translateX(100%); }

.btn-danger {
    background: transparent;
    border-color: var(--alert-edge);
    color: var(--alert);
}
.btn-danger:hover:not(:disabled) {
    background: var(--alert-soft);
    border-color: var(--alert);
    color: #ffb4b4;
}

.btn-full { width: 100%; }
.btn-sm   { padding: 8px 13px; font-size: 11px; gap: 7px; }
.btn-lg   { padding: 15px 26px; font-size: 12.5px; }

.btn-spinner {
    display: none;
    width: 12px;
    height: 12px;
    border: 1.5px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    opacity: 0.85;
}
.btn.is-loading .btn-label { opacity: 0.5; }
.btn.is-loading .btn-spinner { display: inline-block; }
.btn.is-loading { pointer-events: none; }

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

/* Inline link-style button (subtle action) */
.btn-link {
    background: none;
    border: none;
    color: var(--fg-soft);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 0;
    cursor: pointer;
    transition: color var(--t-fast) var(--ease);
}
.btn-link:hover { color: var(--red); }

/* =========================================================
   Fields
   ========================================================= */
.field { display: flex; flex-direction: column; gap: 9px; }
.field-label {
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--fg-mute);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.field-label-aux {
    color: var(--fg-faint);
    text-transform: none;
    letter-spacing: 0;
    font-size: 11px;
    font-weight: 400;
}

.field-input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-1);
    border: 1px solid var(--line-bright);
    border-radius: var(--r-1);
    color: var(--fg);
    font-size: 15px;
    font-family: var(--font-mono);
    letter-spacing: 0.02em;
    outline: none;
    transition: border-color var(--t-base) var(--ease),
                background var(--t-base) var(--ease),
                box-shadow var(--t-base) var(--ease);
}
.field-input::placeholder { color: var(--fg-faint); }
.field-input:hover { border-color: var(--line-emphasis); }
.field-input:focus {
    border-color: var(--red);
    background: var(--bg-2);
    box-shadow: 0 0 0 3px var(--red-soft);
}
.field-input.shake { animation: shake 0.45s var(--ease-snap); }

.field-hint {
    font-size: 11.5px;
    color: var(--fg-dim);
    line-height: 1.5;
    font-family: var(--font-mono);
    letter-spacing: 0;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

/* =========================================================
   Alerts
   ========================================================= */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 12px 14px;
    margin-bottom: var(--s-5);
    border: 1px solid;
    border-left-width: 3px;
    border-radius: var(--r-1);
    font-size: 13px;
    line-height: 1.5;
    animation: slide-in 0.25s var(--ease) both;
}
.alert svg { flex-shrink: 0; margin-top: 1px; }
.alert-error {
    background: var(--alert-soft);
    border-color: var(--alert-edge);
    border-left-color: var(--alert);
    color: #ffb4b4;
}
.alert-error.is-bumped { animation: shake 0.5s var(--ease) 1, slide-in 0.25s var(--ease) both; }
.alert-info {
    background: rgba(96, 165, 250, 0.07);
    border-color: rgba(96, 165, 250, 0.32);
    border-left-color: #60a5fa;
    color: #a5cbff;
}
.alert-success {
    background: var(--ok-soft);
    border-color: var(--ok-edge);
    border-left-color: var(--ok);
    color: #86efac;
}

@keyframes slide-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   Chips / status indicators
   ========================================================= */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    background: transparent;
    border: 1px solid var(--line-bright);
    border-radius: var(--r-1);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--fg-soft);
    line-height: 1.4;
}
.chip::before {
    content: "";
    width: 5px;
    height: 5px;
    background: currentColor;
    border-radius: 50%;
    flex-shrink: 0;
}
.chip-ok   { color: var(--ok);    border-color: var(--ok-edge);    background: var(--ok-soft); }
.chip-warn { color: var(--warn);  border-color: var(--warn-edge);  background: var(--warn-soft); }
.chip-red  { color: var(--red);   border-color: var(--red-edge);   background: var(--red-soft); }
.chip-mute { color: var(--fg-mute); border-color: var(--line-bright); }

/* =========================================================
   ==========  LOGIN  ===================================
   Split-screen: brand panel + form panel
   ========================================================= */
.page-auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
}

/* --- Brand panel (left) --------------------------------- */
.auth-brand {
    position: relative;
    padding: 56px 56px 44px;
    background: var(--bg-deep);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: var(--s-7);
    overflow: hidden;
    isolation: isolate;
}
.auth-brand::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, transparent 0%, rgba(239, 68, 68, 0.05) 100%),
        repeating-linear-gradient(
            transparent 0px,
            transparent 23px,
            rgba(255,255,255,0.022) 23px,
            rgba(255,255,255,0.022) 24px
        );
    z-index: -1;
}
.auth-brand::after {
    content: "";
    position: absolute;
    bottom: -200px;
    left: -120px;
    width: 540px;
    height: 540px;
    background: radial-gradient(circle, rgba(239, 68, 68, 0.22), transparent 60%);
    filter: blur(40px);
    z-index: -1;
}

.auth-brand-head {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    animation: rise 0.6s var(--ease) both;
}
.auth-brand-wordmark {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.auth-brand-wordmark .name {
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--fg);
    line-height: 1;
}
.auth-brand-wordmark .meta {
    font-family: var(--font-mono);
    font-size: 9.5px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--fg-dim);
}

.auth-brand-body {
    display: flex;
    flex-direction: column;
    gap: var(--s-6);
    max-width: 480px;
    animation: rise 0.7s var(--ease) 80ms both;
}
.auth-brand-eyebrow {
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--red);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.auth-brand-eyebrow::before {
    content: "";
    width: 24px;
    height: 1px;
    background: var(--red);
}
.auth-brand-title {
    font-size: clamp(40px, 4.8vw, 64px);
    font-weight: 200;
    line-height: 0.98;
    letter-spacing: -0.038em;
    color: var(--fg);
}
.auth-brand-title em {
    font-style: normal;
    font-weight: 500;
    background: linear-gradient(120deg, var(--fg) 0%, var(--red-bright) 100%);
    -webkit-background-clip: text;
            background-clip: text;
    color: transparent;
}
.lang-zh .auth-brand-title {
    font-size: clamp(34px, 4.4vw, 52px);
    letter-spacing: -0.02em;
}

.auth-brand-tag {
    color: var(--fg-mute);
    font-size: 14.5px;
    line-height: 1.65;
    max-width: 440px;
}
.lang-zh .auth-brand-tag { line-height: 1.85; }

.auth-brand-foot {
    display: flex;
    flex-direction: column;
    gap: 9px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--fg-dim);
    animation: rise 0.8s var(--ease) 160ms both;
}
.auth-brand-foot-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.auth-brand-foot-dot {
    width: 6px;
    height: 6px;
    border-radius: 1px;
    background: var(--ok);
    box-shadow: 0 0 8px var(--ok);
}
.auth-brand-foot-row.is-red .auth-brand-foot-dot {
    background: var(--red);
    box-shadow: 0 0 8px var(--red);
}
.auth-brand-foot-divider {
    color: var(--fg-ghost);
    margin: 0 2px;
}
.auth-brand-foot-val {
    color: var(--fg-soft);
    letter-spacing: 0.08em;
}

/* --- Form panel (right) -------------------------------- */
.auth-form-panel {
    padding: var(--s-9) var(--s-9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    background: var(--bg);
}
.auth-form-wrap {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    animation: rise 0.7s var(--ease) 120ms both;
}

.auth-step {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: var(--s-5);
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--red);
    font-weight: 500;
}
.auth-step-num {
    padding: 2px 7px;
    background: var(--red-soft);
    border: 1px solid var(--red-edge);
    border-radius: var(--r-1);
}
.auth-step-rule {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--red-edge), transparent 80%);
}

.auth-headline {
    font-size: 30px;
    font-weight: 300;
    letter-spacing: -0.028em;
    line-height: 1.1;
    color: var(--fg);
    margin-bottom: var(--s-3);
}
.lang-zh .auth-headline { font-size: 28px; }
.auth-deck {
    color: var(--fg-mute);
    font-size: 14px;
    margin-bottom: var(--s-8);
    line-height: 1.65;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--s-5);
}

.auth-trust {
    margin-top: var(--s-8);
    padding-top: var(--s-5);
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 9px;
}
.auth-trust-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--fg-dim);
}
.auth-trust-row::before {
    content: "▸";
    color: var(--red);
    font-size: 9px;
}
.lang-zh .auth-trust-row { letter-spacing: 0.16em; }

/* =========================================================
   ==========  DASHBOARD  ===============================
   Persistent left rail + main canvas
   ========================================================= */
.page-app {
    display: grid;
    grid-template-columns: 252px minmax(0, 1fr);
    min-height: 100vh;
}

/* --- Left rail ---------------------------------------- */
.app-rail {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: var(--s-6) var(--s-5) var(--s-5);
    background: var(--bg-deep);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: var(--s-7);
    overflow-y: auto;
}

.rail-brand {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding-bottom: var(--s-6);
    border-bottom: 1px solid var(--line);
}
.rail-brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.rail-brand-text .name {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--fg);
    line-height: 1;
}
.rail-brand-text .meta {
    font-family: var(--font-mono);
    font-size: 9.5px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--fg-dim);
}

.rail-block { display: flex; flex-direction: column; gap: var(--s-3); }
.rail-block-title {
    font-family: var(--font-mono);
    font-size: 9.5px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--fg-faint);
    padding-left: 11px;
}

.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 11px;
    border-left: 2px solid transparent;
    border-radius: 0 var(--r-1) var(--r-1) 0;
    font-size: 13px;
    color: var(--fg-soft);
    transition: background var(--t-base) var(--ease), color var(--t-base) var(--ease), border-color var(--t-base) var(--ease);
}
.rail-nav-item:hover {
    background: var(--bg-1);
    color: var(--fg);
}
.rail-nav-item.is-active {
    background: var(--red-soft);
    border-left-color: var(--red);
    color: var(--fg);
}
.rail-nav-item svg { flex-shrink: 0; color: var(--fg-mute); }
.rail-nav-item.is-active svg { color: var(--red); }
.rail-nav-item .badge-dot {
    margin-left: auto;
    width: 5px;
    height: 5px;
    background: var(--red);
    border-radius: 50%;
}

/* Sidebar info blocks (data definition list style) ---- */
.rail-defs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 11px;
    background: var(--bg-1);
    border: 1px solid var(--line);
    border-radius: var(--r-1);
}
.rail-def-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.rail-def-key {
    font-family: var(--font-mono);
    font-size: 9.5px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--fg-faint);
}
.rail-def-val {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--fg);
    letter-spacing: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.rail-def-row.is-ok .rail-def-val { color: var(--ok); }
.rail-def-row.is-red .rail-def-val { color: var(--red-bright); }

.rail-tail {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
}
.rail-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 11px;
    background: transparent;
    border: 1px solid var(--line-bright);
    border-radius: var(--r-1);
    color: var(--fg-soft);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    transition: all var(--t-base) var(--ease);
}
.rail-logout:hover {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
    box-shadow: 0 8px 24px -8px var(--red-glow);
}
.lang-zh .rail-logout { letter-spacing: 0.2em; }

/* --- Main canvas ------------------------------------- */
.app-canvas {
    padding: var(--s-7) var(--s-9) var(--s-10);
    min-width: 0;
    position: relative;
}

/* Top bar inside canvas */
.canvas-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: var(--s-5);
    margin-bottom: var(--s-8);
    border-bottom: 1px solid var(--line);
    gap: var(--s-5);
    flex-wrap: wrap;
}
.canvas-crumb {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--fg-mute);
}
.canvas-crumb-divider { color: var(--fg-ghost); }
.canvas-crumb-active { color: var(--fg); font-weight: 500; }

.canvas-status {
    display: flex;
    align-items: center;
    gap: var(--s-4);
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--fg-mute);
}
.canvas-status-item {
    display: flex;
    align-items: center;
    gap: 7px;
}
.canvas-status-item.is-pulse::before {
    content: "";
    width: 6px;
    height: 6px;
    background: var(--ok);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
    animation: ping 2s ease-out infinite;
}
.canvas-status-val { color: var(--fg); letter-spacing: 0.04em; }

@keyframes ping {
    0%   { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55); }
    70%  { box-shadow: 0 0 0 7px rgba(74, 222, 128, 0); }
    100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

/* Page headline -------------------------------------- */
.page-headline {
    margin-bottom: var(--s-9);
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
    animation: rise 0.6s var(--ease) both;
}
.page-headline-meta {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--red);
    align-self: flex-start;
}
.page-headline-meta::before {
    content: "";
    width: 8px;
    height: 8px;
    background: var(--red);
    border-radius: 1px;
    box-shadow: 0 0 8px var(--red-glow);
}
.page-headline-title {
    font-size: clamp(36px, 4.4vw, 52px);
    font-weight: 200;
    letter-spacing: -0.034em;
    line-height: 1;
    color: var(--fg);
    max-width: 900px;
}
.page-headline-title em {
    font-style: normal;
    font-weight: 500;
    background: linear-gradient(120deg, var(--fg), var(--red-bright) 90%);
    -webkit-background-clip: text;
            background-clip: text;
    color: transparent;
}
.lang-zh .page-headline-title {
    font-size: clamp(30px, 4vw, 44px);
    letter-spacing: -0.015em;
}
.page-headline-deck {
    color: var(--fg-mute);
    font-size: 14.5px;
    max-width: 640px;
    line-height: 1.65;
}
.lang-zh .page-headline-deck { line-height: 1.85; font-size: 14px; }

/* Numbered sections ---------------------------------- */
.section {
    margin-bottom: var(--s-9);
    animation: rise 0.7s var(--ease) both;
    animation-delay: var(--delay, 0s);
}
.section-head {
    display: flex;
    align-items: baseline;
    gap: var(--s-4);
    padding-bottom: 11px;
    margin-bottom: var(--s-5);
    border-bottom: 1px solid var(--line);
}
.section-num {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.18em;
    color: var(--red);
}
.section-title {
    font-size: 15.5px;
    font-weight: 500;
    color: var(--fg);
    letter-spacing: -0.008em;
}
.lang-zh .section-title { font-weight: 500; }
.section-trailing {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--fg-faint);
}

/* =========================================================
   Stat strip (3-column metric panel)
   ========================================================= */
.stat-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border: 1px solid var(--line);
    background: var(--bg-1);
    border-radius: var(--r-1);
    overflow: hidden;
}
.stat-cell {
    padding: 20px 22px 22px;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    transition: background var(--t-base) var(--ease);
}
.stat-cell:last-child { border-right: none; }
.stat-cell:hover { background: var(--bg-2); }
.stat-cell::after {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 2px;
    height: 0;
    background: var(--red);
    transition: height var(--t-slow) var(--ease);
}
.stat-cell:hover::after { height: 100%; }

.stat-cell-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-2);
}
.stat-cell-label {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--fg-mute);
}
.lang-zh .stat-cell-label { letter-spacing: 0.1em; }

.stat-cell-value {
    font-size: 26px;
    font-weight: 300;
    letter-spacing: -0.025em;
    color: var(--fg);
    font-family: var(--font-mono);
    line-height: 1.1;
    word-break: break-word;
}
.lang-zh .stat-cell-value {
    font-family: var(--font-zh), var(--font-mono);
    font-size: 22px;
    line-height: 1.25;
}

.stat-cell-sub {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--fg-dim);
    letter-spacing: 0.04em;
}

/* =========================================================
   Resource panel (main download card)
   ========================================================= */
.resource-panel {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    border: 1px solid var(--line);
    background: var(--bg-1);
    border-radius: var(--r-1);
    overflow: hidden;
    position: relative;
}
.resource-panel::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 60%;
    height: 100%;
    background:
        radial-gradient(ellipse at top right, rgba(239, 68, 68, 0.08), transparent 70%);
    pointer-events: none;
}

.resource-main {
    padding: 28px 32px 30px;
    border-right: 1px solid var(--line);
    position: relative;
    z-index: 1;
}

.resource-id {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: var(--s-4);
}
.resource-id-tag {
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--red);
}
.resource-id-divider {
    width: 1px;
    height: 12px;
    background: var(--line-emphasis);
}
.resource-id-meta {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--fg-mute);
}

.resource-title {
    font-size: 26px;
    font-weight: 300;
    letter-spacing: -0.024em;
    line-height: 1.15;
    color: var(--fg);
    margin-bottom: 10px;
}
.lang-zh .resource-title { font-size: 24px; font-weight: 500; }
.resource-deck {
    color: var(--fg-mute);
    font-size: 13.5px;
    max-width: 520px;
    line-height: 1.65;
    margin-bottom: var(--s-6);
}
.lang-zh .resource-deck { line-height: 1.85; }

.resource-meta {
    display: flex;
    flex-direction: column;
}
.resource-meta-row {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    padding: 12px 0;
    border-top: 1px solid var(--line);
    font-family: var(--font-mono);
    gap: 12px;
    align-items: center;
}
.resource-meta-row:last-child { border-bottom: 1px solid var(--line); }
.resource-meta-key {
    color: var(--fg-mute);
    font-size: 10.5px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-weight: 500;
}
/* keep ASCII labels in mono even under .lang-zh body */
.resource-meta-val {
    color: var(--fg);
    font-size: 12.5px;
    letter-spacing: 0;
    word-break: break-all;
}

/* Resource right side (CTA column) ------------------- */
.resource-side {
    padding: 28px;
    background: var(--bg-deep);
    display: flex;
    flex-direction: column;
    gap: var(--s-5);
    position: relative;
    z-index: 1;
}
.resource-side::before {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--red-edge), transparent);
}
.resource-side-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.resource-side-label {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--fg-mute);
}
.resource-side-value {
    font-size: 34px;
    font-weight: 200;
    letter-spacing: -0.028em;
    font-family: var(--font-mono);
    color: var(--fg);
    line-height: 1.05;
}
.resource-side-sub {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--fg-dim);
    letter-spacing: 0.04em;
}
.resource-side-sep {
    height: 1px;
    background: var(--line);
}
.resource-cta { margin-top: auto; }

.resource-credential {
    background: var(--bg-2);
    border: 1px solid var(--line-bright);
    border-radius: var(--r-1);
    padding: 11px 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.resource-credential-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
    flex: 1;
}
.resource-credential-label {
    font-family: var(--font-mono);
    font-size: 9.5px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--fg-faint);
}
.resource-credential-value {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--fg);
    letter-spacing: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    user-select: all;
}

.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    background: transparent;
    border: 1px solid var(--line-bright);
    border-radius: var(--r-1);
    color: var(--fg-mute);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all var(--t-fast) var(--ease);
    flex-shrink: 0;
}
.copy-btn:hover {
    background: var(--red-soft);
    border-color: var(--red-edge);
    color: var(--red);
}
.copy-btn.is-copied {
    background: var(--ok-soft);
    border-color: var(--ok-edge);
    color: var(--ok);
}

/* Download progress bar */
.download-progress {
    margin-top: 10px;
    height: 2px;
    background: var(--line);
    border-radius: 999px;
    overflow: hidden;
    opacity: 0;
    transition: opacity var(--t-base) var(--ease);
}
.download-progress.is-active { opacity: 1; }
.download-progress-bar {
    height: 100%;
    width: 30%;
    background: linear-gradient(90deg, var(--red), var(--red-bright));
    border-radius: 999px;
    animation: progress-slide 1.4s var(--ease) infinite;
}
@keyframes progress-slide {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}

/* =========================================================
   HWID Panel (hardware binding)
   ========================================================= */
.hwid-panel {
    border: 1px solid var(--line);
    background: var(--bg-1);
    border-radius: var(--r-1);
    padding: 24px 28px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: var(--s-7);
    align-items: stretch;
}
.hwid-main { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
.hwid-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--fg-mute);
    margin-bottom: 4px;
}
.hwid-eyebrow svg { color: var(--warn); }
.hwid-title {
    font-size: 19px;
    font-weight: 400;
    letter-spacing: -0.015em;
    color: var(--fg);
}
.lang-zh .hwid-title { font-weight: 500; font-size: 18px; }
.hwid-text { color: var(--fg-mute); font-size: 13px; line-height: 1.65; max-width: 540px; }
.lang-zh .hwid-text { line-height: 1.85; }

.hwid-meta {
    margin-top: 10px;
    display: flex;
    gap: var(--s-7);
}
.hwid-meta-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.hwid-meta-label {
    font-family: var(--font-mono);
    font-size: 9.5px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--fg-faint);
}
.hwid-meta-value {
    font-family: var(--font-mono);
    font-size: 16px;
    font-weight: 300;
    letter-spacing: -0.012em;
    color: var(--fg);
}

.hwid-action {
    border-left: 1px solid var(--line);
    padding-left: var(--s-6);
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    justify-content: center;
}
.hwid-feedback {
    font-family: var(--font-mono);
    font-size: 11px;
    text-align: center;
    min-height: 14px;
    color: var(--fg-mute);
    letter-spacing: 0.04em;
}
.hwid-feedback.is-success { color: var(--ok); }
.hwid-feedback.is-error   { color: var(--alert); }

/* =========================================================
   Modal
   ========================================================= */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 7, 0.78);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--s-6);
    animation: fade-in 180ms var(--ease) both;
}
.modal-overlay.is-open { display: flex; }

.modal-card {
    width: 100%;
    max-width: 460px;
    background: var(--bg-1);
    border: 1px solid var(--line-emphasis);
    border-radius: var(--r-1);
    padding: 28px 32px 24px;
    position: relative;
    animation: pop-in 220ms var(--ease) both;
    overflow: hidden;
}
.modal-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--red-dim), var(--red-bright));
}
.modal-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--warn);
    margin-bottom: var(--s-4);
}
.modal-eyebrow svg { color: var(--warn); }
.modal-title {
    font-size: 20px;
    font-weight: 500;
    letter-spacing: -0.02em;
    margin-bottom: var(--s-3);
    color: var(--fg);
}
.modal-text {
    color: var(--fg-soft);
    font-size: 14px;
    line-height: 1.65;
    margin-bottom: 10px;
}
.lang-zh .modal-text { line-height: 1.85; }
.modal-text-mute {
    color: var(--fg-mute);
    font-size: 12.5px;
    margin-bottom: var(--s-6);
    line-height: 1.6;
}
.modal-strong {
    color: var(--warn);
    font-weight: 500;
    background: var(--warn-soft);
    padding: 1px 7px;
    border-radius: 2px;
    border: 1px solid var(--warn-edge);
    font-family: var(--font-mono);
    font-size: 13px;
}
.modal-actions {
    display: flex;
    gap: var(--s-2);
    justify-content: flex-end;
}
.modal-actions .btn { min-width: 100px; }

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes pop-in {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* =========================================================
   Footer (dashboard)
   ========================================================= */
.app-footer {
    padding-top: var(--s-7);
    margin-top: var(--s-9);
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    flex-wrap: wrap;
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--fg-faint);
}
.app-footer-row { display: inline-flex; align-items: center; gap: 8px; }
.app-footer-sep { color: var(--fg-ghost); }

/* =========================================================
   Reveal on initial load
   ========================================================= */
@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   Responsive
   ========================================================= */
/* Tablet — login stacks, dashboard rail becomes top bar */
@media (max-width: 1024px) {
    .page-auth { grid-template-columns: 1fr; }
    .auth-brand {
        padding: 36px 40px 32px;
        border-right: none;
        border-bottom: 1px solid var(--line);
        min-height: 320px;
    }
    .auth-brand-title { font-size: clamp(32px, 6vw, 48px); }
    .auth-form-panel { padding: 40px 40px 56px; }

    .page-app { grid-template-columns: 1fr; }
    .app-rail {
        position: relative;
        height: auto;
        flex-direction: row;
        align-items: center;
        gap: var(--s-4);
        padding: 14px 24px;
        border-right: none;
        border-bottom: 1px solid var(--line);
        flex-wrap: nowrap;
    }
    .rail-brand { padding-bottom: 0; border-bottom: none; flex-shrink: 0; }
    .rail-block { display: none; }
    .rail-tail {
        margin-top: 0;
        margin-left: auto;
        flex-direction: row;
        align-items: center;
        gap: var(--s-3);
    }
    .rail-defs {
        flex-direction: row;
        align-items: center;
        gap: var(--s-4);
        padding: 8px 12px;
        max-width: 380px;
        overflow: hidden;
    }
    .rail-def-row { flex-direction: row; align-items: center; gap: 8px; flex-shrink: 1; min-width: 0; }
    .rail-def-key { font-size: 8.5px; flex-shrink: 0; }
    .rail-def-val { font-size: 11px; min-width: 0; }
    .rail-logout { padding: 8px 14px; font-size: 10px; }

    .app-canvas { padding: var(--s-6) var(--s-6) var(--s-9); }

    .resource-panel { grid-template-columns: 1fr; }
    .resource-main { border-right: none; border-bottom: 1px solid var(--line); }
    .resource-side::before { display: none; }
}

/* Mobile */
@media (max-width: 720px) {
    .auth-brand { padding: 28px 24px 24px; min-height: 0; gap: var(--s-5); }
    .auth-brand-body { gap: var(--s-4); }
    .auth-form-panel { padding: 32px 24px 40px; }
    .auth-form-wrap { max-width: 100%; }
    .auth-headline { font-size: 24px; }

    .app-rail { padding: 12px 16px; gap: var(--s-3); }
    .rail-tail .rail-defs { display: none; }
    .app-canvas { padding: var(--s-5) var(--s-4) var(--s-8); }

    .canvas-status { gap: var(--s-3); }
    .canvas-status-item { font-size: 10px; }
    .canvas-status-item.is-pulse-only { display: none; }

    .page-headline-title { font-size: 30px; }

    .stat-strip { grid-template-columns: 1fr; }
    .stat-cell { border-right: none; border-bottom: 1px solid var(--line); }
    .stat-cell:last-child { border-bottom: none; }

    .resource-main, .resource-side { padding: 22px 20px; }
    .resource-meta-row {
        grid-template-columns: 1fr;
        gap: 4px;
        padding: 10px 0;
    }
    .resource-side-value { font-size: 28px; }

    .hwid-panel {
        grid-template-columns: 1fr;
        padding: 22px 20px;
        gap: var(--s-4);
    }
    .hwid-action {
        border-left: none;
        border-top: 1px solid var(--line);
        padding-left: 0;
        padding-top: var(--s-4);
    }
    .hwid-meta { flex-wrap: wrap; gap: var(--s-5); }

    .modal-card { padding: 24px 22px 20px; }
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions .btn { width: 100%; }

    .section-head { flex-wrap: wrap; }
    .section-trailing { width: 100%; margin-left: 0; }
}

@media (max-width: 420px) {
    .resource-id { flex-wrap: wrap; }
    .resource-id-divider { display: none; }
    .auth-brand-foot { font-size: 9.5px; }
    .canvas-crumb { font-size: 10px; letter-spacing: 0.14em; }
}

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