/* SiteScribe AI admin portal - mobile-first stylesheet.
   Tokens mirror AiRams.Shared/Models/BrandPalette.cs and the mobile app's Colors.xaml. */

:root {
    --navy: #16233F;
    --navy-light: #24365C;
    --amber: #F5A623;
    --amber-dark: #C97F0A;
    --bg: #F5F6F9;
    --surface: #FFFFFF;
    --surface-2: #EEF1F6;
    --text: #1A1E28;
    --text-secondary: #5A6272;
    --border: #DDE1E9;
    --risk-low: #2E7D32;
    --risk-medium: #E8A400;
    --risk-high: #E8730A;
    --risk-veryhigh: #C62828;
    --danger: #C62828;
    --success: #2E7D32;
    --info: #1F6FB2;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(22, 35, 63, 0.06), 0 4px 16px rgba(22, 35, 63, 0.06);
    --topbar-h: 56px;
    --tabbar-h: 64px;
    --gutter: 16px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12141B;
        --surface: #1B1F2B;
        --surface-2: #232838;
        --text: #E8EAF0;
        --text-secondary: #9AA2B3;
        --border: #2C3245;
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
    }
}

/* ---- reset & base ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 0.35rem; font-weight: 650; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.6rem; }
a { color: var(--amber-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { margin: 0.25rem 0 0.5rem 1.25rem; padding: 0; }
img { max-width: 100%; height: auto; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.9em; background: var(--surface-2); padding: 0 0.3em; border-radius: 4px; }

.muted { color: var(--text-secondary); }
.small { font-size: 0.82rem; }
.error-text { color: var(--danger); font-size: 0.82rem; }
.prose { white-space: pre-wrap; }

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

/* ---- app shell ---------------------------------------------------------------------------- */
.app-shell { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: calc(var(--topbar-h) + var(--safe-top));
    padding: var(--safe-top) var(--gutter) 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--navy);
    color: #fff;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06);
}

.brand { color: #fff; font-weight: 700; font-size: 1.05rem; letter-spacing: 0.01em; white-space: nowrap; }
.brand span, .login-brand span, .splash-brand span { color: var(--amber); }
.brand:hover { text-decoration: none; }

.topnav { display: none; gap: 0.25rem; margin-left: 0.5rem; }
.topnav a { color: rgba(255, 255, 255, 0.78); padding: 0.4rem 0.7rem; border-radius: var(--radius-sm); font-weight: 500; }
.topnav a:hover { background: rgba(255, 255, 255, 0.08); text-decoration: none; }
.topnav a.active { color: #fff; background: rgba(255, 255, 255, 0.14); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.topbar .btn-ghost { color: rgba(255, 255, 255, 0.85); }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

.net-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.25); }
.net-dot.offline { background: var(--risk-high); box-shadow: 0 0 0 3px rgba(232, 115, 10, 0.25); }

.page {
    flex: 1;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding-block: 1rem calc(var(--tabbar-h) + var(--safe-bottom) + 1rem);
    padding-inline: var(--gutter);
}

