/* IMAP CHECKER web. Design reference: DESIGN.md.
   Flat dark data surface, one signal color, 16px cards, 8px rhythm, mono for
   numbers and credentials. Graphite is the primary theme; Paper is the same
   system on a light surface. No gradients, no glow, no heavy shadows. */

:root {
    --sans: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system,
            "Helvetica Neue", Arial, sans-serif;
    --mono: "JetBrains Mono", "Cascadia Mono", "Cascadia Code", "SFMono-Regular",
            ui-monospace, Menlo, Consolas, monospace;
    --r: 16px;
    --r-ctl: 10px;
    --r-pill: 999px;
    --s1: 8px;
    --s2: 16px;
    --s3: 24px;
    --s4: 32px;
}

/* -- theme: Graphite ------------------------------------------------------- */

:root,
html[data-theme="graphite"] {
    color-scheme: dark;
    --bg: #121212;
    --panel: #1e1e1e;
    --panel-2: #252525;
    --field: #1a1a1a;
    --line: #2c2c2e;
    --line-2: #3a3a3c;
    --text: #ffffff;
    --muted: #98989d;
    --dim: #8a8a90;
    --placeholder: #85858c;
    --accent: #00e5ff;
    --accent-hover: #5cefff;
    --accent-ink: #041418;
    --valid: #32d74b;
    --invalid: #ff453a;
    --warn: #ff9f0a;
    --locked: #bf5af2;
    --blocked: #5e9eff;
    --grey: #98989d;
    --alert-bg: #3a1c1c;
    --alert-text: #ff453a;
    --focus-ring: rgba(0, 229, 255, 0.32);
    --track: #2c2c2e;
    --backdrop: rgba(0, 0, 0, 0.66);
}

/* -- theme: Paper ---------------------------------------------------------- */

html[data-theme="paper"] {
    color-scheme: light;
    --bg: #f2f2f7;
    --panel: #ffffff;
    --panel-2: #f7f7fa;
    --field: #ffffff;
    --line: #dcdce3;
    --line-2: #c7c7d1;
    --text: #101014;
    --muted: #55555e;
    --dim: #6a6a73;
    --placeholder: #6e6e77;
    --accent: #00727f;
    --accent-hover: #005e69;
    --accent-ink: #ffffff;
    --valid: #12803a;
    --invalid: #c4271c;
    --warn: #8a5a00;
    --locked: #6b3fa0;
    --blocked: #1e5aa8;
    --grey: #55555e;
    --alert-bg: #fdecea;
    --alert-text: #a32016;
    --focus-ring: rgba(0, 114, 127, 0.26);
    --track: #e4e4ea;
    --backdrop: rgba(16, 16, 20, 0.42);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

[hidden] { display: none !important; }

a { color: var(--accent); }

code, .mono { font-family: var(--mono); }

::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* -- login gate ------------------------------------------------------------ */

.gate {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: var(--s3);
    background: var(--bg);
}

.gate-card {
    width: 100%;
    max-width: 420px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: var(--s4);
    display: grid;
    gap: var(--s2);
}

.gate-mark {
    font-family: var(--mono);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--text);
}

.gate-mark span { color: var(--accent); }

.gate-copy {
    margin: 0;
    color: var(--muted);
    font-size: 13.5px;
    line-height: 1.55;
}

.gate-card label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.gate-card .primary { width: 100%; min-height: 46px; margin-top: var(--s1); }

.gate-error {
    min-height: 18px;
    margin: 0;
    color: var(--invalid);
    font-size: 12.5px;
}

.gate-note {
    margin: 0;
    color: var(--dim);
    font-size: 12px;
    border-top: 1px solid var(--line);
    padding-top: var(--s2);
    line-height: 1.55;
}

/* -- shell ----------------------------------------------------------------- */

.top {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: var(--s2);
    height: 64px;
    padding: 0 var(--s3);
    background: var(--bg);
    border-bottom: 1px solid var(--line);
}

