/* Zencore Key Manager — Editorial Dark Workspace (v2) */

:root {
    color-scheme: dark;

    --bg: #070709;
    --bg-surface: #0d0d10;
    --bg-elevated: #141418;
    --bg-input: #09090c;
    --bg-hover: rgba(255, 255, 255, 0.035);

    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.16);
    --border-strong: rgba(255, 255, 255, 0.24);

    --text: #fafafa;
    --text-sec: #a1a1aa;
    --text-muted: #71717a;

    --accent: #e11d48;
    --accent-soft: rgba(225, 29, 72, 0.14);
    --accent-border: rgba(225, 29, 72, 0.34);

    --green: #34d399;
    --green-soft: rgba(52, 211, 153, 0.12);
    --green-border: rgba(52, 211, 153, 0.28);

    --blue: #818cf8;
    --blue-soft: rgba(129, 140, 248, 0.12);
    --blue-border: rgba(129, 140, 248, 0.28);

    --amber: #fbbf24;
    --amber-soft: rgba(251, 191, 36, 0.12);
    --amber-border: rgba(251, 191, 36, 0.28);

    --red: #f87171;
    --red-soft: rgba(248, 113, 113, 0.12);
    --red-border: rgba(248, 113, 113, 0.28);

    --discord: #5865f2;
    --discord-hover: #4752c4;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);

    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-display: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background: var(--bg);
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
}

/* Subtle top radial light matching zencore.lol */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(780px 420px at 18% -10%, rgba(225, 29, 72, 0.08), transparent 65%);
    z-index: 0;
}

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

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

[hidden] {
    display: none !important;
}

.visually-hidden:where(:not(:focus-within, :active)) {
    position: absolute !important;
    clip-path: inset(50%) !important;
    overflow: hidden !important;
    width: 1px !important;
    height: 1px !important;
    margin: -1px !important;
    padding: 0 !important;
    border: 0 !important;
    white-space: nowrap !important;
}

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

.tabular {
    font-variant-numeric: tabular-nums;
}

/* ── App Shell ── */
.shell {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin-inline: auto;
    padding: 20px clamp(16px, 3vw, 36px) 48px;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ── Topbar ── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-bottom: 18px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

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

.brand img {
    display: block;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.brand-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    display: inline-flex;
    align-items: baseline;
    gap: 0;
}

.brand-dot {
    color: var(--accent);
}

.sync-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-sec);
}

.sync-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
}

.sync-pill.is-offline .sync-dot {
    background: var(--amber);
    box-shadow: none;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px 4px 6px;
    border-radius: 999px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
}

.user-chip[hidden] {
    display: none;
}

.user-chip img {
    display: block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.user-chip-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    padding-inline-end: 4px;
}

.site-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-sec);
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 500;
    min-block-size: 34px;
    transition: color 0.15s var(--ease), border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.site-link:hover {
    color: var(--text);
    border-color: var(--border-hover);
    background: var(--bg-surface);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 15px;
    min-block-size: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.1s var(--ease);
}

.btn:active:not(:disabled) {
    transform: scale(0.985);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.btn-primary {
    background: var(--text);
    color: var(--bg);
}

.btn-primary:hover:not(:disabled) {
    background: #e4e4e7;
}

.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text-sec);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-elevated);
    border-color: var(--border-hover);
    color: var(--text);
}

.btn-danger {
    background: var(--red-soft);
    border-color: var(--red-border);
    color: var(--red);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(248, 113, 113, 0.2);
    border-color: var(--red);
}

.btn-danger-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text-muted);
}

.btn-danger-ghost:hover:not(:disabled) {
    background: var(--red-soft);
    border-color: var(--red-border);
    color: var(--red);
}

.btn-sm {
    padding: 5px 10px;
    min-block-size: 30px;
    font-size: 0.75rem;
}

.btn-icon {
    padding: 0;
    inline-size: 32px;
    block-size: 32px;
    min-block-size: 32px;
    border-radius: 7px;
}

