/* ============================================================
   MAIN.CSS — Layout & Components
   แก้ theme.css เพื่อเปลี่ยนสี, แก้ไฟล์นี้เพื่อเปลี่ยน layout
   ============================================================ */

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

body {
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  transition: background .25s, color .25s;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-2); border-radius: var(--radius-full); }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  z-index: 300;
  transition: width .22s ease;
  overflow: hidden;
}
.sidebar.is-collapsed { width: var(--sidebar-collapsed-width); }

/* Brand */
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  min-height: var(--header-height);
  overflow: hidden;
  white-space: nowrap;
}
.sidebar__brand-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}
.sidebar__brand-name { font-weight: 800; font-size: var(--font-size-md); color: var(--color-primary); }
.sidebar__brand-sub  { font-size: var(--font-size-xs); color: var(--color-text-3); margin-top: 1px; }

/* Toggle button */
.sidebar__toggle {
  position: absolute;
  top: 50%;
  right: -12px;
  transform: translateY(-50%);
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  color: var(--color-text-2);
  transition: background .15s, color .15s;
  z-index: 10;
  padding: 0;
}
.sidebar__toggle:hover { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* Nav */
.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-3) 0;
}
.sidebar__nav::-webkit-scrollbar { width: 3px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: var(--color-border-2); border-radius: 3px; }

.sidebar__group { margin-bottom: var(--space-4); }
.sidebar__group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--color-text-3);
  padding: 0 var(--space-4) var(--space-1);
  white-space: nowrap;
  overflow: hidden;
  opacity: 1;
  transition: opacity .2s;
}
.sidebar.is-collapsed .sidebar__group-label { opacity: 0; }

.sidebar__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  border-radius: 0;
  text-decoration: none;
  color: var(--color-text-2);
  font-size: var(--font-size-sm);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: background .12s, color .12s;
  position: relative;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.sidebar__item:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}
.sidebar__item--active {
  color: var(--color-primary);
  background: var(--color-primary-light);
  font-weight: 600;
}
.sidebar__item--active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--color-primary);
  border-radius: 0 2px 2px 0;
}
.sidebar__item--disabled {
  opacity: .45;
  cursor: default;
  pointer-events: none;
}
.sidebar__item-icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 32px;
  text-align: center;
  display: inline-flex; align-items: center; justify-content: center;
}
.sidebar__item-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity .15s;
}
.sidebar.is-collapsed .sidebar__item-text { opacity: 0; pointer-events: none; }

/* Badge in nav (e.g. BETA, NEW) */
.sidebar__badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 1px var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--color-primary-light);
  color: var(--color-primary);
  flex-shrink: 0;
  transition: opacity .15s;
}
.sidebar.is-collapsed .sidebar__badge { opacity: 0; }

/* Divider */
.sidebar__divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-2) var(--space-4);
}

/* Footer */
.sidebar__footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-3) 0;
}

/* Tooltip on collapsed */
.sidebar.is-collapsed .sidebar__item { position: relative; }
.sidebar.is-collapsed .sidebar__item:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(var(--sidebar-collapsed-width) + 8px);
  top: 50%; transform: translateY(-50%);
  background: var(--color-text);
  color: var(--color-surface);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  white-space: nowrap;
  pointer-events: none;
  z-index: 999;
  box-shadow: var(--shadow-md);
}

/* Mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 299;
  backdrop-filter: blur(1px);
}
.sidebar-overlay.is-visible { display: block; }

/* ── Main Wrapper (pushes right when sidebar open) ────────── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  transition: margin-left .22s ease;
  min-height: 100vh;
}
.main-wrapper.sidebar-collapsed { margin-left: var(--sidebar-collapsed-width); }

/* ── Header ───────────────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-6);
  gap: var(--space-4);
}
.header__brand { display: flex; align-items: center; gap: var(--space-3); }
.header__icon  { font-size: 1.75rem; }
.header__title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-primary);
  white-space: nowrap;
}
.header__subtitle {
  font-size: var(--font-size-xs);
  color: var(--color-text-2);
}
.header__controls { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

/* ── Main Layout ──────────────────────────────────────────── */
.page { padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-5); max-width: 1600px; margin: 0 auto; }

