/* ============================================================
   Event Report Generator — stylesheet
   Design system: Emerald Dossier (per DESIGN.md)
   ============================================================ */

/* ---------- Fonts ---------- */
@font-face {
    font-family: "Thmanyah Sans";
    src: url("assets/fonts/sans/thmanyahsans-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Thmanyah Sans";
    src: url("assets/fonts/sans/thmanyahsans-Bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Thmanyah Sans";
    src: url("assets/fonts/sans/thmanyahsans-Black.woff2") format("woff2");
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}

/* ---------- Color palette ---------- */
:root {
    color-scheme: dark;
    --bg: #0a0c0b;            /* page background */
    --surface: #111514;       /* cards / panels */
    --surface-2: #171d1b;     /* nested cells, hover states */
    --line: #26302c;          /* default borders */
    --line-strong: #35443e;   /* input borders */
    --accent: #45d69a;        /* emerald — the brand color */
    --accent-ink: #06231a;    /* text color on accent backgrounds */
    --accent-dim: rgba(69, 214, 154, 0.14);
    --text: #e9edeb;          /* primary text */
    --muted: #9aa8a2;         /* secondary text */
    --faint: #6b7772;         /* hints, faint text */
    --danger: #ef6a62;        /* validation errors */
    --danger-dim: rgba(239, 106, 98, 0.12);
    --mono: "Cascadia Mono", ui-monospace, "Courier New", monospace;
    --r: 10px;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Thmanyah Sans", "Segoe UI", Tahoma, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.7;
}

h1, h2, h3 { margin: 0; font-weight: 900; }
p { margin: 0 0 10px; }

.app {
    width: min(1200px, 100vw - 32px);
    margin: 0 auto;
    padding: 24px 0 40px;
}

/* ---------- Topbar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 14px 18px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
    margin-bottom: 18px;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand img { width: 54px; height: 54px; object-fit: contain; }
.brand h1 { font-size: 22px; }
.brand .sub { color: var(--muted); font-size: 13px; }

.topbar-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}
.meta-pill {
    border: 1px solid var(--accent);
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 4px;
}
.meta-pill.is-danger {
    border-color: var(--danger);
    background: var(--danger-dim);
    color: var(--danger);
}
.meta-code {
    font-family: var(--mono);
    color: var(--faint);
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* ---------- Page layout ---------- */
.layout {
    display: grid;
    grid-template-columns: 264px 1fr;
    gap: 20px;
    align-items: start;
}

/* ---------- Sidebar rail ---------- */
.rail {
    position: sticky;
    top: calc(var(--topbar-h, 88px) + 14px);
    display: grid;
    gap: 14px;
}

.rail-box {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    overflow: hidden;
}

.step {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    background: none;
    border: 0;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    font: inherit;
    text-align: start;
    cursor: pointer;
}
.step:last-child { border-bottom: 0; }
.step:disabled { cursor: default; }

.step-num {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    font-family: var(--mono);
    font-size: 13px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    color: var(--muted);
}
.step-label { display: grid; gap: 1px; }
.step-name { font-weight: 700; font-size: 14px; line-height: 1.3; }
.step-status { color: var(--faint); font-size: 12px; line-height: 1.3; }

.step.is-current {
    background: var(--surface-2);
    box-shadow: inset 3px 0 0 var(--accent);
}
.step.is-current .step-num { border-color: var(--accent); color: var(--accent); }
.step.is-done .step-num {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

.rail-block { padding: 14px; }
.rail-block h3 {
    font-size: 12px;
    color: var(--faint);
    margin-bottom: 8px;
}
.rail-block .value {
    font-size: 18px;
    font-weight: 900;
    color: var(--accent);
}
.rail-block .hint { color: var(--faint); font-size: 12px; }
.rail-block ul { list-style: none; margin: 0; padding: 0; }
.rail-block li {
    font-size: 13px;
    color: var(--muted);
    padding: 3px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.rail-block li::before { content: none; }

.local-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.local-item-del {
    background: none;
    border: 0;
    color: var(--faint);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    padding: 0 4px;
}
.local-item-del:hover { color: var(--danger); }

/* ---------- Panels ---------- */
.content { min-width: 0; }

.panel {
    display: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 20px;
}
.panel.is-open { display: block; }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 14px;
    margin-bottom: 18px;
    border-bottom: 1px dashed var(--line-strong);
}
.panel-head h2 { font-size: 20px; }
.panel-tag {
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 4px;
    white-space: nowrap;
}

.panel-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 16px;
    margin-top: 18px;
    border-top: 1px dashed var(--line-strong);
}
.panel-foot.split { justify-content: space-between; }
.panel-foot.center { justify-content: center; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 18px;
    border-radius: 6px;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.15s, border-color 0.15s, color 0.15s;
}
.btn-solid {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: var(--accent-ink);
}
.btn-solid:hover { filter: brightness(1.1); }
.btn-solid:disabled { filter: grayscale(0.6) brightness(0.8); cursor: wait; }
.btn-ghost {
    background: transparent;
    border: 1px solid var(--line-strong);
    color: var(--text);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn-danger-ghost {
    background: transparent;
    border: 1px solid var(--line-strong);
    color: var(--muted);
}
.btn-danger-ghost:hover { border-color: var(--danger); color: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row .btn { flex: 1 1 160px; }

/* ---------- Form fields ---------- */
.field { display: grid; gap: 5px; }
.field label { font-size: 13px; font-weight: 700; color: var(--muted); }
.field small { font-size: 12px; color: var(--faint); }

.field input,
.field select,
.field textarea,
.search-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    min-height: 42px;
    padding: 8px 12px;
    outline: none;
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.search-input:focus { border-color: var(--accent); }
.field input[readonly] { background: var(--surface-2); color: var(--accent); }

.fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.field-full { grid-column: 1 / -1; }

.field-inline { display: flex; gap: 8px; align-items: stretch; }
.field-inline input { flex: 1; }

/* ---------- Quiz card (options) ---------- */
.q {
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 16px;
}
.q-head {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    padding: 10px 14px;
}
.q-num {
    font-family: var(--mono);
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
}
.q-title { font-size: 15px; font-weight: 700; }

.q-opt {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    cursor: pointer;
}
.q-opt:last-child { border-bottom: 0; }
.q-opt:hover { background: var(--surface-2); }
.q-opt input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    flex: 0 0 auto;
    width: 15px;
    height: 15px;
    margin: 0;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    cursor: pointer;
}
.q-opt input[type="radio"]:checked {
    border-color: var(--accent);
    background: radial-gradient(circle at center, var(--accent) 0 4px, transparent 5px);
}
.q-opt:has(input:checked) { background: var(--accent-dim); color: var(--text); }

.q-opts-grid { display: grid; grid-template-columns: 1fr 1fr; }
.q-opts-grid .q-opt:nth-child(odd) { border-inline-end: 1px solid var(--line); }
.q-other-box { padding: 12px 14px; border-top: 1px solid var(--line); }

/* ---------- Tile grid (icon selectors) ---------- */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    padding: 14px;
}
.tile {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 16px 10px 12px;
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.tile:hover { border-color: var(--accent); }
.tile input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.tile .tile-icon {
    font-size: 28px;
    line-height: 1;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 6px;
}
.tile .tile-icon img { width: 30px; height: 30px; object-fit: contain; }
.tile:has(input:checked) {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--text);
}
.tile:has(input:checked) .tile-icon { border-color: var(--accent); }

/* ---------- Dropzone (upload) ---------- */
.dropzone {
    position: relative;
    min-height: 260px;
    display: grid;
    place-items: center;
    text-align: center;
    border: 1px dashed var(--line-strong);
    border-radius: 6px;
    background: var(--bg);
    color: var(--faint);
    font-size: 14px;
    padding: 16px;
    cursor: pointer;
}
.dropzone:hover, .dropzone.is-drag { border-color: var(--accent); }
.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
/* Preview is deliberately roomy so detected-ID boxes are easy to inspect */
.dropzone img,
.dropzone canvas {
    max-width: 100%;
    max-height: 62vh;
    object-fit: contain;
    border-radius: 4px;
}
.dropzone .dz-hint { display: grid; gap: 6px; justify-items: center; }
.dz-icon { font-size: 30px; }

/* ---------- OCR progress ---------- */
.ocr-progress {
    display: none;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    font-size: 13px;
    color: var(--muted);
}
.ocr-progress.is-on { display: flex; }
.ocr-bar {
    flex: 1;
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    overflow: hidden;
}
.ocr-bar-fill {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 0.2s;
}

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 4px;
    border: 1px solid var(--line-strong);
    background: var(--surface-2);
    color: var(--muted);
    font-family: var(--mono);
    cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.is-active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.chip.is-warn { border-color: #e6c95a; color: #e6c95a; }
.chip.is-danger { border-color: var(--danger); color: var(--danger); }
.chip.is-ignored { border-style: dashed; opacity: 0.65; }
.chip.is-ignored:hover { border-color: var(--accent); color: var(--accent); opacity: 1; }

/* Small non-clickable badges */
.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--line-strong);
    background: var(--surface-2);
    color: var(--muted);
    white-space: nowrap;
    font-family: inherit;
}
.badge-auto { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }
.badge-warn { border-color: var(--danger); background: var(--danger-dim); color: var(--danger); }
.badge-local { border-color: var(--line-strong); background: var(--surface-2); color: var(--muted); }

/* ---------- Resolver box (duplicates / unknown tokens) ---------- */
.resolver {
    display: none;
    margin: 10px 0;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: var(--surface-2);
    padding: 14px;
}
.resolver.is-open { display: block; }
.resolver h3 { font-size: 14px; margin-bottom: 10px; }
.resolver-list { display: grid; gap: 8px; margin-bottom: 10px; }
.resolver-opt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    padding: 9px 12px;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    text-align: start;
    cursor: pointer;
}
.resolver-opt:hover { border-color: var(--accent); }
.resolver-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.resolver-actions select {
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    min-height: 34px;
    padding: 4px 8px;
}