.btn-icon-round {
    padding: 0;
    inline-size: 26px;
    block-size: 26px;
    min-block-size: 26px;
    border-radius: 999px;
}

.btn-block {
    width: 100%;
}

@media (pointer: coarse) {
    .btn-icon {
        inline-size: 40px;
        block-size: 40px;
    }
    .btn, .form-input, .form-select {
        min-block-size: 44px;
    }
}

/* ── Auth / Loading Gates ── */
.gate {
    flex: 1;
    display: grid;
    place-items: center;
    padding: 24px 0;
}

.gate[hidden] {
    display: none;
}

.gate-card {
    width: min(400px, 100%);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    text-align: center;
}

.gate-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    margin: 0 auto 20px;
    display: grid;
    place-items: center;
    background: rgba(88, 101, 242, 0.14);
    border: 1px solid rgba(88, 101, 242, 0.3);
    color: #818cf8;
}

.gate-icon svg {
    width: 22px;
    height: 22px;
}

.gate-card h2 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.gate-card p {
    font-size: 0.85rem;
    color: var(--text-sec);
    margin-bottom: 24px;
    line-height: 1.55;
}

.btn-discord {
    width: 100%;
    padding: 12px 18px;
    background: var(--discord);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background 0.15s var(--ease);
}

.btn-discord:hover {
    background: var(--discord-hover);
}

.gate-error {
    margin-top: 14px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--red-soft);
    border: 1px solid var(--red-border);
    color: var(--red);
    font-size: 0.8rem;
}

.gate-error[hidden] {
    display: none;
}

.spinner {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border-hover);
    border-top-color: var(--text);
    animation: spin 0.75s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Main Dashboard Layout ── */
.dashboard[hidden] {
    display: none;
}

.dashboard {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ── KPI Strip (Top Overview) ── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.kpi-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kpi-card-revenue {
    background: linear-gradient(180deg, rgba(52, 211, 153, 0.06), var(--bg-surface) 75%);
    border-color: rgba(52, 211, 153, 0.22);
}

.kpi-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.kpi-label {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.kpi-tag {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--green-soft);
    color: var(--green);
}

.kpi-value {
    font-family: var(--font-display);
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.15;
    color: var(--text);
}

.kpi-sub {
    font-size: 0.76rem;
    color: var(--text-sec);
}

/* ── Asymmetric 2-Column Workspace ── */
.workspace {
    display: grid;
    grid-template-columns: 316px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}

.panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
}

.directory-panel {
    container-type: inline-size;
    container-name: directory;
}

