/* ============================================================
   SJ88 Auto Reframe Web — V8 Desktop Parity CSS
   Dark-mode inspired, premium design matching Tkinter V8 app
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    /* ─── Dark palette inspired by V8 desktop ─── */
    --bg-base: #0f1117;
    --bg-surface: #161922;
    --bg-card: #1c2030;
    --bg-card-hover: #222640;
    --bg-elevated: #252a3a;
    --bg-input: #12151e;
    --border-color: #2a3048;
    --border-strong: #3a4268;
    --border-focus: #4c8bf5;
    --text-primary: #e8eaf0;
    --text-secondary: #9fa6b8;
    --text-muted: #6b7280;
    --text-inverse: #0f1117;

    /* Brand / Accent */
    --brand: #4c8bf5;
    --brand-soft: rgba(76, 139, 245, 0.15);
    --brand-glow: rgba(76, 139, 245, 0.3);
    --accent-green: #2dd4a8;
    --accent-green-soft: rgba(45, 212, 168, 0.15);
    --accent-yellow: #f5b731;
    --accent-yellow-soft: rgba(245, 183, 49, 0.12);
    --accent-red: #f54c5e;
    --accent-red-soft: rgba(245, 76, 94, 0.12);
    --accent-purple: #a78bfa;

    /* Elevation & shadows */
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.03);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.35);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
    --shadow-glow: 0 0 30px rgba(76, 139, 245, 0.15);
    --inner-glow: inset 0 1px 0 rgba(255, 255, 255, 0.05);

    /* Radius */
    --radius-xl: 18px;
    --radius-lg: 14px;
    --radius-md: 10px;
    --radius-sm: 6px;
    --radius-xs: 4px;

    /* Transitions */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --duration: 200ms;
}

/* ─── Reset & Base ─────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

body {
    font-family: 'Inter', 'Segoe UI', -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-base);
    -webkit-font-smoothing: antialiased;
}

/* ─── Animated Background ──────────────────── */
.bg-ribbon {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.bg-ribbon::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(76, 139, 245, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(76, 139, 245, 0.04) 1px, transparent 1px);
    background-size: 32px 32px;
    mask-image: radial-gradient(ellipse at 30% 20%, rgba(0, 0, 0, 0.5), transparent 70%);
    animation: gridPulse 8s ease-in-out infinite alternate;
}

.bg-ribbon::after {
    content: "";
    position: absolute;
    width: 600px;
    height: 600px;
    right: -100px;
    top: -150px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(76, 139, 245, 0.12), transparent 70%);
    animation: orbFloat 12s ease-in-out infinite alternate;
}

@keyframes gridPulse {
    0% { opacity: 0.5; }
    100% { opacity: 1; }
}

@keyframes orbFloat {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-40px, 30px) scale(1.1); }
    100% { transform: translate(20px, -20px) scale(0.95); }
}

/* ─── Layout ───────────────────────────────── */
main {
    width: min(1320px, calc(100% - 2rem));
    margin: 1rem auto 2rem;
}

.page-shell {
    display: grid;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    background: linear-gradient(180deg, rgba(28, 32, 48, 0.95), rgba(22, 25, 34, 0.98));
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
}

.win-app-shell {
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
}

/* ─── Brand Bar (App header) ────────────────── */
.brand-bar {
    display: grid;
    grid-template-columns: minmax(260px, auto) 1fr;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #1a1f30, #161922);
    box-shadow: var(--inner-glow), var(--shadow-sm);
}