/* ---------- Attendee table ---------- */
.att-table-wrap { overflow-x: auto; margin: 14px 0; }
.att-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--line);
    font-size: 13px;
    min-width: 640px;
}
.att-table th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-align: start;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.att-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.att-table tr:last-child td { border-bottom: 0; }
.att-table tr:hover td { background: var(--surface-2); }

.att-table input[type="text"],
.att-table select {
    width: 100%;
    min-width: 70px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    padding: 4px 6px;
    outline: none;
}
.att-table input[type="text"]:hover,
.att-table select:hover { border-color: var(--line-strong); }
.att-table input[type="text"]:focus,
.att-table select:focus { border-color: var(--accent); background: var(--bg); }
.att-table select option { background: var(--surface); }
.att-table .cell-id { font-family: var(--mono); }
.att-table .cell-id input { font-family: var(--mono); direction: ltr; text-align: end; }

.att-check {
    appearance: none;
    -webkit-appearance: none;
    width: 17px;
    height: 17px;
    margin: 0;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    cursor: pointer;
    display: inline-grid;
    place-items: center;
    vertical-align: middle;
}
.att-check:checked { background: var(--accent); border-color: var(--accent); }
.att-check:checked::after {
    content: "✓";
    color: var(--accent-ink);
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
}

.att-remove {
    background: none;
    border: 0;
    color: var(--faint);
    font-size: 15px;
    cursor: pointer;
    padding: 2px 6px;
}
.att-remove:hover { color: var(--danger); }