/* ── KPI Cards ────────────────────────────────────────────── */
.kpi-section {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-4);
}
@media (max-width: 1024px) { .kpi-section { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px)  { .kpi-section { grid-template-columns: repeat(2, 1fr); } }

.kpi-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  position: relative; overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-card__label { font-size: var(--font-size-xs); color: var(--color-text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi-card__value { font-size: var(--font-size-2xl); font-weight: 800; margin: var(--space-1) 0; line-height: 1; }
.kpi-card__sub   { font-size: var(--font-size-xs); color: var(--color-text-3); }

.kpi-card--green { background: var(--color-kpi-green-bg); border-color: var(--color-complete); }
.kpi-card--green .kpi-card__value { color: var(--color-kpi-green); }

.kpi-card--blue  { background: var(--color-kpi-blue-bg); border-color: var(--color-inprogress); }
.kpi-card--blue  .kpi-card__value { color: var(--color-kpi-blue); }

.kpi-card--red   { background: var(--color-kpi-red-bg); border-color: var(--color-blocked); }
.kpi-card--red   .kpi-card__value { color: var(--color-kpi-red); }

.kpi-card--gray  { background: var(--color-kpi-gray-bg); }
.kpi-card--gray  .kpi-card__value { color: var(--color-kpi-gray); }

/* KPI overall progress bar */
.kpi-progress {
  margin-top: var(--space-2);
  height: 6px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.kpi-progress__bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width .6s ease;
}

/* ── Charts Section ───────────────────────────────────────── */
.charts-section {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-4);
}
@media (max-width: 900px) { .charts-section { grid-template-columns: 1fr; } }

.chart-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.chart-card__header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
}
.chart-card__title { font-size: var(--font-size-md); font-weight: 600; }
.chart-card__body  { padding: var(--space-4); }
.chart-card__body--center { display: flex; justify-content: center; align-items: center; }

/* ── Table Section ────────────────────────────────────────── */
.table-section { }

.table-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table-card__header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: var(--space-2);
}
.table-card__title { font-size: var(--font-size-md); font-weight: 600; }
.table-card__hint  { font-size: var(--font-size-xs); color: var(--color-text-3); }
.table-card__body  { }

.table-wrapper { overflow-x: auto; }

table.progress-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-xs);
  white-space: nowrap;
}
table.progress-table th {
  background: var(--color-surface-2);
  color: var(--color-text-2);
  font-weight: 600;
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 2px solid var(--color-border);
  position: sticky; top: 0;
}
table.progress-table th.step-col {
  text-align: center;
  min-width: 36px;
  width: 36px;
  padding: var(--space-2) var(--space-1) var(--space-3);
  vertical-align: bottom;
  height: 140px;
}
.step-col__text {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  display: block;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 130px;
  margin: 0 auto;
}
table.progress-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
table.progress-table tr:hover td { background: var(--color-surface-2); }
table.progress-table tr:last-child td { border-bottom: none; }
table.progress-table td.col-name {
  min-width: 180px;
  white-space: normal;
  word-break: break-word;
  line-height: 1.4;
}

/* Step toggle (checkbox style) */
.step-toggle {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-border-2);
  background: var(--color-surface);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: transparent;
  transition: border-color .15s, background .15s, transform .1s;
  margin: 0 auto;
  outline: none;
}
.step-toggle:hover {
  border-color: var(--color-complete);
  background: var(--color-complete-bg);
  transform: scale(1.12);
}
.step-toggle--checked {
  background: var(--color-complete);
  border-color: var(--color-complete);
  color: #fff;
}
.step-toggle--checked:hover {
  background: var(--color-blocked);
  border-color: var(--color-blocked);
  color: #fff;
  transform: scale(1.12);
}

/* ETA badge */
.eta-badge {
  display: inline-block;
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  font-weight: 500;
}
.eta-badge--past { background: var(--color-blocked-bg); color: var(--color-blocked); }

/* Progress bar in table */
.bar-wrap {
  width: 60px; height: 6px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: var(--space-1);
}
.bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  transition: width .4s;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover { background: var(--color-primary-dark); }
.btn--ghost { background: transparent; border-color: var(--color-border); color: var(--color-text); }
.btn--ghost:hover { background: var(--color-surface-2); }
.btn--danger { background: var(--color-blocked-bg); color: var(--color-blocked); border-color: var(--color-blocked); }
.btn--danger:hover { background: var(--color-blocked); color: #fff; }
.btn--icon { padding: var(--space-2); width: 36px; height: 36px; justify-content: center; border-color: var(--color-border); background: var(--color-surface); }
.btn--sm { padding: var(--space-1) var(--space-2); font-size: var(--font-size-xs); }

/* ── Form Controls ────────────────────────────────────────── */
.select, .input, .textarea {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  padding: var(--space-2) var(--space-3);
  transition: border-color .15s;
  outline: none;
}
.select:focus, .input:focus, .textarea:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(29,78,216,.15); }
.select--full, .input--full, .textarea { width: 100%; }
.textarea { resize: vertical; }
.range { width: 100%; accent-color: var(--color-primary); }