.brand-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    background: linear-gradient(135deg, #e8eaf0, #4c8bf5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-subtitle {
    margin: 0.15rem 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ─── Navigation ───────────────────────────── */
.nav-links {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.nav-links a,
.nav-links button {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.42rem 0.74rem;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.25;
    color: var(--text-secondary);
    text-decoration: none;
    background: linear-gradient(180deg, rgba(42, 48, 72, 0.8), rgba(28, 32, 48, 0.9));
    cursor: pointer;
    transition: all var(--duration) var(--ease);
}

.nav-links a:hover,
.nav-links button:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
    background: linear-gradient(180deg, rgba(60, 68, 100, 0.8), rgba(38, 44, 68, 0.9));
    transform: translateY(-1px);
}

.nav-links a[aria-current="page"] {
    color: #fff;
    border-color: var(--brand);
    background: linear-gradient(180deg, rgba(76, 139, 245, 0.35), rgba(76, 139, 245, 0.2));
    box-shadow: 0 0 12px rgba(76, 139, 245, 0.2);
}

/* ─── Cards ────────────────────────────────── */
.card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    background: var(--bg-card);
    box-shadow: var(--inner-glow), var(--shadow-sm);
    transition: border-color var(--duration) var(--ease);
}

.card:hover {
    border-color: var(--border-strong);
}

.card h2,
.card h3 {
    margin: 0;
    font-weight: 600;
    color: var(--text-primary);
}

.card h2 {
    font-size: 1.1rem;
}

.card h3 {
    font-size: 0.96rem;
}

.card p {
    margin: 0.35rem 0 0;
    color: var(--text-secondary);
}

/* ─── Grid Layouts ─────────────────────────── */
.grid-two {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

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

.grid-four {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

/* ─── Stat Tiles ───────────────────────────── */
.stat-tile {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, var(--bg-elevated), var(--bg-card));
    padding: 0.75rem;
    transition: all var(--duration) var(--ease);
}

.stat-tile:hover {
    border-color: var(--brand);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

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

.stat-tile .value {
    margin-top: 0.25rem;
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-primary), var(--brand));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ─── Forms ────────────────────────────────── */
form {
    display: grid;
    gap: 0.85rem;
}

.row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

label {
    display: inline-block;
    margin-bottom: 0.22rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    padding: 0.52rem 0.65rem;
    color: var(--text-primary);
    font: inherit;
    font-size: 0.88rem;
    transition: all var(--duration) var(--ease);
}

input:hover,
select:hover,
textarea:hover {
    border-color: var(--border-strong);
}

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

input:disabled,
select:disabled,
textarea:disabled {
    background: var(--bg-elevated);
    color: var(--text-muted);
    opacity: 0.7;
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    accent-color: var(--brand);
}

input[type="range"] {
    accent-color: var(--brand);
    padding: 0;
    border: none;
    background: transparent;
}

/* ─── Fieldset ─────────────────────────────── */
fieldset {
    margin: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: linear-gradient(180deg, var(--bg-elevated), var(--bg-card));
    padding: 0.65rem 0.75rem;
    transition: border-color var(--duration) var(--ease);
}

fieldset:hover {
    border-color: var(--border-strong);
}

legend {
    padding: 0 0.35rem;
    color: var(--brand);
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* ─── Check/Radio Items ────────────────────── */
.check-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.check-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    padding: 0.32rem 0.52rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--duration) var(--ease);
}

.check-item:hover {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--text-primary);
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.84rem;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
}

.radio-item:hover {
    border-color: var(--brand);
    background: var(--brand-soft);
}

.radio-item input[type="radio"]:checked ~ span {
    color: var(--brand);
    font-weight: 600;
}

/* ─── Buttons ──────────────────────────────── */
button,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--brand);
    padding: 0.52rem 0.9rem;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(180deg, #4c8bf5, #3b6fd8);
    box-shadow: 0 2px 8px rgba(76, 139, 245, 0.25);
    transition: all var(--duration) var(--ease);
}