.att-empty {
    text-align: center;
    color: var(--faint);
    font-size: 13px;
    padding: 18px 10px !important;
}

/* ---------- Search & suggestions ---------- */
.search-wrap { position: relative; }
.suggestions {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    inset-inline: 0;
    z-index: 40;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45);
}
.suggestions.is-open { display: block; }
.sugg {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    background: none;
    border: 0;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    text-align: start;
    cursor: pointer;
}
.sugg:last-child { border-bottom: 0; }
.sugg:hover { background: var(--surface-2); }
.sugg .sugg-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sugg .sugg-id { font-family: var(--mono); color: var(--accent); direction: ltr; }
.sugg .sugg-meta { color: var(--faint); font-size: 12px; }
.sugg-none {
    padding: 10px 12px;
    color: var(--faint);
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

/* ---------- Search color legend ---------- */
.search-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin: 0;
    font-size: 12px;
    color: var(--faint);
}
.search-legend .leg {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.search-legend .leg-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: 0 0 auto;
}
/* The OCR box legend needs spacing since it sits outside a field grid */
#ocrLegend { margin-bottom: 4px; }

/* ---------- Manual create form ---------- */
.create-box {
    display: none;
    margin-top: 12px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: var(--surface-2);
    padding: 14px;
}
.create-box.is-open { display: block; }
.create-box h3 { font-size: 14px; margin-bottom: 12px; }

