/* ===================================
   ESPACEVISION — espacetechno.info
   Classification IA — Louis WEISS
   =================================== */

:root {
    --bg:         #0e1117;
    --surface:    #161b22;
    --surface-2:  #1c2230;
    --border:     #2a3140;
    --border-light: #363f50;
    --text:       #e6edf3;
    --text-muted: #8b949e;
    --accent:     #00d4aa;
    --accent-dim: rgba(0, 212, 170, 0.12);
    --accent-glow: rgba(0, 212, 170, 0.25);
    --orange:     #f0883e;
    --orange-dim: rgba(240, 136, 62, 0.12);
    --red:        #f85149;
    --green:      #3fb950;
    --radius:     10px;
    --radius-sm:  6px;
    --shadow:     0 2px 12px rgba(0, 0, 0, 0.4);
    --font-body:  'Segoe UI', -apple-system, system-ui, sans-serif;
    --font-mono:  'Cascadia Code', 'Consolas', 'Courier New', monospace;
}

/* ===== LIGHT THEME ===== */
[data-theme="light"] {
    --bg:         #f4f5f7;
    --surface:    #ffffff;
    --surface-2:  #f0f1f3;
    --border:     #d8dce3;
    --border-light: #c5cbd5;
    --text:       #1a1d23;
    --text-muted: #5f6878;
    --accent:     #009b7d;
    --accent-dim: rgba(0, 155, 125, 0.1);
    --accent-glow: rgba(0, 155, 125, 0.2);
    --orange:     #d97218;
    --orange-dim: rgba(217, 114, 24, 0.1);
    --red:        #d1342b;
    --green:      #2da44e;
    --shadow:     0 2px 12px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== HEADER ===== */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.credit {
    font-size: 0.65rem;
    color: var(--text-muted);
    letter-spacing: 0.3px;
}

.credit strong {
    color: var(--accent);
    font-weight: 600;
}

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

.logo-icon {
    font-size: 1.6rem;
    background: var(--accent-dim);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo h1 {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    letter-spacing: 2px;
    color: var(--accent);
}

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

/* Status Chip */
.status-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-chip.loading .status-dot { background: var(--orange); animation: pulse 1.2s ease-in-out infinite; }
.status-chip.ready .status-dot { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-chip.ready .status-text { color: var(--green); }
.status-chip.error .status-dot { background: var(--red); }
.status-chip.error .status-text { color: var(--red); }

/* Mode Toggle Switch */
.mode-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.3s;
}

.mode-toggle:hover { border-color: var(--accent); }

.mode-toggle-label { color: var(--text-muted); white-space: nowrap; }

.mode-toggle-track {
    position: relative;
    width: 34px;
    height: 18px;
    border-radius: 9px;
    background: var(--border);
    transition: background 0.3s;
    flex-shrink: 0;
}

.mode-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform 0.3s, background 0.3s;
}

.mode-toggle.offline .mode-toggle-track { background: var(--accent); }
.mode-toggle.offline .mode-toggle-thumb { transform: translateX(16px); background: #fff; }
.mode-toggle.offline .mode-toggle-label { color: var(--accent); }

.mode-toggle-icon { font-size: 0.85rem; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ===== STEPPER (inline in header) ===== */
.stepper {
    display: flex;
    align-items: center;
    gap: 0;
}

.step {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 16px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.3s ease;
    white-space: nowrap;
}

.step.active { background: var(--accent-dim); color: var(--accent); }
.step.done { color: var(--green); }

.step-number {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1.5px solid currentColor;
    font-size: 0.65rem;
    font-family: var(--font-mono);
    flex-shrink: 0;
}

.step.active .step-number { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.step.done .step-number { background: var(--green); color: var(--bg); border-color: var(--green); }

.step-line {
    flex: 0 0 16px;
    height: 1px;
    background: var(--border);
}

/* ===== HEADER ACTIONS ===== */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden { display: none; }

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 580px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-header h2 {
    font-size: 0.95rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: 0.2s;
}

.modal-close:hover { color: var(--red); background: rgba(248, 81, 73, 0.1); }

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.method-step {
    display: flex;
    gap: 14px;
    margin-bottom: 18px;
}

.method-num {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--accent);
    color: var(--bg);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}

.method-step strong {
    font-size: 0.88rem;
    color: var(--text);
    display: block;
    margin-bottom: 3px;
}

.method-step p {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.modal-divider {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

.method-tips strong {
    font-size: 0.85rem;
    display: block;
    margin-bottom: 8px;
}

.method-tips ul {
    list-style: none;
    padding: 0;
}

.method-tips li {
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 4px 0 4px 18px;
    position: relative;
}

.method-tips li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--accent);
}

/* ===== CONFUSION MATRIX MODAL ===== */
.modal-wide { max-width: 700px; }

.confusion-table-wrap { overflow-x: auto; }

.confusion-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    font-family: var(--font-mono);
}

.confusion-table th,
.confusion-table td {
    padding: 8px 12px;
    text-align: center;
    border: 1px solid var(--border);
}

.confusion-table th {
    background: var(--surface-2);
    color: var(--accent);
    font-weight: 700;
    font-size: 0.72rem;
    letter-spacing: 0.5px;
}

.confusion-corner {
    text-align: left !important;
    color: var(--text-muted) !important;
    font-size: 0.68rem !important;
    font-weight: 600 !important;
}

.confusion-table td {
    color: var(--text-muted);
    font-weight: 600;
}

.cell-correct {
    background: rgba(63, 185, 80, 0.15);
    color: var(--green) !important;
    font-weight: 700 !important;
}

.cell-wrong {
    background: rgba(248, 81, 73, 0.1);
    color: var(--red) !important;
    font-weight: 700 !important;
}

.confusion-accuracy {
    text-align: center;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.accuracy-label {
    font-size: 0.7rem;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-family: var(--font-mono);
    margin-bottom: 2px;
}

.accuracy-value {
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
}

.accuracy-value.good { color: var(--green); }
.accuracy-value.ok   { color: var(--orange); }
.accuracy-value.bad  { color: var(--red); }

.accuracy-detail {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== 3-COLUMN LAYOUT ===== */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 1.4fr 1fr;
    gap: 16px;
    padding: 12px 20px 28px;
    max-width: 1600px;
    margin: 0 auto;
    min-height: calc(100vh - 70px);
}

/* ===== PANELS ===== */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-header h2 { font-size: 0.88rem; font-weight: 700; }

.panel-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    margin-top: auto;
    flex-shrink: 0;
}
.model-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.section-title {
    font-size: 0.82rem;
    font-weight: 700;
    margin-bottom: 8px;
}

/* ===== LEFT: CATEGORIES ===== */
.col-left {
    min-height: 0;
}

.categories-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.empty-state {
    text-align: center;
    padding: 30px 14px;
    color: var(--text-muted);
}

.empty-icon { font-size: 2rem; margin-bottom: 8px; }
.empty-state .hint { font-size: 0.75rem; margin-top: 4px; }

/* Category Card */
.category-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    animation: slideIn 0.25s ease-out;
}

.category-card:hover { border-color: var(--border-light); }
.category-card.drag-over {
    border-color: var(--accent);
    background: var(--accent-dim);
    box-shadow: inset 0 0 0 1px var(--accent);
}

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

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.category-name {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 1px;
}

.category-count {
    font-size: 0.68rem;
    color: var(--text-muted);
    background: var(--bg);
    padding: 1px 7px;
    border-radius: 10px;
}

.category-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 5px;
    border-radius: 4px;
    transition: 0.2s;
}

