/* OrderHub — unified WooCommerce fulfillment dashboard */
:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1e2530;
  --ink-soft: #5a6472;
  --line: #e3e7ec;
  --accent: #5b4fd6;
  --accent-ink: #fff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20,25,40,.06), 0 8px 24px rgba(20,25,40,.06);
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* ---------------- login ---------------- */
.login-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #241d52 0%, #4a3aa8 55%, #6d5be0 100%);
}
.login-card {
  background: var(--panel); border-radius: 16px; box-shadow: var(--shadow);
  padding: 40px 36px; width: 340px; text-align: center;
}
.login-logo { font-size: 40px; }
.login-card h1 { margin: 8px 0 2px; font-size: 24px; letter-spacing: -.02em; }
.login-sub { margin: 0 0 22px; color: var(--ink-soft); font-size: 13px; }
.login-card input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 8px;
  margin-bottom: 12px; font-size: 15px;
}
.login-card input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.login-error { color: #c0392b; font-size: 13px; min-height: 18px; margin-top: 10px; }

/* ---------------- chrome ---------------- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 10px 22px; position: sticky; top: 0; z-index: 30;
}
.brand { font-size: 17px; white-space: nowrap; }
.main-nav { display: flex; gap: 4px; }
.nav-btn {
  border: 0; background: transparent; padding: 8px 14px; border-radius: 8px;
  color: var(--ink-soft); font-weight: 600;
}
.nav-btn.active { background: #efedfc; color: var(--accent); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.store-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--ink-soft);
  display: inline-flex; align-items: center; gap: 6px;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--chip-color, #999); }
.chip.active { border-color: var(--chip-color, var(--accent)); color: var(--ink); background: #fff; box-shadow: inset 0 0 0 1px var(--chip-color, var(--accent)); }

.btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 8px;
  padding: 7px 13px; font-weight: 600; color: var(--ink);
}
.btn:hover { border-color: #c9cfd8; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-soft); }
.btn-block { width: 100%; padding: 11px; }
.btn-sm { padding: 4px 10px; font-size: 13px; }

.store-errors {
  margin: 10px 22px 0; padding: 10px 14px; border-radius: 8px;
  background: #fdf3e7; border: 1px solid #f0d9b8; color: #8a5a1a; font-size: 13px;
}

/* ---------------- views ---------------- */
.view { padding: 18px 22px 60px; max-width: 1500px; margin: 0 auto; }
.toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.status-tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.status-tab {
  border: 0; background: transparent; padding: 7px 12px; border-radius: 8px;
  color: var(--ink-soft); font-weight: 600; font-size: 13.5px;
}
.status-tab .count { opacity: .65; font-weight: 500; margin-left: 3px; }
.status-tab.active { background: var(--accent); color: #fff; }
.status-tab.active .count { opacity: .85; }
.search-wrap { margin-left: auto; }
.search-wrap.grow { flex: 1; margin-left: 0; }
.search-wrap input {
  width: 320px; max-width: 100%; padding: 9px 13px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel);
}
.search-wrap.grow input { width: 100%; }
.search-wrap input:focus { outline: 2px solid var(--accent); border-color: transparent; }

.table-wrap {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow-x: auto;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-soft); padding: 12px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: #fafbfc;
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: #f7f6fe; }
.data-table .num { text-align: right; }
.order-no { font-weight: 700; color: var(--accent); white-space: nowrap; }
.order-cust { color: var(--ink-soft); font-size: 13px; }
.items-cell { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); }
.date-cell { white-space: nowrap; color: var(--ink-soft); }

.store-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap;
  background: color-mix(in srgb, var(--chip-color, #888) 12%, #fff);
  color: color-mix(in srgb, var(--chip-color, #888) 80%, #000);
}
.store-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--chip-color, #888); }

.status-pill {
  display: inline-block; padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
  background: #e9ecf1; color: #46505d;
}
.status-pill.s-processing { background: #e2f4e8; color: #1e7c3c; }
.status-pill.s-completed { background: #e3ecfb; color: #2456a6; }
.status-pill.s-pending, .status-pill.s-pending-confirm { background: #fdf0d5; color: #94660c; }
.status-pill.s-on-hold { background: #fdeacc; color: #a05c0a; }
.status-pill.s-cancelled, .status-pill.s-failed { background: #fbe4e4; color: #ab2626; }
.status-pill.s-refunded { background: #eee7fb; color: #6636b8; }

.empty, .loading { padding: 46px; text-align: center; color: var(--ink-soft); }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 18px; color: var(--ink-soft); }

.prod-img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: #eef0f3; display: block; }
.stock-in { color: #1e7c3c; font-weight: 600; }
.stock-out { color: #ab2626; font-weight: 600; }
.stock-back { color: #a05c0a; font-weight: 600; }
.stock-edit { width: 70px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; }

/* ---------------- drawer ---------------- */
.drawer-overlay { position: fixed; inset: 0; background: rgba(15,18,30,.42); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(680px, 96vw); z-index: 50;
  background: var(--bg); box-shadow: -12px 0 40px rgba(15,18,30,.25);
  display: flex; flex-direction: column;
}
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 18px 22px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-size: 19px; }
.drawer-subtitle { color: var(--ink-soft); font-size: 13px; margin-top: 3px; display: flex; gap: 8px; align-items: center; }
.drawer-body { overflow-y: auto; padding: 18px 22px 60px; flex: 1; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } }
.addr { font-size: 14px; line-height: 1.55; white-space: pre-line; }
.addr a { color: var(--accent); text-decoration: none; }

.li-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.li-table td { padding: 8px 0; border-bottom: 1px solid var(--line); }
.li-table tr:last-child td { border-bottom: 0; }
.li-qty { color: var(--ink-soft); white-space: nowrap; padding-right: 10px !important; }
.li-total { text-align: right; white-space: nowrap; }
.li-sku { color: var(--ink-soft); font-size: 12px; }
.totals-row td { font-weight: 600; }
.grand-total td { font-weight: 800; font-size: 15px; }

.form-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.form-row label { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.form-row select, .form-row input[type=text], .form-row input[type=date], .form-row textarea {
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.form-row textarea { width: 100%; min-height: 64px; resize: vertical; }
.checkbox-row { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--ink-soft); }

.note {
  border-left: 3px solid var(--line); padding: 8px 12px; margin-bottom: 10px;
  background: #fafbfc; border-radius: 0 8px 8px 0; font-size: 13.5px;
}
.note.customer { border-left-color: var(--accent); background: #f5f3fd; }
.note-meta { color: var(--ink-soft); font-size: 12px; margin-top: 4px; }
.tracking-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 12px; background: #f0f7f1; border: 1px solid #d3e8d7; border-radius: 8px; margin-bottom: 8px;
  font-size: 14px;
}
.customer-note-banner {
  background: #fdf6df; border: 1px solid #eedfa2; border-radius: 8px;
  padding: 10px 14px; font-size: 13.5px; margin-bottom: 14px;
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1e2530; color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 14px; z-index: 100; box-shadow: var(--shadow); max-width: 90vw;
}
.toast.err { background: #a82c2c; }
