/* ============================================================
   Cyper — modern responsive theme
   ============================================================ */

:root {
    --bg:           #f4f6fb;
    --bg-grad:      radial-gradient(1200px 600px at 90% -10%, #d9efea 0%, transparent 50%),
                    radial-gradient(900px 500px at -10% 100%, #e1e7ff 0%, transparent 55%),
                    #f4f6fb;
    --panel:        #ffffff;
    --panel-soft:   #fbfdff;
    --text:         #0f172a;
    --muted:        #64748b;
    --line:         #e2e8f0;
    --line-strong:  #cbd5e1;

    --primary:      #0f766e;
    --primary-700:  #0b5f59;
    --primary-50:   #ecfdf5;
    --accent:       #2563eb;
    --danger:       #b42318;
    --danger-50:    #fef2f2;
    --warn:         #b54708;
    --warn-50:      #fffaeb;
    --ok:           #067647;
    --ok-50:        #f0fdf4;

    --r-sm: 6px;
    --r:    10px;
    --r-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 1px rgba(15, 23, 42, .03);
    --shadow:    0 8px 28px rgba(15, 23, 42, .07);
    --shadow-lg: 0 18px 50px rgba(15, 23, 42, .10);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg:           #0b1220;
        --bg-grad:      radial-gradient(1100px 550px at 90% -10%, #0e2b27 0%, transparent 55%),
                        radial-gradient(900px 500px at -10% 100%, #14213d 0%, transparent 60%),
                        #0b1220;
        --panel:        #111a2e;
        --panel-soft:   #0f172a;
        --text:         #e2e8f0;
        --muted:        #94a3b8;
        --line:         #1f2a44;
        --line-strong:  #334155;
        --primary-50:   #062c27;
        --warn-50:      #2b1d09;
        --danger-50:    #2c1110;
        --ok-50:        #0a2818;
    }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg-grad);
    color: var(--text);
    font-family: "Segoe UI", "Tahoma", "Cairo", system-ui, -apple-system, Arial, sans-serif;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

/* ── Top bar ──────────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 14px clamp(16px, 4vw, 36px);
    background: rgba(255, 255, 255, .82);
    border-bottom: 1px solid var(--line);
    backdrop-filter: saturate(140%) blur(12px);
    -webkit-backdrop-filter: saturate(140%) blur(12px);
}
@media (prefers-color-scheme: dark) {
    .topbar { background: rgba(17, 26, 46, .78); }
}
.topbar > div { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.topbar strong {
    font-size: 22px;
    letter-spacing: .3px;
    color: var(--primary-700);
    background: linear-gradient(120deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.topbar span, .muted { color: var(--muted); }
.topbar nav { display: flex; gap: 6px; flex-wrap: wrap; }
.topbar nav a {
    color: var(--text);
    text-decoration: none;
    padding: 7px 12px;
    border-radius: var(--r-sm);
    font-weight: 700;
    font-size: 14px;
}
.topbar nav a:hover { background: var(--panel-soft); }
.topbar nav a.active { background: var(--primary-50); color: var(--primary-700); }

/* ── Layout ───────────────────────────────────────────────── */
.shell {
    width: min(1200px, calc(100% - 24px));
    margin: 28px auto 80px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    padding: clamp(18px, 2.4vw, 28px);
    margin-bottom: 18px;
}
.hero-panel {
    background:
        linear-gradient(135deg, rgba(15,118,110,.05), rgba(37,99,235,.04)),
        var(--panel);
}
.hero-panel h1 {
    margin: 0 0 10px;
    font-size: clamp(22px, 3.4vw, 34px);
    line-height: 1.2;
    letter-spacing: -.01em;
}
.panel h2 {
    margin: 0 0 14px;
    font-size: clamp(17px, 1.6vw, 21px);
    letter-spacing: -.01em;
}
.panel h3 { margin: 18px 0 10px; font-size: 15px; color: var(--muted); font-weight: 700; }
.panel p { margin-top: 0; }

code {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    padding: 2px 6px;
    border-radius: var(--r-sm);
    font-size: 12.5px;
    direction: ltr;
    display: inline-block;
    font-family: ui-monospace, Consolas, "Cascadia Mono", monospace;
}

/* ── Buttons ──────────────────────────────────────────────── */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--text);
    border-radius: var(--r);
    padding: 10px 18px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    transition: transform .04s ease, background .15s ease, box-shadow .15s ease;
    box-shadow: var(--shadow-sm);
}
.button:hover  { background: var(--panel-soft); box-shadow: var(--shadow); }
.button:active { transform: translateY(1px); }
.button.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-700));
    color: #fff;
    border-color: transparent;
}
.button.primary:hover { filter: brightness(1.06); }
.button.large { font-size: 16px; padding: 13px 24px; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
    border-radius: var(--r);
    padding: 14px 16px;
    margin-bottom: 18px;
    border: 1px solid;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: baseline;
}
.alert.error { color: var(--danger); background: var(--danger-50); border-color: #f6c7c0; }
.alert.warn  { color: var(--warn);   background: var(--warn-50);   border-color: #fde68a; }
.alert.ok    { color: var(--ok);     background: var(--ok-50);     border-color: #bbf7d0; }

/* ── Form fields ──────────────────────────────────────────── */
.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field span { color: var(--muted); font-weight: 700; font-size: 13.5px; }

input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--panel);
    color: var(--text);
    padding: 11px 12px;
    font: inherit;
    transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .15);
}
input[disabled], select[disabled] { background: var(--panel-soft); color: var(--muted); cursor: not-allowed; }
textarea { resize: vertical; min-height: 100px; }