.form-group { margin-bottom: var(--space-3); }
.form-label { display: block; font-size: var(--font-size-xs); font-weight: 600; color: var(--color-text-2); margin-bottom: var(--space-1); text-transform: uppercase; letter-spacing: .04em; }
.form-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
@media (max-width: 480px) { .form-grid { grid-template-columns: 1fr; } }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 480px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  animation: modalIn .15s ease;
}
.modal--wide { max-width: 680px; }
@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(-8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal__header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal__title  { font-size: var(--font-size-md); font-weight: 700; }
.modal__close  { background: none; border: none; cursor: pointer; font-size: 1.25rem; color: var(--color-text-3); line-height: 1; padding: var(--space-1); border-radius: var(--radius-sm); }
.modal__close:hover { color: var(--color-text); background: var(--color-surface-2); }
.modal__body   { padding: var(--space-5) var(--space-6); overflow-y: auto; flex: 1; }
.modal__footer { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--color-border); display: flex; align-items: center; gap: var(--space-2); }

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: var(--space-6); right: var(--space-6); z-index: 999;
  background: var(--color-text);
  color: var(--color-surface);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow-lg);
  animation: toastIn .2s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Detail View (Drill-down) ─────────────────────────────── */
.detail-header {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-4) 0;
  flex-wrap: wrap;
}
.detail-header__back {
  display: inline-flex; align-items: center; gap: var(--space-2);
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: var(--space-2) var(--space-4);
  color: var(--color-text-2); font-size: var(--font-size-sm); font-weight: 500;
  cursor: pointer; transition: all .15s; text-decoration: none;
}
.detail-header__back:hover { background: var(--color-primary-light); color: var(--color-primary); border-color: var(--color-primary); }
.detail-header__title { font-size: var(--font-size-lg); font-weight: 700; }
.detail-header__subtitle { font-size: var(--font-size-xs); color: var(--color-text-2); margin-top: 2px; }

/* Section cards on main dashboard — clickable */
.section-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-3);
}
.section-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  box-shadow: var(--shadow-sm);
}
.section-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--color-primary); }
.section-card__id   { font-size: var(--font-size-xs); font-weight: 700; color: var(--color-primary); text-transform: uppercase; letter-spacing: .05em; }
.section-card__name { font-size: var(--font-size-sm); font-weight: 600; margin: var(--space-1) 0; line-height: 1.3; }
.section-card__meta { font-size: var(--font-size-xs); color: var(--color-text-3); }
.section-card__bar  { margin-top: var(--space-3); height: 6px; background: var(--color-border); border-radius: var(--radius-full); overflow: hidden; }
.section-card__bar-fill { height: 100%; background: var(--color-primary); border-radius: var(--radius-full); transition: width .5s ease; }
.section-card__pct  { font-size: var(--font-size-xs); font-weight: 700; color: var(--color-primary); margin-top: var(--space-1); }

/* Section Cards strip on main */
.section-strip-title {
  font-size: var(--font-size-md); font-weight: 600;
  margin-bottom: var(--space-3);
}

/* ── Loading / Empty ──────────────────────────────────────── */
.loading { padding: var(--space-10); text-align: center; color: var(--color-text-3); }
.empty   { padding: var(--space-8); text-align: center; color: var(--color-text-3); font-size: var(--font-size-sm); }

/* ── Badge ────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
}
.badge--section { background: var(--color-primary-light); color: var(--color-primary-dark); }

/* Task status badge */
.task-status {
  display: inline-block;
  padding: 3px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  white-space: nowrap;
}
.task-status--not_started  { background: var(--color-pending-bg);    color: var(--color-pending);    }
.task-status--in_progress  { background: var(--color-inprogress-bg); color: var(--color-inprogress); }
.task-status--completed    { background: var(--color-complete-bg);   color: var(--color-complete);   }

/* ── Edit icon button in table ────────────────────────────── */
.edit-btn {
  background: none; border: none; cursor: pointer;
  color: var(--color-text-3); padding: 2px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  transition: color .15s;
}
.edit-btn:hover { color: var(--color-primary); }

