:root {
  --bg: #0f172a;
  --bg-alt: #172554;
  --panel: #ffffff;
  --muted: #64748b;
  --text: #0f172a;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --accent: #7c3aed;
  --page-bg: #f8fafc;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --success: #059669;
  --success-bg: #d1fae5;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --row-hover: #f1f5f9;
}
* { box-sizing: border-box; }
html, body { margin:0; padding:0; height:100%; font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; color:var(--text); background:var(--page-bg); }
a { color: var(--primary); text-decoration:none; }
a:hover { text-decoration: underline; }
.hidden { display:none !important; }

/* layout */
.shell { display:flex; flex-direction:column; min-height:100vh; }
.topbar {
  display:flex;
  align-items:flex-start;
  padding:12px 20px;
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, .18), transparent 28%),
    radial-gradient(circle at left center, color-mix(in srgb, var(--accent) 24%, transparent), transparent 24%),
    linear-gradient(135deg, var(--bg), var(--bg-alt));
  color:#f8fafc;
  gap:20px;
  border-bottom:1px solid rgba(255,255,255,.08);
  box-shadow:0 16px 40px rgba(15, 23, 42, .18);
}
.topbar .brand {
  display:flex;
  align-items:center;
  gap:12px;
  font-weight:800;
  font-size:16px;
  padding:10px 12px;
  border-radius:12px;
  background:rgba(255,255,255,.08);
  backdrop-filter: blur(10px);
}
.brand-title { line-height:1.2; }
.brand-logo {
  width:42px;
  height:42px;
  border-radius:10px;
  background:rgba(255,255,255,.12);
  border:1px solid rgba(255,255,255,.16);
  padding:4px;
  flex:0 0 auto;
}
.brand-logo-cover { object-fit:cover; }
.brand-logo-contain { object-fit:contain; }
.topbar .nav { display:flex; gap:12px; flex:1; flex-wrap:wrap; align-items:flex-start; }
.topbar .nav-section { position:relative; min-width:0; }
.topbar .nav-trigger {
  display:flex;
  align-items:center;
  gap:8px;
  padding:10px 14px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.06);
  color:#e2e8f0;
  font-weight:700;
  letter-spacing:.01em;
  min-width:160px;
  justify-content:space-between;
  transition:background .18s ease, border-color .18s ease, transform .18s ease;
}
.topbar .nav-trigger:hover,
.topbar .nav-section.active .nav-trigger,
.topbar .nav-section:hover .nav-trigger,
.topbar .nav-section:focus-within .nav-trigger {
  background:rgba(255,255,255,.13);
  border-color:rgba(255,255,255,.22);
  color:#fff;
  text-decoration:none;
  transform:translateY(-1px);
}
.topbar .nav-caret {
  font-size:11px;
  opacity:.78;
  transition:transform .18s ease;
}
.topbar .nav-section:hover .nav-caret,
.topbar .nav-section:focus-within .nav-caret {
  transform:rotate(180deg);
}
.topbar .nav-menu {
  position:absolute;
  top:calc(100% + 8px);
  left:0;
  min-width:220px;
  display:flex;
  flex-direction:column;
  gap:4px;
  padding:10px;
  border-radius:14px;
  border:1px solid rgba(148, 163, 184, .18);
  background:rgba(15, 23, 42, .96);
  box-shadow:0 20px 40px rgba(2, 6, 23, .35);
  opacity:0;
  transform:translateY(6px);
  pointer-events:none;
  transition:opacity .16s ease, transform .16s ease;
  z-index:20;
}
.topbar .nav-section:hover .nav-menu,
.topbar .nav-section:focus-within .nav-menu {
  opacity:1;
  transform:translateY(0);
  pointer-events:auto;
}
.topbar .nav a {
  color:#cbd5e1;
  padding:10px 12px;
  border-radius:10px;
  display:block;
}
.topbar .nav a.active,
.topbar .nav a:hover {
  background:rgba(59, 130, 246, .18);
  color:#fff;
  text-decoration:none;
}
.topbar .user { font-size:13px; color:#cbd5e1; }
.topbar .user button { margin-left:8px; }
.container { padding: 24px; max-width:1400px; width:100%; margin:0 auto; }

/* login page */
.login-wrap { display:flex; align-items:center; justify-content:center; height:100vh; background:linear-gradient(135deg, var(--bg), var(--bg-alt)); }
.login-box { background:var(--panel); padding:32px; border-radius:18px; width:360px; box-shadow: 0 20px 40px rgba(0,0,0,.25); border:1px solid rgba(255,255,255,.08); }
.login-box h1 { margin:0 0 4px; font-size:20px; }
.login-box p.subtitle { margin:0 0 20px; color:var(--muted); font-size:13px; }
.login-logo { display:block; width:72px; height:72px; object-fit:contain; margin:0 0 18px; border-radius:16px; background:rgba(255,255,255,.92); border:1px solid var(--border); padding:8px; }

/* cards */
.card {
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:18px;
  padding:16px 18px;
  margin-bottom:16px;
  box-shadow:0 14px 30px rgba(15, 23, 42, .05);
}
.card h2 { margin:0 0 12px; font-size:16px; }
.stat-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap:12px; }
.stat {
  background:#fff;
  border:1px solid var(--border);
  border-radius:16px;
  padding:14px 16px;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.75);
}
.stat .label { color:var(--muted); font-size:12px; text-transform:uppercase; letter-spacing:.06em; font-weight:700; }
.stat .value { font-size:24px; font-weight:800; margin-top:8px; }
.stat-sky { background:linear-gradient(135deg, #eff6ff, #dbeafe); border-color:#bfdbfe; }
.stat-sky .value { color:#1d4ed8; }
.stat-rose { background:linear-gradient(135deg, #fff1f2, #ffe4e6); border-color:#fecdd3; }
.stat-rose .value { color:#e11d48; }
.stat-violet { background:linear-gradient(135deg, #f5f3ff, #ede9fe); border-color:#ddd6fe; }
.stat-violet .value { color:#7c3aed; }
.stat-amber { background:linear-gradient(135deg, #fffbeb, #fef3c7); border-color:#fde68a; }
.stat-amber .value { color:#b45309; }
.stat-emerald { background:linear-gradient(135deg, #ecfdf5, #d1fae5); border-color:#a7f3d0; }
.stat-emerald .value { color:#059669; }
.stat-indigo { background:linear-gradient(135deg, #eef2ff, #e0e7ff); border-color:#c7d2fe; }
.stat-indigo .value { color:#4338ca; }
.booking-progress-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap:16px; margin-bottom:16px; }
.dashboard-widget-grid { display:grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap:16px; margin-bottom:16px; align-items:stretch; }
.dashboard-widget {
  min-height:220px;
  position:relative;
  overflow:hidden;
  grid-column: span 1;
  height:100%;
}
.dashboard-widget.widget-compact { grid-column: span 1; min-height:220px; }
.dashboard-widget.widget-wide { grid-column: span 1; min-height:220px; }
.dashboard-widget.widget-full { grid-column: span 1; min-height:220px; }
.dashboard-widget::before {
  content:"";
  position:absolute;
  inset:0;
  opacity:.9;
  pointer-events:none;
}
.dashboard-widget > * { position:relative; z-index:1; }
.dashboard-widget h2 {
  display:flex;
  align-items:center;
  justify-content:space-between;
  font-size:15px;
}
.dashboard-widget-header {
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  margin-bottom:12px;
  flex-wrap:wrap;
}
.dashboard-widget-header h2 { margin:0; }
.widget-vendor::before { background:linear-gradient(180deg, rgba(14, 165, 233, .10), rgba(255,255,255,0) 36%); }
.widget-asin::before { background:linear-gradient(180deg, rgba(168, 85, 247, .10), rgba(255,255,255,0) 36%); }
.widget-deadline::before { background:linear-gradient(180deg, rgba(249, 115, 22, .10), rgba(255,255,255,0) 36%); }
.widget-flow::before { background:linear-gradient(180deg, rgba(16, 185, 129, .10), rgba(255,255,255,0) 36%); }
.widget-fc::before { background:linear-gradient(180deg, rgba(59, 130, 246, .10), rgba(255,255,255,0) 36%); }
.dashboard-widget table { background:rgba(255,255,255,.88); border-radius:12px; overflow:hidden; }
.dashboard-widget th { background:rgba(248, 250, 252, .94); }
.toggle-group { display:flex; gap:6px; flex-wrap:wrap; }
.toggle-group button {
  padding:6px 10px;
  border-radius:999px;
  background:rgba(255,255,255,.72);
  border:1px solid var(--border);
  font-size:12px;
}
.toggle-group button.active {
  background:#0f172a;
  color:#fff;
  border-color:#0f172a;
}
.pie-widget { display:flex; align-items:center; gap:18px; flex-wrap:wrap; min-height: 200px; }
.pie-chart {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  display:flex;
  align-items:center;
  justify-content:center;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.55);
}
.pie-hole {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: rgba(255,255,255,.96);
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 800;
  color: var(--text);
}
.pie-legend { display:flex; flex-direction:column; gap:8px; min-width: 180px; }
.pie-legend-item { display:flex; align-items:center; gap:8px; font-size:13px; }
.pie-dot { width:12px; height:12px; border-radius:999px; display:inline-block; }
.booking-progress-card { border-width:2px; }
.booking-progress-card .stat { margin-bottom:0; }
.booking-progress-card.carton-progress { border-color:#22c55e; }
.booking-progress-card.qty-progress { border-color:#a855f7; }
.booking-progress-metrics { display:grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap:12px; }
.booking-progress-row { display:flex; justify-content:space-between; align-items:center; margin:12px 0 8px; gap:12px; }
.booking-progress-bar { height:10px; border-radius:999px; background:#e2e8f0; overflow:hidden; }
.booking-progress-fill { height:100%; border-radius:999px; background:linear-gradient(90deg, var(--primary), var(--primary-hover)); }
.carton-progress .booking-progress-fill { background:linear-gradient(90deg, #16a34a, #22c55e); }
.qty-progress .booking-progress-fill { background:linear-gradient(90deg, #7c3aed, #a855f7); }

/* forms and buttons */
label { display:block; font-size:12px; color:var(--muted); margin-bottom:4px; }
.inline-check { display:flex; align-items:center; gap:8px; margin-top:8px; font-size:13px; color:var(--text); }
.inline-check input[type=checkbox] { width:auto; margin:0; }
.role-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap:6px 12px; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width:100%; padding:8px 10px; border:1px solid var(--border); border-radius:6px; font-size:14px; background:#fff; color:var(--text);
}
input:focus, select:focus, textarea:focus { outline:2px solid var(--primary); outline-offset:-2px; }
button {
  padding:8px 14px; border-radius:6px; border:1px solid var(--border); background:#fff; cursor:pointer; font-size:13px;
}
button.primary { background:var(--primary); color:#fff; border-color:var(--primary); }
button.primary:hover { background:var(--primary-hover); }
button.danger { color:var(--danger); border-color:var(--danger); background:#fff; }
button.danger:hover { background:var(--danger-bg); }
button.ghost { background:transparent; }
button:disabled { opacity:0.5; cursor:not-allowed; }
.row { display:flex; gap:12px; flex-wrap:wrap; align-items:end; }
.row > div { flex:1; min-width:180px; }
.inline-form { display:flex; gap:8px; align-items:end; }

/* tables */
table { width:100%; border-collapse:collapse; font-size:13px; }
th, td { padding:8px 10px; text-align:left; border-bottom:1px solid var(--border); }
th { background:#f8fafc; font-weight:600; color:var(--muted); text-transform:uppercase; font-size:11px; letter-spacing:.03em; cursor:pointer; user-select:none; position:sticky; top:0; }
tbody tr:hover { background: var(--row-hover); }
tbody tr.po-urgent-row { background:#fff7ed; }
tbody tr.po-overdue-row { background:#fef2f2; }
tbody tr.po-cancelled-row { background:#f8fafc; }
tbody tr.stock-critical-row { background:#fff1f2; }
tbody tr.stock-priority-row { background:#ecfeff; }
tbody tr.stock-drr-row { background:#eff6ff; }
tbody tr.stock-medium-row { background:#fffbeb; }
td.num, th.num { text-align:right; font-variant-numeric: tabular-nums; }
.pill { display:inline-block; padding:2px 8px; border-radius:999px; font-size:11px; font-weight:500; }
.pill.active { background:var(--success-bg); color:var(--success); }
.pill.cancelled { background:var(--danger-bg); color:var(--danger); }
.pill.partial { background:var(--warn-bg); color:var(--warn); }
.pill.match { background:var(--success-bg); color:var(--success); }
.pill.mismatch { background:var(--danger-bg); color:var(--danger); }

/* toasts */
#toasts { position:fixed; bottom:20px; right:20px; display:flex; flex-direction:column; gap:8px; z-index:9999; }
.toast { background:#0f172a; color:#fff; padding:10px 14px; border-radius:8px; font-size:13px; box-shadow:0 8px 20px rgba(0,0,0,.2); }
.toast.error { background:var(--danger); }
.toast.success { background:var(--success); }

/* modals */
.modal-backdrop { position:fixed; inset:0; background:rgba(0,0,0,.45); display:flex; align-items:center; justify-content:center; z-index:1000; }
.modal { background:#fff; border-radius:10px; padding:20px 24px; width:500px; max-width:95vw; max-height:90vh; overflow:auto; }
.modal h3 { margin:0 0 12px; }
.modal .actions { display:flex; justify-content:flex-end; gap:8px; margin-top:16px; }

/* utility */
.spacer { flex:1; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--muted); font-size:12px; }
.scroll-x { overflow-x:auto; }
.qty-input { width: 80px; }
.small { font-size:11px; color:var(--muted); }
.warn-text { color:var(--warn); font-weight:600; }
.danger-text { color:var(--danger); font-weight:600; }
.stock-critical-text { color:#be123c; font-weight:700; }
.stock-priority-text { color:#0f766e; font-weight:700; }
.stock-drr-text { color:#1d4ed8; font-weight:700; }
.branding-intro { max-width:780px; line-height:1.5; }
.branding-editor-card { overflow:hidden; }
.branding-grid { display:grid; grid-template-columns: minmax(320px, 420px) minmax(320px, 1fr); gap:20px; align-items:start; }
.branding-form { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap:14px; }
.branding-preview-shell {
  border:1px solid var(--border);
  border-radius:20px;
  overflow:hidden;
  background:var(--page-bg);
  box-shadow:0 18px 36px rgba(15, 23, 42, .08);
}
.branding-preview-topbar {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  padding:18px 20px;
  color:#f8fafc;
  background:
    radial-gradient(circle at top right, rgba(56, 189, 248, .18), transparent 28%),
    radial-gradient(circle at left center, color-mix(in srgb, var(--accent) 24%, transparent), transparent 24%),
    linear-gradient(135deg, var(--bg), var(--bg-alt));
}
.branding-preview-body { padding:20px; }
.branding-preview-card { margin-top:16px; }
.branding-preview-user { font-size:13px; color:#cbd5e1; }
.branding-color-row { display:flex; gap:8px; align-items:center; }
.branding-color-input { width:52px !important; min-width:52px; height:40px; padding:2px; border-radius:10px; }
.branding-hex-input { font-family:ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-transform:uppercase; }
.branding-upload-actions { display:flex; gap:8px; margin:10px 0 6px; flex-wrap:wrap; }
.branding-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:18px; flex-wrap:wrap; }

/* tabs */
.tabs { display:flex; gap:4px; margin-bottom:12px; border-bottom:1px solid var(--border); }
.tabs button { background:none; border:none; padding:10px 14px; border-bottom:2px solid transparent; color:var(--muted); cursor:pointer; }
.tabs button.active { color:var(--primary); border-bottom-color:var(--primary); font-weight:600; }

@media (max-width: 720px) {
  .booking-progress-metrics { grid-template-columns: 1fr; }
  .booking-progress-row { flex-direction:column; align-items:flex-start; }
  .topbar { flex-direction:column; align-items:stretch; }
  .topbar .nav { width:100%; }
  .dashboard-widget-grid { grid-template-columns: 1fr; }
  .dashboard-widget, .dashboard-widget.widget-compact, .dashboard-widget.widget-wide, .dashboard-widget.widget-full { grid-column: auto; }
  .topbar .nav-section { width:100%; }
  .topbar .nav-trigger { width:100%; min-width:0; }
  .topbar .nav-menu { position:static; margin-top:8px; min-width:0; opacity:1; transform:none; pointer-events:auto; display:none; }
  .topbar .nav-section:hover .nav-menu,
  .topbar .nav-section:focus-within .nav-menu { display:flex; }
  .branding-grid { grid-template-columns: 1fr; }
  .branding-form { grid-template-columns: 1fr; }
}

@media (min-width: 721px) and (max-width: 1100px) {
  .dashboard-widget-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
