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

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #222222;
  --surface3: #2a2a2a;
  --border: rgba(255,255,255,0.08);
  --border2: rgba(255,255,255,0.14);
  --text: #f0f0f0;
  --text2: #a0a0a0;
  --text3: #666666;
  --blue: #3b82f6;
  --blue-bg: rgba(59,130,246,0.15);
  --blue-text: #93c5fd;
  --green: #22c55e;
  --green-bg: rgba(34,197,94,0.15);
  --green-text: #86efac;
  --amber: #f59e0b;
  --amber-bg: rgba(245,158,11,0.15);
  --amber-text: #fcd34d;
  --coral: #ef4444;
  --coral-bg: rgba(239,68,68,0.15);
  --coral-text: #fca5a5;
  --purple: #8b5cf6;
  --purple-bg: rgba(139,92,246,0.15);
  --purple-text: #c4b5fd;
  --radius: 8px;
  --radius-lg: 12px;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; min-height: 100vh; }

/* Auth */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.auth-card { background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius-lg); padding: 2rem; width: 100%; max-width: 420px; }
.auth-logo { font-size: 20px; font-weight: 700; margin-bottom: 1.5rem; }
.auth-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 0.25rem; }
.auth-card p { color: var(--text2); font-size: 13px; margin-bottom: 1.5rem; }

/* Forms */
.form-field { margin-bottom: 1rem; }
.form-field label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.05em; }
.form-field input, .form-field select, .form-field textarea { width: 100%; padding: 10px 12px; font-size: 14px; border: 1px solid var(--border2); border-radius: var(--radius); background: var(--surface2); color: var(--text); outline: none; transition: border-color 0.15s; font-family: inherit; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--blue); }
.form-field textarea { min-height: 80px; resize: vertical; }
.form-field select option { background: var(--surface2); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; font-size: 13px; font-weight: 500; border: 1px solid var(--border2); border-radius: var(--radius); background: var(--surface2); color: var(--text); cursor: pointer; transition: all 0.12s; white-space: nowrap; font-family: inherit; }
.btn:hover { background: var(--surface3); border-color: var(--border2); }
.btn.primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn.primary:hover { background: #2563eb; border-color: #2563eb; }
.btn.danger { color: var(--coral-text); border-color: var(--coral-bg); }
.btn.danger:hover { background: var(--coral-bg); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.full { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.error-msg { color: var(--coral-text); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* App layout */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 1.5rem; display: flex; align-items: center; gap: 1rem; height: 54px; position: sticky; top: 0; z-index: 50; }
.topbar-logo { font-size: 16px; font-weight: 700; color: var(--text); white-space: nowrap; }
.topbar-nav { display: flex; gap: 2px; flex: 1; margin-left: 1rem; }
.nav-item { padding: 6px 12px; font-size: 13px; border-radius: var(--radius); color: var(--text2); cursor: pointer; border: none; background: none; transition: all 0.12s; font-family: inherit; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--blue-bg); color: var(--blue-text); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-pill { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text2); }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; background: var(--blue-bg); color: var(--blue-text); flex-shrink: 0; }
.main { padding: 1.5rem; max-width: 1200px; margin: 0 auto; }

/* Page header */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 20px; font-weight: 700; }
.page-header p { font-size: 13px; color: var(--text2); margin-top: 2px; }
.page-header-left { display: flex; flex-direction: column; }
.header-btns { display: flex; gap: 8px; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; }
.stat-label { font-size: 11px; color: var(--text3); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.stat-val { font-size: 28px; font-weight: 700; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; margin-bottom: 1rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text3); }

