:root {
  font-family: Inter, Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #e9eef4;
  background: #080d12;
  font-synthesis: none;
  --bg: #080d12;
  --panel: #101820;
  --panel-2: #151f28;
  --line: #273440;
  --muted: #8fa1b1;
  --text: #e9eef4;
  --cyan: #38d6c8;
  --cyan-soft: rgba(56, 214, 200, 0.12);
  --green: #54d391;
  --red: #ff6b71;
  --yellow: #f1bd58;
  --radius: 14px;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(circle at 80% -20%, #16313a 0, transparent 36%), var(--bg); }
button, input { font: inherit; }
button { color: inherit; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }

.app-shell { width: min(1480px, 100%); min-height: 100vh; margin: 0 auto; border-inline: 1px solid rgba(255,255,255,.04); background: rgba(8,13,18,.76); }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 26px; border-bottom: 1px solid var(--line); background: rgba(11,17,23,.88); backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 40; }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 750; letter-spacing: -.02em; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--cyan-soft); color: var(--cyan); border: 1px solid rgba(56,214,200,.24); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.status-chip, .pill { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: #0d151c; color: var(--muted); border-radius: 999px; padding: 6px 10px; font-size: 12px; white-space: nowrap; }
.status-chip i { width: 7px; height: 7px; background: var(--yellow); border-radius: 50%; box-shadow: 0 0 10px currentColor; }
.status-chip.online i { background: var(--green); }
.status-chip.error i { background: var(--red); }
.icon-button, .help-button { border: 0; background: transparent; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; cursor: pointer; color: var(--muted); }
.icon-button:hover, .help-button:hover { background: var(--panel-2); color: var(--text); }

.contextbar { min-height: 72px; padding: 14px 26px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.contextbar > div:first-child { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.contextbar strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eyebrow { color: var(--cyan); text-transform: uppercase; font-size: 10px; font-weight: 800; letter-spacing: .13em; }
.context-meta { color: var(--muted); font-size: 13px; text-align: right; }

.tabs { display: flex; gap: 4px; padding: 10px 18px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { min-width: 112px; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 16px 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--cyan); border-bottom-color: var(--cyan); background: linear-gradient(to top, var(--cyan-soft), transparent); }

main { padding: 28px 26px 70px; }
.panel { display: none; }
.panel.active { display: block; animation: reveal .18s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(4px); } }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.section-head h1 { font-size: 22px; margin: 0 0 6px; letter-spacing: -.035em; }
.section-head p { margin: 0; color: var(--muted); font-size: 13px; }
.help-button { border: 1px solid var(--line); }

.upload-zone { min-height: 210px; border: 1px dashed #40515e; border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; cursor: pointer; background: linear-gradient(135deg, rgba(56,214,200,.05), rgba(255,255,255,.015)); transition: .2s ease; padding: 28px; text-align: center; }
.upload-zone:hover, .upload-zone.dragging { border-color: var(--cyan); background: var(--cyan-soft); }
.upload-zone input { display: none; }
.upload-zone > span:not(.upload-icon) { color: var(--muted); font-size: 13px; }
.upload-icon { width: 52px; height: 52px; display: grid; place-items: center; color: var(--cyan); border-radius: 16px; background: var(--cyan-soft); margin-bottom: 5px; }
.upload-icon svg { width: 25px; height: 25px; }
.progress-track { width: min(440px, 90%); height: 7px; background: #071016; border-radius: 99px; overflow: hidden; margin-top: 9px; }
.progress-track i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, #20aeb4, var(--cyan)); transition: width .2s; }
.upload-zone small { color: var(--muted); min-height: 18px; }

.table-card, .video-card, .inspector, .segment-panel, .chart-card, .rule-card, .details-card, .analysis-visual-card { border: 1px solid var(--line); border-radius: var(--radius); background: rgba(16,24,32,.86); }
.table-card { margin-top: 20px; overflow: hidden; }
.table-title { min-height: 51px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--line); }
.text-button { border: 0; background: transparent; color: var(--cyan); cursor: pointer; padding: 8px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 16px; border-bottom: 1px solid rgba(39,52,64,.65); text-align: left; font-size: 13px; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.selected { background: rgba(56,214,200,.06); }
tbody tr.selected td:first-child { box-shadow: inset 3px 0 var(--cyan); }
.file-cell { display: flex; align-items: center; gap: 10px; max-width: 360px; }
.file-cell span:last-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.file-icon { width: 32px; height: 32px; border-radius: 9px; background: var(--panel-2); display: grid; place-items: center; color: var(--cyan); flex: 0 0 auto; }
.pill { padding: 4px 8px; }
.pill.green { color: var(--green); border-color: rgba(84,211,145,.35); background: rgba(84,211,145,.08); }
.pill.red { color: var(--red); border-color: rgba(255,107,113,.35); background: rgba(255,107,113,.08); }
.pill.yellow { color: var(--yellow); border-color: rgba(241,189,88,.35); background: rgba(241,189,88,.08); }
.pill.cyan { color: var(--cyan); border-color: rgba(56,214,200,.35); background: rgba(56,214,200,.08); }
.empty-row { padding: 32px; text-align: center; color: var(--muted); }

.empty-state { min-height: 330px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 14px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty-state svg { width: 42px; height: 42px; color: #50616f; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 18px; align-items: start; }
.video-stage { position: relative; min-height: 360px; display: grid; place-items: center; background: #03070a; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; touch-action: none; }
.video-stage video { display: block; max-width: 100%; width: 100%; max-height: 68vh; object-fit: contain; }
.roi-box { position: absolute; border: 2px solid var(--cyan); background: rgba(56,214,200,.12); box-shadow: 0 0 0 9999px rgba(0,0,0,.3); pointer-events: none; }
.roi-box span { position: absolute; width: 9px; height: 9px; right: -5px; bottom: -5px; border-radius: 50%; background: var(--cyan); }
.draw-hint { position: absolute; pointer-events: none; padding: 8px 12px; border-radius: 9px; background: rgba(0,0,0,.72); color: #cbd7df; font-size: 12px; }
.video-toolbar, .range-bar { min-height: 54px; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; color: var(--muted); font-size: 12px; }
.inspector, .segment-panel { padding: 17px; }
.inspector-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.metric-list { margin: 0; }
.metric-list div { display: flex; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid rgba(39,52,64,.65); }
.metric-list dt { color: var(--muted); }
.metric-list dd { margin: 0; font-variant-numeric: tabular-nums; }
.action-stack { display: grid; gap: 9px; margin-top: 18px; }
.primary-button, .secondary-button { min-height: 40px; border-radius: 10px; padding: 9px 14px; cursor: pointer; border: 1px solid transparent; font-weight: 700; }
.primary-button { background: var(--cyan); color: #04110f; }
.primary-button:hover { background: #6de6dc; }
.secondary-button { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.secondary-button:hover { border-color: #485b68; }
button:disabled { opacity: .45; cursor: not-allowed; }
.inline-note { display: flex; align-items: flex-start; gap: 8px; color: var(--muted); font-size: 12px; line-height: 1.5; margin: 16px 0 0; }
.inline-note span { width: 17px; height: 17px; border: 1px solid rgba(241,189,88,.4); color: var(--yellow); border-radius: 50%; display: inline-grid; place-items: center; flex: 0 0 auto; font-weight: 800; }

.label-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.label-video-stage { min-height: 360px; display: grid; place-items: center; overflow: hidden; background: #03070a; border-radius: var(--radius) var(--radius) 0 0; }
.label-video-frame { position: relative; display: inline-block; max-width: 100%; line-height: 0; overflow: hidden; }
.label-video { display: block; width: auto; height: auto; max-width: 100%; max-height: 62vh; background: #03070a; }
.label-roi-box { position: absolute; border: 2px solid var(--cyan); background: rgba(56,214,200,.1); box-shadow: 0 0 0 9999px rgba(0,0,0,.52), inset 0 0 24px rgba(56,214,200,.07); pointer-events: none; }
.label-roi-box > span { position: absolute; top: 7px; left: 7px; padding: 5px 7px; border-radius: 6px; background: rgba(4,17,15,.88); color: var(--cyan); font-size: 10px; font-weight: 800; line-height: 1; white-space: nowrap; }
.scope-strip { min-height: 54px; display: flex; align-items: center; gap: 11px; padding: 10px 14px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: rgba(56,214,200,.045); }
.scope-strip > i { width: 9px; height: 9px; border-radius: 2px; background: var(--cyan); box-shadow: 0 0 12px rgba(56,214,200,.7); flex: 0 0 auto; }
.scope-strip div { display: flex; flex-direction: column; gap: 3px; }
.scope-strip strong { color: var(--text); font-size: 12px; }
.scope-strip span { color: var(--muted); font-size: 11px; }
.label-timeline { position: relative; height: 34px; margin: 15px 14px 7px; overflow: hidden; cursor: pointer; border: 1px solid var(--line); border-radius: 8px; background: #071016; }
.timeline-labels, .timeline-selection { position: absolute; inset: 0; }
.timeline-labels i { position: absolute; top: 0; bottom: 0; min-width: 2px; opacity: .8; border-inline: 1px solid rgba(255,255,255,.2); }
.timeline-labels i.normal { background: rgba(84,211,145,.72); }
.timeline-labels i.abnormal { background: rgba(255,107,113,.78); }
.timeline-labels i.uncertain { background: rgba(241,189,88,.72); }
.timeline-selection { right: auto; border: 1px solid #fff; background: rgba(255,255,255,.16); box-shadow: inset 0 0 0 1px rgba(0,0,0,.3); pointer-events: none; }
.timeline-playhead { position: absolute; top: 0; bottom: 0; left: 0; width: 2px; background: #fff; box-shadow: 0 0 8px rgba(255,255,255,.8); pointer-events: none; }
.timeline-legend { display: flex; align-items: center; gap: 13px; padding: 0 14px 5px; color: var(--muted); font-size: 11px; }
.timeline-legend span { display: inline-flex; align-items: center; gap: 5px; }
.timeline-legend span > i { width: 7px; height: 7px; border-radius: 2px; }
.timeline-legend i.normal { background: var(--green); }
.timeline-legend i.abnormal { background: var(--red); }
.timeline-legend i.uncertain { background: var(--yellow); }
.timeline-legend small { margin-left: auto; color: #60717e; }
.range-bar strong { color: var(--text); font-variant-numeric: tabular-nums; }
.label-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0 14px 14px; }
.label-button { min-height: 48px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-weight: 750; }
.label-button.normal:hover { border-color: var(--green); color: var(--green); }
.label-button.abnormal:hover { border-color: var(--red); color: var(--red); }
.label-button.uncertain:hover { border-color: var(--yellow); color: var(--yellow); }
kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-right: 5px; border: 1px solid #495a67; border-radius: 5px; color: var(--muted); font-size: 11px; }
.segment-list { display: grid; gap: 8px; max-height: 65vh; overflow-y: auto; }
.segment { display: grid; grid-template-columns: 10px 1fr auto; gap: 10px; align-items: center; border: 1px solid var(--line); background: #0c141b; border-radius: 10px; padding: 10px; }
.segment-dot { width: 8px; height: 8px; border-radius: 50%; }
.segment.normal .segment-dot { background: var(--green); }
.segment.abnormal .segment-dot { background: var(--red); }
.segment.uncertain .segment-dot { background: var(--yellow); }
.segment strong { display: block; font-size: 12px; }
.segment small { color: var(--muted); }
.segment button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.metric-card { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); padding: 16px; }
.metric-card span { color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; margin-top: 8px; font-size: 25px; font-variant-numeric: tabular-nums; }
.analysis-visual-card { margin-top: 14px; overflow: hidden; }
.analysis-visual-head { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.analysis-visual-head > div:first-child { display: flex; flex-direction: column; gap: 5px; }
.analysis-visual-head strong { font-size: 14px; }
.preview-selector { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.preview-selector button { min-width: 62px; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; color: var(--muted); background: var(--panel-2); cursor: pointer; font-size: 11px; }
.preview-selector button:hover, .preview-selector button.active { color: var(--cyan); border-color: rgba(56,214,200,.55); background: var(--cyan-soft); }
.analysis-image-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); }
.analysis-image-grid figure { min-width: 0; margin: 0; background: #050a0e; }
.analysis-image-grid figcaption { min-height: 51px; display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 8px 12px; background: #0d151c; }
.analysis-image-grid figcaption strong { font-size: 12px; }
.analysis-image-grid figcaption span { color: var(--muted); font-size: 10px; }
.analysis-image-grid img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #020405; }
.preview-summary { display: flex; flex-wrap: wrap; gap: 8px 22px; padding: 12px 16px; color: var(--muted); font-size: 11px; }
.preview-summary strong { color: var(--text); font-variant-numeric: tabular-nums; }
.analysis-visual-empty { margin: 14px; padding: 24px; border: 1px dashed var(--line); border-radius: 10px; text-align: center; color: var(--muted); font-size: 12px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.chart-card { padding-bottom: 14px; }
.spark-bars { min-height: 180px; display: flex; align-items: end; gap: 2px; padding: 18px 16px 4px; overflow: hidden; }
.spark-bars i { flex: 1 1 4px; min-width: 2px; max-width: 12px; background: linear-gradient(to top, #13868c, var(--cyan)); border-radius: 3px 3px 0 0; opacity: .8; }
.danger-chart .spark-bars i { background: linear-gradient(to top, #8f3039, var(--red)); }
.analysis-note { display: flex; align-items: flex-start; gap: 9px; margin: 12px 2px 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.analysis-note span { width: 17px; height: 17px; display: inline-grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 50%; color: var(--cyan); font-size: 10px; font-weight: 800; }
.rule-card { margin-top: 14px; padding: 20px; display: flex; align-items: center; justify-content: space-between; gap: 30px; }
.rule-card h2 { margin: 6px 0; font-size: 18px; }
.rule-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.details-card { margin-top: 14px; padding: 14px 16px; }
.details-card summary { cursor: pointer; color: var(--muted); }
.details-card pre { max-height: 350px; overflow: auto; color: #b9cad5; font-size: 11px; white-space: pre-wrap; }

.history-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.history-group { min-width: 0; }
.history-group-title { min-height: 43px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.history-group-title strong { color: var(--text); font-size: 13px; }
.history-list { display: grid; gap: 10px; }
.history-item { display: grid; grid-template-columns: 40px 1fr auto; gap: 13px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.history-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--panel-2); color: var(--muted); }
.history-item strong { display: block; font-size: 13px; }
.history-item p { margin: 4px 0 0; color: var(--muted); font-size: 12px; max-width: 760px; overflow-wrap: anywhere; }
.history-item time { color: var(--muted); font-size: 11px; }
.empty-row.compact { padding: 22px 14px; border: 1px dashed var(--line); border-radius: 12px; font-size: 12px; }

dialog { width: min(520px, calc(100% - 30px)); padding: 0; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 30px 90px rgba(0,0,0,.6); }
dialog::backdrop { background: rgba(0,0,0,.65); backdrop-filter: blur(4px); }
.dialog-head { min-height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 0 17px; border-bottom: 1px solid var(--line); }
.dialog-head button { border: 0; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; }
.help-content { padding: 18px; color: #c2d0da; line-height: 1.7; font-size: 13px; }
.help-content ol { padding-left: 20px; margin: 0; }
.help-content li + li { margin-top: 8px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: #eaf4f5; color: #081215; padding: 11px 16px; border-radius: 10px; font-size: 13px; font-weight: 700; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; box-shadow: 0 10px 40px rgba(0,0,0,.4); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #ffd7d9; color: #4e070a; }

@media (max-width: 900px) {
  .workspace-grid, .label-layout { grid-template-columns: 1fr; }
  .history-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .analysis-image-grid { grid-template-columns: 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
  .segment-panel { max-height: none; }
  .context-meta { display: none; }
}

@media (max-width: 620px) {
  .topbar, .contextbar { padding-inline: 15px; }
  .status-chip { display: none; }
  .tabs { padding-left: 6px; }
  .tab { min-width: 88px; padding-inline: 10px; font-size: 12px; }
  main { padding: 22px 14px 60px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .label-actions { grid-template-columns: 1fr; }
  .rule-card { align-items: stretch; flex-direction: column; gap: 14px; }
  .analysis-visual-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  .preview-selector { justify-content: flex-start; }
  .video-stage { min-height: 230px; }
  .label-video-stage { min-height: 230px; }
  .timeline-legend small { display: none; }
}
