/* Dashboard — production monitoring UI
   Brand: dark theme, DM Sans/Syne from landing page */

:root {
  --accent: #E8782A;
  --accent-dim: rgba(232, 120, 42, 0.15);
  --green: #2db67d;
  --amber: #f0a030;
  --red: #e84a3a;
  --bg-2: #111116;
  --bg-3: #18181f;
  --border: rgba(240, 236, 228, 0.08);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'DM Sans', sans-serif;
  font-weight: 300;
}

/* TOPBAR */
.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.topbar-sub {
  font-size: 0.75rem;
  color: var(--fg-muted);
  padding-left: 1rem;
  border-left: 1px solid var(--border);
}
.topbar-right {
  margin-left: auto;
  display: flex;
  gap: 1rem;
  align-items: center;
}
.topbar-link {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}
.topbar-link:hover { color: var(--fg); }

/* LAYOUT */
.layout { display: flex; flex: 1; }

/* SIDEBAR */
.sidebar {
  width: 180px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  background: var(--bg-2);
}
.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--fg-muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 400;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-btn:hover { background: var(--bg-3); color: var(--fg); }
.nav-btn.active { background: var(--accent-dim); color: var(--accent); }
.nav-btn svg { flex-shrink: 0; opacity: 0.7; }
.nav-btn.active svg { opacity: 1; }

/* CONTENT */
.content { flex: 1; padding: 2rem; min-width: 0; overflow-x: auto; }
section > .section-header {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 1.5rem;
}
section h2 {
  font-family: 'Syne', sans-serif; font-size: 1.25rem; font-weight: 700;
  letter-spacing: -0.01em; color: var(--fg);
}

/* STAT CARDS */
.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 1rem 1.25rem; min-width: 140px; flex: 1;
}
.stat-card.loading { display: flex; align-items: center; }
.stat-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--fg-muted); }
.stat-value { font-family: 'Syne', sans-serif; font-size: 1.75rem; font-weight: 700; color: var(--fg); margin-bottom: 0.25rem; }
.stat-sub { font-size: 0.75rem; color: var(--fg-muted); }
.stat-card.alert { border-color: var(--red); }
.stat-card.alert .stat-value { color: var(--red); }
.stat-card.ok .stat-value { color: var(--green); }

/* PANELS */
.panel { background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 0.875rem 1rem; border-bottom: 1px solid var(--border); }
.panel-header h3 { font-size: 0.875rem; font-weight: 600; color: var(--fg); }
.panel-header .btn { font-size: 0.75rem; }

/* DATA TABLES */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th {
  padding: 0.625rem 1rem; text-align: left;
  font-size: 0.7rem; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--fg-muted);
  border-bottom: 1px solid var(--border); background: var(--bg-3);
  white-space: nowrap;
}
.data-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.empty-row { text-align: center; color: var(--fg-muted); padding: 2rem !important; }
.td-mono { font-family: 'DM Mono', monospace; font-size: 0.8rem; }
.td-muted { color: var(--fg-muted); }

/* STATUS BADGES */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.6rem; border-radius: 20px;
  font-size: 0.7rem; font-weight: 500; white-space: nowrap;
}
.badge-pending    { background: rgba(138,135,153,0.15); color: var(--fg-muted); }
.badge-production { background: rgba(232,120,42,0.15);  color: var(--accent); }
.badge-at_facility{ background: rgba(245,158,11,0.15);  color: #f59e0b; }
.badge-in_transit { background: rgba(45,182,125,0.15);  color: var(--green); }
.badge-delivered  { background: rgba(45,182,125,0.25);  color: var(--green); font-weight: 600; }
.badge-delayed    { background: rgba(232,74,58,0.15);   color: var(--red); }
.badge-active     { background: rgba(232,120,42,0.15);  color: var(--accent); }
.badge-completed  { background: rgba(45,182,125,0.15);  color: var(--green); }
.badge-cancelled  { background: rgba(138,135,153,0.15); color: var(--fg-muted); }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 0.9rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg-3);
  color: var(--fg); font-family: 'DM Sans', sans-serif; font-size: 0.875rem;
  font-weight: 400; cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.btn:hover { background: var(--bg); border-color: var(--fg-muted); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.75rem; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-3); border-color: var(--border); }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: rgba(232,74,58,0.1); }
