:root {
    --bg: #0f1419;
    --bg-soft: #161c24;
    --panel: #1b232e;
    --panel-2: #212c39;
    --line: #2c3947;
    --text: #e8edf2;
    --muted: #93a1b0;
    --accent: #e8842c;
    --accent-2: #f0a35e;
    --ok: #3fb56b;
    --warn: #d8a33a;
    --bad: #e05c5c;
    --radius: 12px;
    --shadow: 0 6px 24px rgba(0, 0, 0, .35);
    font-synthesis: none;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: radial-gradient(1200px 600px at 70% -10%, #1d2733 0%, var(--bg) 60%);
    color: var(--text);
    font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    min-height: 100vh;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: rgba(255, 255, 255, .06);
    padding: 1px 5px;
    border-radius: 5px;
    font-size: .9em;
}

.muted { color: var(--muted); }
.small { font-size: .85em; }
.link { color: var(--accent-2); cursor: pointer; text-decoration: underline; }

/* ---- brand ---- */
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { margin: 0; font-size: 1.4rem; letter-spacing: .2px; }
.brand .sub { color: var(--muted); font-size: .85rem; }
.brand-mark {
    display: grid; place-items: center;
    width: 46px; height: 46px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), #b9611a);
    color: #fff; font-weight: 700; letter-spacing: .5px;
    box-shadow: var(--shadow);
}
.brand.small .brand-mark { width: 38px; height: 38px; border-radius: 10px; font-size: .9rem; }
.brand.small strong { display: block; line-height: 1.1; }
.brand.small .sub { display: block; }

/* ---- login ---- */
.login-body { display: grid; place-items: center; padding: 24px; }
.login-card {
    width: 100%; max-width: 380px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
}
.login-card .brand { margin-bottom: 22px; }
.login-card form { display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; }
.login-card label span { font-size: .85rem; color: var(--muted); }
.foot-note { margin: 18px 0 0; font-size: .78rem; color: var(--muted); text-align: center; }

input[type=text], input[type=password], textarea {
    width: 100%;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--text);
    padding: 11px 12px;
    font: inherit;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(232, 132, 44, .15);
}
textarea { resize: vertical; }

/* ---- buttons ---- */
.btn {
    appearance: none; cursor: pointer;
    border: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--text);
    padding: 10px 16px;
    border-radius: 9px;
    font: inherit; font-weight: 600;
    transition: transform .05s, background .15s, border-color .15s, opacity .15s;
}
.btn:hover { border-color: #3a4a5c; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #c96f1f); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---- layout ---- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 22px;
    border-bottom: 1px solid var(--line);
    background: rgba(15, 20, 25, .6);
    backdrop-filter: blur(6px);
    position: sticky; top: 0; z-index: 5;
}
.wrap { max-width: 860px; margin: 0 auto; padding: 26px 20px 60px; }

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px 22px 24px;
    box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 6px; font-size: 1.15rem; }
.panel > p { margin-top: 0; }

.field { display: block; margin: 16px 0; }
.field > span { display: block; margin-bottom: 6px; font-size: .85rem; color: var(--muted); }
.field em { font-style: normal; }

/* ---- dropzone ---- */
.dropzone {
    position: relative;
    border: 1.5px dashed var(--line);
    border-radius: 10px;
    padding: 22px;
    text-align: center;
    color: var(--muted);
    transition: border-color .15s, background .15s;
}
.dropzone.drag { border-color: var(--accent); background: rgba(232, 132, 44, .06); }
.dropzone p { margin: 4px 0; }
.dropzone input[type=file] {
    position: absolute; inset: 0;
    opacity: 0; cursor: pointer; width: 100%; height: 100%;
}