.category-delete:hover { color: var(--red); background: rgba(248, 81, 73, 0.1); }

.category-images {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-bottom: 6px;
    min-height: 32px;
}

.category-thumb {
    position: relative;
    cursor: pointer;
}

.category-thumb img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 3px;
    border: 1px solid var(--border);
    transition: transform 0.15s, opacity 0.15s;
}

.category-thumb:hover img { opacity: 0.5; }

.thumb-delete {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--red);
    font-size: 0.7rem;
    font-weight: 700;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}

.category-thumb:hover .thumb-delete { opacity: 1; }

.category-upload label {
    font-size: 0.72rem;
    color: var(--accent);
    cursor: pointer;
    padding: 3px 8px;
    border: 1px dashed var(--accent);
    border-radius: var(--radius-sm);
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.category-upload label:hover { background: var(--accent-dim); }

/* ===== CENTER: WEBCAM STAGE ===== */
.col-center {
    min-height: 0;
    overflow: hidden;
}

.webcam-stage {
    position: relative;
    flex: 1;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: var(--radius) var(--radius) 0 0;
}

#webcam {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Overlay: cam off */
.webcam-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(14, 17, 23, 0.92);
    color: var(--text-muted);
    font-size: 0.85rem;
    gap: 6px;
    transition: opacity 0.3s;
    z-index: 5;
}