.top-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.12em;
}

.top-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: var(--accent);
    display: inline-block;
}

.top-sub {
    color: var(--dim);
    letter-spacing: 0.06em;
    border: 1px solid var(--line-2);
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 500;
}

.top-state {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    padding: 5px 12px;
    font-family: var(--mono);
    font-size: 11.5px;
    white-space: nowrap;
}

.top-state::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 auto;
}

.top-state.is-run { color: var(--accent); }
.top-state.is-done { color: var(--valid); }
.top-state.is-stop { color: var(--invalid); }

.top-theme { min-height: 36px; padding: 0 12px; font-size: 12px; }

.shell {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    align-items: start;
    gap: var(--s3);
    padding: var(--s3);
    max-width: 1720px;
    margin: 0 auto;
}

.rail {
    position: sticky;
    top: calc(64px + var(--s3));
    max-height: calc(100vh - 64px - var(--s3) * 2);
    display: flex;
    flex-direction: column;
    gap: var(--s2);
    overflow: hidden;
}

/* The settings scroll; the run controls stay pinned under them. Without this split
   the sticky action row sat on top of the last block and looked like clipped fields. */
.rail-scroll {
    display: grid;
    gap: var(--s2);
    overflow-y: auto;
    min-height: 0;
    padding-right: 2px;
    padding-bottom: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--line-2) transparent;
}

.rail-scroll::-webkit-scrollbar { width: 8px; }
.rail-scroll::-webkit-scrollbar-track { background: transparent; }
.rail-scroll::-webkit-scrollbar-thumb {
    background: var(--line-2);
    border-radius: var(--r-pill);
}
.rail-scroll::-webkit-scrollbar-thumb:hover { background: var(--muted); }

.block {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: var(--s2) 20px 20px;
    display: grid;
    gap: var(--s2);
}

.block-head {
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    gap: var(--s1);
    padding-top: 4px;
}

.block-head .hint { margin-left: auto; }

/* Console settings collapse to a single row each, so the rail stays short and the
   live log is never pushed off-screen by a wall of fields. */
summary.block-head {
    cursor: pointer;
    list-style: none;
    user-select: none;
    align-items: center;
}

summary.block-head::-webkit-details-marker { display: none; }

summary.block-head::after {
    content: "+";
    flex: 0 0 auto;
    width: 18px;
    text-align: right;
    font-family: var(--mono);
    font-size: 15px;
    line-height: 1;
    color: var(--muted);
}

details[open] > summary.block-head::after { content: "\2212"; }

summary.block-head:hover::after { color: var(--text); }

.block-head h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
}

.hint {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 400;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: 0.02em;
    min-width: 0;
}

input[type="text"], input[type="password"], input[type="number"], input[type="search"],
input[type="date"], input:not([type]),
select, textarea {
    width: 100%;
    min-width: 0;
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: var(--r-ctl);
    color: var(--text);
    padding: 9px 12px;
    min-height: 40px;
    font-family: var(--sans);
    font-size: 13px;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

textarea {
    font-family: var(--mono);
    font-size: 12.5px;
}

input[type="number"], input[type="search"], input[type="date"] {
    font-family: var(--mono);
    font-size: 12.5px;
}

/* The native picker indicator is invisible on a dark field. */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}

html[data-theme="paper"] input[type="date"]::-webkit-calendar-picker-indicator {
    filter: none;
}

input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }

textarea {
    resize: vertical;
    min-height: 132px;
    line-height: 1.6;
}

textarea.small { min-height: 92px; }

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--focus-ring);
}

input[type="date"]:focus-visible, input[type="search"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

input::placeholder, textarea::placeholder { color: var(--placeholder); }

.row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--s1);
}

.row2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s1);
}

.grid3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 400;
    letter-spacing: 0;
    cursor: pointer;
    user-select: none;
    min-height: 28px;
}

.check input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    margin: 0;
    flex: 0 0 auto;
}

