* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #1a1a2e; --bg-card: #16213e; --bg-dark: #0d1120; --bg-input: #1a1a2e;
  --border: #0f3460; --border-light: #1e3050;
  --text: #e0e0e0; --text-muted: #a0a0c0;
  --accent: #e94560; --success: #2ecc71; --warning: #f39c12;
  --header-bg: #16213e; --tab-bg: #0d1b2a; --tab-hover: #1a2640;
  --btn-bg: #16213e; --shadow: rgba(0,0,0,0.4);
}
[data-theme="light"] {
  --bg: #f0f2f5; --bg-card: #ffffff; --bg-dark: #e8eaed; --bg-input: #f9fafb;
  --border: #d1d5db; --border-light: #e5e7eb;
  --text: #1f2937; --text-muted: #6b7280;
  --accent: #dc3545; --success: #059669; --warning: #d97706;
  --header-bg: #ffffff; --tab-bg: #e5e7eb; --tab-hover: #d1d5db;
  --btn-bg: #f3f4f6; --shadow: rgba(0,0,0,0.08);
}

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--text); height: 100vh; overflow: hidden; display: flex; flex-direction: column;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 20% 30%, color-mix(in srgb, var(--accent) 12%, transparent) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, color-mix(in srgb, #3b82f6 10%, transparent) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, transparent 60%, var(--bg) 100%),
    repeating-linear-gradient(color-mix(in srgb, var(--border) 30%, transparent) 0, color-mix(in srgb, var(--border) 30%, transparent) 1px, transparent 1px, transparent 50px),
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--border) 30%, transparent) 0, color-mix(in srgb, var(--border) 30%, transparent) 1px, transparent 1px, transparent 50px);
}
.page { display: none; flex: 1; flex-direction: column; overflow: hidden; position: relative; z-index: 0; }
.page.active { display: flex; height: calc(100vh - 46px); }

/* Header */
header { background: var(--header-bg); padding: 12px 20px; border-bottom: 1px solid var(--border); }
h1 { font-size: 20px; margin-bottom: 8px; color: var(--accent); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input { flex: 1; min-width: 160px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-input); color: var(--text); font-size: 14px; }
.stats { margin-left: auto; font-size: 13px; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }

/* Buttons */
button { padding: 8px 16px; border: 1px solid var(--border); border-radius: 4px; background: var(--btn-bg); color: var(--text); cursor: pointer; font-size: 13px; transition: all 0.2s; }
button:hover { background: var(--tab-hover); }
button.primary { background: var(--accent); border-color: var(--accent); color: white; }
button.primary:hover { background: #c73650; }

/* Image Gallery */
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; padding: 20px; overflow-y: auto; flex: 1; }
.grid-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; color: var(--text-muted); min-height: 300px; }
.grid-empty svg { margin-bottom: 16px; opacity: 0.6; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--accent); margin-bottom: 6px; }
.empty-desc { font-size: 13px; color: var(--text-muted); }
.image-card { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; cursor: pointer; transition: border-color 0.2s; background: var(--bg-card); position: relative; }
.image-card:hover { border-color: var(--accent); }
.image-card img { width: 100%; height: 150px; object-fit: cover; display: block; }
.image-card .info { padding: 8px 12px; font-size: 12px; }
.image-card .info .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.image-card .badge { position: absolute; top: 8px; right: 8px; width: 20px; height: 20px; border-radius: 50%; background: #555; display: flex; align-items: center; justify-content: center; font-size: 11px; }
.image-card .badge.done { background: var(--success); }
.image-card .badge.pending { background: var(--warning); }

/* Annotator Layout */
.annotator-layout { display: flex; flex: 1; overflow: hidden; }
.nav-bar { display: flex; align-items: center; gap: 12px; }
.nav-bar .file-name { flex: 1; font-weight: 600; }
.nav-bar .nav-pos { color: var(--text-muted); font-size: 13px; }

.canvas-area { flex: 1; overflow: hidden; position: relative; background: var(--bg-dark); }
.canvas-area canvas { display: block; width: 100%; height: 100%; }

/* Side Panel */
.side-panel { width: 280px; background: var(--bg-card); border-left: 1px solid var(--border); padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.side-panel h3 { font-size: 16px; color: var(--accent); margin-bottom: 8px; }
.side-panel h4 { font-size: 14px; color: var(--text-muted); margin-bottom: 4px; }
.tool-section { padding: 8px 0; border-bottom: 1px solid var(--border); }
.tool-section:last-child { border-bottom: none; }
.tool-section label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.tool-section select { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-input); color: var(--text); font-size: 13px; margin-bottom: 8px; }
.tool-section button { width: 100%; }
.hints { padding-left: 16px; font-size: 12px; line-height: 1.8; color: var(--text-muted); }

/* Polygon List */
.poly-list { display: flex; flex-direction: column; gap: 4px; }
.poly-item { display: flex; flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 4px; cursor: pointer; font-size: 13px; transition: background 0.2s; min-width: 0; }
.poly-item:hover { background: var(--bg-input); }
.poly-item.active { background: var(--border); outline: 1px solid var(--accent); }
.poly-item .color-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.poly-item .poly-label { flex: 1; white-space: nowrap; text-overflow: ellipsis; }
.poly-item .delete-poly { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0 4px; font-size: 16px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal.hidden { display: none; }
.modal-content { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 24px; min-width: 320px; max-width: 480px; }
.modal-content h3 { margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.modal-actions input { flex: 1; padding: 8px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-input); color: var(--text); }
#label-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.label-tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; }
.label-tag .remove-label { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 14px; padding: 0; }

/* Loading/Error states */
.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.error { text-align: center; padding: 40px; color: var(--accent); }

/* Tab bar */
#tab-bar { display: flex; align-items: center; background: var(--tab-bg); border-bottom: 2px solid var(--border); position: relative; z-index: 1; }
.tab-brand { display: flex; align-items: center; gap: 8px; padding: 10px 20px; border-right: 1px solid var(--border); margin-right: 4px; flex-shrink: 0; }
.tab-brand span { font-size: 15px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.tab-btn { padding: 12px 24px; border: none; background: transparent; color: var(--text-muted); cursor: pointer; font-size: 15px; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; display: flex; align-items: center; gap: 6px; }
.tab-icon { flex-shrink: 0; opacity: 0.7; }
.tab-btn:hover { color: var(--text); background: var(--tab-hover); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.theme-btn { margin-left: auto; padding: 12px 16px; border: none; width: auto; display: flex; align-items: center; gap: 4px; }
.user-menu-wrap { position: relative; }
.user-btn { padding: 12px 16px; border: none; width: auto; display: flex; align-items: center; }
.user-dropdown { position: absolute; top: 100%; right: 0; min-width: 140px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px var(--shadow); z-index: 100; overflow: hidden; }
.user-dropdown.hidden { display: none; }
.user-dropdown-item { padding: 10px 16px; font-size: 13px; color: var(--text); cursor: pointer; transition: background 0.2s; }
.user-dropdown-item:hover { background: var(--bg-input); }

/* Panel grid */
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 20px; }
.panel-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 20px; }
.panel-card h3 { color: var(--accent); margin-bottom: 12px; }

/* Form rows */
.form-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.form-row label { width: 120px; font-size: 13px; color: var(--text-muted); }
.form-row input { flex: 1; padding: 6px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-input); color: var(--text); font-size: 14px; }
.form-row input:focus { outline: none; border-color: var(--accent); }

/* Command box */
.cmd-box { background: var(--bg-dark); border: 1px solid var(--border); border-radius: 4px; padding: 12px; font-family: monospace; font-size: 13px; color: var(--success); word-break: break-all; line-height: 1.5; }

/* --- old detection styles kept for compat, cleaned by new inference page --- */
.det-item { display: flex; justify-content: space-between; padding: 4px 8px; background: var(--bg-input); border-radius: 4px; margin-bottom: 4px; font-size: 13px; }
.det-label { color: var(--accent); }
.det-conf { color: var(--success); }
.cropped-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.cropped-item { background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.cropped-item img { width: 100%; height: 140px; object-fit: contain; display: block; background: var(--bg-dark); }
.cropped-item .item-info { padding: 6px 8px; font-size: 12px; }
.cropped-item .item-label { color: var(--accent); font-weight: 600; }
.cropped-item .item-conf { color: var(--success); float: right; }

/* Validation Panel */
.validation-panel { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 560px; max-height: 80vh; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; z-index: 500; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
.validation-panel.hidden { display: none; }
.validation-panel .panel-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-card); }
.validation-panel .panel-header h3 { color: var(--accent); }
.validation-panel .panel-header button { padding: 4px 10px; }
#validation-content { padding: 16px; }
.report-summary { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.report-stat { font-size: 13px; padding: 4px 10px; background: var(--bg-input); border-radius: 4px; }
.report-stat.ok { color: var(--success); }
.report-stat.warn { color: var(--warning); }
.report-stat b.sufficient { color: var(--success); }
.report-stat b.minimal { color: var(--warning); }
.report-stat b.insufficient { color: var(--accent); }
.report-section { margin-top: 12px; }
.report-section h4 { color: var(--text-muted); margin-bottom: 6px; font-size: 14px; }
.class-stat { display: inline-block; padding: 2px 8px; margin: 2px; background: var(--bg-input); border-radius: 3px; font-size: 12px; }
.issue-list, .warning-list, .rec-list { font-size: 12px; line-height: 1.8; padding-left: 18px; }
.issue-list li { color: var(--accent); }
.warning-list li { color: var(--warning); }
.rec-list li { color: var(--text-muted); }

/* User Guide */
.guide-bar { background: var(--tab-hover); border-bottom: 1px solid var(--border); padding: 8px 20px; font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.guide-bar .guide-toggle { cursor: pointer; color: var(--accent); font-size: 12px; padding: 2px 8px; border: 1px solid var(--border); border-radius: 4px; background: transparent; }
.guide-bar .guide-toggle:hover { background: var(--border); }
.guide-content { display: none; flex-wrap: wrap; gap: 6px 16px; padding: 8px 20px 10px; background: var(--tab-hover); border-bottom: 1px solid var(--border); font-size: 12px; color: var(--text-muted); }
.guide-content.expanded { display: flex; }
.guide-content .step { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.guide-content .step-num { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.guide-content .step-arrow { color: var(--accent); font-weight: 700; }
.guide-content .step-done { color: var(--success); }

/* Guide card on training page */
.guide-card { background: var(--tab-hover); border: 1px solid var(--border); border-radius: 8px; padding: 16px 20px; margin-bottom: 16px; }
.guide-card h3 { color: var(--accent); margin-bottom: 8px; font-size: 15px; }
.guide-card .step-list { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.guide-card .step-item { display: flex; align-items: flex-start; gap: 6px; font-size: 12px; color: #c0c0d0; line-height: 1.6; }
.guide-card .step-item .step-num { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; flex-shrink: 0; margin-top: 1px; }
.guide-card .req-list { font-size: 12px; color: var(--text-muted); line-height: 1.8; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.guide-card .req-list b { color: var(--warning); }

/* Button tooltip */
button[title] { position: relative;    right: 0px; }
button[title]:hover::after { content: attr(title); position: absolute; bottom: 110%; left: 50%; transform: translateX(-50%); background: var(--bg-dark); color: var(--text); padding: 4px 10px; border-radius: 4px; font-size: 11px; white-space: nowrap; z-index: 100; border: 1px solid var(--border); }

/* System Info */
.sys-row { display: flex; padding: 4px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.sys-row:last-child { border-bottom: none; }
.sys-label { color: var(--text-muted); width: 80px; flex-shrink: 0; }
.sys-value { color: var(--text); }

/* Subtle background pulse (GPU-composited, zero CPU cost) */
@keyframes bgPulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 0.8; } }

/* === Help Page === */
.help-container { display: flex; flex: 1; overflow: hidden; }
.help-nav { width: 200px; padding: 20px 16px; background: var(--bg-card); border-right: 1px solid var(--border); overflow-y: auto; flex-shrink: 0; }
.help-nav a { display: block; padding: 8px 12px; color: var(--text-muted); font-size: 13px; text-decoration: none; border-radius: 6px; margin-bottom: 4px; transition: all 0.2s; }
.help-nav a:hover { background: var(--bg-input); color: var(--accent); }
.help-content { flex: 1; overflow-y: auto; padding: 24px 32px; margin-top: 24px;}
.help-content section { margin-bottom: 36px; }
.help-content h2 { font-size: 20px; color: var(--accent); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.help-content h3 { font-size: 15px; color: var(--text); margin: 16px 0 8px; }
.help-content p { font-size: 13px; line-height: 1.8; color: var(--text-muted); margin-bottom: 8px; }
.help-content ol, .help-content ul { padding-left: 22px; margin-bottom: 12px; }
.help-content li { font-size: 13px; line-height: 1.9; color: var(--text-muted); }
.help-content dl { margin-bottom: 12px; }
.help-content dt { font-size: 14px; font-weight: 600; color: var(--text); margin: 12px 0 4px; }
.help-content dd { font-size: 13px; color: var(--text-muted); line-height: 1.7; margin: 0 0 10px 16px; }
.help-content code { background: var(--bg-dark); padding: 2px 6px; border-radius: 4px; font-size: 12px; color: var(--accent); }
.help-content kbd { display: inline-block; padding: 2px 8px; font-size: 11px; line-height: 1.4; color: var(--text); background: var(--bg-dark); border: 1px solid var(--border); border-radius: 4px; font-family: inherit; box-shadow: 0 1px 0 var(--border); }
.help-content table { width: 100%; max-width: 520px; border-collapse: collapse; margin-bottom: 12px; }
.help-content td { padding: 8px 12px; font-size: 13px; border-bottom: 1px solid var(--border); color: var(--text-muted); }
.help-content td:first-child { color: var(--text); font-weight: 600; width: 180px; }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse at 25% 25%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
              radial-gradient(ellipse at 75% 75%, color-mix(in srgb, #3b82f6 8%, transparent), transparent 60%);
  animation: bgPulse 5s ease-in-out infinite;
}

/* === Login Page === */
#login-overlay { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 20% 30%, color-mix(in srgb, var(--accent) 25%, transparent) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, color-mix(in srgb, #3b82f6 20%, transparent) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, transparent 60%, var(--bg) 100%),
    repeating-linear-gradient(color-mix(in srgb, var(--border) 30%, transparent) 0, color-mix(in srgb, var(--border) 30%, transparent) 1px, transparent 1px, transparent 50px),
    repeating-linear-gradient(90deg, color-mix(in srgb, var(--border) 30%, transparent) 0, color-mix(in srgb, var(--border) 30%, transparent) 1px, transparent 1px, transparent 50px);
}
.login-theme-float { position: absolute !important; top: 20px !important; right: 20px !important; background: var(--bg-card); border: 1px solid var(--border); color: var(--text-muted); border-radius: 8px; padding: 10px 14px; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 6px; font-size: 13px; box-shadow: 0 1px 4px var(--shadow); z-index: 2; }
.login-theme-float:hover { border-color: var(--accent); color: var(--accent); background: var(--bg-input); }
@keyframes fadeOut { to { opacity: 0; visibility: hidden; } }
.login-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; padding: 48px 40px; width: 380px; max-width: 90vw; box-shadow: 0 4px 24px var(--shadow); position: relative; z-index: 1; }
.login-brand { text-align: center; margin-bottom: 32px; }
.login-brand svg { margin-bottom: 12px; }
.login-brand h1 { color: var(--accent); font-size: 22px; font-weight: 700; }
.login-brand p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.login-field { display: flex; align-items: center; gap: 10px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; padding: 0 14px; margin-bottom: 12px; transition: border-color 0.2s; }
.login-field:focus-within { border-color: var(--accent); }
.login-icon { stroke: var(--text-muted); flex-shrink: 0; }
.login-field input { flex: 1; padding: 14px 0; background: transparent; border: none; color: var(--text); font-size: 14px; outline: none; }
.login-field input::placeholder { color: #9ca3af; }
.login-error { display: none; color: var(--accent); font-size: 12px; text-align: center; margin-bottom: 12px; min-height: 18px; }
.login-submit { width: 100%; padding: 14px; font-size: 15px; font-weight: 600; border-radius: 8px; margin-top: 4px; }
.login-submit:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(233,69,96,0.3); transition: all 0.2s; }

/* Range slider styling */
.form-row input[type=range] { flex: 1; height: 6px; -webkit-appearance: none; appearance: none; background: var(--border); border-radius: 3px; outline: none; }
.form-row input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid var(--bg-card); }
.form-row input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid var(--bg-card); }

/* Canvas Loading */
.canvas-loading { display: none; position: absolute; inset: 0; background: rgba(15, 15, 35, 0.85); z-index: 10; flex-direction: column; align-items: center; justify-content: center; gap: 16px; font-size: 14px; color: var(--text-muted); }
.canvas-loading.visible { display: flex; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Pagination */
.pagination-bar { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 12px 20px; background: var(--bg-card); border-top: 1px solid var(--border); }
.page-btn { padding: 6px 16px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-input); color: var(--text); cursor: pointer; font-size: 13px; }
.page-btn:hover:not(:disabled) { background: var(--border); }
.page-btn:disabled { opacity: 0.4; cursor: default; }
.page-info { font-size: 13px; color: var(--text-muted); }

/* === Inference Page === */
.infer-layout { display: flex; flex: 1; overflow: hidden; }
.infer-left { width: 340px; padding: 20px; display: flex; flex-direction: column; gap: 16px; background: var(--bg-card); border-right: 1px solid var(--border); overflow-y: auto; min-height: 0; }
.infer-right { flex: 1; padding: 20px; overflow-y: auto; min-height: 0; }

/* Dropzone */
.infer-dropzone { border: 2px dashed var(--border); border-radius: 10px; padding: 24px; text-align: center; cursor: pointer; transition: all 0.2s; min-height: 200px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.infer-dropzone:hover, .infer-dropzone.dragover { border-color: var(--accent); background: rgba(233, 69, 96, 0.05); }
.dropzone-icon { font-size: 40px; color: var(--border); }
.infer-dropzone:hover .dropzone-icon, .infer-dropzone.dragover .dropzone-icon { color: var(--accent); }
.dropzone-text { font-size: 13px; color: var(--text-muted); }
.infer-preview { max-width: 100%; max-height: 240px; object-fit: contain; border-radius: 6px; }

/* Controls */
.infer-controls { display: flex; flex-direction: column; gap: 12px; }
.conf-group label { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.conf-group input[type=range] { width: 100%; height: 6px; -webkit-appearance: none; appearance: none; background: var(--border); border-radius: 3px; outline: none; }
.conf-group input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid var(--bg-card); }
.conf-presets { display: flex; gap: 6px; margin-top: 5px;}
.conf-btn { flex: 1; padding: 6px 0; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-input); color: var(--text-muted); font-size: 12px; cursor: pointer; transition: all 0.2s; }
.conf-btn:hover { border-color: var(--accent); }
.conf-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(233, 69, 96, 0.1); }
.infer-run { width: 100%; padding: 12px; font-size: 15px; }
#infer-status { font-size: 13px; color: var(--warning); text-align: center; min-height: 20px; }
.history-section { border-top: 1px solid var(--border); padding-top: 12px; }
.history-header { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); cursor: pointer; padding: 6px 0; }
.history-header:hover { color: var(--accent); }
.history-clear { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 2px 6px; font-size: 12px; opacity: 0.6; display: none; }
.history-clear:hover { opacity: 1; color: var(--accent); }
.history-clear.visible { display: inline-block; }
.history-badge { background: var(--accent); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 10px; min-width: 20px; text-align: center; }
.history-list { max-height: 260px; overflow-y: auto; }
.history-list.collapsed { display: none; }
.history-empty { text-align: center; padding: 16px; font-size: 12px; color: var(--text-muted); }
.history-item { padding: 8px 10px; border-radius: 6px; cursor: pointer; margin-bottom: 4px; transition: background 0.2s; background: var(--bg-input); border: 1px solid transparent; }
.history-item:hover { border-color: var(--accent); background: var(--bg); }
.history-item-name { font-size: 12px; color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item-meta { font-size: 11px; color: var(--text-muted); margin: 2px 0; }
.history-item-labels { font-size: 11px; }
.history-detail { padding: 20px; }
.history-detail-item { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding: 8px 12px; background: var(--bg-input); border-radius: 6px; }
.history-detail-item .detail-label { font-size: 13px; font-weight: 600; color: var(--accent); min-width: 80px; }
.history-detail-item .detail-label small { font-weight: 400; color: var(--text-muted); }
.history-detail-item .detail-bar { flex: 1; height: 6px; background: var(--bg-dark); border-radius: 3px; overflow: hidden; }
.history-detail-item .detail-bar span { display: block; height: 100%; border-radius: 3px; }
.history-detail-item .detail-conf { font-size: 13px; font-weight: 600; min-width: 48px; text-align: right; }
.history-detail-footer { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); text-align: center; }

/* Annotated image */
.infer-annotated { margin-bottom: 16px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.infer-annotated img { width: 100%; display: block; }

/* Item cards */
.infer-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.infer-empty { grid-column: 1 / -1; text-align: center; padding: 40px; color: var(--text-muted); font-size: 14px; }
.infer-loading { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 80px 20px; gap: 12px; }
.infer-loading span { color: var(--text-muted); font-size: 14px; }
.infer-placeholder { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 80px 20px; gap: 12px; }
.log-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; gap: 10px; /*height: 100%;*/ }
.placeholder-title { font-size: 15px; font-weight: 600; color: var(--text-muted); }
.placeholder-desc { font-size: 12px; color: var(--text-muted); opacity: 0.7; }
.infer-card { background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; transition: border-color 0.2s; }
.infer-card:hover { border-color: var(--accent); }
.infer-card img { width: 100%; height: 160px; object-fit: contain; display: block; background: var(--bg-dark); }
.infer-card .card-body { padding: 10px 12px; }
.infer-card .card-label { font-size: 14px; font-weight: 600; color: var(--accent); margin-bottom: 6px; }
.infer-card .card-item-conf { font-size: 11px; font-weight: 400; color: var(--text-muted); float: right; }
.infer-card .card-conf { position: relative; height: 6px; background: var(--border); border-radius: 3px; margin-bottom: 4px; }
.infer-card .conf-bar { position: absolute; top: 0; left: 0; height: 100%; border-radius: 3px; transition: width 0.3s; }
.infer-card .conf-text { display: block; font-size: 12px; color: var(--text-muted); text-align: right; margin-top: 2px; }
.infer-card .card-saved { font-size: 11px; color: var(--text-muted); margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }

/* Summary bar */
.infer-summary { display: flex; gap: 16px; flex-wrap: wrap; padding: 10px 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; margin-top: 16px; font-size: 13px; color: var(--text-muted); }
.infer-summary span { white-space: nowrap; }

/* === Lightbox === */
.lightbox { position: fixed; inset: 0; z-index: 2000; background: rgba(0, 0, 0, 0.92); display: flex; flex-direction: column; }
.lightbox.hidden { display: none; }
.lightbox-toolbar { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; background: rgba(0, 0, 0, 0.6); }
.lightbox-toolbar button { padding: 6px 14px; border: 1px solid #555; border-radius: 4px; background: var(--bg-input); color: var(--text); cursor: pointer; font-size: 16px; transition: all 0.15s; }
.lightbox-toolbar button:hover { border-color: var(--accent); background: var(--bg-card); }
#lb-close { margin-left: 16px; font-size: 18px; }
#lb-zoom-level { font-size: 13px; color: var(--text-muted); min-width: 44px; text-align: center; }
.lightbox-body { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; cursor: grab; }
.lightbox-body:active { cursor: grabbing; }
#lightbox-img { display: block; transition: transform 0.2s; user-select: none; -webkit-user-drag: none; }

/* === Training Page === */
.train-container { display: flex; flex-direction: column; flex: 1; overflow-y: auto; }
.train-dashboard { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; padding: 16px 20px; background: var(--bg-card); border-bottom: 1px solid var(--border); }
.dash-card { background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; text-align: center; }
.dash-num { font-size: 22px; font-weight: 700; color: var(--accent); }
.dash-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.train-main { display: flex; flex: 1; gap: 20px; padding: 20px; overflow: hidden; }
.train-config { width: 320px; flex-shrink: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.train-config h3 { color: var(--accent); font-size: 15px; margin-bottom: 4px; }
.env-status { display: flex; gap: 12px; align-items: center; padding: 6px 10px; background: var(--bg-input); border-radius: 6px; margin-bottom: 12px; font-size: 12px; }
.env-status span { flex: 1; }
#env-setup-btn { font-size: 11px; padding: 4px 12px; white-space: nowrap; }
.config-row { display: flex; flex-direction: column; gap: 6px; }
.config-row.nums { flex-direction: column; gap: 8px; }
.config-row.nums > div { flex: 1; }
.config-row label { font-size: 12px; color: var(--text-muted); margin-right: 10px;}
.config-row select, .config-row input { padding: 7px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-input); color: var(--text); font-size: 13px; }
.config-row select:focus, .config-row input:focus { outline: none; border-color: var(--accent); }
.train-actions { display: flex; gap: 8px; margin-top: auto; }
.train-actions button { flex: 1; padding: 10px; font-size: 14px; }
#train-device-status { font-size: 11px; }
.train-progress { flex: 1; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }

/* Progress */
.progress-section { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.progress-section.hidden { display: none; }
.progress-header { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 13px; }
#train-phase { color: var(--warning); font-weight: 600; }
#train-eta { color: var(--text-muted); }
.progress-bar-track { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin-bottom: 8px; }
.progress-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), var(--accent)); border-radius: 4px; transition: width 0.5s ease; }
.progress-stats { font-size: 12px; color: var(--text-muted); text-align: center; margin-bottom: 12px; }

/* Metric cards */
.metric-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.metric-card { background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; padding: 12px; text-align: center; }
.metric-val { font-size: 20px; font-weight: 700; color: var(--success); font-variant-numeric: tabular-nums; }
.metric-name { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.log-section { background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; flex: 1; display: flex; flex-direction: column; }
.log-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; cursor: pointer; font-size: 13px; color: var(--text-muted); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.log-header:hover { background: var(--bg-input); }
.log-arrow { font-size: 11px; }
.log-body { flex: 1; overflow-y: auto; padding: 10px 14px; font: 11px "Consolas", monospace; color: var(--text-muted); white-space: pre-wrap; line-height: 1.6; background: var(--bg-dark); }
.log-body.collapsed { display: none; }

/* Old training styles - keep for fallback */
.guide-card { background: var(--tab-hover); border: 1px solid var(--border); border-radius: 8px; padding: 16px 20px; margin-bottom: 16px; }
.guide-card h3 { color: var(--accent); margin-bottom: 8px; font-size: 15px; }
.guide-card .step-list { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.guide-card .step-item { display: flex; align-items: flex-start; gap: 6px; font-size: 12px; color: #c0c0d0; line-height: 1.6; }
.guide-card .step-item .step-num { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; flex-shrink: 0; margin-top: 1px; }
.guide-card .req-list { font-size: 12px; color: var(--text-muted); line-height: 1.8; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.guide-card .req-list b { color: var(--warning); }
.sys-row { display: flex; padding: 4px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.sys-row:last-child { border-bottom: none; }
.sys-label { color: var(--text-muted); width: 80px; flex-shrink: 0; }
.sys-value { color: var(--text); }