/* ==========================================================================
   Virage Procedures Assistant — shared brand stylesheet
   Light "race-control" theme matching virage.ws
   Display: Airstrike (self-hosted) · Body: Roboto
   ========================================================================== */

@font-face {
    font-family: 'Airstrike';
    src: url('/static/fonts/airstrike.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg:         #ffffff;   /* page canvas            */
    --bg-subtle:  #f4f4f4;   /* assistant cards/panels */
    --bg-soft:    #fafafa;   /* sources, insets        */
    --bg-tint:    #fff6ee;   /* warm tint, user bubble */
    --bar:        #000000;   /* black accents          */
    --text:       #1a1a1a;   /* primary text           */
    --text-muted: #6b6b6b;   /* labels, secondary      */
    --text-faint: #9a9a9a;   /* placeholders, hints    */
    --border:     #e2e2e2;   /* borders                */
    --border-mid: #cfcfcf;   /* stronger borders       */
    --orange:     #f6761f;   /* primary accent         */
    --orange-dk:  #d6600f;   /* hover/pressed orange   */
    --yellow:     #fbba2a;   /* secondary accent       */
    --good:       #2fa84f;
    --good-bg:    #eef9f1;
    --bad:        #d23b3b;
    --bad-bg:     #fdeeee;

    --font-display: 'Airstrike', 'Arial Narrow', sans-serif;
    --font-body:    'Roboto', system-ui, -apple-system, sans-serif;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 14px rgba(0,0,0,.07);
}

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

/* Pin form controls to the light scheme. Without this, a browser/OS in dark mode renders
   <input> with its own dark-theme colors (light text on a light field = invisible typing). */
html { -webkit-text-size-adjust: 100%; color-scheme: light; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ----------------------------------------------------------------- Header */

.header {
    background: #fff;
    border-top: 5px solid var(--bar);       /* black utility edge (echoes site) */
    border-bottom: 3px solid var(--orange); /* race-orange rule                 */
    padding: 0.7rem 1.3rem;
    display: flex;
    align-items: center;
    gap: 0.95rem;
    position: relative;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}
.header .logo { height: 46px; width: auto; display: block; }
.header .titles { display: flex; flex-direction: column; min-width: 0; }
.header h1 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 1.6rem;
    letter-spacing: 0.5px;
    line-height: 1;
    color: var(--text);
    white-space: nowrap;
}
.header h1 .accent { color: var(--orange); }
.header .subtitle {
    font-family: var(--font-body);
    font-size: 0.74rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    letter-spacing: 0.2px;
}
.header .admin-link,
.header-links { margin-left: auto; }
.header-links { display: flex; gap: 1.1rem; align-items: center; }
.header .admin-link,
.header-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    transition: color .15s;
    white-space: nowrap;
}
.header .admin-link:hover,
.header-links a:hover { color: var(--orange); }

/* ------------------------------------------------------- Buttons & inputs */

.btn,
.input-wrapper button {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.95rem;
    background: var(--orange);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.7rem 1.4rem;
    cursor: pointer;
    transition: background .16s, color .16s, transform .05s, box-shadow .16s;
}
.btn:hover,
.input-wrapper button:hover { background: var(--yellow); color: #1a1a1a; }
.btn:active,
.input-wrapper button:active { transform: translateY(1px); }
.btn:disabled,
.input-wrapper button:disabled {
    background: #dcdcdc; color: #9a9a9a; cursor: not-allowed; transform: none;
}
.btn-full { width: 100%; padding: 0.85rem; font-size: 1rem; }
.btn-danger {
    background: transparent;
    border: 1px solid var(--border-mid);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.4rem 0.8rem;
}
.btn-danger:hover { border-color: var(--bad); color: var(--bad); background: var(--bad-bg); }

input[type="text"],
input[type="password"] {
    background: #fff;
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    color: var(--text);
    /* Force the typed-text colour. `color` alone is overridden by autofill and by some
       mobile/WebKit themes, which left the password text white-on-white (invisible). */
    -webkit-text-fill-color: var(--text);
    caret-color: var(--text);
    font-family: var(--font-body);
    font-size: 1rem;
    outline: none;
    transition: border-color .16s, box-shadow .16s;
}
input[type="text"]:focus,
input[type="password"]:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(246,118,31,.15);
}
input::placeholder { color: var(--text-faint); }
/* Keep autofilled fields readable: dark text on the white field (browsers otherwise paint
   their own background + text colour over the value). */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0 1000px #fff inset;
    caret-color: var(--text);
}