.num {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.num input { width: 68px; }

.file {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line-2);
    border-radius: var(--r-ctl);
    padding: 7px 12px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    min-height: 36px;
    transition: border-color 140ms ease, color 140ms ease;
}

.file:hover { border-color: var(--accent); color: var(--text); }

.file input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.seg {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: var(--r-ctl);
    padding: 3px;
    gap: 3px;
}

.seg-btn {
    background: transparent;
    border: 0;
    border-radius: 7px;
    padding: 8px 10px;
    color: var(--muted);
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 500;
    min-height: 34px;
    transition: background 140ms ease, color 140ms ease;
}

.seg-btn:hover { color: var(--text); }

.seg-btn.is-on {
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 600;
}

.link {
    background: none;
    border: 0;
    padding: 0;
    color: var(--accent);
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 500;
    text-align: left;
    min-height: 30px;
}

.link:hover { text-decoration: underline; }

.rail-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    flex: 0 0 auto;
    padding: var(--s2) 0 0;
    border-top: 1px solid var(--line);
    background: var(--bg);
}

.primary, .ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s1);
    border-radius: var(--r-ctl);
    padding: 10px 18px;
    cursor: pointer;
    min-height: 42px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.primary {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: var(--accent-ink);
}

.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.primary:disabled { opacity: 0.4; cursor: not-allowed; }

.ghost {
    background: transparent;
    border: 1px solid var(--line-2);
    color: var(--text);
}

.ghost:hover { background: var(--panel-2); border-color: var(--line-2); }
.ghost:disabled { opacity: 0.4; cursor: not-allowed; }

/* -- work ------------------------------------------------------------------ */

.work {
    display: grid;
    gap: var(--s2);
    min-width: 0;
}

.work-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--s1) var(--s2);
    padding: 2px 2px 0;
}

.work-head h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.work-sub {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.banner {
    border: 1px solid var(--invalid);
    border-left: 4px solid var(--invalid);
    background: var(--alert-bg);
    color: var(--alert-text);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
}

.banner.is-info {
    border-color: var(--accent);
    background: var(--panel);
    color: var(--text);
}

.banner.is-key {
    border-color: var(--valid);
    background: var(--panel);
    color: var(--text);
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--s2);
}

.stat {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: baseline;
    gap: 4px var(--s1);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 18px 20px;
    min-width: 0;
}

.stat-label {
    grid-column: 1 / -1;
    color: var(--muted);
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.stat-value {
    font-family: var(--mono);
    font-size: 32px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    min-width: 0;
    overflow-wrap: anywhere;
}

.stat-value.small { font-size: 14px; font-weight: 500; letter-spacing: 0; color: var(--muted); }

.stat-sub {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11.5px;
    align-self: end;
    padding-bottom: 3px;
    white-space: nowrap;
}

.stat.hit .stat-value { color: var(--valid); }
.stat.bad .stat-value { color: var(--invalid); }
.stat.warn .stat-value { color: var(--warn); }

/* The last card fills the second row instead of leaving a hole. */
.stat.wide { grid-column: span 2; }

.progress {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 14px 20px;
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--muted);
}

.bar {
    flex: 1;
    height: 10px;
    background: var(--track);
    border-radius: var(--r-pill);
    overflow: hidden;
}

.fill {
    height: 100%;
    width: 0;
    background: var(--accent);
    border-radius: var(--r-pill);
    transition: width 220ms linear;
}

.bar-pct { color: var(--text); min-width: 44px; text-align: right; font-weight: 600; }
.bar-note { color: var(--muted); }

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s1);
    padding: 4px 2px;
}