.webcam-overlay span { font-size: 2.8rem; }
.webcam-overlay.hidden { opacity: 0; pointer-events: none; }

/* Overlay: prediction tag */
.prediction-overlay {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 12;
    transition: opacity 0.25s;
}

.prediction-overlay.hidden { opacity: 0; pointer-events: none; }

.prediction-tag {
    display: flex;
    align-items: baseline;
    gap: 10px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 10px 18px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.prediction-tag-label {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 2px;
}

.prediction-tag-conf {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.6);
}

/* Floating controls */
.webcam-controls-float {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 5px;
    z-index: 12;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 5px 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.ctrl-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #fff;
    padding: 7px 14px;
    border-radius: 18px;
    font-size: 0.74rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.ctrl-btn:hover { background: rgba(255, 255, 255, 0.2); }

.ctrl-btn-accent {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

.ctrl-btn-accent:hover { box-shadow: 0 0 16px var(--accent-glow); }

.ctrl-btn-accent:disabled {
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.08);
    cursor: not-allowed;
    box-shadow: none;
}

.ctrl-btn-stop {
    background: var(--red);
    color: #fff;
    border-color: var(--red);
}

.ctrl-btn-stop:hover { box-shadow: 0 0 16px rgba(248, 81, 73, 0.4); }

/* Alert overlay on webcam */
.alert-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
    z-index: 10;
}

.alert-overlay.hidden { opacity: 0; }

.alert-overlay.red-cross {
    opacity: 1;
    background: rgba(248, 81, 73, 0.15);
    border: 4px solid var(--red);
}

.alert-overlay.red-cross::before,
.alert-overlay.red-cross::after {
    content: '';
    position: absolute;
    width: 60%;
    height: 6px;
    background: var(--red);
    border-radius: 3px;
}

.alert-overlay.red-cross::before { transform: rotate(45deg); }
.alert-overlay.red-cross::after  { transform: rotate(-45deg); }

.alert-overlay.green-dot { opacity: 1; }

.alert-overlay.green-dot::before {
    content: '';
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 40px var(--green), 0 0 80px rgba(63, 185, 80, 0.4);
    animation: pulseGreen 0.8s ease-in-out infinite;
}

@keyframes pulseGreen {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.8; }
}

/* Alert banner */
.alert-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.alert-banner.hidden { display: none; }

.alert-banner.alert-red {
    background: rgba(248, 81, 73, 0.12);
    color: var(--red);
    border-top-color: var(--red);
}

.alert-banner.alert-green {
    background: rgba(63, 185, 80, 0.12);
    color: var(--green);
    border-top-color: var(--green);
}

/* ===== RIGHT: RESULTS ===== */
.col-right {
    min-height: 0;
    overflow-y: auto;
}