/* ---------- Errors box ---------- */
.errors {
    display: none;
    background: var(--danger-dim);
    border: 1px solid var(--danger);
    border-radius: 6px;
    color: var(--danger);
    font-size: 13px;
    padding: 10px 14px;
    margin-top: 14px;
}
.errors.is-on { display: block; }

/* ---------- Fallback bar ---------- */
.fallback {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
    padding: 10px 14px;
    margin: 12px 0;
}
.fallback.is-on { display: flex; }
.fallback .fb-actions { display: flex; gap: 8px; flex: 0 0 auto; }

/* ---------- Template outputs ---------- */
.output {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.6;
    min-height: 150px;
    padding: 12px;
    resize: vertical;
    outline: none;
    direction: ltr;
    text-align: left;
    white-space: pre;
}
.output:focus { border-color: var(--accent); }
.output-tall { min-height: 260px; }

.char-count {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--faint);
    direction: ltr;
    text-align: end;
    margin-top: 6px;
}
.char-count.is-over { color: var(--danger); font-weight: 700; }

.outputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}
.outputs .out-cell {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 16px;
}
.out-cell h3 { font-size: 16px; margin-bottom: 4px; }
.out-cell .note { color: var(--faint); font-size: 13px; margin-bottom: 12px; }

/* Paste shortcuts help under the combined-copy button */
.paste-help {
    display: grid;
    gap: 4px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--muted);
}
.paste-help .kbd {
    display: inline-block;
    direction: ltr;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--accent);
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    padding: 0 6px;
}

/* ---------- Issues report ---------- */
.issues-box {
    display: none;
    margin-top: 18px;
    border: 1px solid var(--danger);
    border-radius: 6px;
    overflow: hidden;
}
.issues-box.is-on { display: block; }
.issues-head {
    background: var(--danger-dim);
    border-bottom: 1px solid var(--danger);
    color: var(--danger);
    font-weight: 900;
    font-size: 14px;
    padding: 10px 14px;
}
.issues-body { padding: 14px; }

/* Auto-delivery status under the Issues textarea */
.issues-send-status { font-size: 12px; margin-top: 8px; min-height: 16px; }
.issues-send-status.is-ok { color: var(--accent); font-weight: 700; }
.issues-send-status.is-bad { color: var(--danger); font-weight: 700; }
.issues-send-status.is-muted { color: var(--faint); }

/* ---------- Review (step 3) — deliberately compact for fast completion ---------- */
.review-grid {
    display: grid;
    grid-template-columns: 190px 1fr;
    gap: 10px;
    margin-bottom: 10px;
}
.review-img {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    display: grid;
    place-items: center;
    padding: 4px;
    align-self: start;
}
.review-img img { max-width: 100%; max-height: 150px; object-fit: contain; border-radius: 4px; }

.review-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-content: start; }
.fact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 13px;
    min-width: 0;
}
.fact .fact-label { color: var(--faint); font-size: 11px; white-space: nowrap; }
.fact .fact-value {
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fact .fact-edit {
    background: none;
    border: 0;
    color: var(--faint);
    font: inherit;
    font-size: 11px;
    cursor: pointer;
    text-decoration: underline;
    flex: 0 0 auto;
}
.fact .fact-edit:hover { color: var(--accent); }

.review-group { margin-bottom: 2px; }
.review-group h3 {
    font-size: 12px;
    color: var(--accent);
    margin: 8px 0 4px;
}
.review-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    margin-bottom: 3px;
    font-size: 13px;
    background: var(--surface-2);
}
.review-row .rr-name { font-weight: 700; }
.review-row .rr-meta { color: var(--faint); font-size: 12px; font-family: var(--mono); direction: ltr; }
.review-row.is-off { opacity: 0.45; }