.filelist { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.filelist li {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: .9rem;
}
.filelist .fmeta { color: var(--muted); font-size: .82rem; }
.filelist .rm { cursor: pointer; color: var(--bad); font-weight: 700; border: none; background: none; font-size: 1rem; }

.actions { display: flex; gap: 10px; margin-top: 20px; }

/* ---- status ---- */
.status {
    margin-top: 20px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.steps li { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.steps li.active { color: var(--text); }
.steps li.done { color: var(--ok); }
.dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--line); flex: none;
}
.steps li.active .dot { background: var(--accent); box-shadow: 0 0 0 4px rgba(232,132,44,.18); animation: pulse 1.1s infinite; }
.steps li.done .dot { background: var(--ok); }
@keyframes pulse { 50% { opacity: .45; } }

.alert { padding: 11px 14px; border-radius: 9px; margin-bottom: 14px; font-size: .92rem; }
.alert.error { background: rgba(224, 92, 92, .12); border: 1px solid rgba(224,92,92,.4); color: #f3b4b4; }

/* ---- results ---- */
.results { margin-top: 22px; }
.results-head { display: flex; align-items: center; gap: 12px; }
.results-head h2 { margin: 0; font-size: 1.15rem; }
.badge {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .5px;
    color: var(--muted); border: 1px solid var(--line);
    padding: 3px 9px; border-radius: 999px;
}
.cards { display: grid; gap: 14px; margin-top: 14px; }
.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    padding: 16px 18px;
}
.card.backfill { border-left-color: var(--warn); }
.card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 1.35rem; font-weight: 700; letter-spacing: .5px; }
.code .heading-part { color: var(--accent-2); }
.card .title { margin: 2px 0 8px; font-weight: 600; }
.card .rationale { color: var(--muted); font-size: .92rem; margin: 8px 0 0; }
.tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.tag {
    font-size: .74rem; color: var(--muted);
    background: var(--bg-soft); border: 1px solid var(--line);
    border-radius: 6px; padding: 2px 8px;
}
.tag.ok { color: var(--ok); border-color: rgba(63,181,107,.4); }
.conf { font-size: .78rem; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); }
.conf.high { color: var(--ok); border-color: rgba(63,181,107,.5); }
.conf.medium { color: var(--warn); border-color: rgba(216,163,58,.5); }
.conf.low { color: var(--muted); }

.raw { margin-top: 18px; }
.raw summary { cursor: pointer; color: var(--muted); }
.disclaimer {
    margin-top: 18px; font-size: .82rem; color: var(--muted);
    border-top: 1px solid var(--line); padding-top: 14px;
}

.spinner {
    width: 16px; height: 16px; flex: none;
    border: 2px solid rgba(255,255,255,.25);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
    .actions { flex-direction: column; }
    .actions .btn { width: 100%; }
}

/* ===== HS-HISTORY-STYLES (download record, history icon, history table) ===== */
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
    display: grid; place-items: center;
    width: 38px; height: 38px;
    border: 1px solid var(--line); border-radius: 10px;
    color: var(--muted); background: var(--panel-2);
    text-decoration: none;
    transition: color .15s, border-color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); border-color: #3a4a5c; background: #283545; }

.record {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; flex-wrap: wrap;
    margin-top: 18px; padding: 14px 16px;
    background: var(--bg-soft);
    border: 1px solid var(--line); border-radius: 10px;
}
.record-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.record-info code { word-break: break-all; }
.result-actions { margin-top: 20px; }

.nowrap { white-space: nowrap; }
.btn.sm { padding: 6px 13px; font-size: .85rem; }

.history-wrap { overflow-x: auto; }
.history-table { width: 100%; border-collapse: collapse; margin-top: 14px; }
.history-table th, .history-table td {
    text-align: left; padding: 11px 12px;
    border-bottom: 1px solid var(--line); vertical-align: top; font-size: .92rem;
}
.history-table th {
    color: var(--muted); font-weight: 600;
    font-size: .76rem; text-transform: uppercase; letter-spacing: .4px;
}
.history-table tbody tr:hover { background: rgba(255, 255, 255, .03); }
.history-table .codes { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; color: var(--accent-2); }
.history-table .dl { white-space: nowrap; }
.history-empty { color: var(--muted); padding: 30px 0; text-align: center; }