.generator-panel {
    position: sticky;
    top: 20px;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.panel-title {
    font-family: var(--font-display);
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.panel-title svg {
    width: 16px;
    height: 16px;
    color: var(--accent);
}

.panel-subtitle {
    margin-top: 2px;
    font-size: 0.76rem;
    color: var(--text-muted);
}

.mono-tag {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    white-space: nowrap;
}

/* ── Form Controls ── */
.form-stack {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label, fieldset.preset-group legend {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-sec);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.field-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.form-input, .form-select {
    width: 100%;
    min-block-size: 38px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text);
    font-family: inherit;
    font-size: max(0.85rem, 14px);
    transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input:hover, .form-select:hover {
    border-color: var(--border-hover);
}

.form-input:focus-visible, .form-select:focus-visible {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-input:user-invalid {
    border-color: var(--red);
}

.form-select option {
    background: #111114;
    color: var(--text);
}

/* Duration Radio Presets */
fieldset.preset-group {
    border: none;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

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

.preset-option {
    position: relative;
}

.preset-option input {
    position: absolute;
    opacity: 0;
    inline-size: 1px;
    block-size: 1px;
}

.preset-option label {
    display: flex;
    align-items: center;
    justify-content: center;
    min-block-size: 34px;
    padding: 6px 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-sec);
    font-size: 0.76rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s var(--ease);
    text-align: center;
}

.preset-option label:hover {
    border-color: var(--border-hover);
    color: var(--text);
}

.preset-option input:checked + label {
    background: var(--text);
    border-color: var(--text);
    color: var(--bg);
    font-weight: 600;
}

.preset-option input:focus-visible + label {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.custom-duration-box {
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.custom-duration-box[hidden], .field[hidden] {
    display: none;
}

/* ── Generated Key Output ── */
.gen-result[hidden] {
    display: none;
}

.gen-result {
    margin-top: 16px;
    padding: 14px;
    border-radius: var(--radius);
    background: linear-gradient(180deg, rgba(52, 211, 153, 0.07), var(--bg-elevated));
    border: 1px solid var(--green-border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.gen-result-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.gen-result-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--green);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.gen-result-meta {
    font-size: 0.74rem;
    color: var(--text-sec);
}

.gen-result-key {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--text);
    word-break: break-all;
    background: var(--bg);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    user-select: all;
    line-height: 1.55;
}

/* ── Directory Toolbar & Filters ── */
.directory-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.directory-count {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding-bottom: 16px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.segmented {
    display: inline-flex;
    align-items: center;
    padding: 3px;
    border-radius: 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    gap: 2px;
}

.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 11px;
    border-radius: 7px;
    border: none;
    background: transparent;
    color: var(--text-sec);
    font-family: inherit;
    font-size: 0.77rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s var(--ease);
}

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

.filter-btn.active {
    background: var(--bg-elevated);
    color: var(--text);
    box-shadow: inset 0 0 0 1px var(--border-hover);
}

.filter-count {
    font-size: 0.68rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 1px 6px;
    border-radius: 999px;
}

.filter-btn.active .filter-count {
    background: var(--accent-soft);
    color: var(--accent);
}

.search-wrap {
    position: relative;
    flex: 1 1 220px;
    min-inline-size: 0;
}

.search-wrap svg {
    position: absolute;
    inset-inline-start: 11px;
    inset-block-start: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    padding-inline-start: 33px;
    min-block-size: 35px;
    font-size: 0.82rem;
}

.toolbar-select {
    inline-size: auto;
    min-inline-size: 126px;
    min-block-size: 35px;
    padding: 6px 10px;
    font-size: 0.78rem;
}

/* ── Semantic Responsive License Table ── */
.table-wrapper {
    overflow: auto;
    max-block-size: min(640px, 68dvh);
    scrollbar-gutter: stable;
    overscroll-behavior: contain;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
}

.keys-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: start;
    font-size: 0.8rem;
}

.keys-table th {
    text-align: start;
}

.keys-table thead th {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    background: #101014;
    border-bottom: 1px solid var(--border);
    padding: 10px 7px;
    font-size: 0.67rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

.keys-table thead th:first-child,
.keys-table tbody th:first-child {
    padding-inline-start: 12px;
}

.keys-table thead th:last-child,
.keys-table tbody td:last-child {
    padding-inline-end: 10px;
}

.keys-table tbody td,
.keys-table tbody th {
    padding: 10px 7px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.045);
    vertical-align: middle;
    font-weight: 400;
}

.keys-table tbody tr:last-child td,
.keys-table tbody tr:last-child th {
    border-bottom: none;
}

.keys-table tbody tr {
    transition: background 0.12s var(--ease);
}

.keys-table tbody tr:hover {
    background: var(--bg-hover);
}

.holder-cell {
    min-inline-size: 120px;
    max-inline-size: 162px;
}

.holder-name {
    font-weight: 600;
    font-size: 0.84rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.holder-sub {
    margin-top: 2px;
    font-size: 0.72rem;
    color: var(--text-sec);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.holder-sub.is-note {
    color: var(--text-muted);
}

.cell-main {
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
}

.cell-sub {
    margin-top: 2px;
    font-size: 0.71rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
}

.badge-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

.badge-stripe {
    background: var(--green-soft);
    color: var(--green);
    border-color: var(--green-border);
}

.badge-manual {
    background: var(--blue-soft);
    color: var(--blue);
    border-color: var(--blue-border);
}

.badge-lifetime {
    background: var(--blue-soft);
    color: #a5b4fc;
    border-color: var(--blue-border);
}

.badge-active {
    background: var(--green-soft);
    color: var(--green);
    border-color: var(--green-border);
}

.badge-unbound {
    background: var(--amber-soft);
    color: var(--amber);
    border-color: var(--amber-border);
}

.badge-expired {
    background: var(--red-soft);
    color: var(--red);
    border-color: var(--red-border);
}

/* Copyable mono pill */
.mono-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 7px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-sec);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    cursor: pointer;
    max-inline-size: 155px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.mono-btn:hover {
    border-color: var(--border-hover);
    color: var(--text);
    background: var(--bg-elevated);
}

.hwid-pill {
    color: #c7d2fe;
}

.hwid-empty {
    font-size: 0.74rem;
    color: var(--text-muted);
}

.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.row-actions .btn-icon {
    inline-size: 29px;
    block-size: 29px;
    min-block-size: 29px;
}

@media (pointer: coarse) {
    .row-actions .btn-icon {
        inline-size: 40px;
        block-size: 40px;
    }
}

.empty-state {
    padding: 56px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.84rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.empty-state svg {
    width: 28px;
    height: 28px;
    opacity: 0.35;
}

/* Stacked card layout inside narrow container */
@container directory (width < 720px) {
    .table-wrapper {
        border: none;
        background: transparent;
        max-block-size: none;
        overflow: visible;
        scrollbar-gutter: auto;
    }

    .keys-table, .keys-table thead, .keys-table tbody, .keys-table tr, .keys-table th, .keys-table td {
        display: block;
    }

    .keys-table thead {
        display: none;
    }

    .keys-table tbody tr {
        background: var(--bg-input);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 12px 14px;
        margin-block-end: 10px;
    }

    .keys-table tbody th,
    .keys-table tbody td {
        border-bottom: 1px solid rgba(255, 255, 255, 0.04);
        padding: 7px 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        max-inline-size: none;
    }

    .keys-table thead th:first-child,
    .keys-table tbody th:first-child,
    .keys-table thead th:last-child,
    .keys-table tbody td:last-child {
        padding-inline: 0;
    }

    .keys-table tbody th {
        display: block;
        padding-top: 2px;
        padding-bottom: 10px;
    }

    .keys-table tbody td::before {
        content: attr(data-label);
        font-size: 0.68rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--text-muted);
        flex-shrink: 0;
    }

    .keys-table tbody td[data-col="actions"] {
        border-bottom: none;
        padding-bottom: 2px;
        justify-content: flex-end;
    }

    .keys-table tbody td[data-col="actions"]::before {
        display: none;
    }

    .cell-sub {
        text-align: end;
    }
}

/* ── Native Dialog Modals ── */
dialog.modal {
    margin: auto;
    padding: 0;
    inline-size: min(480px, calc(100vw - 32px));
    background: var(--bg-surface);
    color: var(--text);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
}

dialog:modal {
    overscroll-behavior: contain;
}

dialog.modal::backdrop {
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
    overflow: hidden;
    overscroll-behavior: contain;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    font-size: 0.85rem;
    color: var(--text-sec);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-elevated);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border);
}

.detail-item.full {
    grid-column: 1 / -1;
}

.detail-label {
    font-size: 0.67rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.detail-val {
    font-size: 0.82rem;
    color: var(--text);
    word-break: break-word;
}

.detail-val.mono {
    font-size: 0.73rem;
    user-select: all;
}

/* ── Live Toast ── */
.toast {
    position: fixed;
    inset-block-end: 24px;
    inset-inline-end: 24px;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border-hover);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.is-error {
    border-color: var(--red-border);
    color: var(--red);
}

.toast.is-success {
    border-color: var(--green-border);
}

/* ── Viewport Breakpoints ── */
@media (max-width: 1080px) {
    .workspace {
        grid-template-columns: 1fr;
    }

    .generator-panel {
        position: static;
    }
}

@media (max-width: 760px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }
}

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

    .preset-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
