/* ==========================================================================
   미천시스템 도장공정 AI 대시보드 — 공통 스타일
   ========================================================================== */

:root {
  /* Dark (default) */
  --bg: #0B1220;
  --bg-elev: #0E1627;
  --surface: #111A2E;
  --surface-2: #162138;
  --border: #1F2A44;
  --border-strong: #2A3760;
  --text: #E5ECF7;
  --text-dim: #93A3BE;
  --text-muted: #5E6E8C;

  --accent-primary: #22D3EE;
  --accent-primary-soft: rgba(34, 211, 238, 0.12);
  --accent-secondary: #818CF8;
  --accent-good: #22C55E;
  --accent-good-soft: rgba(34, 197, 94, 0.12);
  --accent-warn: #F59E0B;
  --accent-warn-soft: rgba(245, 158, 11, 0.12);
  --accent-danger: #EF4444;
  --accent-danger-soft: rgba(239, 68, 68, 0.12);
  --accent-orange: #FB923C;

  --shadow-card: 0 1px 2px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.03);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

[data-theme="light"] {
  --bg: #F4F6FB;
  --bg-elev: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F7F9FC;
  --border: #E4E9F2;
  --border-strong: #CFD6E4;
  --text: #0F172A;
  --text-dim: #4B5A75;
  --text-muted: #8A96AC;

  --accent-primary: #0891B2;
  --accent-primary-soft: rgba(8, 145, 178, 0.10);
  --accent-secondary: #4F46E5;
  --accent-good: #16A34A;
  --accent-good-soft: rgba(22, 163, 74, 0.10);
  --accent-warn: #D97706;
  --accent-warn-soft: rgba(217, 119, 6, 0.10);
  --accent-danger: #DC2626;
  --accent-danger-soft: rgba(220, 38, 38, 0.10);
  --accent-orange: #EA580C;

  --shadow-card: 0 1px 2px rgba(15,23,42,0.06), 0 1px 3px rgba(15,23,42,0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'tnum' 1, 'cv11' 1;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }

/* ---- App Shell ------------------------------------------------------------ */

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex; flex-direction: column;
}

.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.sidebar__brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  display: grid; place-items: center;
  color: #0B1220; font-weight: 800; font-size: 15px;
}
.sidebar__brand-text { line-height: 1.2; }
.sidebar__brand-title { font-weight: 700; font-size: 14px; letter-spacing: -0.2px; }
.sidebar__brand-sub { font-size: 11px; color: var(--text-muted); }

.sidebar__section-label {
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 10px 10px 6px;
}

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--text-dim);
  font-size: 13.5px; font-weight: 500;
  transition: background 120ms, color 120ms;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--accent-primary-soft);
  color: var(--accent-primary);
  font-weight: 600;
}
.nav-item i { width: 18px; height: 18px; }

.sidebar__footer {
  margin-top: auto;
  padding: 12px 10px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

/* ---- Top bar -------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 64px;
  display: flex; align-items: center; gap: 16px;
}

.topbar__title { font-size: 15px; font-weight: 600; letter-spacing: -0.2px; }
.topbar__crumbs { color: var(--text-muted); font-size: 12px; }

.topbar__spacer { flex: 1; }

.topbar__selector {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 7px 12px; border-radius: 8px;
  font-size: 13px; color: var(--text);
}
.topbar__selector i { color: var(--accent-primary); }

.topbar__clock {
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  font-size: 13px;
  padding: 0 6px;
}

.icon-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--text-dim);
  position: relative;
  transition: background 120ms, color 120ms;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.icon-btn__badge {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-danger);
  box-shadow: 0 0 0 2px var(--bg);
}

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.user-chip__avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-secondary), var(--accent-primary));
  display: grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 700;
}
.user-chip__name { font-size: 12.5px; font-weight: 600; }
.user-chip__role { font-size: 11px; color: var(--text-muted); }

/* ---- Page content --------------------------------------------------------- */

.page {
  padding: 24px 28px 48px;
}

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 20px; gap: 16px;
  flex-wrap: wrap;
}
.page-header__title { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }
.page-header__subtitle { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 12px; font-weight: 500;
}
.chip--active { background: var(--accent-primary-soft); color: var(--accent-primary); border-color: transparent; }