button:hover,
.button-link:hover {
    background: linear-gradient(180deg, #5d9aff, #4c8bf5);
    box-shadow: 0 4px 16px rgba(76, 139, 245, 0.35);
    transform: translateY(-1px);
}

button:active,
.button-link:active {
    background: linear-gradient(180deg, #3b6fd8, #4c8bf5);
    transform: translateY(0);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.button-secondary {
    color: var(--text-secondary);
    border-color: var(--border-color);
    background: linear-gradient(180deg, var(--bg-elevated), var(--bg-card));
    box-shadow: var(--shadow-sm);
}

.button-secondary:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
    background: linear-gradient(180deg, rgba(58, 66, 104, 0.6), var(--bg-elevated));
    box-shadow: var(--shadow-md);
}

.button-accent {
    border-color: #1aa37a;
    background: linear-gradient(180deg, #2dd4a8, #1aa37a);
    box-shadow: 0 2px 8px rgba(45, 212, 168, 0.25);
}

.button-accent:hover {
    background: linear-gradient(180deg, #45e0b8, #2dd4a8);
    box-shadow: 0 4px 16px rgba(45, 212, 168, 0.35);
}

.button-danger {
    border-color: var(--accent-red);
    background: linear-gradient(180deg, #f54c5e, #d93a4a);
    box-shadow: 0 2px 8px rgba(245, 76, 94, 0.25);
}

.button-danger:hover {
    background: linear-gradient(180deg, #ff6070, #f54c5e);
}

/* ─── Big Start Button (V8 Easy Start) ─────── */
.btn-big-start {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 700;
    border: 1px solid #1aa37a;
    border-radius: var(--radius-md);
    color: #fff;
    background: linear-gradient(135deg, #2dd4a8, #1aa37a, #18956e);
    box-shadow: 0 4px 20px rgba(45, 212, 168, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: all 0.3s var(--ease);
    position: relative;
    overflow: hidden;
}

.btn-big-start::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.btn-big-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(45, 212, 168, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-big-start:hover::before {
    transform: translateX(100%);
}

/* ─── Quick Count Buttons (V8 lens count) ──── */
.quick-count {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.quick-count-btn {
    min-width: 38px;
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    background: var(--bg-card);
    cursor: pointer;
    transition: all var(--duration) var(--ease);
}

.quick-count-btn:hover {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-soft);
}

.quick-count-btn.is-active {
    border-color: var(--brand);
    color: #fff;
    background: linear-gradient(180deg, #4c8bf5, #3b6fd8);
    box-shadow: 0 0 8px rgba(76, 139, 245, 0.3);
}

/* ─── Banners / Alerts ─────────────────────── */
.banner {
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.7rem;
    font-size: 0.84rem;
    font-weight: 500;
    transition: all var(--duration) var(--ease);
}

.banner.info {
    background: var(--brand-soft);
    border-color: rgba(76, 139, 245, 0.3);
    color: #8ab4f8;
}

.banner.error {
    background: var(--accent-red-soft);
    border-color: rgba(245, 76, 94, 0.3);
    color: #f8a0aa;
}

.banner.success {
    background: var(--accent-green-soft);
    border-color: rgba(45, 212, 168, 0.3);
    color: #70e8c0;
}

.hidden {
    display: none !important;
}

/* ─── Auth Pages ───────────────────────────── */
.auth-shell {
    width: min(520px, calc(100% - 1rem));
    margin: 3rem auto;
}

.auth-card {
    border-radius: var(--radius-lg);
    border-color: var(--border-strong);
    background: linear-gradient(180deg, var(--bg-card), var(--bg-surface));
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    padding: 1.5rem;
}

.auth-card h1 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, #e8eaf0, #4c8bf5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-card .lead {
    margin: 0.35rem 0 1rem;
    color: var(--text-secondary);
}

.helper-line {
    margin-top: 0.6rem;
    font-size: 0.84rem;
    color: var(--text-secondary);
}

.helper-line a,
a {
    color: var(--brand);
    text-decoration: none;
    transition: color var(--duration) var(--ease);
}

a:hover {
    color: #7ab0ff;
}

/* ─── Tables ───────────────────────────────── */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

th,
td {
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 0.6rem;
    white-space: nowrap;
    text-align: left;
}

th {
    background: linear-gradient(180deg, var(--bg-elevated), var(--bg-card));
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

td {
    color: var(--text-secondary);
}

/* ─── Status Badges ────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.16rem 0.52rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.status-queued,
.status-retry_queued {
    background: var(--accent-yellow-soft);
    border-color: rgba(245, 183, 49, 0.3);
    color: #f5b731;
}

.status-running {
    background: var(--brand-soft);
    border-color: rgba(76, 139, 245, 0.3);
    color: #4c8bf5;
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.status-completed {
    background: var(--accent-green-soft);
    border-color: rgba(45, 212, 168, 0.3);
    color: #2dd4a8;
}

.status-failed,
.status-cancelled {
    background: var(--accent-red-soft);
    border-color: rgba(245, 76, 94, 0.3);
    color: #f54c5e;
}

/* ─── Progress Bar ─────────────────────────── */
.progress-wrap {
    width: 100%;
    height: 14px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--bg-input);
    overflow: hidden;
}

.progress-fill {
    width: 0;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #4c8bf5, #2dd4a8, #a78bfa);
    background-size: 200% 100%;
    animation: progressShimmer 3s linear infinite;
    transition: width 0.5s var(--ease);
}

@keyframes progressShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─── Timeline ─────────────────────────────── */
.timeline {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    max-height: 340px;
    overflow-y: auto;
}

.timeline ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.timeline li {
    border-bottom: 1px solid var(--border-color);
    padding: 0.55rem 0.65rem;
    transition: background var(--duration) var(--ease);
}

.timeline li:hover {
    background: var(--bg-card);
}

.timeline li:last-child {
    border-bottom: none;
}

.timeline .event {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-primary);
}

.timeline .meta {
    display: flex;
    justify-content: space-between;
    gap: 0.6rem;
    color: var(--text-muted);
    font-size: 0.72rem;
}

.timeline .payload {
    margin: 0.2rem 0 0;
    color: var(--brand);
    font-size: 0.74rem;
    font-family: 'JetBrains Mono', 'Cascadia Mono', 'Consolas', monospace;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ─── Inline Actions ───────────────────────── */
.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.kicker {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.footer-note {
    margin: 0.35rem 0 0;
    color: var(--text-muted);
    font-size: 0.74rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

[data-loading="true"] {
    opacity: 0.6;
    pointer-events: none;
}

/* ─── Window Chrome (V8 title bar) ─────────── */
.window-title-tools {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.55rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.window-chrome-dots {
    display: inline-flex;
    gap: 0.3rem;
}

.window-chrome-dots span {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.3);
    transition: transform 0.2s;
}

.window-chrome-dots span:hover {
    transform: scale(1.2);
}

.window-chrome-dots span:first-child {
    background: #f54c5e;
}

.window-chrome-dots span:nth-child(2) {
    background: #f5b731;
}

.window-chrome-dots span:last-child {
    background: #2dd4a8;
}

/* ─── V8 Workbench ─────────────────────────── */
.win-workbench {
    background: linear-gradient(180deg, var(--bg-card), var(--bg-surface));
}

/* ─── V8 Notebook (Tab System) ─────────────── */
.win-notebook {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.win-tab-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    background: linear-gradient(180deg, #1a1f30, #141722);
    padding: 0 2px;
}

.win-tab {
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 600;
    padding: 0.6rem 0.8rem;
    box-shadow: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--duration) var(--ease);
}

.win-tab:hover {
    background: rgba(76, 139, 245, 0.08);
    color: var(--text-secondary);
    transform: none;
    box-shadow: none;
}

.win-tab.is-active {
    color: var(--brand);
    background: rgba(76, 139, 245, 0.1);
    border-bottom: 2px solid var(--brand);
    box-shadow: 0 2px 8px rgba(76, 139, 245, 0.15);
}

.win-tab-panels {
    padding: 0.85rem;
    background: var(--bg-card);
}

.win-tab-panel {
    display: none;
    gap: 0.75rem;
    animation: panelFadeIn 0.3s var(--ease);
}

.win-tab-panel.is-active {
    display: grid;
}

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

/* ─── Lens Grid ────────────────────────────── */
.lens-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(115px, 1fr));
    gap: 0.4rem;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    padding: 0.5rem;
}

/* Custom scrollbar for lens grid */
.lens-grid::-webkit-scrollbar {
    width: 6px;
}

.lens-grid::-webkit-scrollbar-track {
    background: var(--bg-surface);
}

.lens-grid::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 3px;
}

.lens-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xs);
    background: var(--bg-card);
    padding: 0.3rem 0.42rem;
    font-size: 0.74rem;
    color: var(--text-secondary);
    transition: all var(--duration) var(--ease);
}

.lens-chip:hover {
    border-color: var(--brand);
    background: var(--brand-soft);
}

.lens-chip input:checked {
    accent-color: var(--brand);
}

.lens-chip input:checked + span {
    font-weight: 700;
    color: var(--brand);
}

/* ─── Quick Strip ──────────────────────────── */
.quick-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

.quick-strip input {
    width: 76px;
}

/* ─── Bottom Control Bar (V8 fixed bar) ────── */
.bottom-control-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, #1a1f30, #141722);
    padding: 0.65rem 0.75rem;
    box-shadow: var(--shadow-md);
}

.bottom-control-bar .progress-wrap {
    flex: 1;
    min-width: 200px;
    max-width: 350px;
}

/* ─── Section Headers (V8-style LabelFrame) ── */
.section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.section-header .icon {
    font-size: 1rem;
}

.section-header .title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
}

.section-header .subtitle {
    font-size: 0.76rem;
    color: var(--text-muted);
}

/* ─── Slider Row (V8 smoothing) ────────────── */
.slider-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0;
}

.slider-row label {
    white-space: nowrap;
    min-width: 140px;
    margin: 0;
}

.slider-row input[type="range"] {
    flex: 1;
    max-width: 200px;
}

.slider-row .slider-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    color: var(--brand);
    min-width: 50px;
}

/* ─── Lens Preview (V8 auto-pick section) ──── */
.lens-preview-box {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    padding: 0.6rem 0.8rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    color: var(--accent-green);
    line-height: 1.8;
    min-height: 48px;
    max-height: 120px;
    overflow-y: auto;
}

/* ─── Upload Drop Zone ─────────────────────── */
.drop-zone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-md);
    padding: 2.5rem;
    text-align: center;
    transition: all 0.3s var(--ease);
    cursor: pointer;
    background: var(--bg-surface);
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--brand);
    background: var(--brand-soft);
    box-shadow: 0 0 20px rgba(76, 139, 245, 0.1);
}