/* --------------------------------------------------------------- Chat view */

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.message { margin-bottom: 1.6rem; animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.message-label {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 1.2px; margin-bottom: 0.4rem;
}
.message.user .message-label { color: var(--orange); }
.message.assistant .message-label { color: var(--text-muted); }

.message-content {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border-mid);
    border-radius: 10px;
    padding: 1rem 1.2rem;
    line-height: 1.65;
    color: var(--text);
    box-shadow: var(--shadow-sm);
}
.message.user .message-content {
    background: var(--bg-tint);
    border-left-color: var(--orange);
}

.message-content h1, .message-content h2, .message-content h3 {
    font-family: var(--font-body);
    color: var(--orange);
    font-weight: 700;
    margin: 1rem 0 0.5rem 0;
    line-height: 1.3;
}
.message-content h1 { font-size: 1.25rem; }
.message-content h2 { font-size: 1.1rem; }
.message-content h3 { font-size: 1rem; }
.message-content ul, .message-content ol { padding-left: 1.5rem; margin: 0.5rem 0; }
.message-content li { margin-bottom: 0.3rem; }
.message-content strong { color: var(--text); font-weight: 700; }
.message-content p { margin-bottom: 0.5rem; }
.message-content p:last-child { margin-bottom: 0; }
.message-content a { color: var(--orange-dk); }

