/* KFC Order Center — Apple-style minimal, with dark-mode variants at the end. */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --border: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.12);
  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --text-faint: #a1a1a6;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-soft: rgba(0, 113, 227, 0.08);
  --success: #29c160;
  --warning: #ff9500;
  --danger: #ff3b30;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 6px 18px rgba(0, 0, 0, 0.05);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
               "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

/* ---------- Nav ---------- */
.nav {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.nav-brand {
  font-weight: 600;
  color: var(--text);
  font-size: 15px;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.nav-brand .brand-logo {
  width: 34px;
  height: 34px;
  display: block;
  border-radius: 50%;
  object-fit: cover;
}
.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}
.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}
.nav-link:hover { background: rgba(0,0,0,0.04); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-right { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.lang-toggle {
  display: flex;
  background: rgba(0,0,0,0.04);
  border-radius: 999px;
  padding: 2px;
}
.lang-toggle a {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 15px;
  line-height: 1.1;
  font-weight: 500;
  color: var(--text-muted);
  filter: saturate(0.85);
  transition: filter 0.12s, transform 0.12s;
}
.lang-toggle a:hover { filter: saturate(1); }
.lang-toggle a.active { filter: saturate(1); transform: scale(1.05); }
.lang-toggle a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Layout ---------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-header .subtitle { color: var(--text-muted); margin-top: 4px; font-size: 14px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); border-color: rgba(0,0,0,0.2); }
.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: white; }
.btn-ghost { border: none; background: transparent; }
.btn-ghost:hover { background: rgba(0,0,0,0.04); }
.btn-danger { color: var(--danger); border-color: rgba(255,59,48,0.3); }
.btn-danger:hover { background: rgba(255,59,48,0.06); }
/* Two-click confirmation pattern — first click arms the button (red),
   second click submits. Used on Close-order buttons. */
.confirm-arm {
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}
.confirm-arm.armed {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.confirm-arm.armed:hover {
  background: #d9302a;
  border-color: #d9302a;
}
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.card-lg { padding: 28px 32px; }
.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0;
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="datetime-local"],
select, textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 60px; }
input[type="file"] {
  font-size: 13px;
  padding: 6px;
}
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- Progress stepper ---------- */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 12px 0 28px;
}
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  flex: 1;
  text-decoration: none;
  color: inherit;
}
.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  z-index: 2;
}
.step-label {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: -0.005em;
}
.step.done .step-dot { background: var(--accent); border-color: var(--accent); color: white; }
.step.done .step-label { color: var(--text); }
.step.current .step-dot {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0,113,227,0.12);
}
.step.current .step-label { color: var(--accent); font-weight: 600; }
.step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 13px;
  left: 50%;
  right: -50%;
  height: 2px;
  background: var(--border-strong);
  z-index: 1;
}
.step.done:not(:last-child)::after { background: var(--accent); }

/* ---------- Progress bar (top of order card) ---------- */
.progress-bar {
  background: rgba(0,0,0,0.06);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}
.progress-fill {
  background: var(--accent);
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* ---------- Stage sections ---------- */
.stage-section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.stage-header {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}
.stage-header:hover { background: rgba(0, 0, 0, 0.02); }
.stage-header:active { background: rgba(0, 0, 0, 0.04); }
.stage-header .stage-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
  font-size: 13px;
}
.stage-header.done .stage-num { background: var(--accent); color: white; }
.stage-header h2 { flex: 1; }
.stage-body { padding: 20px 24px 24px; }

/* Collapse chevron — visual only; the whole .stage-header is the click target */
.collapse-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.stage-header:hover .collapse-btn { color: var(--text); }
.collapse-btn svg { width: 14px; height: 14px; transition: transform 0.2s; }
.stage-section.collapsed .stage-body { display: none; }
.stage-section.collapsed .stage-header { border-bottom: none; }
.stage-section.collapsed .collapse-btn svg { transform: rotate(-90deg); }