.upload-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: end;
    margin-top: 12px;
}

.upload-form-full { margin-top: 14px; }
.upload-form-full .field small { display: block; margin-top: 4px; }
.upload-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: end;
}
.upload-row .grow { margin-bottom: 0; }

.alert.info,
.ctx-pill {
    background: linear-gradient(135deg, rgba(37, 99, 235, .06), rgba(15, 118, 110, .04));
    border-color: rgba(37, 99, 235, .35);
    color: var(--text);
}
.ctx-pill {
    display: flex;
    gap: 10px;
    align-items: baseline;
    margin-bottom: 14px;
}
.ctx-label { color: var(--accent); font-weight: 800; white-space: nowrap; }

.decrypt-note {
    background: linear-gradient(135deg, rgba(15, 118, 110, .07), rgba(15, 118, 110, .02));
    border-color: rgba(15, 118, 110, .35);
    margin-bottom: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 14px;
}

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 14px 0; border: 1px solid var(--line); border-radius: var(--r); }
.data-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.data-table th, .data-table td {
    border-bottom: 1px solid var(--line);
    padding: 11px 12px;
    text-align: right;
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table th {
    background: var(--panel-soft);
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.data-table tbody tr:hover { background: var(--panel-soft); }
.data-table .samples { color: var(--muted); }
.data-table .samples code { background: var(--panel-soft); border-color: var(--line); }

.cols-table td.col-name { width: 25%; }
.cols-table td.actions  { width: 38%; }
.cols-table td.samples  { width: 37%; }

/* ── Action radio pills ───────────────────────────────────── */
.radio-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    margin-inline-end: 6px;
    margin-block: 3px;
    border: 1px solid var(--line);
    border-radius: 999px;
    cursor: pointer;
    background: var(--panel-soft);
    font-size: 13px;
    transition: transform .04s ease, background .15s ease, border-color .15s ease;
    user-select: none;
}
.radio-pill:hover  { border-color: var(--line-strong); }
.radio-pill:active { transform: translateY(1px); }
.radio-pill input { position: absolute; opacity: 0; pointer-events: none; }
.radio-pill:has(input:checked) { font-weight: 800; box-shadow: var(--shadow-sm); }
.radio-pill.encrypt:has(input:checked) { background: #fef3c7; border-color: #f59e0b; color: #92400e; }
.radio-pill.send:has(input:checked)    { background: #dcfce7; border-color: #16a34a; color: #166534; }
.radio-pill.skip:has(input:checked)    { background: #fee2e2; border-color: #dc2626; color: #991b1b; }

.payload-preview { margin: 18px 0; }
.payload-preview h3 { margin: 0 0 8px; }

/* ── Recent grid ──────────────────────────────────────────── */
.recent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}
.recent-card {
    display: grid;
    gap: 5px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    color: var(--text);
    text-decoration: none;
    background: var(--panel-soft);
    transition: transform .08s ease, box-shadow .15s ease, border-color .15s ease;
}
.recent-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}
.recent-card span { color: var(--muted); font-size: 13px; }

/* ── Install checks ───────────────────────────────────────── */
.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.checks li {
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--panel-soft);
}
.checks li.ok   { border-color: #bbf7d0; background: var(--ok-50); }
.checks li.fail { border-color: #fecaca; background: var(--danger-50); }
.check-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.check-head .icon { font-weight: 900; font-size: 16px; }
.checks .ok   .icon { color: var(--ok); }
.checks .fail .icon { color: var(--danger); }
.check-head .detail { color: var(--muted); font-size: 13px; }
.fix {
    margin-top: 6px;
    padding: 8px 10px;
    background: var(--warn-50);
    border-radius: var(--r-sm);
    color: var(--warn);
    font-size: 13px;
}

/* ── Analysis result ──────────────────────────────────────── */
.status-line { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; color: var(--muted); }
.badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 3px 11px;
    font-size: 12.5px;
    font-weight: 800;
    background: #edf2ff;
    color: #3446a1;
    letter-spacing: .03em;
}
.badge.completed { background: var(--ok-50);     color: var(--ok); }
.badge.failed    { background: var(--danger-50); color: var(--danger); }
.badge.prepared  { background: var(--warn-50);   color: var(--warn); }

.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}
.markdown-box, .code-box {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 16px;
    min-height: 220px;
}
.code-box {
    direction: rtl;
    white-space: pre-wrap;
    overflow: auto;
    max-height: 560px;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 13px;
}
.code-box.ltr { direction: ltr; text-align: left; }

.tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
}
.tag.enc  { background: #fef3c7; color: #92400e; }
.tag.send { background: #dcfce7; color: #166534; }
.tag.skip { background: #fee2e2; color: #991b1b; }

/* ── Chart cards ──────────────────────────────────────────── */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 8px;
}
.chart-card {
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--panel-soft);
    padding: 14px 16px 18px;
}
.chart-card h3 { margin-top: 0; }
.chart-card canvas { width: 100% !important; height: auto !important; }

/* ── Brand link + breadcrumbs ─────────────────────────────── */
.brand { text-decoration: none; }
.crumbs {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    color: var(--muted);
    font-size: 14px;
}
.crumbs a { color: var(--primary-700); text-decoration: none; font-weight: 700; }
.crumbs a:hover { text-decoration: underline; }
.crumb-sep { color: var(--line-strong); }

/* ── Danger / icon buttons ────────────────────────────────── */
.button.danger {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    color: #fff;
    border-color: transparent;
}
.button.danger:hover { filter: brightness(1.06); }

.icon-btn {
    background: transparent;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 5px 9px;
    cursor: pointer;
    font-size: 14px;
    color: var(--muted);
    transition: background .15s ease, color .15s ease, border-color .15s ease, transform .08s ease, box-shadow .15s ease;
}
.icon-btn:hover {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    color: #fff;
    border-color: transparent;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(220, 38, 38, .35);
}

.inline-form { display: inline; margin-inline-start: auto; }
.grow { flex: 1; }

/* Recent-card layout: link content + absolutely-positioned delete icon */
.recent-card {
    position: relative;
    padding-block-start: 42px; /* room for the icon at top */
}
.recent-card .icon-btn {
    position: absolute;
    top: 8px;
    inset-inline-end: 8px;
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 15px;
}
.recent-link { display: grid; gap: 5px; text-decoration: none; color: var(--text); }
.status-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; font-size: 13px; color: var(--muted); }