.message-images { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1rem; }
.message-images img {
    width: 100%; border-radius: 8px; border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.sources {
    margin-top: 0.75rem; padding: 0.6rem 1rem;
    background: var(--bg-soft); border: 1px solid var(--border);
    border-radius: 8px; font-size: 0.82rem; color: var(--text-muted);
}
.sources summary { cursor: pointer; color: var(--orange); font-weight: 600; }
.sources ul { margin-top: 0.45rem; padding-left: 1.2rem; }
.sources strong { color: var(--text); }

/* Parts mode: the expandable "other related parts" selector under an answer. */
.part-options {
    margin-top: 0.75rem; padding: 0.6rem 1rem;
    background: var(--bg-soft); border: 1px solid var(--border);
    border-radius: 8px; font-size: 0.82rem; color: var(--text-muted);
}
.part-options summary { cursor: pointer; color: var(--orange); font-weight: 600; }
.part-options-list {
    list-style: none; margin: 0.5rem 0 0; padding: 0;
    display: flex; flex-direction: column; gap: 0.3rem;
}
.part-option {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    text-align: left; cursor: pointer; gap: 0.75rem;
    padding: 0.5rem 0.6rem; border: 1px solid var(--border); border-radius: 7px;
    background: #fff; color: var(--text);
    font-family: var(--font-body); font-size: 0.86rem;
    transition: border-color .12s, background .12s;
}
.part-option:hover { border-color: var(--orange); background: var(--bg-subtle); }
.part-option-name { font-weight: 600; }
.part-option-price { color: var(--orange-dk); white-space: nowrap; }

/* Feedback */
.feedback-bar { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; font-size: 0.85rem; }
.feedback-bar span { color: var(--text-faint); font-size: 0.78rem; }
.feedback-btn {
    background: #fff; border: 1px solid var(--border); border-radius: 6px;
    padding: 0.3rem 0.6rem; cursor: pointer; font-size: 1rem;
    transition: all .18s; color: var(--text-muted); line-height: 1;
}
.feedback-btn:hover { border-color: var(--orange); }
.feedback-btn.selected-good { border-color: var(--good); background: var(--good-bg); color: var(--good); }
.feedback-btn.selected-bad  { border-color: var(--bad);  background: var(--bad-bg);  color: var(--bad);  }
.feedback-btn:disabled { opacity: 0.6; cursor: default; }
/* Copy-answer button: sits at the far right of the action bar (margin-left:auto). */
.copy-btn {
    margin-left: auto; display: inline-flex; align-items: center; gap: 0.3rem;
    background: #fff; border: 1px solid var(--border); border-radius: 6px;
    padding: 0.3rem 0.6rem; cursor: pointer; font-size: 0.78rem; line-height: 1;
    color: var(--text-muted); transition: all .18s;
}
.copy-btn:hover { border-color: var(--orange); color: var(--text); }
.copy-btn.copied { border-color: var(--good); background: var(--good-bg); color: var(--good); }

.feedback-form { margin-top: 0.5rem; display: none; animation: fadeIn .2s ease; }
.feedback-form.visible { display: flex; gap: 0.5rem; }
.feedback-form input { flex: 1; font-size: 0.85rem; padding: 0.55rem 0.75rem; }
.feedback-form button {
    background: var(--bg-subtle); border: 1px solid var(--border); border-radius: 6px;
    padding: 0.55rem 0.85rem; color: var(--text-muted); cursor: pointer;
    font-family: var(--font-body); font-size: 0.8rem; font-weight: 600; transition: all .18s;
}
.feedback-form button:hover { background: var(--orange); color: #fff; border-color: var(--orange); }
.feedback-thanks { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.5rem; display: none; }

/* Loading */
.loading { display: flex; align-items: center; gap: 0.5rem; color: var(--text-muted); padding: 1rem; }
.loading-dots span {
    display: inline-block; width: 7px; height: 7px; background: var(--orange);
    border-radius: 50%; animation: bounce 1.4s infinite ease-in-out;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* Input bar */
.input-area {
    background: #fff; border-top: 1px solid var(--border);
    padding: 1rem 1.25rem; flex-shrink: 0; box-shadow: 0 -1px 0 rgba(0,0,0,.03);
}
.input-wrapper { max-width: 900px; margin: 0 auto; display: flex; gap: 0.6rem; }
.input-wrapper input { flex: 1; }

/* Procedures / Regulations mode picker — a pop-up ("push-up") menu like a model selector */
/* The mode picker and the regulations series picker sit side-by-side in this row. */
.picker-row { max-width: 900px; margin: 0 auto 0.55rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.mode-picker { position: relative; width: max-content; }
.mode-picker[hidden] { display: none; }
.mode-trigger {
    display: inline-flex; align-items: center; gap: 0.45rem;
    font-family: var(--font-body); font-size: 0.82rem; font-weight: 600;
    letter-spacing: 0.2px; padding: 0.4rem 0.8rem; cursor: pointer;
    background: #fff; color: var(--text-muted);
    border: 1px solid var(--border-mid); border-radius: 999px;
    transition: border-color .12s, color .12s;
}
.mode-trigger:hover { border-color: var(--orange); color: var(--text); }
.mode-trigger-label { color: var(--text-faint); font-weight: 500; }
.mode-trigger-value { color: var(--text); }
.mode-caret { font-size: 0.7rem; color: var(--text-muted); transition: transform .15s; }
.mode-picker.open .mode-caret { transform: rotate(180deg); }

.mode-menu {
    position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 20;
    min-width: 200px; padding: 0.3rem;
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    box-shadow: var(--shadow-md);
}
.mode-menu[hidden] { display: none; }
.mode-option {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    font-family: var(--font-body); font-size: 0.86rem; text-align: left; cursor: pointer;
    padding: 0.5rem 0.6rem; border: none; border-radius: 7px;
    background: transparent; color: var(--text);
    transition: background .12s;
}
.mode-option:hover { background: var(--bg-subtle); }
.mode-option .mode-check { color: var(--orange); font-weight: 700; opacity: 0; }
.mode-option.active { color: var(--text); font-weight: 600; }
.mode-option.active .mode-check { opacity: 1; }
.mode-option.disabled,
.mode-option:disabled {
    color: var(--text-muted); cursor: default; opacity: 0.55;
}
.mode-option.disabled:hover,
.mode-option:disabled:hover { background: transparent; }
.mode-empty {
    padding: 0.5rem 0.6rem; font-family: var(--font-body); font-size: 0.84rem;
    color: var(--text-muted);
}

/* Welcome */
.welcome { text-align: center; padding: 3.5rem 1rem; color: var(--text-muted); }
.welcome h2 {
    font-family: var(--font-display); font-weight: 400; color: var(--text);
    font-size: 1.7rem; letter-spacing: 0.5px; margin-bottom: 0.6rem;
}
.welcome h2 .accent { color: var(--orange); }

/* -------------------------------------------------------------- Admin view */

.container { max-width: 820px; margin: 0 auto; padding: 1.75rem 1rem; }

.section {
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: var(--shadow-sm);
}
.section h2 {
    font-family: var(--font-display); font-weight: 400; font-size: 1.25rem;
    color: var(--text); margin-bottom: 1rem; letter-spacing: 0.5px;
    padding-bottom: 0.6rem; border-bottom: 2px solid var(--orange); display: inline-block;
}
.note { color: var(--text-muted); font-size: 0.88rem; line-height: 1.6; }

.doc-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.7rem 0; border-bottom: 1px solid var(--border);
}
.doc-item:last-child { border-bottom: none; }
.doc-name { font-size: 0.95rem; }
.doc-ext {
    display: inline-block; background: var(--bg-tint); padding: 0.15rem 0.5rem;
    border-radius: 4px; font-size: 0.7rem; color: var(--orange-dk);
    margin-left: 0.5rem; text-transform: uppercase; font-weight: 600;
}
.doc-count {
    display: inline-block; background: var(--bg-tint); padding: 0.1rem 0.55rem;
    border-radius: 999px; font-size: 0.78rem; color: var(--text-muted);
    margin-left: 0.5rem; font-weight: 600; vertical-align: middle;
}

.status-row { display: flex; justify-content: space-between; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.status-row:last-child { border-bottom: none; }
.status-label { color: var(--text-muted); }
.status-value.ok   { color: var(--good); font-weight: 600; }
.status-value.warn { color: var(--orange-dk); font-weight: 600; }
.status-value.err  { color: var(--bad); font-weight: 600; }

.rebuild-results {
    margin-top: 1rem; padding: 1rem; background: var(--bg-soft);
    border: 1px solid var(--border); border-radius: 8px; font-size: 0.85rem; display: none;
}
.rebuild-results .section-item { padding: 0.3rem 0; color: var(--text-muted); }

/* Feedback log (admin) */
.fb-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.fb-meta span { color: var(--text-muted); font-size: 0.85rem; }
.fb-card {
    background: var(--bg-soft); border: 1px solid var(--border);
    border-left: 3px solid var(--border-mid); border-radius: 8px;
    padding: 0.75rem 1rem; margin-bottom: 0.6rem;
}
.fb-card.good { border-left-color: var(--good); }
.fb-card.bad  { border-left-color: var(--bad); }
.fb-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.3rem; }
.fb-rating { font-size: 0.85rem; font-weight: 600; }
.fb-card.good .fb-rating { color: var(--good); }
.fb-card.bad  .fb-rating { color: var(--bad); }
.fb-user { color: var(--text-muted); font-size: 0.78rem; font-weight: 600; }
.fb-time { color: var(--text-faint); font-size: 0.75rem; }
.fb-q { font-size: 0.88rem; margin-bottom: 0.3rem; }
.fb-q strong { color: var(--orange-dk); }
.fb-a { font-size: 0.82rem; color: var(--text-muted); }
.fb-comment {
    font-size: 0.85rem; margin-top: 0.4rem; padding: 0.45rem 0.65rem;
    background: var(--bg-tint); border-radius: 5px; color: var(--orange-dk);
}
.fb-sources { font-size: 0.75rem; color: var(--text-faint); margin-top: 0.3rem; }

/* Toast */
.toast {
    position: fixed; bottom: 2rem; right: 2rem; background: #fff;
    border: 1px solid var(--orange); border-left: 4px solid var(--orange);
    border-radius: 8px; padding: 1rem 1.5rem; font-size: 0.9rem;
    box-shadow: var(--shadow-md); z-index: 100; animation: slideIn .3s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------------------------------------- Chat: mandatory name gate */
/* Overlay shown until the user enters their name; the chat sits behind it. */
.name-gate {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: center; justify-content: center; padding: 1rem;
    background: rgba(26,26,26,.55);
}
.name-gate[hidden] { display: none; }
.name-gate-box {
    background: #fff; border: 1px solid var(--border); border-top: 5px solid var(--bar);
    border-radius: 14px; padding: 2rem; width: 100%; max-width: 380px;
    text-align: center; box-shadow: var(--shadow-md);
}
.name-gate-box .logo { height: 54px; width: auto; margin: 0 auto 1rem; display: block; }
.name-gate-box h2 {
    font-family: var(--font-display); font-weight: 400; font-size: 1.4rem;
    letter-spacing: 0.5px; color: var(--text); margin-bottom: 0.4rem;
}
.name-gate-sub { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1.2rem; }
.name-gate form { display: flex; flex-direction: column; gap: 0.75rem; }
.name-gate input { width: 100%; }
.name-gate-error {
    background: var(--bad-bg); border: 1px solid var(--bad); border-radius: 6px;
    padding: 0.5rem; font-size: 0.82rem; color: var(--bad);
}
.name-gate-error[hidden] { display: none; }

/* "Asking as <name>" indicator above the input pickers. */
.user-row {
    max-width: 900px; margin: 0 auto 0.5rem;
    display: flex; align-items: center; gap: 0.6rem;
    font-size: 0.8rem; color: var(--text-muted);
}
.user-row[hidden] { display: none; }
.user-tag strong { color: var(--text); }
.user-change {
    background: none; border: none; color: var(--orange); cursor: pointer;
    font-family: var(--font-body); font-size: 0.8rem; font-weight: 600;
    padding: 0; text-decoration: underline;
}
.user-change:hover { color: var(--orange-dk); }

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

.login-page { height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-box {
    background: #fff; border: 1px solid var(--border); border-top: 5px solid var(--bar);
    border-radius: 14px; padding: 2.5rem; width: 100%; max-width: 390px;
    text-align: center; box-shadow: var(--shadow-md);
}
.login-box .logo { height: 84px; width: auto; margin: 0 auto 1.25rem; display: block; }
.login-box h1 {
    font-family: var(--font-display); font-weight: 400; font-size: 1.6rem;
    letter-spacing: 0.5px; color: var(--text); margin-bottom: 0.3rem;
}
.login-box h1 .accent { color: var(--orange); }
.login-box .subtitle { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.login-box form { display: flex; flex-direction: column; gap: 0.75rem; }
.login-box input { width: 100%; }
.login-box button { width: 100%; margin-top: 0.3rem; }
.login-box .error {
    background: var(--bad-bg); border: 1px solid var(--bad); border-radius: 6px;
    padding: 0.55rem; margin-bottom: 1rem; font-size: 0.85rem; color: var(--bad);
}
.back-link { display: inline-block; margin-top: 1.1rem; color: var(--text-muted); text-decoration: none; font-size: 0.85rem; }
.back-link:hover { color: var(--orange); }

/* --------------------------------------------------------------- Responsive */

@media (max-width: 600px) {
    .header { padding: 0.6rem 0.9rem; gap: 0.6rem; }
    .header .logo { height: 38px; }
    .header h1 { font-size: 1.25rem; }
    .header .subtitle { display: none; }
    .message-content { padding: 0.85rem 0.95rem; font-size: 0.95rem; }
    .input-wrapper button { padding: 0.7rem 1rem; }
    .header-links { gap: 0.7rem; }
    .toast { left: 1rem; right: 1rem; bottom: 1rem; }
}

/* --------------------------------------------------------- Admin navigation */

.admin-nav {
    display: flex; gap: 0.6rem; max-width: 820px; margin: 0 auto;
    padding: 0.9rem 1rem 0;
}
.admin-nav a {
    text-decoration: none; color: var(--text-muted); font-weight: 600;
    font-size: 0.9rem; padding: 0.5rem 0.9rem; border-radius: 8px 8px 0 0;
    border: 1px solid transparent; border-bottom: none;
}
.admin-nav a:hover { color: var(--orange); background: var(--bg-soft); }
.admin-nav a.active {
    color: var(--text); background: #fff; border-color: var(--border);
    border-bottom: 2px solid var(--orange);
}

/* ----------------------------------------------------- Admin: folder groups */

.folder { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 0.7rem; overflow: hidden; }
.folder[open] { box-shadow: var(--shadow-sm); }
.folder-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.6rem 0.85rem; cursor: pointer; list-style: none;
    background: var(--bg-soft); font-weight: 600; font-size: 0.9rem;
}
.folder-head::-webkit-details-marker { display: none; }
.folder-head:hover { background: var(--bg-tint); }
.folder-name { color: var(--text); }
/* Disclosure arrow: points right when collapsed, rotates down when the folder is open.
   `> .folder-head` scopes the rotation to THIS folder so nested arrows are unaffected. */
.folder-arrow {
    display: inline-block; width: 0.8em; color: var(--text-muted);
    font-size: 0.85em; transition: transform 0.15s ease;
}
.folder[open] > .folder-head .folder-arrow { transform: rotate(90deg); }
.folder-body { padding: 0 0.85rem; }
/* Nested folders: indent comes from .folder-body padding; add breathing room so a
   subfolder card doesn't butt against its parent's summary or the doc list. */
.folder-body > .folder:first-child { margin-top: 0.7rem; }
.folder-body > .folder:last-child { margin-bottom: 0.7rem; }
.doc-modified { font-size: 0.78rem; color: var(--text-faint); white-space: nowrap; margin-left: 1rem; }

/* ------------------------------------------------ Admin: feedback detail/debug */

.fb-details { margin-top: 0.55rem; }
.fb-details > summary {
    cursor: pointer; font-size: 0.8rem; font-weight: 600; color: var(--orange-dk);
}
.fb-detail-block { margin-top: 0.6rem; }
.fb-detail-block h4 {
    font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.4px;
    color: var(--text-muted); margin-bottom: 0.3rem;
}
.fb-detail-block pre {
    background: #fff; border: 1px solid var(--border); border-radius: 6px;
    padding: 0.7rem; font-size: 0.78rem; line-height: 1.5; color: var(--text);
    white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto;
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

/* ---------------------------------------------------------- Admin: analytics */

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.8rem; }
.stat {
    background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
    padding: 1rem 0.75rem; text-align: center; display: flex; flex-direction: column; gap: 0.25rem;
}
.stat-num { font-size: 1.35rem; font-weight: 700; color: var(--text); }
.stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); }
.chart-wrap { position: relative; height: 320px; }
.chart-wrap--pie { height: 300px; max-width: 360px; margin: 0 auto; }

/* ------------------------------------------------------- Chat: debug context */

.debug-details { margin: 0.4rem 0 0.2rem; }
.debug-details > summary {
    cursor: pointer; font-size: 0.78rem; font-weight: 600; color: var(--text-muted);
}
.debug-details > summary:hover { color: var(--orange); }
.debug-pre {
    margin-top: 0.5rem; background: var(--bg-soft); border: 1px solid var(--border);
    border-radius: 6px; padding: 0.7rem; font-size: 0.76rem; line-height: 1.5;
    color: var(--text-muted); white-space: pre-wrap; word-break: break-word;
    max-height: 320px; overflow: auto;
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

/* ------------------------------------------------- Driver reports (pilot view) */

/* A report row reuses .doc-item; the title is a download link with optional chassis detail. */
.report-link { color: var(--orange-dk); text-decoration: none; font-weight: 600; }
.report-link:hover { text-decoration: underline; }
.report-detail { color: var(--text-muted); font-size: 0.8rem; margin-left: 0.5rem; }

/* ----------------------------------------------------- Admin: pilot management */

.pilot-card {
    background: var(--bg-soft); border: 1px solid var(--border);
    border-left: 3px solid var(--orange); border-radius: 8px;
    padding: 0.9rem 1rem; margin-bottom: 0.8rem;
}
.pilot-card.inactive { border-left-color: var(--border-mid); opacity: 0.8; }
.pilot-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.7rem; }
.pilot-name { font-weight: 700; font-size: 0.98rem; }
.pilot-flag {
    background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad);
    border-radius: 999px; padding: 0.05rem 0.55rem; font-size: 0.7rem;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
}

.pilot-form { display: flex; flex-direction: column; gap: 0.7rem; }
.pf-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem 0.8rem; }
.pf-grid label {
    display: flex; flex-direction: column; gap: 0.25rem;
    font-size: 0.74rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.3px; color: var(--text-muted);
}
.pf-grid input[type="text"], .pf-grid input[type="password"] { font-size: 0.92rem; padding: 0.55rem 0.7rem; }
.pf-grid .pf-check {
    flex-direction: row; align-items: center; gap: 0.45rem; align-self: end;
    text-transform: none; letter-spacing: normal; font-size: 0.9rem; color: var(--text);
}
.pf-grid .pf-check input { width: auto; }
.pilot-form .btn { align-self: flex-start; }

.pilot-actions {
    display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center;
    margin-top: 0.8rem; padding-top: 0.7rem; border-top: 1px solid var(--border);
}
.pilot-inline { display: flex; gap: 0.4rem; align-items: center; }
.pilot-inline input { font-size: 0.85rem; padding: 0.4rem 0.6rem; }

@media (max-width: 600px) {
    .admin-nav { padding: 0.6rem 0.9rem 0; gap: 0.4rem; flex-wrap: wrap; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .doc-item { flex-wrap: wrap; }
    .pf-grid { grid-template-columns: 1fr; }
}

/* ----------------------------------------------- Show/hide password ("eye") toggle */
/* Injected by static/js/password-toggle.js, which wraps every <input type="password">
   in a .pw-field. Kept LAST in the sheet so the input padding-right (room for the eye)
   wins over the earlier .pf-grid / .pilot-inline padding shorthands at equal specificity. */
.pw-field { position: relative; display: block; }
.pw-field > input[type] { width: 100%; padding-right: 2.6rem; }
.pilot-inline .pw-field { flex: 1; }
/* Use the `.pw-field > .pw-toggle` descendant form (two classes) so this wins over
   `.login-box button { width:100%; margin-top:.3rem }` (one class + one element) — otherwise
   the eye button stretches full-width, its centred icon lands mid-field and the margin pushes it
   down onto the box border. `margin:0` cancels that inherited top margin. */
.pw-field > .pw-toggle {
    position: absolute;
    top: 50%;
    right: 0.45rem;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    border-radius: 6px;
    transition: color .15s, background .15s;
}
.pw-toggle:hover { color: var(--text-muted); background: var(--bg-subtle); }
.pw-toggle.is-on { color: var(--orange); }
.pw-toggle svg { width: 1.15rem; height: 1.15rem; display: block; }

/* ----------------------------------------------- Framed driver-reports login fallback */
/* The reports login can't keep its cookie inside a cross-site iframe, so when embedded we hide
   the form (.frame-hide) and show an "open in its own window" button (.frame-only). The head
   script adds .is-framed to <html> before paint when window.top !== window.self. */
html:not(.is-framed) .frame-only { display: none; }
.is-framed .frame-hide { display: none; }