.drop-zone .drop-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.drop-zone .drop-text {
    font-size: 0.92rem;
    color: var(--text-secondary);
}

.drop-zone .drop-hint {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

/* ─── Log Console (V8 Log tab) ─────────────── */
.log-console {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #0a0d14;
    padding: 0.65rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.76rem;
    color: var(--accent-green);
    max-height: 260px;
    min-height: 120px;
    overflow-y: auto;
    line-height: 1.7;
}

/* ─── Focus ────────────────────────────────── */
:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* ─── Version Badge ────────────────────────── */
.version-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    background: linear-gradient(135deg, rgba(76, 139, 245, 0.2), rgba(167, 139, 250, 0.2));
    color: var(--accent-purple);
    border: 1px solid rgba(167, 139, 250, 0.3);
}

/* ─── Responsive ───────────────────────────── */
@media (max-width: 1080px) {
    .grid-four {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .grid-three {
        grid-template-columns: 1fr;
    }
    .brand-bar {
        grid-template-columns: 1fr;
    }
    .nav-links {
        justify-content: flex-start;
    }
}

@media (max-width: 860px) {
    .grid-two,
    .row {
        grid-template-columns: 1fr;
    }
    .win-tab {
        flex: 1 1 45%;
    }
    .lens-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    .bottom-control-bar {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 620px) {
    main {
        width: calc(100% - 0.8rem);
        margin-top: 0.5rem;
    }
    .page-shell {
        padding: 0.55rem;
    }
    .card {
        padding: 0.7rem;
    }
    .auth-shell {
        margin-top: 1.5rem;
    }
    .win-tab {
        font-size: 0.7rem;
        padding: 0.45rem 0.5rem;
    }
    .table-wrap {
        border-radius: 0;
    }
    .btn-big-start {
        padding: 0.8rem 1rem;
        font-size: 0.95rem;
    }
}