/* ── Markdown article rendering ───────────────────────────── */
.markdown {
    font-size: 15px;
    line-height: 1.85;
    color: var(--text);
}
.markdown .md-h1, .markdown .md-h2, .markdown .md-h3, .markdown .md-h4 {
    margin-top: 1.6em;
    margin-bottom: .5em;
    line-height: 1.3;
    letter-spacing: -.01em;
}
.markdown .md-h1 { font-size: 1.7em; border-bottom: 2px solid var(--primary); padding-bottom: 6px; color: var(--primary-700); }
.markdown .md-h2 {
    font-size: 1.35em;
    color: var(--primary-700);
    display: flex;
    align-items: center;
    gap: 8px;
}
.markdown .md-h2::before {
    content: '';
    width: 4px;
    height: 1em;
    background: linear-gradient(180deg, var(--primary), var(--accent));
    border-radius: 2px;
}
.markdown .md-h3 { font-size: 1.15em; color: var(--text); }
.markdown .md-h4 { font-size: 1em; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.markdown p { margin: .7em 0; }
.markdown strong { color: var(--primary-700); }
.markdown em { color: var(--text); }
.markdown ul, .markdown ol { padding-inline-start: 1.6em; margin: .6em 0; }
.markdown li { margin: .25em 0; }
.markdown a { color: var(--accent); text-decoration: none; border-bottom: 1px dashed var(--accent); }
.markdown a:hover { border-bottom-style: solid; }
.markdown code {
    background: var(--primary-50);
    border-color: transparent;
    color: var(--primary-700);
    font-weight: 700;
}
.markdown .md-code {
    background: #0f172a;
    color: #e2e8f0;
    padding: 14px 16px;
    border-radius: var(--r);
    overflow-x: auto;
    direction: ltr;
    text-align: left;
    font-size: 13px;
}
.markdown .md-code code { background: transparent; color: inherit; border: 0; padding: 0; }
.markdown blockquote {
    border-inline-start: 4px solid var(--primary);
    background: var(--primary-50);
    margin: 1em 0;
    padding: 10px 16px;
    border-radius: var(--r-sm);
}
.markdown blockquote p { margin: .25em 0; color: var(--primary-700); font-weight: 600; }
.markdown hr { border: 0; border-top: 1px dashed var(--line-strong); margin: 1.6em 0; }
.markdown table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    font-size: 14px;
    background: var(--panel-soft);
    border-radius: var(--r);
    overflow: hidden;
}
.markdown th, .markdown td {
    border: 1px solid var(--line);
    padding: 8px 12px;
    text-align: right;
}
.markdown th { background: var(--primary-50); color: var(--primary-700); font-weight: 800; }