.filters-space { flex: 1; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    padding: 7px 14px;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    min-height: 36px;
    text-decoration: none;
    transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.chip span {
    color: var(--dim);
    font-family: var(--mono);
    font-size: 11px;
    margin-left: 2px;
}

.chip:hover { border-color: var(--line-2); color: var(--text); }

.chip.is-on {
    border-color: var(--accent);
    color: var(--accent-ink);
    background: var(--accent);
    font-weight: 600;
}

.chip.is-on span { color: var(--accent-ink); opacity: 0.7; }

.empty {
    background: var(--panel);
    border: 1px dashed var(--line-2);
    border-radius: var(--r);
    padding: 56px 24px;
    text-align: center;
}

.empty-title {
    margin: 0 0 var(--s1);
    color: var(--text);
    font-size: 17px;
    font-weight: 600;
}

.empty-copy {
    margin: 0 auto;
    max-width: 48ch;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

/* -- live log -------------------------------------------------------------- */

.logwrap {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.logbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.log-title {
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
}

.log-space { flex: 1; }

.log-btn {
    background: transparent;
    border: 1px solid var(--line-2);
    border-radius: 8px;
    color: var(--muted);
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 500;
    padding: 5px 11px;
    cursor: pointer;
    min-height: 30px;
    transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.log-btn:hover { border-color: var(--line-2); color: var(--text); background: var(--panel-2); }

.log-btn.is-on {
    border-color: var(--accent);
    color: var(--accent-ink);
    background: var(--accent);
}

.log {
    max-height: 54vh;
    overflow-y: auto;
    scrollbar-gutter: stable;
    background: var(--panel);
}

.log-body { display: block; }

.ln {
    display: grid;
    grid-template-columns: 66px 92px minmax(150px, 1.3fr) minmax(90px, 0.8fr) 122px minmax(160px, 2fr);
    gap: 12px;
    align-items: baseline;
    padding: 11px 16px;
    border-bottom: 1px solid var(--line);
    font-size: 12.5px;
    min-width: 0;
    animation: rowin 140ms ease-out;
    transition: background 120ms ease;
}

.ln:last-child { border-bottom: 0; }
.ln:hover { background: var(--panel-2); }

@keyframes rowin {
    from { opacity: 0; transform: translateY(2px); }
    to { opacity: 1; transform: none; }
}

.ln > * {
    min-width: 0;
    overflow-wrap: anywhere;
}

.ln-time { color: var(--muted); font-family: var(--mono); font-size: 11px; }

.ln-status {
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.ln[data-status="VALID"] .ln-status { color: var(--valid); }
.ln[data-status="APP_PASSWORD"] .ln-status { color: var(--warn); }
.ln[data-status="INVALID"] .ln-status { color: var(--invalid); }
.ln[data-status="LOCKED"] .ln-status { color: var(--locked); }
.ln[data-status="BLOCKED"] .ln-status { color: var(--blocked); }
.ln[data-status="CAPTCHA"] .ln-status { color: var(--warn); }
.ln[data-status="TIMEOUT"] .ln-status,
.ln[data-status="CONN_ERR"] .ln-status,
.ln[data-status="ERROR"] .ln-status { color: var(--grey); }
.ln[data-status="SSL_ERR"] .ln-status { color: var(--locked); }
.ln[data-status="PROXY_ERR"] .ln-status { color: var(--invalid); }
.ln[data-status="DISCOVERY"] .ln-status { color: var(--locked); }

.ln-email { color: var(--text); font-family: var(--mono); font-size: 12px; }
.ln-pass { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.ln-meta { color: var(--blocked); font-family: var(--mono); font-size: 11px; }
.ln-detail { color: var(--muted); font-size: 12px; }

.ln-detail .s-hit { color: var(--accent); font-family: var(--mono); }
.ln-detail .s-zero { color: var(--muted); font-family: var(--mono); }
.ln-detail .s-fail { color: var(--invalid); font-family: var(--mono); }
.ln-detail .s-hit, .ln-detail .s-zero, .ln-detail .s-fail { white-space: nowrap; }
.ln-detail .s-reuse {
    color: var(--accent-ink);
    background: var(--accent);
    font-family: var(--mono);
    border-radius: 4px;
    padding: 1px 5px;
    margin-right: 6px;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.log-foot {
    border-top: 1px solid var(--line);
    text-align: center;
    padding: 8px 0;
}

/* -- toasts ---------------------------------------------------------------- */

.toasts {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
}

.toasts:empty { display: none; }

.toast {
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 4px solid var(--line-2);
    border-radius: 12px;
    padding: 12px 16px;
    animation: toastin 180ms ease-out;
}

.toast.is-out { animation: toastout 160ms ease-in forwards; }

.toast.is-hit { border-left-color: var(--valid); }
.toast.is-done { border-left-color: var(--accent); }
.toast.is-warn { border-left-color: var(--warn); }
.toast.is-error { border-left-color: var(--invalid); }
.toast.is-info { border-left-color: var(--blocked); }

.toast-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.toast-title {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.toast.is-hit .toast-title { color: var(--valid); }
.toast.is-done .toast-title { color: var(--accent); }
.toast.is-warn .toast-title { color: var(--warn); }
.toast.is-error .toast-title { color: var(--invalid); }

.toast-x {
    background: none;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0 2px;
    min-height: 24px;
}

.toast-x:hover { color: var(--text); }

.toast-body {
    margin: 4px 0 0;
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
    overflow-wrap: anywhere;
}

@keyframes toastin {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

@keyframes toastout {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(4px); }
}

.work-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 4px;
}

.jobline {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 11px;
}

.exports {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.dl {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 11px;
    background: var(--panel);
    color: var(--muted);
    text-decoration: none;
    font-family: var(--mono);
    font-size: 11px;
    min-height: 32px;
    transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.dl:hover { border-color: var(--line-2); color: var(--text); background: var(--panel-2); }

/* -- dialogs --------------------------------------------------------------- */

.dlg {
    width: min(780px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line-2);
    border-radius: var(--r);
    padding: 0;
    overflow: hidden;
}

.dlg::backdrop { background: var(--backdrop); }

.dlg-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}

.dlg-head h3 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }

.dlg-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(100vh - 210px);
}

.dlg-foot {
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: flex-end;
}

.dlg-note { color: var(--muted); font-size: 12.5px; min-height: 18px; margin: 10px 0 0; }

.dlg h4 {
    margin: 22px 0 10px;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
}

.dlg h4:first-child { margin-top: 0; }

.rep-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.rep-table th, .rep-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    font-family: var(--mono);
}

.rep-table th {
    color: var(--muted);
    font-weight: 500;
    font-size: 10.5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.rep-table td.num, .rep-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

.mini {
    display: grid;
    gap: 4px;
    font-family: var(--mono);
    font-size: 11px;
    max-height: 180px;
    overflow-y: auto;
}

.mini-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
}

.mini-row .ok { color: var(--valid); }
.mini-row .bad { color: var(--invalid); }

/* -- history and admin ----------------------------------------------------- */

.top-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 12px;
    font-size: 12px;
    text-decoration: none;
    border: 1px solid var(--line-2);
    border-radius: var(--r-ctl);
    color: var(--muted);
}

.top-link:hover { border-color: var(--accent); color: var(--text); }

.hist {
    padding: var(--s3);
    display: grid;
    gap: var(--s2);
    max-width: 1720px;
    margin: 0 auto;
    grid-template-columns: minmax(0, 1fr);
}

.hist > * { min-width: 0; }

.hist-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--s2);
}

.hstat {
    display: grid;
    gap: 4px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 18px 20px;
    min-width: 0;
}

.hstat-label {
    color: var(--muted);
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hstat-value {
    font-family: var(--mono);
    font-size: 32px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.hstat-value.small { font-size: 14px; font-weight: 500; color: var(--muted); }
.hstat.is-hit .hstat-value { color: var(--valid); }

.hist-filters {
    display: grid;
    gap: var(--s2);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 20px;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s1);
}

.hist-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    align-items: end;
}

.hist-fields .primary {
    min-height: 40px;
    justify-self: start;
    padding: 0 28px;
}

.hist-submit {
    display: flex;
    align-items: center;
    gap: 14px;
}

.hist-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 0 2px;
}

.hist-table {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r);
    overflow-x: auto;
    max-width: 100%;
}