/* ── Steps legend ─────────────────────────────────────────── */
.legend { display: flex; gap: var(--space-4); flex-wrap: wrap; padding: var(--space-3) var(--space-5); border-top: 1px solid var(--color-border); }
.legend-item { display: flex; align-items: center; gap: var(--space-1); font-size: var(--font-size-xs); color: var(--color-text-2); }
.legend-dot { width: 12px; height: 12px; border-radius: var(--radius-sm); }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — Tablet & Mobile
   ══════════════════════════════════════════════════════════ */

/* ── Sidebar Mobile ───────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .22s ease, width .22s ease;
    width: var(--sidebar-width) !important; /* always full width on mobile */
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-wrapper,
  .main-wrapper.sidebar-collapsed { margin-left: 0 !important; }
  .sidebar__toggle { display: none; } /* hide collapse btn on mobile */
}

/* ── Tablet (≤ 900px) ─────────────────────────────────────── */
@media (max-width: 900px) {
  .header {
    flex-wrap: wrap;
    height: auto;
    padding: var(--space-3) var(--space-4);
    gap: var(--space-2);
  }
  .header__brand { flex: 1; min-width: 0; }
  .header__title { font-size: var(--font-size-md); }
  .header__controls {
    width: 100%;
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  .header__controls .select { flex: 1; min-width: 120px; }

  .page {
    padding: var(--space-4);
    gap: var(--space-4);
  }

  .kpi-section {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
  }
  .kpi-section > .kpi-card:first-child {
    grid-column: 1 / -1;
  }

  /* Charts: already stacked via existing media query */
  .chart-card__body--center canvas {
    max-width: 240px;
    max-height: 240px;
  }

  .section-cards {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

/* ── Mobile (≤ 640px) ─────────────────────────────────────── */
@media (max-width: 640px) {
  .header__icon { font-size: 1.4rem; }
  .header__title { font-size: var(--font-size-sm); }
  .header__subtitle { display: none; }
  .header__controls .select {
    font-size: var(--font-size-xs);
    padding: var(--space-1) var(--space-2);
  }

  .page { padding: var(--space-3); gap: var(--space-3); }

  .kpi-section {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-2);
  }
  .kpi-section > .kpi-card:first-child { grid-column: 1 / -1; }
  .kpi-card { padding: var(--space-3) var(--space-4); }
  .kpi-card__value { font-size: var(--font-size-xl); }

  .chart-card__header { padding: var(--space-3) var(--space-4); }
  .chart-card__title  { font-size: var(--font-size-sm); }
  .chart-card__body   { padding: var(--space-3); }
  .chart-card__body--center canvas {
    max-width: 200px;
    max-height: 200px;
  }

  .table-card__header { padding: var(--space-3) var(--space-4); flex-direction: column; align-items: flex-start; }
  .table-card__title  { font-size: var(--font-size-sm); }

  /* Sticky Tag column so name stays visible while scrolling steps */
  table.progress-table th:first-child,
  table.progress-table td:first-child {
    position: sticky;
    left: 0;
    background: var(--color-surface);
    z-index: 2;
    box-shadow: 2px 0 6px rgba(0,0,0,.08);
  }
  table.progress-table tr:hover td:first-child { background: var(--color-surface-2); }

  /* Larger touch targets for step cells */
  .step-cell {
    width: 30px;
    height: 30px;
    font-size: 11px;
  }

  .section-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-2);
  }
  .section-card { padding: var(--space-3); }
  .section-card__name { font-size: var(--font-size-xs); }

  /* Modal slides up from bottom on mobile */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-width: 100%;
    max-height: 92vh;
    animation: modalUp .2s ease;
  }
  @keyframes modalUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
  }
  .form-grid { grid-template-columns: 1fr; }

  .btn--primary, .btn--ghost { font-size: var(--font-size-xs); padding: var(--space-2) var(--space-3); }
  .toast { right: var(--space-3); left: var(--space-3); bottom: var(--space-4); text-align: center; }
}

/* ── Small mobile (≤ 375px) ──────────────────────────────── */
@media (max-width: 375px) {
  .header__controls .select { display: none; }
  .kpi-section { grid-template-columns: 1fr 1fr; }
  .section-cards { grid-template-columns: 1fr; }
}