/* Slim banner that replaces stage 1 when an admin has hidden it */
.sampling-hidden-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 18px;
  margin-bottom: 16px;
  color: var(--text-muted);
}
.sampling-hidden-banner .banner-body { flex: 1; font-size: 13px; }
.sampling-hidden-banner .stage-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.05);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}

/* ---------- Deadline countdown ---------- */
.countdown-card {
  padding: 22px 24px 20px;
  position: relative;
}
.countdown-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}
.countdown-side { text-align: left; min-width: 0; }
.countdown-side-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.countdown-side-date {
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}
.countdown {
  grid-column: 2;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 22px;
}
.cd-segment { text-align: center; min-width: 56px; }
.cd-num {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 56px;
  font-weight: 500;
  color: var(--danger);
  font-variant-numeric: tabular-nums;
  line-height: 0.95;
  letter-spacing: -0.04em;
}
.cd-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-top: 8px;
}
.cd-sep {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 44px;
  font-weight: 300;
  color: var(--text-faint);
  align-self: flex-start;
  line-height: 1;
  margin-top: 4px;
}
@media (max-width: 720px) {
  .countdown-row { grid-template-columns: 1fr; gap: 12px; text-align: center; }
  .countdown-side { text-align: center; }
  .countdown { grid-column: auto; }
}
.countdown.overdue .overdue-prefix {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--danger);
  align-self: center;
  margin-right: 4px;
}

/* The little change-deadline link tucked under the countdown */
.countdown-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  font-size: 12px;
}
.countdown-meta details summary {
  cursor: pointer;
  color: var(--text-muted);
  list-style: none;
}
.countdown-meta details summary::-webkit-details-marker { display: none; }
.countdown-meta details summary:hover { color: var(--text); }
.countdown-meta details[open] summary { color: var(--text); }
.deadline-edit-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.deadline-edit-row input[type="date"] { max-width: 180px; }

.no-deadline-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  font-size: 13px;
  color: var(--text-muted);
}
.no-deadline-card form {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

/* ---------- Milestones card (sits below the stepper) ---------- */
.milestones-card {
  padding: 16px 22px 14px;
}
.milestones-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.milestones {
  list-style: none;
  padding: 0;
  margin: 0;
}
.milestone { border-bottom: 1px solid var(--border); }
.milestone:last-child { border-bottom: none; }
.milestone-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  margin: 0 -8px;
  font-size: 13px;
  color: inherit;
  text-decoration: none;
  border-radius: 6px;
  transition: background 0.12s;
}
.milestone-link:hover {
  background: rgba(0, 113, 227, 0.05);
  color: inherit;
}
.milestone-text { flex: 1; min-width: 0; }
.milestone-date {
  color: var(--text-faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  margin-left: 16px;
}
.milestone-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.milestone-done .milestone-dot { background: var(--success); }
.milestone-progress .milestone-dot { background: var(--warning); }
.milestone-todo .milestone-dot {
  background: transparent;
  border: 1.5px solid var(--text-faint);
}
.milestone-skip .milestone-dot {
  background: transparent;
  border: 1.5px dashed var(--border-strong);
}
.milestone-todo .milestone-text,
.milestone-skip .milestone-text { color: var(--text-muted); }

/* ---------- Order page 2-col grid (stages + sidebar) ---------- */
.order-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 960px) {
  .order-grid { grid-template-columns: 1fr; }
  .doc-sidebar { position: static !important; max-height: none !important; }
}
.doc-sidebar {
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.doc-sidebar h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 14px;
}
.doc-sidebar .count {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: rgba(0,0,0,0.05);
  padding: 2px 8px;
  border-radius: 999px;
}
.doc-sidebar .stage-group {
  margin-bottom: 14px;
}
.doc-sidebar .stage-group-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 6px;
  padding-left: 2px;
}
.doc-side-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  transition: background 0.12s;
}
.doc-side-item:hover { background: var(--accent-soft); }
.doc-side-item .ds-icon {
  width: 22px; height: 22px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px;
  font-weight: 600;
  flex-shrink: 0;
}
.doc-side-item .ds-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 500;
}
.doc-side-item .ds-dl {
  opacity: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: opacity 0.12s, background 0.12s;
}
.doc-side-item:hover .ds-dl { opacity: 1; }
.doc-side-item .ds-dl:hover { background: rgba(0,0,0,0.06); color: var(--text); }
.doc-sidebar .empty-small {
  text-align: center;
  color: var(--text-faint);
  padding: 24px 12px;
  font-size: 12px;
}