.icon-btn {
  background: none; border: none; cursor: pointer;
  color: var(--fg-muted); padding: 0.2rem; border-radius: 4px;
  font-size: 0.8rem; line-height: 1;
}
.icon-btn:hover { color: var(--fg); background: var(--bg-3); }

/* FILTERS */
.filter-row { display: flex; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
select {
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--fg); font-family: 'DM Sans', sans-serif; font-size: 0.875rem;
  padding: 0.4rem 0.75rem; border-radius: 6px; cursor: pointer;
}
select:focus { outline: none; border-color: var(--accent); }

/* FORM PANEL */
.form-panel {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 1.25rem; margin-bottom: 1.25rem;
}
.form-panel h4 {
  font-family: 'Syne', sans-serif; font-size: 0.95rem; font-weight: 700;
  margin-bottom: 1rem; color: var(--fg);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.875rem; }
.form-grid label { display: flex; flex-direction: column; gap: 0.35rem; }
.form-grid label span { font-size: 0.75rem; color: var(--fg-muted); }
.form-grid input, .form-grid select, .form-grid textarea {
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--fg); font-family: 'DM Sans', sans-serif; font-size: 0.875rem;
  padding: 0.5rem 0.75rem; border-radius: 6px; width: 100%;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  outline: none; border-color: var(--accent);
}
.form-grid textarea { resize: vertical; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 0.75rem; }

/* SKU LINE ROWS */
.sku-line { display: grid; grid-template-columns: 1fr 2fr 1fr 1fr auto; gap: 0.5rem; align-items: end; margin-bottom: 0.5rem; }
.sku-line input, .sku-line select {
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--fg); font-family: 'DM Sans', sans-serif; font-size: 0.875rem;
  padding: 0.4rem 0.6rem; border-radius: 6px;
}
.sku-line input:focus, .sku-line select:focus { outline: none; border-color: var(--accent); }

/* DELAY ALERT BANNER */
.alert-banner {
  display: flex; align-items: center; gap: 0.75rem;
  background: rgba(232,74,58,0.08); border: 1px solid rgba(232,74,58,0.25);
  border-radius: 8px; padding: 0.875rem 1rem; margin-bottom: 1rem;
  font-size: 0.875rem; color: var(--red);
}
.alert-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--red);
  flex-shrink: 0; animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* TOAST */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 1000;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.75rem 1.25rem; font-size: 0.875rem;
  color: var(--fg); max-width: 320px;
  transform: translateY(0.75rem); opacity: 0; transition: all 0.25s ease;
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: var(--red); color: var(--red); }
.toast.success { border-color: var(--green); color: var(--green); }

/* DAYS BADGE */
.days-overdue { font-family: 'DM Mono', monospace; font-size: 0.8rem; }
.days-overdue.hot { color: var(--red); font-weight: 500; }
.days-overdue.warm { color: var(--amber); }

/* EMPTY STATE */
.empty-section { text-align: center; padding: 3rem; color: var(--fg-muted); }
.empty-section p { font-size: 0.875rem; margin-top: 0.5rem; }

/* Edit/delete row actions */
.row-actions { display: flex; gap: 0.25rem; }

/* Responsive */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border); padding: 0.5rem; }
  .nav-btn { white-space: nowrap; font-size: 0.8rem; }
  .content { padding: 1rem; }
  .form-grid { grid-template-columns: 1fr; }
  .sku-line { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .data-table th, .data-table td { padding-left: 0.6rem; padding-right: 0.6rem; }
  .stat-card { min-width: 0; flex: 1 1 140px; }
  .topbar { padding: 0 0.75rem; gap: 0.5rem; }
  .topbar-sub { display: none; }
  .panel { min-width: 0; }
}