/* ── Collapsible details panel ────────────────────────────── */
.collapsible {
    padding: 0;
    overflow: hidden;
}
.collapsible > summary {
    cursor: pointer;
    list-style: none;
    padding: 18px 24px;
    user-select: none;
    transition: background .12s ease;
}
.collapsible > summary::-webkit-details-marker { display: none; }
.collapsible > summary::before {
    content: '▸';
    display: inline-block;
    margin-inline-end: 8px;
    color: var(--muted);
    transition: transform .15s ease;
}
.collapsible[open] > summary::before { transform: rotate(90deg); }
.collapsible[open] > summary { border-bottom: 1px solid var(--line); background: var(--panel-soft); }
.collapsible h2.inline-h { display: inline; margin: 0; font-size: 17px; }
.collapsible > *:not(summary) {
    padding-inline: 24px;
}
.collapsible > *:last-child { padding-bottom: 22px; }

/* ── User chip + logout in topbar ─────────────────────────── */
.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--primary-50);
    color: var(--primary-700);
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 700;
    border: 1px solid transparent;
}
.logout-link {
    color: var(--danger) !important;
    font-size: 13.5px;
}
.logout-link:hover { background: var(--danger-50) !important; }

/* ── Auth pages (login.php) ───────────────────────────────── */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.auth-shell {
    width: 100%;
    max-width: 460px;
}
.auth-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px 28px;
}
.auth-brand {
    text-align: center;
    margin-bottom: 22px;
}
.auth-brand strong {
    display: block;
    font-size: 30px;
    background: linear-gradient(120deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: .5px;
}
.auth-brand span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
}
.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 4px;
    margin-bottom: 18px;
}
.auth-tabs a {
    text-align: center;
    padding: 9px 10px;
    border-radius: var(--r-sm);
    text-decoration: none;
    color: var(--muted);
    font-weight: 700;
    font-size: 14px;
    transition: background .15s ease, color .15s ease;
}
.auth-tabs a:hover { color: var(--text); }
.auth-tabs a.active {
    background: var(--panel);
    color: var(--primary-700);
    box-shadow: var(--shadow-sm);
}
.auth-form .button.large { width: 100%; }
.auth-footer { text-align: center; margin-top: 18px; }