/* ---- Grid ----------------------------------------------------------------- */

.grid { display: grid; gap: 20px; }
.grid-12 { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.grid-6  { grid-template-columns: repeat(6,  minmax(0, 1fr)); }
.grid-5  { grid-template-columns: repeat(5,  minmax(0, 1fr)); }
.grid-4  { grid-template-columns: repeat(4,  minmax(0, 1fr)); }
.grid-3  { grid-template-columns: repeat(3,  minmax(0, 1fr)); }
.grid-2  { grid-template-columns: repeat(2,  minmax(0, 1fr)); }

.col-span-3  { grid-column: span 3;  }
.col-span-4  { grid-column: span 4;  }
.col-span-5  { grid-column: span 5;  }
.col-span-6  { grid-column: span 6;  }
.col-span-7  { grid-column: span 7;  }
.col-span-8  { grid-column: span 8;  }
.col-span-9  { grid-column: span 9;  }
.col-span-12 { grid-column: span 12; }

/* ---- Card ----------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
  position: relative;
}
.card--tight { padding: 16px; }
.card--flush { padding: 0; overflow: hidden; }

.card__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 12px;
}
.card__title { font-size: 14px; font-weight: 600; letter-spacing: -0.2px; }
.card__subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card__actions { display: flex; align-items: center; gap: 6px; }

/* ---- KPI Card ------------------------------------------------------------- */

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}
.kpi__label {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-dim); font-size: 12px; font-weight: 500;
}
.kpi__label .kpi__tag {
  font-size: 10px; padding: 2px 6px; border-radius: 4px;
  background: var(--accent-primary-soft); color: var(--accent-primary);
  font-weight: 600; letter-spacing: 0.03em;
}
.kpi__value {
  font-size: 30px; font-weight: 700; letter-spacing: -0.6px;
  line-height: 1; display: flex; align-items: baseline; gap: 4px;
}
.kpi__unit { font-size: 14px; font-weight: 500; color: var(--text-dim); }
.kpi__meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; font-size: 11.5px; color: var(--text-muted);
}
.kpi__delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.kpi__delta--up   { color: var(--accent-good); }
.kpi__delta--down { color: var(--accent-danger); }
.kpi__delta--flat { color: var(--text-muted); }