/* ── LV Compact Table & Row Expand ──────────────────────── */
.lv-compact-table { table-layout: auto; }
.lv-compact-table .col-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* step dots */
.step-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--color-pending);
  opacity: 0.45;
  flex-shrink: 0;
}
.step-dot--done {
  background: var(--color-complete);
  opacity: 1;
}

/* row hover */
.lv-row:hover td { background: var(--color-surface-2); }
.lv-row--open td { background: var(--color-surface-2); }

/* expand body */
.lv-expand-row td { padding: 0 !important; border-bottom: 2px solid var(--color-primary); }
.lv-expand-body {
  padding: var(--space-3) var(--space-4) var(--space-4);
  background: var(--color-surface-2);
}

/* step grid inside expand */
.lv-steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-2) var(--space-3);
}
.lv-step-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}
.lv-step-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-2);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── LV Step Modal ───────────────────────────────────────── */
.lv-sm-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  transition: background .15s;
}
.lv-sm-row:hover { background: var(--color-surface-2); }
.lv-sm-row--done { opacity: 0.55; }
.lv-sm-row--current { background: color-mix(in srgb, var(--color-primary) 6%, transparent); }

.lv-sm-btn {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text-2);
  cursor: pointer;
  transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.lv-sm-btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.lv-sm-btn--done {
  background: var(--color-complete);
  border-color: var(--color-complete);
  color: #fff;
}

.lv-sm-info { flex: 1; min-width: 0; }
.lv-sm-name {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lv-sm-party {
  font-size: var(--font-size-xs);
  color: var(--color-text-3);
  margin-top: 1px;
}

.lv-sm-badge {
  font-size: 0.7em;
  background: var(--color-primary);
  color: #fff;
  border-radius: 20px;
  padding: 2px 8px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── LV Table: Current Step cell ────────────────────────── */
.lv-step-cell { max-width: 200px; }
.lv-cur-step {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-size: var(--font-size-xs);
  color: var(--color-text-2);
  white-space: nowrap;
}
.lv-cur-step__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
  display: inline-block;
}

/* ── LV Minimal Dot Steps ────────────────────────────────── */
.lv-step-th { width: 28px; min-width: 28px; padding: 4px 2px !important; text-align: center; }
.lv-step-th th { font-size: 0.7em; color: var(--color-text-3); }

.lv-dot {
  display: inline-block;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--color-border-2);
  background: transparent;
  cursor: pointer;
  transition: all .12s;
  padding: 0;
  vertical-align: middle;
}
.lv-dot:hover { border-color: var(--color-primary); background: var(--color-primary-light); }
.lv-dot--done {
  background: var(--color-complete);
  border-color: var(--color-complete);
}

/* row tint by status */
.lv-row--in_progress td:first-child { border-left: 3px solid var(--color-inprogress); }
.lv-row--completed  td:first-child { border-left: 3px solid var(--color-complete); }

/* sticky columns */
.col-sticky {
  position: sticky;
  left: 0;
  background: var(--color-surface);
  z-index: 2;
}
.col-sticky--2 { left: 100px; }
.lv-row:hover .col-sticky { background: var(--color-surface-2); }

/* ── LV Step Popover ─────────────────────────────────────── */
#lvPopover {
  position: absolute;
  z-index: 500;
  width: 280px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.lv-pop-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
}
.lv-pop-kks  { font-weight: 700; font-size: var(--font-size-sm); color: var(--color-primary); }
.lv-pop-name { font-size: var(--font-size-xs); color: var(--color-text-1); margin-top: 1px; line-height: 1.3; }
.lv-pop-meta { font-size: 10px; color: var(--color-text-3); margin-top: 2px; }
.lv-pop-count { font-size: var(--font-size-xs); font-weight: 600; color: var(--color-text-2); white-space: nowrap; }
.lv-pop-close {
  background: none; border: none; cursor: pointer;
  color: var(--color-text-3); font-size: 12px; padding: 2px 4px;
  border-radius: var(--radius-sm);
}
.lv-pop-close:hover { background: var(--color-surface); color: var(--color-text); }

.lv-pop-list { max-height: 280px; overflow-y: auto; padding: 4px 0; }
.lv-pop-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
}
.lv-pop-row:hover { background: var(--color-surface-2); }
.lv-pop-row--done { opacity: 0.5; }
.lv-pop-label { font-size: var(--font-size-xs); color: var(--color-text-2); }

/* name clickable */
.lv-name-btn {
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
  color: inherit;
}
.lv-name-btn:hover { color: var(--color-primary); }