/* ── Share button + panel ─────────────────────────────────── */
.share-btn {
    background: linear-gradient(135deg, var(--accent), #1e40af);
    color: #fff !important;
    border-color: transparent;
}
.share-btn:hover { filter: brightness(1.06); }
.share-panel {
    margin-top: 14px;
    padding: 14px 16px;
    border: 1px dashed var(--accent);
    border-radius: var(--r);
    background: linear-gradient(135deg, rgba(37,99,235,.06), rgba(15,118,110,.04));
}
.share-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}
.share-row input {
    flex: 1;
    background: var(--panel);
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12.5px;
}
.share-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 11px;
    background: var(--accent);
    color: #fff;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 800;
    margin-inline-start: 8px;
}

/* ── Modal dialog ─────────────────────────────────────────── */
body.modal-open { overflow: hidden; }
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
    animation: fade-in .12s ease-out;
}
.modal-backdrop[hidden] { display: none; }
.modal {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    width: min(460px, calc(100% - 32px));
    overflow: hidden;
    animation: pop-in .15s cubic-bezier(.2, 1.4, .5, 1);
}
.modal-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px 0;
}
.modal-head h3 {
    margin: 0;
    font-size: 18px;
    color: var(--text);
}
.modal-icon {
    width: 38px; height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--danger-50);
    color: var(--danger);
    border-radius: 50%;
    font-size: 18px;
}
.modal-body {
    padding: 12px 20px 4px;
    color: var(--text);
}
.modal-body p { margin: 8px 0; }
.modal-target {
    margin-top: 12px;
    padding: 10px 14px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: var(--r);
    display: flex;
    gap: 8px;
    align-items: baseline;
    flex-wrap: wrap;
}
.modal-target strong {
    color: var(--primary-700);
    font-size: 15px;
    word-break: break-word;
}
.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 14px 20px 18px;
}
.modal-actions .button { min-width: 100px; }

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes pop-in {
    from { opacity: 0; transform: scale(.94); }
    to   { opacity: 1; transform: scale(1); }
}

/* ── Progress modal (AJAX analysis flow) ──────────────────── */
.progress-modal {
    width: min(520px, calc(100% - 32px));
    padding: 22px 24px;
}
.progress-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.progress-head h3 { margin: 0; font-size: 18px; color: var(--text); }

.progress-spinner {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid var(--line);
    border-top-color: var(--primary);
    animation: spin 0.9s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-steps {
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
    display: grid;
    gap: 8px;
}
.progress-steps li {
    display: flex;
    align-items: center;
    padding: 9px 12px;
    border-radius: var(--r);
    background: var(--panel-soft);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 14px;
    transition: background .25s ease, color .25s ease, border-color .25s ease, transform .15s ease;
}
.progress-steps li.active {
    background: linear-gradient(135deg, rgba(15,118,110,.10), rgba(37,99,235,.06));
    color: var(--primary-700);
    border-color: var(--primary);
    font-weight: 800;
    transform: translateX(-3px);
    box-shadow: var(--shadow-sm);
}
[dir="rtl"] .progress-steps li.active { transform: translateX(3px); }
.progress-steps li.done {
    color: var(--ok);
    background: var(--ok-50);
    border-color: #bbf7d0;
}
.progress-steps li.done::after {
    content: '✓';
    margin-inline-start: auto;
    font-weight: 900;
    color: var(--ok);
}
.progress-steps li.active::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    margin-inline-start: auto;
    animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: .4; transform: scale(.7); }
}