.kpi__bar {
  height: 6px; border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden; position: relative;
}
.kpi__bar-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
}
.kpi__bar--good  .kpi__bar-fill { background: linear-gradient(90deg, var(--accent-good), #86EFAC); }
.kpi__bar--warn  .kpi__bar-fill { background: linear-gradient(90deg, var(--accent-warn), #FCD34D); }
.kpi__bar--danger .kpi__bar-fill { background: linear-gradient(90deg, var(--accent-danger), #FCA5A5); }

.kpi__sparkline { position: relative; height: 34px; margin-top: 2px; }
.kpi__sparkline canvas { display: block; }

/* ---- Badges --------------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
  background: var(--surface-2);
  color: var(--text-dim);
}
.badge--good   { background: var(--accent-good-soft);   color: var(--accent-good); }
.badge--warn   { background: var(--accent-warn-soft);   color: var(--accent-warn); }
.badge--danger { background: var(--accent-danger-soft); color: var(--accent-danger); }
.badge--info   { background: var(--accent-primary-soft); color: var(--accent-primary); }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---- Buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
  transition: background 120ms, border-color 120ms, transform 80ms;
}
.btn:hover { background: var(--surface); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--accent-primary); color: #0B1220;
  border-color: transparent;
}
.btn--primary:hover { background: var(--accent-primary); filter: brightness(1.08); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn--ghost:hover { color: var(--text); background: var(--surface-2); }
.btn--danger { background: var(--accent-danger-soft); color: var(--accent-danger); border-color: transparent; }
.btn--warn   { background: var(--accent-warn-soft);   color: var(--accent-warn);   border-color: transparent; }
.btn--good   { background: var(--accent-good-soft);   color: var(--accent-good);   border-color: transparent; }
.btn--sm { padding: 5px 10px; font-size: 12px; }
.btn--lg { padding: 11px 18px; font-size: 14px; }
.btn i { width: 16px; height: 16px; }

/* ---- Alert banner --------------------------------------------------------- */

.alert {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--accent-warn);
  background: linear-gradient(90deg, var(--accent-warn-soft), transparent);
  color: var(--text);
}
.alert--danger {
  border-color: var(--accent-danger);
  background: linear-gradient(90deg, var(--accent-danger-soft), transparent);
}
.alert__icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent-warn); color: #0B1220;
  display: grid; place-items: center;
}
.alert--danger .alert__icon { background: var(--accent-danger); color: #fff; }
.alert__body { flex: 1; }
.alert__title { font-weight: 700; font-size: 14px; }
.alert__desc  { color: var(--text-dim); font-size: 12.5px; margin-top: 2px; }

/* ---- Table ---------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th, .table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-2);
}
.table tbody tr:hover td { background: var(--surface-2); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Form ----------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
  font-size: 12px; font-weight: 600; color: var(--text-dim);
  display: flex; align-items: center; justify-content: space-between;
}
.field__hint { font-size: 11px; color: var(--text-muted); font-weight: 500; }
.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-primary-soft);
}
.input--warn { border-color: var(--accent-warn); }
.textarea { min-height: 80px; resize: vertical; }

.range {
  -webkit-appearance: none;
  width: 100%; height: 4px;
  background: var(--surface-2);
  border-radius: 99px; outline: none;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 3px solid var(--bg-elev);
  box-shadow: 0 0 0 1px var(--accent-primary);
  cursor: pointer;
}
.range::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 3px solid var(--bg-elev);
  cursor: pointer;
}

.range-row {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--text-muted);
  margin-top: 2px;
}

/* ---- Tabs ----------------------------------------------------------------- */

.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  padding: 10px 14px;
  font-size: 13px; font-weight: 600;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

/* ---- Dropzone ------------------------------------------------------------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  background: var(--surface-2);
  color: var(--text-dim);
  transition: border-color 120ms, background 120ms;
  cursor: pointer;
  min-height: 140px;
}
.dropzone:hover, .dropzone.is-drag {
  border-color: var(--accent-primary);
  background: var(--accent-primary-soft);
  color: var(--text);
}
.dropzone i { width: 32px; height: 32px; color: var(--accent-primary); margin-bottom: 8px; flex-shrink: 0; }

/* ---- Confusion Matrix ----------------------------------------------------- */

.cm {
  display: grid;
  grid-template-columns: 120px 1fr 1fr;
  grid-template-rows: 40px 1fr 1fr;
  gap: 0;
  background: var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.cm__header, .cm__row-label {
  background: var(--surface-2);
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 600; color: var(--text-muted);
  padding: 8px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.cm__cell {
  background: var(--surface);
  padding: 16px;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 4px; min-height: 90px;
}
.cm__cell-label { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.cm__cell-value { font-size: 26px; font-weight: 700; letter-spacing: -0.4px; }
.cm__cell-pct   { font-size: 11.5px; color: var(--text-dim); }
.cm__cell--tp { background: linear-gradient(135deg, var(--accent-good-soft), transparent); }
.cm__cell--tn { background: linear-gradient(135deg, var(--accent-good-soft), transparent); }
.cm__cell--fp { background: linear-gradient(135deg, var(--accent-warn-soft), transparent); }
.cm__cell--fn { background: linear-gradient(135deg, var(--accent-danger-soft), transparent); }

/* ---- Gauge (semicircle) --------------------------------------------------- */

.gauge {
  position: relative; width: 100%;
  aspect-ratio: 2 / 1.2;
  display: grid; place-items: center;
}
.gauge canvas { width: 100%; height: 100%; }
.gauge__center {
  position: absolute;
  bottom: 16%;
  display: flex; flex-direction: column; align-items: center;
}
.gauge__value {
  font-size: 26px; font-weight: 700; letter-spacing: -0.4px;
}
.gauge__label { font-size: 11px; color: var(--text-muted); font-weight: 600; margin-top: 2px; }

/* ---- Feature importance row ---------------------------------------------- */

.feat {
  display: grid; grid-template-columns: 180px 1fr 60px;
  gap: 14px; align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.feat:last-child { border-bottom: none; }
.feat__name { font-size: 13px; font-weight: 500; }
.feat__bar {
  height: 8px; border-radius: 99px;
  background: var(--surface-2); position: relative; overflow: hidden;
}
.feat__bar-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
}
.feat__value { font-size: 13px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

/* ---- Equipment card ------------------------------------------------------- */

.eq-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: relative;
}
.eq-card__top { display: flex; align-items: center; justify-content: space-between; }
.eq-card__name { font-size: 13px; font-weight: 600; }
.eq-card__id { font-size: 11px; color: var(--text-muted); }
.eq-card__sensors { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.eq-sensor {
  background: var(--surface-2); border-radius: 6px;
  padding: 6px 8px;
}
.eq-sensor__label { font-size: 10px; color: var(--text-muted); }
.eq-sensor__value { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.eq-card--warn   { border-color: var(--accent-warn); }
.eq-card--danger {
  border-color: var(--accent-danger);
  box-shadow: 0 0 0 3px var(--accent-danger-soft);
}
.eq-card__glow::before {
  content: '';
  position: absolute; inset: 0; border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(135deg, var(--accent-danger-soft), transparent 60%);
}

/* ---- Modal ---------------------------------------------------------------- */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(8, 12, 24, 0.72);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
}
.modal-backdrop.is-open { display: flex; }
.modal {
  width: min(560px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  padding: 22px 22px 18px;
}
.modal__head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.modal__title { font-size: 16px; font-weight: 700; }
.modal__body { color: var(--text-dim); font-size: 13.5px; }
.modal__footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.info-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.info-list__row {
  display: flex; justify-content: space-between;
  padding: 8px 12px; background: var(--surface-2);
  border-radius: 8px;
  font-size: 12.5px;
}
.info-list__label { color: var(--text-muted); }
.info-list__value { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---- Pipeline flow -------------------------------------------------------- */

.flow {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
  align-items: center;
  padding: 18px 10px;
}
.flow__node {
  padding: 16px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  position: relative; z-index: 1;
  cursor: pointer;
  transition: transform 120ms, border-color 120ms, background 120ms;
}
.flow__node:hover { transform: translateY(-2px); border-color: var(--accent-primary); }
.flow__node.active { border-color: var(--accent-primary); background: var(--accent-primary-soft); }
.flow__node-tag {
  display: inline-block;
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--accent-primary);
  background: var(--accent-primary-soft);
  padding: 2px 6px; border-radius: 4px; margin-bottom: 6px;
}
.flow__node-title { font-size: 13px; font-weight: 700; }
.flow__node-desc  { font-size: 11px; color: var(--text-muted); margin-top: 3px; line-height: 1.4; }
.flow__arrow {
  color: var(--border-strong);
  display: grid; place-items: center;
  font-size: 20px;
}

/* ---- Roadmap timeline ----------------------------------------------------- */

.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: ''; position: absolute;
  left: 8px; top: 4px; bottom: 4px;
  width: 2px;
  background: var(--border);
}
.timeline__item { position: relative; padding: 6px 0 20px; }
.timeline__dot {
  position: absolute; left: -20px; top: 10px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 0 0 4px var(--bg);
}
.timeline__item--future .timeline__dot { background: var(--border-strong); }
.timeline__item--done .timeline__dot { background: var(--accent-good); }
.timeline__phase { font-size: 11px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.timeline__title { font-size: 14px; font-weight: 700; margin-top: 2px; }
.timeline__desc  { font-size: 12.5px; color: var(--text-dim); margin-top: 4px; }

/* ---- Toast ---------------------------------------------------------------- */

.toast-host {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-primary);
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  font-size: 13px;
  max-width: 340px;
  animation: toast-in 200ms ease-out;
}
.toast--good   { border-left-color: var(--accent-good); }
.toast--warn   { border-left-color: var(--accent-warn); }
.toast--danger { border-left-color: var(--accent-danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Misc utilities ------------------------------------------------------- */

.hstack { display: flex; align-items: center; gap: 10px; }
.vstack { display: flex; flex-direction: column; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.bold { font-weight: 700; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }

.chart-box { position: relative; width: 100%; }
.chart-box--sm { height: 220px; }
.chart-box--md { height: 300px; }
.chart-box--lg { height: 380px; }

/* ---- MES 보조 컴포넌트 ---------------------------------------------------- */

/* 미니 KPI (메인 대시보드 MES 보조 영역용 — RAG KPI 대비 작게) */
.kpi--mini {
  padding: 12px 14px;
  gap: 6px;
}
.kpi--mini .kpi__label { font-size: 11px; }
.kpi--mini .kpi__value { font-size: 20px; line-height: 1.1; }
.kpi--mini .kpi__unit  { font-size: 12px; }

/* 진행률 막대 (작업지시 / 검사 진행 등) */
.progress {
  height: 6px; border-radius: 99px;
  background: var(--surface-2);
  position: relative; overflow: hidden;
}
.progress__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-good));
  border-radius: 99px;
  transition: width 240ms;
}
.progress--warn .progress__fill { background: linear-gradient(90deg, var(--accent-warn), #FCD34D); }
.progress--danger .progress__fill { background: linear-gradient(90deg, var(--accent-danger), #FCA5A5); }

/* Gantt 단순 막대 (생산진척) */
.gantt-row {
  display: grid;
  grid-template-columns: 160px 1fr 80px;
  gap: 12px; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.gantt-row:last-child { border-bottom: none; }
.gantt-row__label { font-weight: 600; }
.gantt-row__sub { color: var(--text-muted); font-size: 11px; }
.gantt-bar {
  height: 22px;
  background: var(--surface-2);
  border-radius: 4px;
  position: relative; overflow: hidden;
}
.gantt-bar__plan {
  position: absolute;
  top: 0; height: 100%;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 4px;
}
.gantt-bar__fill {
  position: absolute;
  top: 0; height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 4px;
}
.gantt-bar__fill--done   { background: linear-gradient(90deg, var(--accent-good), #86EFAC); }
.gantt-bar__fill--delay  { background: linear-gradient(90deg, var(--accent-danger), #FCA5A5); }

/* BOM 트리 */
.bom-tree { font-size: 13px; padding: 6px 0; }
.bom-tree__root {
  font-weight: 700;
  color: var(--text);
  padding: 8px 10px;
  background: var(--accent-primary-soft);
  border-radius: 6px;
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 8px;
}
.bom-tree__node {
  padding: 8px 10px 8px 22px;
  border-left: 2px solid var(--border);
  margin-left: 14px;
  position: relative;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.bom-tree__node::before {
  content: '';
  position: absolute;
  left: -2px; top: 16px;
  width: 14px; height: 2px;
  background: var(--border);
}
.bom-tree__name { color: var(--text); }
.bom-tree__qty  { color: var(--text-dim); font-variant-numeric: tabular-nums; font-size: 12px; }

/* 검사 도넛 카드 (수입/공정/출하) */
.insp-card {
  display: flex; flex-direction: column; align-items: center;
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  gap: 8px;
}
.insp-card__title { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.insp-card__chart { width: 110px; height: 110px; position: relative; }
.insp-card__pct {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 18px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.insp-card__legend {
  display: flex; gap: 10px; font-size: 11px; color: var(--text-muted);
}

/* 작업일지 카드 */
.log-card {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.log-card__head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 4px;
}
.log-card__title { font-size: 13px; font-weight: 700; }
.log-card__meta  { font-size: 11px; color: var(--text-muted); }
.log-card__body  { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Responsive breakpoints */

/* 데스크탑 기본: 햄버거 / 백드롭 숨김 */
.topbar__menu-btn { display: none; }
.sidebar__backdrop { display: none; }

@media (max-width: 1280px) {
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: relative; height: auto; width: 100%;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .grid-12, .grid-6, .grid-5, .grid-4, .grid-3 { grid-template-columns: 1fr 1fr; }
  .col-span-3, .col-span-4, .col-span-5, .col-span-6, .col-span-7, .col-span-8, .col-span-9 { grid-column: span 2; }
  .col-span-12 { grid-column: span 2; }
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 16px; }
}

/* 휴대폰 — 사이드바 드로어 + 단일 컬럼 */
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed; top: 0; left: 0;
    width: 260px; height: 100vh; z-index: 100;
    border-right: 1px solid var(--border);
    border-bottom: none;
    transform: translateX(-100%);
    transition: transform 220ms ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.4);
  }
  .sidebar.is-open { transform: translateX(0); }

  .sidebar__backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    opacity: 0; pointer-events: none;
    transition: opacity 220ms;
  }
  .sidebar__backdrop.is-open { opacity: 1; pointer-events: auto; }

  /* Topbar */
  .topbar {
    padding: 0 12px; gap: 8px;
    flex-wrap: nowrap; height: 56px;
  }
  .topbar__menu-btn { display: grid; }
  .topbar__crumbs { display: none; }
  .topbar__title { font-size: 14px; }
  .topbar__selector,
  .topbar__clock,
  .user-chip { display: none; }

  /* Page padding */
  .page { padding: 16px 12px 32px; }
  .page-header { gap: 10px; margin-bottom: 14px; }
  .page-header__title { font-size: 18px; }
  .page-header__subtitle { font-size: 12px; }

  /* 모든 grid 1열 */
  .grid { gap: 12px; }
  .grid-12, .grid-6, .grid-5, .grid-4, .grid-3, .grid-2 {
    grid-template-columns: 1fr;
  }
  .col-span-3, .col-span-4, .col-span-5,
  .col-span-6, .col-span-7, .col-span-8,
  .col-span-9, .col-span-12 { grid-column: span 1; }

  /* Card / KPI */
  .card { padding: 14px; }
  .kpi { padding: 14px; }
  .kpi__value { font-size: 24px; }

  /* Alert */
  .alert { flex-wrap: wrap; padding: 10px 12px; }

  /* Card head wrap */
  .card__head { flex-wrap: wrap; }

  /* Feature importance */
  .feat { grid-template-columns: 1fr 80px; gap: 6px; }
  .feat__bar { grid-column: 1 / -1; }

  /* Confusion matrix */
  .cm { grid-template-columns: 80px 1fr 1fr; }
  .cm__cell { padding: 10px; min-height: 70px; }
  .cm__cell-value { font-size: 20px; }

  /* Charts */
  .chart-box--md { height: 240px; }
  .chart-box--lg { height: 280px; }

  /* Table */
  .table th, .table td { padding: 8px 10px; font-size: 12px; }

  /* Chip row 가로 스크롤 */
  .chip-row { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .chip { flex-shrink: 0; }
}