.hist-head,
.hist-row {
    display: grid;
    grid-template-columns: 118px 96px minmax(180px, 1.2fr) minmax(110px, 0.8fr) 150px 80px minmax(200px, 1.6fr);
    gap: 12px;
    padding: 11px 16px;
    align-items: baseline;
    min-width: 900px;
}

.hist-head {
    border-bottom: 1px solid var(--line);
    background: var(--panel-2);
}

.hist-head span {
    color: var(--muted);
    font-family: var(--sans);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hist-row {
    border-bottom: 1px solid var(--line);
    font-size: 12.5px;
    transition: background 120ms ease;
}

.hist-row:last-child { border-bottom: 0; }
.hist-row:hover { background: var(--panel-2); }

.hist-row > * {
    min-width: 0;
    overflow-wrap: anywhere;
}

.hist-time { color: var(--muted); font-family: var(--mono); font-size: 11px; }

.hist-status {
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.hist-row[data-status="VALID"] .hist-status { color: var(--valid); }
.hist-row[data-status="APP_PASSWORD"] .hist-status { color: var(--warn); }
.hist-row[data-status="INVALID"] .hist-status { color: var(--invalid); }
.hist-row[data-status="LOCKED"] .hist-status { color: var(--locked); }
.hist-row[data-status="BLOCKED"] .hist-status { color: var(--blocked); }
.hist-row[data-status="CAPTCHA"] .hist-status { color: var(--warn); }
.hist-row[data-status="TIMEOUT"] .hist-status,
.hist-row[data-status="CONN_ERR"] .hist-status,
.hist-row[data-status="ERROR"] .hist-status { color: var(--grey); }
.hist-row[data-status="SSL_ERR"] .hist-status { color: var(--locked); }
.hist-row[data-status="PROXY_ERR"] .hist-status { color: var(--invalid); }
.hist-row[data-status="DISCOVERY"] .hist-status { color: var(--locked); }

.hist-email { font-family: var(--mono); }
.hist-pass { font-family: var(--mono); color: var(--muted); }
.hist-server { font-family: var(--mono); font-size: 11px; color: var(--blocked); }
.hist-inbox { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.hist-detail { color: var(--muted); font-size: 12px; }
.hist-state { font-family: var(--mono); font-size: 11px; color: var(--muted); }

.hist-head.jobs,
.hist-row.jobs {
    grid-template-columns: minmax(190px, 1.3fr) 118px 92px minmax(140px, 1fr) 62px 62px 62px 80px minmax(90px, 0.5fr);
}

/* -- admin panel ----------------------------------------------------------- */

.admin-dot { background: var(--warn); }

.admin-block { gap: var(--s2); }

.keyform {
    display: grid;
    grid-template-columns: 120px minmax(160px, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.keyform .primary { min-height: 40px; }

.keycell code {
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--accent);
}

.keycode {
    font-family: var(--mono);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--valid);
    border: 1px solid var(--line-2);
    border-radius: 8px;
    padding: 3px 10px;
}

.hist-head.keys,
.hist-row.keys {
    grid-template-columns: 110px minmax(120px, 1fr) 118px 60px 118px 130px 80px minmax(200px, 1fr);
}

.hist-head.days,
.hist-row.days {
    grid-template-columns: minmax(140px, 1fr) 90px 100px minmax(160px, 1fr);
}

.hist-head.log,
.hist-row.log {
    grid-template-columns: 118px 90px 96px minmax(170px, 1.1fr) minmax(100px, 0.7fr) 150px minmax(200px, 1.6fr);
}

.history .top,
.adminpage .top { gap: var(--s1); }

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

.hist-jobid a { color: var(--accent); text-decoration: none; font-family: var(--mono); }
.hist-jobid a:hover { text-decoration: underline; }

.hist-do {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.hist-do form.inline { display: inline; margin: 0; }

.dl.danger {
    background: none;
    cursor: pointer;
    color: var(--invalid);
    border-color: var(--line);
    font-family: var(--mono);
}

.dl.danger:hover { border-color: var(--invalid); background: var(--alert-bg); }

.hist-pages {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hist-jobs h2,
.hist h2.section-title {
    margin: 10px 0 0;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
}

@media (max-width: 720px) {
    .hist { padding: var(--s2); }
    .hist-summary { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .hstat { padding: 14px 16px; }
    .hstat-value { font-size: 22px; }
    .hist-fields { grid-template-columns: 1fr; }
    .top-link { min-height: 44px; }
    .chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 2px;
        scrollbar-width: none;
    }
    .chips::-webkit-scrollbar { display: none; }
    .chips .chip { flex: 0 0 auto; }
    .history .top-brand { font-size: 11px; letter-spacing: 0.04em; }
    .history .top-sub { display: none; }
    .history .top-state { font-size: 11px; }
    .history .top { gap: 4px; padding: 0 10px; }
    .history .top-link,
    .history .top-theme,
    .history #btn-logout { padding: 0 8px; font-size: 11px; }
    .history #btn-theme .theme-word { display: none; }
}

/* -- responsive ------------------------------------------------------------ */

@media (max-width: 1180px) {
    .shell { grid-template-columns: 320px minmax(0, 1fr); }
    .ln { grid-template-columns: 60px 84px minmax(120px, 1.2fr) minmax(80px, 0.8fr) minmax(140px, 1.6fr); }
    .ln-meta { display: none; }
}

@media (max-width: 980px) {
    .shell {
        grid-template-columns: 1fr;
        padding: var(--s2);
        gap: var(--s2);
    }
    .rail {
        position: static;
        max-height: none;
        overflow: visible;
    }
    .rail-scroll { overflow: visible; padding-right: 0; }
    .rail-actions { position: static; }
    .shell.has-job { display: flex; flex-direction: column; }
    .shell.has-job .work { order: -1; }
}

@media (max-width: 720px) {
    .top { height: 56px; padding: 0 var(--s2); gap: 6px; }
    .top-brand { font-size: 11px; letter-spacing: 0.08em; }
    .top-theme .theme-word { display: none; }
    .top-theme { min-height: 44px; padding: 0 10px; }
    .top-state { padding: 4px 9px; font-size: 10.5px; }
    .block { padding: var(--s2); }
    .work { gap: 12px; }
    .work-head h1 { font-size: 20px; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .stat { padding: 14px 16px; }
    .stat-value { font-size: 24px; }
    .stat.wide { grid-column: span 2; }
    .ln {
        grid-template-columns: 60px minmax(0, 1fr);
        grid-template-areas:
            "time status"
            "email email"
            "pass meta"
            "detail detail";
        gap: 3px 12px;
        padding: 12px 16px;
    }
    .ln-time { grid-area: time; }
    .ln-status { grid-area: status; }
    .ln-email { grid-area: email; font-size: 12.5px; }
    .ln-pass { grid-area: pass; }
    .ln-meta { grid-area: meta; display: block; text-align: right; }
    .ln-detail { grid-area: detail; margin-top: 3px; }
    .log { max-height: 60vh; }
    .log-btn { min-height: 44px; padding: 0 12px; }
    .primary, .ghost, .seg-btn, .chip, .file, .dl, .link { min-height: 44px; }
    .link { display: inline-flex; align-items: center; }
    .dl { display: inline-flex; align-items: center; }
    .grid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .toast-x { min-height: 34px; min-width: 34px; }
    .gate-card { padding: var(--s3); }
}

@media (max-width: 430px) {
    .row2, .grid3 { grid-template-columns: 1fr; }
    .stats { grid-template-columns: 1fr 1fr; }
    .top-sub { display: none; }
    .top { gap: 4px; }
    .top #btn-logout { padding: 0 10px; font-size: 11px; }
}

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