.progress-bar {
    height: 8px;
    background: var(--panel-soft);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid var(--line);
    margin-bottom: 12px;
}
.progress-bar > div {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 999px;
    transition: width .4s cubic-bezier(.4, 0, .2, 1);
    background-size: 30px 30px;
    background-image:
        linear-gradient(90deg, var(--primary), var(--accent)),
        linear-gradient(45deg,
            rgba(255,255,255,.18) 25%, transparent 25%,
            transparent 50%, rgba(255,255,255,.18) 50%,
            rgba(255,255,255,.18) 75%, transparent 75%);
    background-blend-mode: overlay;
    animation: stripes 1s linear infinite;
}
@keyframes stripes {
    from { background-position: 0 0, 0 0; }
    to   { background-position: 0 0, 30px 0; }
}
.progress-hint { margin: 0; }

.progress-error {
    margin-top: 14px;
    padding: 12px 14px;
    background: var(--danger-50);
    border: 1px solid #fecaca;
    border-radius: var(--r);
    color: var(--danger);
}
.progress-error strong { display: block; margin-bottom: 4px; }
.progress-error p { margin: 6px 0 10px; color: var(--text); word-break: break-word; }
.progress-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Retry banner on a failed analysis */
.retry-block {
    display: flex;
    gap: 14px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}
.retry-block > div { flex: 1; min-width: 220px; }
.retry-block .button { white-space: nowrap; }

/* ── Misc small helpers ───────────────────────────────────── */
.req { color: var(--danger); margin-inline-start: 3px; }
.small { font-size: 12.5px; }

.prompt-details {
    margin-top: 10px;
    border: 1px dashed var(--line);
    border-radius: var(--r);
    background: var(--panel-soft);
}
.prompt-details > summary {
    cursor: pointer;
    padding: 8px 14px;
    color: var(--primary-700);
    font-weight: 700;
    user-select: none;
    list-style: none;
}
.prompt-details > summary::-webkit-details-marker { display: none; }
.prompt-details .prompt-box {
    margin: 0;
    padding: 12px 16px;
    border-top: 1px dashed var(--line);
    white-space: pre-wrap;
    line-height: 1.7;
    color: var(--text);
    font-size: 14px;
}

/* ── Log viewer ───────────────────────────────────────────── */
.log-toolbar {
    display: grid;
    grid-template-columns: 1.4fr .6fr .6fr auto;
    gap: 12px;
    align-items: end;
}
.log-toolbar .field { margin-bottom: 0; }
.log-toolbar .log-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.log-panel { padding-block-end: 18px; }
.log-list {
    max-height: 70vh;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: #0f172a;
    padding: 10px;
    direction: ltr;
}
.log-line {
    padding: 4px 8px;
    border-radius: var(--r-sm);
    margin-bottom: 2px;
}
.log-line code {
    background: transparent;
    border: 0;
    color: #e2e8f0;
    padding: 0;
    font-size: 12.5px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    display: block;
}
.log-info { background: rgba(56, 189, 248, .07); }
.log-info code { color: #bae6fd; }
.log-warn { background: rgba(245, 158, 11, .10); }
.log-warn code { color: #fcd34d; }
.log-err  { background: rgba(239, 68, 68, .12); }
.log-err code  { color: #fca5a5; font-weight: 600; }

@media (max-width: 720px) {
    .log-toolbar { grid-template-columns: 1fr; }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 980px) {
    .form-grid { grid-template-columns: 1fr 1fr; }
    .result-grid, .chart-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .topbar { padding: 12px 16px; }
    .topbar > div { flex-direction: column; gap: 2px; align-items: flex-start; }
    .topbar nav { width: 100%; }
    .form-grid, .upload-form { grid-template-columns: 1fr; }
    .data-table th, .data-table td { padding: 9px 10px; font-size: 13.5px; }
    .panel { border-radius: var(--r); }
}