.tabbar {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 30;
    height: calc(var(--tabbar-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-secondary); font-size: 0.72rem; font-weight: 600; min-height: 44px; }
.tabbar a:hover { text-decoration: none; }
.tabbar a.active { color: var(--navy); }
@media (prefers-color-scheme: dark) { .tabbar a.active { color: var(--amber); } }
.tab-icon { font-size: 1.25rem; line-height: 1; }

@media (min-width: 768px) {
    :root { --gutter: 24px; }
    .topnav { display: flex; }
    .tabbar { display: none; }
    .page { padding-block: 1.5rem 3rem; }
    h1 { font-size: 1.75rem; }
}

/* ---- banners, alerts, toasts ------------------------------------------------------------- */
.banner { padding: 0.55rem var(--gutter); font-size: 0.88rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.banner-offline { background: #FFF1DE; color: #7A4A00; }
.banner-info { background: #E7F0FA; color: #133E66; }
.banner-update { background: #E8F5E9; color: #1B5E20; }
@media (prefers-color-scheme: dark) {
    .banner-offline { background: #3A2A10; color: #FFD59A; }
    .banner-info { background: #14293D; color: #BBD8F4; }
    .banner-update { background: #163A1B; color: #B9E5BD; }
}

.alert { padding: 0.75rem 0.9rem; border-radius: var(--radius-sm); margin-bottom: 0.9rem; font-size: 0.92rem; display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.alert-error { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }
.alert-success { background: color-mix(in srgb, var(--success) 12%, var(--surface)); color: var(--success); border: 1px solid color-mix(in srgb, var(--success) 35%, transparent); }
.alert-warning { background: color-mix(in srgb, var(--amber) 16%, var(--surface)); color: var(--amber-dark); border: 1px solid color-mix(in srgb, var(--amber) 45%, transparent); }
.alert-info { background: color-mix(in srgb, var(--info) 12%, var(--surface)); color: var(--info); border: 1px solid color-mix(in srgb, var(--info) 35%, transparent); }

.job-tray {
    position: fixed;
    right: var(--gutter);
    bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
    z-index: 25;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(360px, calc(100vw - 2 * var(--gutter)));
}
@media (min-width: 768px) { .job-tray { bottom: 20px; } }
.job-chip { display: flex; align-items: center; gap: 0.6rem; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--amber); border-radius: var(--radius-sm); padding: 0.55rem 0.75rem; box-shadow: var(--shadow); color: var(--text); }
.job-chip:hover { text-decoration: none; }
.job-chip.done { border-left-color: var(--success); }
.job-chip.failed { border-left-color: var(--danger); }
.job-chip-text { display: flex; flex-direction: column; line-height: 1.25; }
.job-chip-text small { color: var(--text-secondary); font-size: 0.75rem; }

/* ---- buttons --------------------------------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
    min-height: 44px; padding: 0.55rem 1rem;
    border-radius: 10px; border: 1px solid transparent;
    font: inherit; font-weight: 600; font-size: 0.95rem;
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background 0.15s, transform 0.05s;
    -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--amber); color: #1A1E28; }
.btn-primary:hover:not(:disabled) { background: #F7B449; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-link { background: none; color: var(--amber-dark); padding: 0 0.25rem; min-height: 0; font-weight: 600; }
.btn-link:hover { text-decoration: underline; }
.btn-sm { min-height: 36px; padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.btn-lg { min-height: 52px; font-size: 1.02rem; }
.btn-block { width: 100%; }

/* ---- forms ---------------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.85rem; min-width: 0; }
.field label { font-weight: 600; font-size: 0.9rem; }
.field small { line-height: 1.35; }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="tel"],
.field input[type="number"], .field input[type="date"], .field input[type="time"], .field input[type="search"],
.field textarea, .field select, .search, .choice-detail, .location-field input[type="text"] {
    width: 100%; min-height: 44px; padding: 0.6rem 0.75rem;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--text);
    font: inherit; font-size: 1rem;
}
.field input:focus, .field textarea:focus, .field select:focus, .search:focus, .choice-detail:focus, .location-field input:focus {
    outline: 2px solid var(--amber); outline-offset: 1px; border-color: var(--amber);
}
.field textarea { resize: vertical; min-height: 88px; }
.field input[type="color"] { width: 44px; height: 44px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.field-row { display: grid; grid-template-columns: 1fr; gap: 0 1rem; }
.field-row.tight { grid-template-columns: 1fr 1fr auto; align-items: end; gap: 0.5rem; }
.field-row.tight .field { margin-bottom: 0.5rem; }
.field-row.wrap { display: flex; flex-wrap: wrap; align-items: end; }
.req { color: var(--danger); margin-left: 2px; }
.form-field.invalid input, .form-field.invalid textarea { border-color: var(--danger); }
label.check { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 500; }
label.check input { width: 20px; height: 20px; }

@media (min-width: 640px) {
    .field-row { grid-template-columns: 1fr 1fr; }
}

.stack { display: flex; flex-direction: column; gap: 0.9rem; }
.hstack { display: flex; align-items: center; gap: 0.5rem; }
.hstack.wrap { flex-wrap: wrap; }
.hstack.end { justify-content: flex-end; }
.hstack.center { justify-content: center; }

/* ---- cards & layout blocks ---------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card > h2 { margin-bottom: 0.75rem; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.75rem; }
details.card summary { cursor: pointer; }

.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; }
.page-header p { margin: 0; }

.toolbar { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1rem; }
.chip-row { display: flex; gap: 0.4rem; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }

.empty-state { text-align: center; padding: 2.5rem 1rem; }
.empty-state .btn { margin-top: 0.75rem; }
.loading-block { display: flex; align-items: center; gap: 0.75rem; justify-content: center; padding: 2rem; color: var(--text-secondary); }

.sticky-actions { position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px); z-index: 5; padding: 0.5rem 0; background: linear-gradient(to top, var(--bg) 70%, transparent); }
@media (min-width: 768px) { .sticky-actions { bottom: 8px; } }

.settings-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 900px) { .settings-grid { grid-template-columns: 3fr 2fr; align-items: start; } .settings-grid aside { position: sticky; top: calc(var(--topbar-h) + 16px); } }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; padding: 1rem; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 1.25rem; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
@media (min-width: 640px) { .modal-backdrop { align-items: center; } }

/* ---- pills -------------------------------------------------------------------------------- */
.pill { display: inline-flex; align-items: center; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; }
.pill-neutral { background: var(--surface-2); color: var(--text-secondary); }
.pill-warning { background: color-mix(in srgb, var(--amber) 22%, var(--surface)); color: var(--amber-dark); }
.pill-info { background: color-mix(in srgb, var(--info) 16%, var(--surface)); color: var(--info); }
.pill-success { background: color-mix(in srgb, var(--success) 16%, var(--surface)); color: var(--success); }
.pill-danger { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); color: var(--danger); }
.pill-risk-low { background: var(--risk-low); color: #fff; }
.pill-risk-medium { background: var(--risk-medium); color: #1A1E28; }
.pill-risk-high { background: var(--risk-high); color: #fff; }
.pill-risk-veryhigh { background: var(--risk-veryhigh); color: #fff; }

/* ---- spinner ------------------------------------------------------------------------------ */
.spinner { width: 16px; height: 16px; border: 2px solid color-mix(in srgb, currentColor 30%, transparent); border-top-color: currentColor; border-radius: 50%; display: inline-block; animation: spin 0.8s linear infinite; flex: none; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.splash { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; background: var(--navy); color: #fff; }
.splash-brand { font-size: 1.6rem; font-weight: 700; }
.splash .spinner { color: var(--amber); }

/* ---- document list ------------------------------------------------------------------------ */
.doc-list { display: flex; flex-direction: column; gap: 0.6rem; }
.doc-card { display: flex; align-items: center; gap: 0.75rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem 0.9rem; color: var(--text); box-shadow: var(--shadow); }
.doc-card:hover { text-decoration: none; border-color: var(--amber); }
.doc-card-main { flex: 1; min-width: 0; }
.doc-card-title { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.doc-ref { font-weight: 700; }
.doc-project { font-size: 1rem; margin-top: 0.1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta { display: flex; gap: 0.35rem; font-size: 0.8rem; flex-wrap: wrap; }
.doc-card-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.35rem; }
.doc-delete { font-size: 1rem; }

@media (min-width: 768px) {
    .doc-list { gap: 0.5rem; }
    .doc-card-side { flex-direction: row; align-items: center; }
}

/* ---- tables -------------------------------------------------------------------------------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grid { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.grid th, table.grid td { padding: 0.5rem 0.6rem; border: 1px solid var(--border); text-align: left; vertical-align: top; }
table.grid th { background: var(--navy); color: #fff; font-weight: 600; }
table.grid.matrix th { text-align: center; }
dl.kv { display: grid; grid-template-columns: minmax(110px, 35%) 1fr; gap: 0.35rem 0.75rem; margin: 0; }
dl.kv dt { font-weight: 600; color: var(--navy); }
@media (prefers-color-scheme: dark) { dl.kv dt { color: var(--amber); } }
dl.kv dd { margin: 0; }

/* ---- chips (answers) ------------------------------------------------------------------------- */
.chip {
    display: inline-flex; align-items: center; gap: 0.35rem;
    min-height: 40px; padding: 0.4rem 0.85rem;
    border-radius: 999px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text);
    font: inherit; font-size: 0.9rem; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.chip.selected { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip-grid { display: grid; grid-template-columns: 1fr; gap: 0.5rem; margin-bottom: 0.5rem; }
.chip-grid.two { grid-template-columns: 1fr 1fr; }
.chip.choice { flex-direction: column; align-items: flex-start; text-align: left; white-space: normal; border-radius: 12px; padding: 0.65rem 0.9rem; min-height: 48px; gap: 0.15rem; }
.chip.choice.big { align-items: center; justify-content: center; font-size: 1.05rem; min-height: 56px; }
.chip.choice.selected { background: color-mix(in srgb, var(--navy) 92%, #fff); border-color: var(--amber); box-shadow: inset 0 0 0 1px var(--amber); }
.chip.choice.selected::before { content: "✓"; position: absolute; right: 12px; top: 10px; color: var(--amber); font-weight: 700; }
.chip.choice { position: relative; padding-right: 2rem; }
.chip-label { font-weight: 600; }
.chip-detail { font-size: 0.8rem; opacity: 0.8; font-weight: 400; line-height: 1.3; }
.chip.choice.selected .chip-detail { opacity: 0.9; }
@media (min-width: 640px) { .chip-grid { grid-template-columns: 1fr 1fr; } }

/* ---- builder: mode picker ----------------------------------------------------------------- */
.mode-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.mode-card { text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; cursor: pointer; font: inherit; color: var(--text); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 0.35rem; }
.mode-card:hover { border-color: var(--amber); }
.mode-card.featured { border-color: var(--amber); background: linear-gradient(135deg, var(--surface), color-mix(in srgb, var(--amber) 8%, var(--surface))); }
.mode-card h2 { margin: 0; }
.mode-card p { margin: 0; color: var(--text-secondary); }
.mode-icon { font-size: 1.8rem; }
@media (min-width: 640px) { .mode-grid { grid-template-columns: 1fr 1fr; } }

/* ---- builder: chat ------------------------------------------------------------------------ */
.builder-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.75rem; }
.builder-head h1 { font-size: 1.2rem; }
.builder-head p { margin: 0; }
.chat-transcript { display: flex; flex-direction: column; gap: 0.5rem; padding-bottom: 1rem; }
.chat-transcript.compact { max-height: 40vh; overflow-y: auto; }
.bubble { max-width: 92%; padding: 0.65rem 0.85rem; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.bubble.agent { align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.user { align-self: flex-end; background: var(--navy); color: #fff; border-color: var(--navy); border-bottom-right-radius: 4px; }
.bubble.thinking { display: flex; gap: 0.5rem; align-items: center; color: var(--text-secondary); }
.bubble-text { white-space: pre-wrap; }
.reg-note { margin-top: 0.4rem; padding: 0.4rem 0.6rem; border-left: 3px solid var(--amber); background: color-mix(in srgb, var(--amber) 12%, var(--surface)); font-size: 0.82rem; border-radius: 0 6px 6px 0; color: var(--text); }
.agent-note { padding: 0.6rem 0.85rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); margin-bottom: 0.75rem; }
@media (min-width: 768px) { .bubble { max-width: 75%; } }

.action-sheet {
    position: sticky; bottom: calc(var(--tabbar-h) + var(--safe-bottom));
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
    padding: 0.75rem; margin: 0 calc(-1 * var(--gutter)) calc(-1 * (var(--tabbar-h) + var(--safe-bottom) + 1rem));
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.08);
    display: flex; flex-direction: column; gap: 0.5rem;
}
.action-sheet textarea { width: 100%; min-height: 56px; padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; resize: vertical; }
.action-hint { margin: 0; font-size: 0.8rem; }
@media (min-width: 768px) {
    .action-sheet { position: static; margin: 0; border-radius: var(--radius); box-shadow: var(--shadow); }
}

/* ---- builder: expert form ----------------------------------------------------------------- */
.form-step { padding: 1.1rem; }
.form-step-header { margin-bottom: 1rem; }
.step-badge { display: inline-block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--amber-dark); margin-bottom: 0.25rem; }
.form-field { padding: 0.75rem 0; border-top: 1px solid var(--border); margin-bottom: 0; }
.form-field:first-of-type { border-top: 0; }
.form-field > label { font-size: 1rem; }
.form-step-actions { margin-top: 1rem; }
.choice-detail { margin-top: 0.25rem; }
.transcript-details { padding: 0.75rem 1rem; }
.transcript-details summary { font-weight: 600; cursor: pointer; }
.transcript-details .chat-transcript { margin-top: 0.75rem; }

.location-field { display: flex; flex-direction: column; gap: 0.5rem; }
.autocomplete-host { min-height: 44px; }
.autocomplete-host gmp-place-autocomplete, .gmp-autocomplete { width: 100%; display: block; --gmpx-color-surface: var(--surface); }
.location-summary { padding: 0.5rem 0.75rem; background: var(--surface-2); border-radius: 8px; font-size: 0.9rem; }

.upload-field { display: flex; flex-direction: column; gap: 0.5rem; }
.upload-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.25rem; padding: 1rem; border: 2px dashed var(--border); border-radius: 12px; text-align: center; cursor: pointer; background: var(--surface-2); }
.upload-drop input[type="file"] { width: 100%; font-size: 0.85rem; }
.upload-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.upload-list li { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.upload-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-icon { font-size: 1.1rem; }

.install-steps { margin: 0 0 1rem; padding-left: 1.25rem; display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.92rem; }

/* ---- progress pages ----------------------------------------------------------------------- */
.progress-page { display: flex; justify-content: center; padding-top: 1rem; }
.progress-card { max-width: 520px; width: 100%; text-align: center; padding: 2rem 1.25rem; display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.progress-icon { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--surface-2); font-size: 1.75rem; font-weight: 700; margin-bottom: 0.5rem; }
.progress-icon .spinner { color: var(--amber); }
.progress-icon.done { background: var(--success); color: #fff; }
.progress-icon.failed { background: var(--danger); color: #fff; }
.progress-stage { font-weight: 600; }
.progress-steps { display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem; text-align: left; margin: 0.5rem 0 0.75rem; font-size: 0.9rem; color: var(--text-secondary); }
.progress-step { display: flex; align-items: center; gap: 0.5rem; }
.progress-step .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.progress-step.active { color: var(--text); font-weight: 600; }
.progress-step.active .dot { background: var(--amber); box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 30%, transparent); }
.progress-step.done { color: var(--success); }
.progress-step.done .dot { background: var(--success); }

/* ---- document detail ---------------------------------------------------------------------- */
.detail-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem; align-items: flex-start; margin-bottom: 0.75rem; }
.detail-head h1 { margin: 0; }
.detail-head p { margin: 0.25rem 0 0; }
.section-nav { position: sticky; top: calc(var(--topbar-h) + var(--safe-top)); z-index: 20; display: flex; gap: 0.4rem; overflow-x: auto; padding: 0.5rem 0; margin: 0 0 0.75rem; background: var(--bg); scrollbar-width: none; }
.section-nav::-webkit-scrollbar { display: none; }
.section-nav .chip { min-height: 34px; padding: 0.3rem 0.7rem; font-size: 0.82rem; }
.section-nav .chip:hover { text-decoration: none; border-color: var(--amber); }

.doc-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 0.75rem; box-shadow: var(--shadow); overflow: hidden; }
.section-title { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.85rem 1rem; background: none; border: 0; border-left: 4px solid var(--amber); color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.section-title h2 { margin: 0; font-size: 1.05rem; }
.section-meta { font-size: 0.8rem; white-space: nowrap; }
.chev { margin-left: 0.35rem; }
.section-body { padding: 0 1rem 1rem; display: flex; flex-direction: column; gap: 0.75rem; }

.component-card { border: 1px solid var(--border); border-radius: 10px; padding: 0.75rem; background: var(--bg); }
.component-card.editing { border-color: var(--amber); background: var(--surface); }
.component-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.5rem; }
.component-title { display: flex; flex-direction: column; line-height: 1.2; }
.component-actions { display: flex; gap: 0.25rem; flex: none; }
.component-save { margin-top: 0.75rem; }
.add-component { display: flex; gap: 0.5rem; align-items: center; }
.add-component select { flex: 1; min-height: 40px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); padding: 0.4rem 0.6rem; font: inherit; }

.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.checklist li { display: flex; gap: 0.5rem; align-items: flex-start; }
.checklist li.na { opacity: 0.6; }
.checklist .tick { color: var(--amber-dark); font-weight: 700; flex: none; width: 1rem; }
.checklist-edit { display: grid; grid-template-columns: 1fr; gap: 0.4rem; padding: 0.5rem; border: 1px solid var(--border); border-radius: 8px; }
.checklist-edit .field { margin: 0; }
@media (min-width: 640px) { .checklist-edit { grid-template-columns: auto 1fr 1fr auto; align-items: center; } }
.table-row-edit { display: grid; grid-template-columns: 1fr; gap: 0.35rem; padding: 0.5rem; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 0.5rem; }
.table-row-edit .field { margin: 0; }
@media (min-width: 640px) { .table-row-edit { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); align-items: end; } }

.hazard-card { border: 1px solid var(--border); border-radius: 10px; padding: 0.75rem; background: var(--surface); }
.hazard-top { display: flex; justify-content: space-between; gap: 0.5rem; align-items: flex-start; flex-wrap: wrap; }
.hazard-scores { display: flex; gap: 0.4rem; }
.score { display: inline-flex; flex-direction: column; align-items: center; min-width: 56px; padding: 0.25rem 0.5rem; border-radius: 8px; font-weight: 700; font-size: 1.05rem; line-height: 1.1; }
.score small { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.06em; opacity: 0.9; }
.measures { margin-top: 0.5rem; }
.hazard-edit { border: 1px solid var(--border); border-radius: 10px; padding: 0.75rem; background: var(--surface); display: flex; flex-direction: column; gap: 0.25rem; }
.score-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.75rem; }
@media (min-width: 640px) { .score-grid { grid-template-columns: repeat(4, 1fr); } }

.doc-image { margin: 0.25rem 0; text-align: center; }
.doc-image img { max-height: 420px; border-radius: 8px; border: 1px solid var(--border); }
.doc-image figcaption { font-size: 0.82rem; margin-top: 0.25rem; }
.emergency-block { display: flex; flex-direction: column; gap: 0.75rem; }
.emergency-summary { margin-top: 0.25rem; padding: 0.6rem 0.75rem; border-radius: 8px; background: color-mix(in srgb, var(--danger) 8%, var(--surface)); border-left: 3px solid var(--danger); font-size: 0.92rem; }
.attachments { margin-top: 0.75rem; }
.finalize-card { border-color: var(--amber); }

/* ---- settings preview --------------------------------------------------------------------- */
.logo-preview { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.logo-preview img { max-width: 180px; max-height: 80px; border: 1px solid var(--border); border-radius: 8px; padding: 4px; background: #fff; }
.pdf-preview { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; color: #1A1E28; font-size: 0.78rem; }
.pdf-banner { display: flex; align-items: center; gap: 0.75rem; padding: 0.85rem; color: #fff; }
.pdf-banner img { max-width: 72px; max-height: 40px; background: #fff; border-radius: 4px; padding: 2px; }
.pdf-banner-text { flex: 1; min-width: 0; }
.pdf-eyebrow { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.04em; }
.pdf-title { font-size: 1.05rem; font-weight: 700; }
.pdf-sub { font-size: 0.72rem; opacity: 0.9; }
.pdf-company { align-self: flex-end; font-weight: 600; font-size: 0.7rem; }
.pdf-info { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.25rem; padding: 0.5rem 0.75rem; border-bottom: 1px solid #DDE1E9; }
.pdf-info small { display: block; font-size: 0.55rem; color: #5A6272; letter-spacing: 0.04em; }
.pdf-info strong { font-size: 0.7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.pdf-contact { padding: 0.35rem 0.75rem; font-size: 0.62rem; border-bottom: 1px solid #DDE1E9; min-height: 1.2rem; }
.pdf-section-title { margin: 0.75rem 0.75rem 0; padding-bottom: 0.2rem; border-bottom: 2px solid; font-weight: 700; font-size: 0.85rem; }
.pdf-footer { display: flex; justify-content: space-between; padding: 1rem 0.75rem 0.5rem; font-size: 0.6rem; }

/* ---- login ---------------------------------------------------------------------------------- */
.login-page { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 1.25rem; background: radial-gradient(1200px 600px at 20% -10%, var(--navy-light), var(--navy)); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 16px; padding: 1.75rem 1.5rem; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); }
.login-brand { font-size: 1.5rem; font-weight: 700; text-align: center; }
.login-card .subtitle { text-align: center; color: var(--text-secondary); margin-bottom: 1.25rem; }

/* ---- markdown (regulation digest) --------------------------------------------------------- */
.md h2 { margin-top: 1.25rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.md h3 { margin-top: 1rem; }
.md ul { margin-bottom: 0.75rem; }
.md table.grid { margin: 0.5rem 0 1rem; font-size: 0.85rem; }
.source-list { list-style: none; margin: 0.75rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.source-list li { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

/* ---- blazor error UI -------------------------------------------------------------------- */
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000; padding: 0.6rem 1.25rem 0.75rem 1.25rem; background: lightyellow; color: #1A1E28; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
.blazor-error-boundary { background: var(--danger); color: #fff; padding: 1rem; border-radius: 8px; }
.blazor-error-boundary::after { content: "An error has occurred."; }
.loading-progress-text { font-size: 0.85rem; }