/* Table */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text2); padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface); white-space: nowrap; }
td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }
.tracking-mono { font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; }
.tracking-mono:hover { color: var(--blue-text); }
.cell-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-ordered { background: var(--blue-bg); color: var(--blue-text); }
.badge-transit { background: var(--amber-bg); color: var(--amber-text); }
.badge-out_for_delivery { background: var(--purple-bg); color: var(--purple-text); }
.badge-delivered { background: var(--green-bg); color: var(--green-text); }
.badge-delayed { background: var(--coral-bg); color: var(--coral-text); }
.carrier-tag { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.carrier-UPS { background: rgba(255,180,0,0.15); color: #fcd34d; }
.carrier-USPS { background: rgba(59,130,246,0.15); color: #93c5fd; }
.carrier-FedEx { background: rgba(139,92,246,0.15); color: #c4b5fd; }
.carrier-DHL { background: rgba(245,158,11,0.15); color: #fcd34d; }
.carrier-default { background: var(--surface3); color: var(--text2); }

/* Filter bar */
.filter-bar { display: flex; gap: 8px; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.search-box { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--border2); border-radius: var(--radius); background: var(--surface2); flex: 1; max-width: 340px; }
.search-box input { border: none; outline: none; font-size: 13px; background: none; color: var(--text); width: 100%; }
.search-box input::placeholder { color: var(--text3); }
.search-box svg { color: var(--text3); flex-shrink: 0; }
.filter-chip { padding: 6px 14px; font-size: 12px; border: 1px solid var(--border); border-radius: 20px; cursor: pointer; background: var(--surface2); color: var(--text2); transition: all 0.12s; font-family: inherit; }
.filter-chip:hover { border-color: var(--border2); color: var(--text); }
.filter-chip.active { background: var(--blue-bg); color: var(--blue-text); border-color: rgba(59,130,246,0.3); font-weight: 600; }

/* Tip box */
.tip-box { display: flex; gap: 10px; padding: 12px 14px; background: var(--blue-bg); border: 1px solid rgba(59,130,246,0.3); border-radius: var(--radius); margin-bottom: 1.25rem; font-size: 13px; color: var(--blue-text); }
.tip-box svg { flex-shrink: 0; margin-top: 1px; }

/* Bulk textarea */
.bulk-textarea { width: 100%; padding: 12px; font-family: 'SF Mono','Fira Code','Consolas',monospace; font-size: 13px; background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--radius); color: var(--text); min-height: 140px; resize: vertical; outline: none; line-height: 1.6; }
.bulk-textarea:focus { border-color: var(--blue); }
.bulk-textarea::placeholder { color: var(--text3); }
.bulk-count { font-size: 12px; color: var(--text3); margin-top: 4px; }
.field-hint { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* Vendor grid */
.vendor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.vendor-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem; cursor: pointer; transition: border-color 0.15s; }
.vendor-card:hover { border-color: var(--border2); }
.vendor-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.vendor-avatar { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.vendor-stats-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 10px; }
.vendor-stat { text-align: center; }
.vendor-stat-val { font-size: 17px; font-weight: 700; display: block; }
.vendor-stat-label { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.04em; }
.progress-bar { height: 3px; background: var(--surface3); border-radius: 2px; overflow: hidden; margin-top: 10px; }
.progress-fill { height: 100%; background: var(--green); border-radius: 2px; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200; align-items: center; justify-content: center; padding: 1rem; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border2); padding: 1.5rem; width: 100%; max-width: 580px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.modal-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.modal-title h3 { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.close-btn { background: none; border: none; cursor: pointer; color: var(--text3); padding: 4px; border-radius: 4px; font-size: 18px; line-height: 1; }
.close-btn:hover { background: var(--surface2); color: var(--text); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* Daily log */
.daily-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 1rem; }
.daily-date-display { font-size: 14px; font-weight: 600; padding: 7px 16px; background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius); color: var(--text); }
.daily-log-entry { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.daily-log-entry:last-child { border-bottom: none; }
.daily-log-entry input[type=checkbox] { margin-top: 3px; width: 16px; height: 16px; cursor: pointer; flex-shrink: 0; accent-color: var(--blue); }
.received-label { font-size: 11px; color: var(--green-text); font-weight: 600; margin-top: 2px; }

/* Team */
.team-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.team-row:last-child { border-bottom: none; }
.role-badge { padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.role-admin { background: var(--blue-bg); color: var(--blue-text); }
.role-employee { background: var(--green-bg); color: var(--green-text); }
.role-viewer { background: var(--surface3); color: var(--text2); }

/* Activity */
.activity-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.activity-item:last-child { border-bottom: none; }
.activity-who { font-weight: 600; color: var(--blue-text); }
.activity-time { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* Timeline */
.timeline { padding-left: 8px; }
.tl-item { display: flex; gap: 12px; padding-bottom: 14px; position: relative; }
.tl-item::before { content: ''; position: absolute; left: -4px; top: 8px; bottom: -6px; width: 1px; background: var(--border2); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; margin-left: -9px; }
.tl-dot.done { background: var(--green); }
.tl-dot.active { background: var(--blue); box-shadow: 0 0 0 3px var(--blue-bg); }
.tl-dot.pending { background: var(--surface3); }

/* Empty state */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text3); font-size: 13px; }

/* Toast */
.toast { position: fixed; bottom: 1.5rem; right: 1.5rem; background: var(--surface3); color: var(--text); border: 1px solid var(--border2); padding: 10px 18px; border-radius: var(--radius); font-size: 13px; z-index: 999; opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--coral-bg); color: var(--coral-text); border-color: var(--coral-bg); }

/* Last updated */
.last-updated { font-size: 12px; color: var(--text3); }

@media (max-width: 700px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .vendor-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .topbar-nav { display: none; }
  .main { padding: 1rem; }
}

/* Tracking panel */
.tracking-panel { background: var(--surface2); border-radius: var(--radius); padding: 1rem; margin-top: 1rem; }
.tracking-loading { display:flex; align-items:center; gap:8px; color:var(--text2); font-size:13px; }
.tracking-scan { display:flex; gap:12px; padding: 8px 0; border-bottom: 0.5px solid var(--border); font-size:12px; }
.tracking-scan:last-child { border-bottom:none; }
.scan-dot { width:8px; height:8px; border-radius:50%; background:var(--blue); flex-shrink:0; margin-top:4px; }
.scan-dot.delivered { background:var(--green); }
.scan-dot.exception { background:var(--coral); }
.track-link { display:inline-flex; align-items:center; gap:6px; color:var(--blue-text); font-size:13px; text-decoration:none; }
.track-link:hover { text-decoration:underline; }

/* Warehouse stages */
.warehouse-stages { display:flex; gap:8px; flex-wrap:wrap; margin-top:1rem; padding-top:1rem; border-top:1px solid var(--border); }
.stage-btn { display:flex; flex-direction:column; align-items:center; gap:4px; padding:10px 14px; border-radius:var(--radius); border:1px solid var(--border2); background:var(--surface2); cursor:pointer; font-size:12px; color:var(--text2); min-width:100px; transition:all 0.15s; font-family:inherit; }
.stage-btn:hover { border-color:var(--border2); background:var(--surface3); }
.stage-btn.done { background:var(--green-bg); border-color:rgba(34,197,94,0.3); color:var(--green-text); }
.stage-btn.done .stage-icon { color:var(--green); }
.stage-btn .stage-icon { font-size:18px; margin-bottom:2px; }
.stage-btn .stage-by { font-size:10px; opacity:0.7; margin-top:2px; }
.notify-row { display:flex; gap:8px; align-items:center; margin-top:10px; padding:10px; background:var(--surface2); border-radius:var(--radius); }
.notify-row input { flex:1; padding:7px 10px; font-size:13px; border:1px solid var(--border2); border-radius:var(--radius); background:var(--surface3); color:var(--text); outline:none; font-family:inherit; }
.notify-row input:focus { border-color:var(--blue); }

/* Platform selector buttons */
.platform-btn {
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text2);
  cursor: pointer;
  transition: all 0.12s;
  font-family: inherit;
  text-align: center;
}
.platform-btn:hover { background: var(--surface3); color: var(--text); border-color: var(--border2); }
.platform-btn.selected { background: var(--blue-bg); color: var(--blue-text); border-color: rgba(59,130,246,0.4); font-weight: 600; }