/* ---------- File row download button (alongside delete) ---------- */
.file-actions { display: flex; gap: 4px; align-items: center; }

/* ---------- Modal viewer ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px;
  animation: fadeIn 0.18s ease;
}
.modal-overlay.open { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 900px;
  height: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.4);
  animation: scaleIn 0.18s ease;
}
@keyframes scaleIn {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-body {
  flex: 1;
  overflow: auto;
  background: #1d1d1f;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-body img { max-width: 100%; max-height: 100%; display: block; }
.modal-body embed, .modal-body iframe { width: 100%; height: 100%; border: none; background: white; }
.modal-body pre {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 24px;
  background: white;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow: auto;
  text-align: left;
}
.modal-body .preview-fallback {
  color: white;
  text-align: center;
  padding: 40px;
}
.modal-body .preview-fallback .icon {
  font-size: 48px;
  opacity: 0.5;
  margin-bottom: 16px;
}
.modal-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(0,0,0,0.05);
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: rgba(0,0,0,0.1); color: var(--text); }

/* ---------- Order list ---------- */
.filter-pills { display: flex; gap: 6px; margin-bottom: 20px; }
.filter-pills a {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
}
.filter-pills a.active { background: var(--text); color: white; border-color: var(--text); }

.order-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 22px;
  margin-bottom: 12px;
  display: block;
  color: var(--text);
  transition: transform 0.12s, box-shadow 0.12s;
}
.order-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06), 0 12px 28px rgba(0,0,0,0.08);
  color: var(--text);
}
.order-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}
.order-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}
.order-number {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Pills/Tags ---------- */
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(0,0,0,0.06);
  color: var(--text-muted);
}
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-success { background: rgba(41,193,96,0.12); color: #1e8e4d; }
.pill-warning { background: rgba(255,149,0,0.14); color: #b56a00; }
.pill-danger { background: rgba(255,59,48,0.12); color: #c62b21; }

/* ---------- Pricing spreadsheet (Stage 2 default view) ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.price-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.price-grid th {
  text-align: left;
  font-weight: 500;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.price-grid td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.price-grid tr.price-row:hover { background: rgba(0, 0, 0, 0.015); }
.price-grid .pname { font-weight: 500; color: var(--text); }
.price-grid .submeta {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}
.price-grid .empty-cell { color: var(--text-faint); }
.price-grid .actions-col { text-align: right; white-space: nowrap; }

.spec-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  margin: 2px 4px 2px 0;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.spec-chip:hover { background: var(--accent); color: white; }

/* Slide-down edit row */
.price-edit-row { display: none; }
.price-edit-row.open { display: table-row; }
.price-edit-row > td {
  background: var(--surface-2);
  padding: 20px 20px 24px;
  border-bottom: 1px solid var(--border);
}
.edit-row-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 24px;
}
@media (max-width: 760px) {
  .edit-row-grid { grid-template-columns: 1fr; }
}
.edit-row-grid h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ---------- Document tiles (Stage 3 Order section) ---------- */
.doc-tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 640px) { .doc-tiles { grid-template-columns: 1fr; } }
.doc-tile {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.doc-tile-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 12px 16px 8px;
}
.doc-tile-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}
.doc-tile-file:first-of-type { border-top: none; }
.doc-tile-file:hover { background: rgba(0, 113, 227, 0.04); }
.doc-tile-icon {
  width: 40px; height: 40px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.doc-tile-meta { flex: 1; min-width: 0; }
.doc-tile-name {
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-tile-sub {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}
.doc-tile-actions {
  display: flex;
  gap: 2px;
  align-items: center;
}
.doc-tile-empty {
  padding: 24px 16px;
  text-align: center;
  border-top: 1px solid var(--border);
}
.doc-tile-empty .empty-icon {
  font-size: 32px;
  opacity: 0.4;
  margin-bottom: 8px;
}
.doc-tile-empty .empty-text {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 14px;
}
.doc-tile-empty .add-more {
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  text-align: center;
}

/* ---------- Order summary read-only grid ---------- */
.order-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px 24px;
  margin-bottom: 14px;
}
.summary-grid .cell label {
  display: block;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.summary-grid .cell .val {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}
.summary-grid .cell .val.empty { color: var(--text-faint); font-weight: 400; }
.summary-grid .cell.span-2 { grid-column: span 2; }

.order-edit-form {
  display: none;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-top: 16px;
}
.order-edit-form.open { display: block; }

/* ---------- Product blocks inside stages ---------- */
.product-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 12px;
  background: var(--surface-2);
}
.product-block h4 {
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ---------- File rows ---------- */
.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.file-row:last-child { border-bottom: none; }
.file-icon {
  width: 28px; height: 28px;
  background: var(--accent-soft);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}
.file-meta { flex: 1; }
.file-meta .filename { font-weight: 500; color: var(--text); }
.file-meta .submeta { color: var(--text-faint); font-size: 11px; }

/* ---------- Flash ---------- */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
}
.flash-error { background: rgba(255,59,48,0.08); color: #c62b21; }
.flash-success { background: rgba(41,193,96,0.1); color: #1e8e4d; }

/* ---------- Login ---------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #fafafa 0%, #f0f0f3 100%);
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 380px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.04), 0 24px 60px rgba(0,0,0,0.08);
}
.login-card h1 { font-size: 22px; margin-bottom: 0; }
.login-card .subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; }
.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
}
.login-logo {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* ---------- Misc ---------- */
.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.center { text-align: center; }
.right { text-align: right; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-end { display: flex; justify-content: flex-end; gap: 8px; }
.hidden { display: none; }

/* Empty state */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty .empty-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* Activity log */
.activity-row {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.activity-row:last-child { border-bottom: none; }
.activity-time { color: var(--text-faint); flex-shrink: 0; width: 90px; }
.activity-actor { color: var(--text); font-weight: 500; flex-shrink: 0; width: 100px; }
.activity-action { color: var(--text-muted); flex: 1; }

/* ============================================================
   Dark mode  (toggled via data-theme="dark" on <html>)
   ============================================================ */
[data-theme="dark"] {
  --bg: #1c1c1e;
  --surface: #2c2c2e;
  --surface-2: #3a3a3c;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --text: #f5f5f7;
  --text-muted: #98989d;
  --text-faint: #636366;
  --accent: #0a84ff;
  --accent-hover: #3395ff;
  --accent-soft: rgba(10, 132, 255, 0.18);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.3);
}

/* Surfaces / chrome ------------------------------------------- */
[data-theme="dark"] .nav { background: rgba(28, 28, 30, 0.78); }
[data-theme="dark"] .nav-link:hover { background: rgba(255, 255, 255, 0.06); }
[data-theme="dark"] .lang-toggle { background: rgba(255, 255, 255, 0.07); }
[data-theme="dark"] .filter-pills a { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .filter-pills a.active { background: var(--text); color: var(--bg); border-color: var(--text); }

[data-theme="dark"] .login-shell {
  background: linear-gradient(180deg, #1c1c1e 0%, #0a0a0b 100%);
}
[data-theme="dark"] .login-card {
  box-shadow: 0 4px 12px rgba(0,0,0,0.4), 0 24px 60px rgba(0,0,0,0.5);
}

/* Inputs -------------------------------------------------------- */
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="datetime-local"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder { color: var(--text-faint); }
[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.8); }

/* Buttons ------------------------------------------------------- */
[data-theme="dark"] .btn { background: var(--surface-2); border-color: var(--border-strong); }
[data-theme="dark"] .btn:hover { background: #48484a; border-color: rgba(255,255,255,0.25); }
[data-theme="dark"] .btn-ghost { background: transparent; border-color: transparent; }
[data-theme="dark"] .btn-ghost:hover { background: rgba(255, 255, 255, 0.06); }

/* Pills --------------------------------------------------------- */
[data-theme="dark"] .pill { background: rgba(255, 255, 255, 0.08); color: var(--text-muted); }
[data-theme="dark"] .pill-accent { background: rgba(10, 132, 255, 0.2); color: #5eb1ff; }
[data-theme="dark"] .pill-success { background: rgba(41, 193, 96, 0.18); color: #4dd084; }
[data-theme="dark"] .pill-warning { background: rgba(255, 149, 0, 0.2); color: #ffb84d; }
[data-theme="dark"] .pill-danger { background: rgba(255, 59, 48, 0.18); color: #ff6b62; }

/* Cards / sections / hovers ------------------------------------ */
[data-theme="dark"] .order-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.4), 0 12px 28px rgba(0,0,0,0.5);
}
[data-theme="dark"] .stage-header:hover { background: rgba(255, 255, 255, 0.03); }
[data-theme="dark"] .stage-header:active { background: rgba(255, 255, 255, 0.05); }
[data-theme="dark"] .price-grid tr.price-row:hover { background: rgba(255, 255, 255, 0.02); }
[data-theme="dark"] .doc-side-item:hover { background: rgba(10, 132, 255, 0.14); }
[data-theme="dark"] .doc-tile-file:hover { background: rgba(10, 132, 255, 0.08); }
[data-theme="dark"] .milestone-link:hover { background: rgba(10, 132, 255, 0.12); }
[data-theme="dark"] .product-block { background: rgba(255, 255, 255, 0.02); border-color: var(--border); }
[data-theme="dark"] .doc-tile { background: rgba(255, 255, 255, 0.02); border-color: var(--border); }
[data-theme="dark"] .sampling-hidden-banner {
  background: rgba(255, 255, 255, 0.02);
  border-color: var(--border-strong);
}

/* Flash messages ----------------------------------------------- */
[data-theme="dark"] .flash-error { background: rgba(255, 59, 48, 0.12); color: #ff6b62; }
[data-theme="dark"] .flash-success { background: rgba(41, 193, 96, 0.14); color: #4dd084; }

/* Stepper ------------------------------------------------------- */
[data-theme="dark"] .step-dot { background: var(--surface-2); border-color: var(--border-strong); }
[data-theme="dark"] .step.current .step-dot {
  background: var(--accent-soft);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.18);
}
[data-theme="dark"] .step:not(:last-child)::after { background: var(--border-strong); }

/* Modal viewer body keeps its dark backdrop; tweak fallback text */
[data-theme="dark"] .modal-close { background: rgba(255, 255, 255, 0.06); }
[data-theme="dark"] .modal-close:hover { background: rgba(255, 255, 255, 0.12); color: var(--text); }

/* Confirmation address bar / lang toggle scoping --------------- */
[data-theme="dark"] .lang-toggle a.active { background: var(--surface-2); color: var(--text); }
[data-theme="dark"] .countdown-side-date { color: var(--text); }

/* The theme toggle button itself */
.theme-toggle {
  width: 28px; height: 28px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, transform 0.12s;
  font-size: 13px;
  line-height: 1;
}
.theme-toggle:hover { background: rgba(0, 0, 0, 0.05); transform: scale(1.08); }
.theme-toggle::before { content: "🌙"; }
[data-theme="dark"] .theme-toggle::before { content: "☀️"; }
[data-theme="dark"] .theme-toggle:hover { background: rgba(255, 255, 255, 0.08); }