/* ─── Owner-Dashboard additions ────────────────────────────────────────────── */

/* Panel subtitle (right of the panel-header h3) */
.panel-sub {
  font-size: 0.72rem;
  color: var(--fg-muted);
  font-family: 'DM Mono', monospace;
}

/* KPI sparkline caption inside .stat-card */
.kpi-spark {
  font-size: 0.72rem;
  color: var(--fg-muted);
  margin-top: 0.15rem;
}

/* Stage pill — mirrors the design_stage.js#stageInfo color ramp */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 500;
  white-space: nowrap;
}
.status-pill.stage-pending     { background: rgba(138,135,153,0.15); color: var(--fg-muted); }
.status-pill.stage-concept     { background: rgba(232,120,42,0.15); color: var(--accent); }
.status-pill.stage-vectoring   { background: rgba(245,158,11,0.15); color: #f59e0b; }
.status-pill.stage-print-ready { background: rgba(45,182,125,0.15); color: var(--green); font-weight: 600; }

/* Inventory stock-state badges (colors align with the badge-* ramp) */
.badge-in_stock     { background: rgba(45,182,125,0.15); color: var(--green); }
.badge-reorder_soon { background: rgba(245,158,11,0.15); color: #f59e0b; }
.badge-out_of_stock { background: rgba(232,74,58,0.15); color: var(--red); font-weight: 600; }

/* Inventory bar cell — width set inline via --w */
.bar-cell {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 90px;
}
.bar-num { font-family: 'DM Mono', monospace; font-size: 0.78rem; color: var(--fg); }
.bar {
  --w: 0%;
  display: inline-block;
  width: 110px;
  max-width: 100%;
  height: 5px;
  border-radius: 3px;
  background: var(--bg-3);
  position: relative;
  overflow: hidden;
}
.bar::before {
  content: '';
  display: block;
  height: 100%;
  width: var(--w);
  border-radius: 3px;
  transition: width 0.25s ease;
}
.bar.bar-ok::before  { background: var(--green); }
.bar.bar-warm::before { background: #f59e0b; }
.bar.bar-hot::before { background: var(--red); }

/* Design-pipeline revision-count emphasis */
.revisions-warm { color: #f59e0b; font-weight: 500; font-family: 'DM Mono', monospace; font-size: 0.8rem; }
.revisions-hot  { color: var(--red);  font-weight: 600; font-family: 'DM Mono', monospace; font-size: 0.8rem; }

/* Supplier country pill */
.flag-pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  color: var(--fg-muted);
}

/* Quality rating (5 dots, .on = filled) */
.quality { display: inline-flex; gap: 0.2rem; }
.q-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--bg-3); border: 1px solid var(--border);
}
.q-dot.on { background: var(--accent); border-color: var(--accent); }

/* ─── Login wall (copied from public/css/admin-orders.css so /app stands alone) ── */
.login-wall {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  padding: 2rem;
}
.login-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
}
.login-title {
  font-family: 'Syne', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}
.login-sub {
  color: var(--fg-muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.login-input {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  padding: 0.7rem 1rem;
  outline: none;
  transition: border-color 0.15s;
}
.login-input::placeholder { color: var(--fg-muted); }
.login-input:focus { border-color: var(--accent); }
.login-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.7rem 1.5rem;
  cursor: pointer;
  transition: opacity 0.15s;
}
.login-btn:hover { opacity: 0.85; }
.login-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.login-error {
  color: var(--red);
  font-size: 0.8rem;
  display: none;
}
.login-error.visible { display: block; }

/* Mobile additions specific to owner-dashboard */
@media (max-width: 768px) {
  .login-wall { padding: 1rem; min-height: 60vh; }
  .login-card { padding: 1.5rem; }
  .bar { width: 90px; }
}