.result-box {
    padding: 16px 14px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.result-label-title {
    font-size: 0.68rem;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 2px;
    font-family: var(--font-mono);
}

.result-value {
    font-family: var(--font-mono);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 2px;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-confidence {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.result-bars {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.result-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.72rem;
}

.result-bar-label {
    width: 70px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    flex-shrink: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-bar-track {
    flex: 1;
    height: 7px;
    background: var(--surface-2);
    border-radius: 4px;
    overflow: hidden;
}

.result-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--accent);
    transition: width 0.3s ease;
}

.result-bar-fill.top { background: linear-gradient(90deg, var(--accent), var(--green)); }

.result-bar-pct {
    width: 35px;
    text-align: left;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* ===== THRESHOLD CONFIG ===== */
.threshold-config {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.threshold-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.threshold-row label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
}

.threshold-value {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--accent);
    min-width: 36px;
    text-align: right;
}

.threshold-config input[type="range"] {
    width: 100%;
    height: 5px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.threshold-config input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--surface);
    cursor: pointer;
    box-shadow: 0 0 6px var(--accent-glow);
}

.threshold-config input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--surface);
    cursor: pointer;
}

.threshold-config .hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ===== UPLOAD TEST ===== */
.upload-test {
    padding: 14px;
    border-bottom: 1px solid var(--border);
}

.upload-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.8rem;
    transition: 0.2s;
}

.upload-area:hover { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

.test-preview { margin-top: 8px; text-align: center; }
.test-preview img { max-width: 180px; max-height: 140px; border-radius: var(--radius-sm); border: 1px solid var(--border); }

/* ===== ALERT CONFIG ===== */
.alert-config {
    padding: 14px;
}

.alert-config .hint {
    font-size: 0.73rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.alert-config-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert-config-row {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}

.alert-config-row-header {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.alert-options {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.alert-option {
    font-size: 0.72rem;
    padding: 4px 10px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.2s;
    font-family: var(--font-body);
}

.alert-option:hover { border-color: var(--accent); color: var(--accent); }

.alert-option.selected {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}

.alert-option.selected-red {
    background: rgba(248, 81, 73, 0.12);
    border-color: var(--red);
    color: var(--red);
    font-weight: 600;
}

.alert-option.selected-green {
    background: rgba(63, 185, 80, 0.12);
    border-color: var(--green);
    color: var(--green);
    font-weight: 600;
}

.alert-message-input {
    margin-top: 6px;
    width: 100%;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 0.75rem;
    font-family: var(--font-body);
    outline: none;
    display: none;
}

.alert-message-input:focus { border-color: var(--accent); }
.alert-message-input.visible { display: block; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.btn:active { transform: scale(0.97); }

.btn-sm { padding: 5px 10px; font-size: 0.74rem; }

.btn-accent { background: var(--accent); color: var(--bg); }
.btn-accent:hover { box-shadow: 0 0 14px var(--accent-glow); }
.btn-accent:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; box-shadow: none; }

.btn-primary { background: var(--orange); color: #000; width: 100%; }
.btn-primary:hover { box-shadow: 0 0 14px var(--orange-dim); filter: brightness(1.1); }
.btn-primary:disabled { background: var(--border); color: var(--text-muted); cursor: not-allowed; box-shadow: none; filter: none; }

.btn-lg { padding: 11px 18px; font-size: 0.85rem; }

.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.btn-icon { font-size: 1em; }

/* ===== PROGRESS BAR ===== */
.progress-bar {
    width: 100%;
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--orange));
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 9px 22px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    z-index: 1000;
    animation: toastIn 0.3s ease;
    box-shadow: var(--shadow);
}

.toast.success { background: var(--green); color: #000; }
.toast.error   { background: var(--red); color: #fff; }
.toast.info    { background: var(--accent); color: #000; }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== LIGHT THEME OVERRIDES ===== */
[data-theme="light"] .webcam-overlay {
    background: rgba(244, 245, 247, 0.92);
}

[data-theme="light"] .toast.success { color: #fff; }
[data-theme="light"] .toast.info { color: #fff; }

[data-theme="light"] .btn-primary { color: #fff; }
[data-theme="light"] .btn-primary:disabled { color: var(--text-muted); }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
    .main-layout {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
    }
    .col-center { grid-column: 1 / -1; order: -1; }
    .stepper { display: none; }
}

@media (max-width: 700px) {
    .main-layout { grid-template-columns: 1fr; }
    .col-center { order: -1; }
    .header-inner { flex-wrap: wrap; gap: 8px; }
}