@media (max-width: 920px) {
    .review-facts { grid-template-columns: 1fr; }
}

/* ---------- Field responsibilities (review step, توزيع مهام only) ---------- */
.roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 8px;
    margin-top: 10px;
}
/* Pinned roles (أعلى رتبة بالميدان + مسؤول الفترة): own emphasized top row */
.roles-grid-top {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    margin-bottom: 2px;
}
.roles-grid-top .role-row { border-color: var(--line-strong); background: var(--surface); }
.roles-grid-top .role-row label { color: var(--text); }
.role-row {
    display: grid;
    gap: 4px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
}
.role-row label { font-size: 12px; font-weight: 700; color: var(--muted); }
.role-row .role-tag { color: var(--faint); font-weight: 400; }
.role-row select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    min-height: 36px;
    padding: 4px 8px;
    outline: none;
}
.role-row select:focus { border-color: var(--accent); }
.role-row:has(select option:checked:not([value=""])) { border-color: var(--accent); }

/* ---------- Landing panel ---------- */
.landing {
    display: grid;
    justify-items: center;
    text-align: center;
    gap: 14px;
    padding: 40px 20px;
}
.landing img { width: 110px; height: 110px; object-fit: contain; }
.landing h2 { font-size: 24px; }
.landing p { color: var(--muted); font-size: 14px; max-width: 460px; }
.landing .btn { min-width: 220px; }
.landing-status { font-size: 13px; color: var(--faint); min-height: 22px; }

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translate(-50%, 16px);
    z-index: 90;
    background: var(--accent);
    color: var(--accent-ink);
    font-size: 14px;
    font-weight: 700;
    padding: 10px 22px;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Modal ---------- */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(4, 6, 5, 0.8);
    place-items: center;
    padding: 20px;
}
.modal-backdrop.is-open { display: grid; }
.modal {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    padding: 24px;
    text-align: center;
    display: grid;
    gap: 12px;
    justify-items: center;
}
.modal .modal-icon { font-size: 34px; }
.modal h2 { font-size: 20px; }
.modal p { color: var(--muted); font-size: 14px; margin: 0; }
.modal .modal-actions { display: flex; gap: 10px; }
body.modal-open { overflow: hidden; }

/* ---------- Footer ---------- */
.footer {
    margin-top: 24px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    text-align: center;
    color: var(--faint);
    font-size: 13px;
    display: grid;
    gap: 4px;
}
.footer .credit { color: var(--muted); }
.footer .credit b { color: var(--accent); font-weight: 700; }

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
.ltr { direction: ltr; }
.mono { font-family: var(--mono); }
.mt { margin-top: 14px; }
.section-sep {
    border: 0;
    border-top: 1px dashed var(--line-strong);
    margin: 18px 0;
}

/* ---------- Breakpoints ---------- */
@media (max-width: 920px) {
    .layout { grid-template-columns: 1fr; }
    .rail { position: static; }
    .rail-box.stepper-box { order: -1; }
    .stepper { display: grid; grid-template-columns: repeat(5, 1fr); }
    .step {
        flex-direction: column;
        gap: 6px;
        padding: 10px 4px;
        border-bottom: 0;
        border-inline-end: 1px solid var(--line);
        text-align: center;
        align-items: center;
    }
    .step:last-child { border-inline-end: 0; }
    .step-status { display: none; }
    .step-name { font-size: 13px; }
    .step.is-current { box-shadow: inset 0 -3px 0 var(--accent); }
    .fields, .outputs, .review-grid, .q-opts-grid { grid-template-columns: 1fr; }
    .q-opts-grid .q-opt { border-inline-end: 0 !important; }
}

@media (max-width: 560px) {
    .topbar { position: static; flex-direction: column; align-items: flex-start; }
    .topbar-meta { align-items: flex-start; }
    .step-name { font-size: 12px; }
    .att-table { min-width: 560px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
