/* ─── Google Font ────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ─── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── CSS Variables ──────────────────────────────────────────── */
:root {
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --nav-bg: #0f172a;
  --nav-h: 56px;

  /* Status colors */
  --c-success:  #16a34a;
  --c-blue:     #2563eb;
  --c-amber:    #d97706;
  --c-red:      #dc2626;
  --c-purple:   #7c3aed;
  --c-gray:     #94a3b8;

  --radius: 8px;
  --radius-sm: 6px;

  /* Text hierarchy */
  --text-sub:   #475569;
  --text-muted: #94a3b8;
}

html, body {
  font-family: var(--font);
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ─── Navbar ──────────────────────────────────────────────────── */
.navbar {
  height: var(--nav-h);
  background: var(--nav-bg);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid #1e293b;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.nav-brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 2px;
  flex-shrink: 0;
  color: #fff;
}

.nav-version {
  font-size: 10px;
  color: #64748b;
  font-weight: 400;
  margin-left: 4px;
}

.nav-links {
  display: flex;
  gap: 2px;
  flex: 1;
}

.nav-links a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  min-height: 44px;
  display: flex;
  align-items: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.nav-links a:hover { color: #fff; background: #1e293b; }
.nav-links a.active { color: #fff; background: #334155; }

.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.user-badge {
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 20px;
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid #334155;
}

.user-badge.role-manager  { background: #1e3a5f; color: #93c5fd; border-color: #2563eb; }
.user-badge.role-qc       { background: #14532d; color: #86efac; border-color: #16a34a; }
.user-badge.role-supervisor { background: #3b0764; color: #d8b4fe; border-color: #7c3aed; }
.user-badge.role-worker   { background: #1e293b; color: #cbd5e1; border-color: #475569; }

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dc2626;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: 10px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  margin-left: 3px;
  vertical-align: middle;
  line-height: 1;
}

/* ─── Main Content ────────────────────────────────────────────── */
.main-content {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}

/* ─── Page Header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-wrap: balance;
}

.page-actions {
  display: flex;
  gap: 8px;
}

/* ─── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  padding: 16px;
}

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 14px;
  min-height: 44px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s;
  line-height: 1.4;
}

.btn:hover { background: #f1f5f9; border-color: #94a3b8; }
.btn:active { background: #e2e8f0; }

.btn-primary {
  background: #1e293b;
  color: #fff;
  border-color: #1e293b;
}
.btn-primary:hover { background: #0f172a; border-color: #0f172a; }

.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 5px; }
.btn-full { width: 100%; }

.btn:disabled,
.btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ─── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 5px;
}

.form-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 13px;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

select.form-input { height: 38px; }
textarea.form-input { resize: vertical; }

/* ─── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge-done     { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.badge-active   { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.badge-qc       { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.badge-locked   { background: #f1f5f9; color: #94a3b8; border-color: #e2e8f0; }
.badge-rejected { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }

/* ─── Tables ──────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.data-table th {
  background: #f8fafc;
  color: var(--muted);
  padding: 8px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  border-bottom: 1px solid #f1f5f9;
  padding: 10px 12px;
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }

/* ─── Section Label ───────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

/* ─── Flash Messages ──────────────────────────────────────────── */
.flash-container { margin-bottom: 16px; }

.flash-msg {
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  transition: opacity 0.4s;
  border: 1px solid transparent;
}

.flash-msg { background: #1e293b; color: #fff; }
.flash-msg.success { background: #dcfce7; color: #15803d; border-color: #86efac; }
.flash-msg.error   { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.flash-msg.warning { background: #fef3c7; color: #92400e; border-color: #fcd34d; }

/* ─── KPI Cards (Dashboard) ───────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px)  { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kpi-num {
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.kpi-trend {
  font-size: 11px;
  font-weight: 600;
  min-height: 16px;
}
.kpi-card.green  .kpi-trend .trend-up,
.kpi-card.purple .kpi-trend .trend-up   { color: var(--c-success); }
.kpi-trend .trend-up                    { color: var(--c-success); }
.kpi-trend .trend-down                  { color: var(--c-red); }
.kpi-trend .trend-flat                  { color: var(--text-muted); font-weight: 400; }

.kpi-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 500;
}

/* Live clock */
.dash-topbar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px; justify-content: flex-end;
}
.dash-clock {
  font-size: 13px; font-weight: 600; color: var(--text-sub);
  font-variant-numeric: tabular-nums;
}

.kpi-card.warn .kpi-num   { color: var(--c-red); }
.kpi-card.blue .kpi-num   { color: var(--c-blue); }
.kpi-card.green .kpi-num  { color: var(--c-success); }
.kpi-card.amber .kpi-num  { color: var(--c-amber); }
.kpi-card.purple .kpi-num { color: #7c3aed; }

/* ─── Kanban Board ────────────────────────────────────────────── */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 900px) { .kanban-board { grid-template-columns: 1fr; } }

.kanban-col {
  background: #f1f5f9;
  border-radius: var(--radius);
  padding: 12px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
}

/* 카드 목록 영역: 고정 높이 + 내부 스크롤 */
.kanban-col-body {
  flex: 1;
  overflow-y: auto;
  max-height: 480px;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}
.kanban-col-body::-webkit-scrollbar { width: 4px; }
.kanban-col-body::-webkit-scrollbar-track { background: transparent; }
.kanban-col-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.kanban-col-header {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 10px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kanban-col-header .col-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.12);
  border-radius: 10px;
  min-width: 20px;
  height: 20px;
  font-size: 11px;
  padding: 0 5px;
}

.kanban-col.col-inprogress { border-top: 3px solid var(--c-blue); }
.kanban-col.col-inprogress .kanban-col-header { color: var(--c-blue); }

.kanban-col.col-qcwait { border-top: 3px solid var(--c-amber); }
.kanban-col.col-qcwait .kanban-col-header { color: var(--c-amber); }

.kanban-col.col-done { border-top: 3px solid var(--c-success); }
.kanban-col.col-done .kanban-col-header { color: var(--c-success); }

.kanban-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  margin-bottom: 5px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  font-size: 11px;
}

.kanban-card:last-child { margin-bottom: 0; }

.kanban-card-title {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 2px;
  color: var(--text);
  text-decoration: none;
  display: inline-block;
  padding: 4px 0;
  min-height: 28px;
  line-height: 1.4;
}

.kanban-card-title:hover { color: var(--c-blue); }

.kanban-card-sub {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 4px;
}

/* ─── Progress Bar ────────────────────────────────────────────── */
.prog-wrap {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  width: 80px;
}

.prog-fill      { height: 100%; background: var(--c-success); float: left; }
.prog-fill-qc   { height: 100%; background: var(--c-amber); float: left; }
.prog-fill-warn { height: 100%; background: var(--c-red); float: left; }

/* ─── Dashboard Charts ────────────────────────────────────────── */
.chart-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.chart-bars { display: flex; align-items: flex-end; gap: 3px; height: 130px; }
.chart-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; }
.chart-bar-stack { width: 100%; display: flex; flex-direction: column; justify-content: flex-end; height: 90px; }
.bar-seg { width: 100%; }
.bar-completed { background: var(--c-success); }
.bar-qc { background: var(--c-amber); }
.bar-wo { background: #7c3aed; }
.chart-nums { display:flex; flex-direction:column; align-items:center; gap:2px; margin-bottom:3px; }
.chart-num-c { font-size:11px; font-weight:800; color:#fff; background:#16a34a;
               line-height:1; padding:2px 5px; border-radius:4px; white-space:nowrap; }
.chart-num-w { font-size:11px; font-weight:800; color:#fff; background:#7c3aed;
               line-height:1; padding:2px 5px; border-radius:4px; white-space:nowrap; }
.chart-label { font-size: 9px; color: var(--muted); margin-top: 3px; }
.chart-cur { outline: 2px dashed #334155; border-radius: 2px; }

.section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ─── Side Panel ──────────────────────────────────────────────── */
.side-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.dist-bar-wrap { margin-bottom: 8px; }
.dist-label { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; margin-bottom: 3px; font-weight: 500; }
.dist-bar-bg { background: #e2e8f0; height: 6px; border-radius: 3px; overflow: hidden; }
.dist-bar-fill { height: 6px; background: var(--c-success); }

.alert-item {
  border-left: 3px solid var(--c-red);
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 12px;
  background: #fff5f5;
  border-radius: 0 4px 4px 0;
}

.alert-item.warn { border-left-color: var(--c-amber); background: #fffbeb; }

.qc-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12px;
  gap: 8px;
}

.qc-item:last-child { border-bottom: none; }

.recent-item {
  padding: 5px 0;
  font-size: 12px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--muted);
}

.recent-item:last-child { border-bottom: none; }

/* ─── Dashboard Layout ────────────────────────────────────────── */
.dash-row { display: flex; gap: 20px; }
.dash-main { flex: 1; min-width: 0; }
.dash-side { width: 280px; flex-shrink: 0; }

@media (max-width: 1024px) {
  .dash-row { flex-direction: column; }
  .dash-side { width: 100%; }
}

/* ─── Step Progress Bar ───────────────────────────────────────── */
.step-progress-wrap {
  margin-bottom: 24px;
}

.step-progress-bar {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.step-pip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.step-pip-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.step-pip-label {
  font-size: 10px;
  color: var(--muted);
  max-width: 60px;
  text-align: center;
  line-height: 1.2;
}

.step-pip.done .step-pip-circle   { background: #dcfce7; border-color: var(--c-success); color: var(--c-success); }
.step-pip.active .step-pip-circle { background: #1e293b; border-color: #1e293b; color: #fff; }
.step-pip.qc .step-pip-circle     { background: #fef3c7; border-color: var(--c-amber); color: var(--c-amber); }
.step-pip.rejected .step-pip-circle { background: #fee2e2; border-color: var(--c-red); color: var(--c-red); }
.step-pip.active .step-pip-label  { color: var(--text); font-weight: 600; }

.step-connector {
  height: 2px;
  flex: 1;
  min-width: 16px;
  background: var(--border);
  margin-bottom: 18px;
}

.step-connector.done { background: var(--c-success); }

/* ─── History Timeline ────────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 16px;
}

.timeline-dot {
  position: absolute;
  left: -22px;
  top: 10px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--border);
}

.timeline-dot.done     { background: var(--c-success); box-shadow: 0 0 0 2px #dcfce7; }
.timeline-dot.active   { background: var(--c-blue);    box-shadow: 0 0 0 2px #dbeafe; }
.timeline-dot.qc       { background: var(--c-amber);   box-shadow: 0 0 0 2px #fef3c7; }
.timeline-dot.rejected { background: var(--c-red);     box-shadow: 0 0 0 2px #fee2e2; }

.timeline-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 12px;
}

/* ─── Login ───────────────────────────────────────────────────── */
.login-body {
  background: #0f172a;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-wrap { width: 100%; max-width: 420px; }

.login-box {
  background: #fff;
  border-radius: 12px;
  padding: 36px 32px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.4);
}

.login-header { text-align: center; margin-bottom: 28px; }
.login-logo { font-size: 30px; font-weight: 700; letter-spacing: 4px; color: #0f172a; }
.login-subtitle { font-size: 12px; color: #94a3b8; margin-top: 4px; }

.role-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.role-btn { cursor: pointer; }
.role-btn input[type="radio"] { display: none; }

.role-btn span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  color: #64748b;
  transition: all 0.15s;
  background: #f8fafc;
}

.role-btn:hover span { border-color: #94a3b8; color: #334155; background: #f1f5f9; }

.role-btn input:checked + span {
  background: #0f172a;
  color: #fff;
  border-color: #0f172a;
}

/* ─── WO List (worker) ────────────────────────────────────────── */
.wo-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow 0.15s;
  position: relative;
}

.wo-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

/* 카드 전체를 탭 가능하게 (절대 위치 오버레이 링크) */
.wo-card-link {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: var(--radius);
}
/* 버튼 영역은 오버레이 위에 */
.wo-card-actions {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ─── Checklist card ──────────────────────────────────────────── */
.checklist-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.1s;
  min-height: 48px;
}

.checklist-item:last-child { border-bottom: none; }
.checklist-item:hover { background: #f8fafc; }
.checklist-item.checked { background: #f0fdf4; }
.checklist-item.checked .checklist-text { color: var(--muted); text-decoration: line-through; }

.checklist-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
  cursor: pointer;
  accent-color: #1e293b;
}

.checklist-text {
  font-size: 13px;
  line-height: 1.5;
  flex: 1;
}

/* ─── Sticky complete button (mobile) ────────────────────────── */
.sticky-complete-wrap {
  display: none;
}
@media (max-width: 768px) {
  .sticky-complete-wrap {
    display: block;
    position: sticky;
    bottom: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    margin: 0 -16px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
    z-index: 100;
  }
  /* 모바일에서 인라인 완료 버튼 숨김 (sticky 버튼만 사용) */
  #complete-btn { display: none !important; }
  .checklist-item {
    padding: 16px;
    min-height: 56px;
    gap: 14px;
  }
  .checklist-item input[type="checkbox"] {
    width: 24px;
    height: 24px;
    margin-top: 0;
  }
  .checklist-text { font-size: 14px; }
  .worker-steps-layout { flex-direction: column; }
  .worker-step-list { width: 100%; }
}

.option-group-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--c-amber);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 16px 4px;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
}

/* ─── Dashboard now_hour ──────────────────────────────────────── */
.now_hour { outline: 2px dashed #334155; border-radius: 2px; }

/* ─── Supervisor / QC layout ──────────────────────────────────── */
.approval-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

/* ─── Template Mgmt ───────────────────────────────────────────── */
.tmpl-layout { display: flex; gap: 20px; }
.tmpl-list-col { width: 220px; flex-shrink: 0; }
.tmpl-detail-col { flex: 1; min-width: 0; }

.tmpl-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  margin-bottom: 2px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.1s;
}

.tmpl-item:hover { background: #f1f5f9; }
.tmpl-item.active { background: #1e293b; color: #fff; font-weight: 600; }
.tmpl-item.active .tmpl-inactive-dot { color: #94a3b8; }

/* ─── History layout ──────────────────────────────────────────── */
.history-layout { display: flex; gap: 20px; }
.history-list-col { width: 320px; flex-shrink: 0; }
.history-detail-col { flex: 1; min-width: 0; }

.wo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 12px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  transition: background 0.1s, box-shadow 0.1s;
}

.wo-row:hover { background: #f8fafc; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.wo-row.active { border-left: 3px solid #1e293b; background: #f8fafc; }
.wo-row.completed { background: #f8fafc; }

/* ─── Worker steps layout ─────────────────────────────────────── */
.worker-steps-layout { display: flex; gap: 20px; }
.worker-step-list { width: 260px; flex-shrink: 0; }
.worker-step-detail { flex: 1; min-width: 0; }

/* ─── Worker step rows ────────────────────────────────────────── */
.step-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: all 0.1s;
  min-height: 48px;
}
.step-row:hover  { background: #f8fafc; border-color: #94a3b8; }
.step-row.active { border-color: #1e293b; background: #f8fafc; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.step-row.locked { color: #94a3b8; cursor: default; background: #f8fafc; }
.step-row.done   { background: #f0fdf4; border-color: #bbf7d0; }
.step-row.awaiting { border-color: #fde68a; background: #fffbeb; }
.step-row.rejected { border-color: #fca5a5; background: #fff5f5; color: #dc2626; }

@media (max-width: 768px) {
  .step-row { padding: 14px; min-height: 60px; font-size: 14px; }
}

/* ─── Checklist reference photo ───────────────────────────────── */
.cl-photo {
  max-width: 220px;
  max-height: 160px;
  margin-top: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  display: block;
  object-fit: cover;
  cursor: zoom-in;
}
.cl-caption {
  font-size: 11px;
  color: #64748b;
  font-style: italic;
  margin-top: 4px;
  padding: 4px 8px;
  border-left: 2px solid #e2e8f0;
}

/* ─── Navbar mobile ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .nav-links { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .user-badge { display: none; }
}
@media (max-width: 640px) {
  .navbar {
    height: auto;
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 4px;
  }
  .nav-brand { order: 1; }
  .nav-user  { order: 2; margin-left: auto; gap: 4px; }
  .nav-user .btn { font-size: 11px; padding: 3px 7px; min-height: 32px; }
  .nav-links {
    order: 3;
    width: 100%;
    flex-wrap: wrap;
    overflow-x: unset;
    padding: 2px 0 4px;
    gap: 2px;
  }
  .nav-links a { font-size: 12px; padding: 5px 10px; min-height: 36px; }
}

/* ─── Mobile responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .history-layout   { flex-direction: column; }
  .history-list-col { width: 100%; }

  .tmpl-layout   { flex-direction: column; }
  .tmpl-list-col { width: 100%; }

  .main-content { padding: 16px 16px 40px; }
}
