:root {
  /* Palette sampled from VastraVedukaLOGO.pdf: deep maroon-red, mustard
     gold, dark maroon-brown ink, and warm ivory — the same tones as the
     saree, the shirt, the mandala/text, and the card background. */
  --ink: #3a211d;
  --muted: #8a7368;
  --border: #e8dccb;
  --bg: #faf5ec;
  --card-bg: #fffdf9;
  --accent: #8f2430;
  --accent-dark: #6e1b24;
  --green: #15803d;
  --green-bg: #dcfce7;
  --amber: #96650b;
  --amber-bg: #fbead0;
  --red: #c1272d;
  --red-bg: #fbe3e1;
  --info: #3d5a73;
  --info-bg: #dde8ef;
  --wine: #7a3b52;
  --wine-bg: #f3e3ea;
  --accent-bg: #f3e0e1;
  --input-bg: #ffffff;
  --hover-bg: #f1e7d8;
  --spinner-track: #e2d3bf;
  --overlay: rgba(15, 18, 25, .45);
  --shadow: rgba(0, 0, 0, .25);
}
:root[data-theme="dark"] {
  /* Same brand hues, lifted in lightness/saturation so they still read
     clearly against a dark chocolate-brown background. */
  --ink: #f2e8de;
  --muted: #ab9689;
  --border: #4a382f;
  --bg: #1c1512;
  --card-bg: #251c18;
  --accent: #e0596d;
  --accent-dark: #c5495c;
  --green: #4ade80;
  --green-bg: #163220;
  --amber: #f2b84a;
  --amber-bg: #3a2b10;
  --red: #f77f7f;
  --red-bg: #3a1a1a;
  --info: #85b8dd;
  --info-bg: #172a3a;
  --wine: #dd9ab6;
  --wine-bg: #3a2530;
  --accent-bg: #3a2226;
  --input-bg: #2c221d;
  --hover-bg: #3a2b23;
  --spinner-track: #4a382f;
  --overlay: rgba(0, 0, 0, .6);
  --shadow: rgba(0, 0, 0, .5);
}
* { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  margin: 0;
  font-size: 13.5px;
  /* Faint logo watermark, fixed in the viewport so it stays put behind
     every screen (Active Orders, Trade Book, Settings) as you scroll. */
  background-color: var(--bg);
  background-image: url('logo-watermark.png');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 380px;
  background-attachment: fixed;
}
h1, h2, h3 { margin: 0 0 4px; }
h1 { font-size: 19px; }
h2 { font-size: 15px; }
.subtitle { color: var(--muted); margin: 0 0 16px; font-size: 12px; }

/* ---------- App shell ---------- */
.header-accent {
  height: 5px;
  background: linear-gradient(90deg, var(--accent), var(--amber), var(--info), var(--wine), var(--green));
  position: sticky; top: 0; z-index: 11;
}
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; background: var(--card-bg); border-bottom: 1px solid var(--border);
  position: sticky; top: 5px; z-index: 10;
}
.app-header .brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--card-bg), 0 0 0 3.5px var(--accent);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { font-weight: 800; font-size: 18px; color: var(--ink); }
.brand-subtitle { font-weight: 600; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tabs { display: flex; gap: 4px; }
.tabs button {
  background: transparent; border: none; padding: 8px 14px; border-radius: 8px;
  font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer;
}
.tabs button.active { background: var(--accent); color: #fff; }
.tabs button:hover:not(.active) { background: var(--hover-bg); }
.header-actions { display: flex; align-items: center; gap: 8px; }
.theme-toggle { padding: 8px 10px; font-size: 15px; line-height: 1; }
.signed-in-as { font-size: 11px; color: var(--muted); margin-right: 2px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.app-version { text-align: center; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); }

/* ---------- Login screen ---------- */
.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: var(--bg); margin: 0;
}
.login-card {
  width: 100%; max-width: 340px; background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 14px; padding: 32px 28px; box-shadow: 0 8px 24px var(--shadow);
}
.login-logo { display: block; width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 50%; object-fit: cover; }
.login-title { text-align: center; font-size: 18px; }
.login-subtitle { text-align: center; margin-bottom: 22px; }
.login-card .actions { justify-content: stretch; }
.login-card button.primary { width: 100%; }

.app-body { max-width: 1080px; margin: 0 auto; padding: 20px 24px 60px; }
.screen { display: none; }
.screen.active { display: block; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: 12px; color: var(--ink); }
input[type=text], input[type=tel], input[type=number], input[type=email], input[type=password],
select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; background: var(--input-bg); color: var(--ink);
}
textarea { resize: vertical; min-height: 54px; }
.row { display: flex; gap: 10px; }
.row > div { flex: 1; }
.hint { color: var(--muted); font-size: 11px; margin-top: 3px; }
fieldset { border: 1px solid var(--border); border-radius: 10px; margin: 16px 0 0; padding: 4px 14px 12px; }
legend { font-weight: 600; font-size: 12px; color: var(--ink); padding: 0 6px; }

/* ---------- Buttons ---------- */
button {
  font-family: inherit; font-size: 12.5px; font-weight: 600; border-radius: 8px;
  border: 1px solid var(--border); background: var(--input-bg); color: var(--ink);
  padding: 8px 14px; cursor: pointer;
}
button:hover { border-color: #d8c5ac; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: linear-gradient(135deg, var(--accent), #b23a30); border-color: var(--accent); color: white; }
button.primary:hover { background: var(--accent-dark); filter: brightness(1.05); }
button.subtle { background: transparent; border-color: transparent; color: var(--accent); padding: 6px 8px; }
/* Status-colored call-to-action buttons, so the action on a card always
   matches that status's color throughout (badge, left stripe, button). */
button.cta-amber { background: var(--amber); border-color: var(--amber); color: white; }
button.cta-info { background: var(--info); border-color: var(--info); color: white; }
button.cta-wine { background: var(--wine); border-color: var(--wine); color: white; }
button.cta-amber:hover, button.cta-info:hover, button.cta-wine:hover { filter: brightness(1.1); }
.actions { margin-top: 20px; display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.toolbar .right { display: flex; gap: 8px; }
.search { width: 260px; }

/* ---------- Filter bar (Trade Book date range + inline summary) ---------- */
.filter-bar {
  display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 14px;
}
.filter-bar > div { display: flex; flex-direction: column; }
.filter-bar label { margin: 0 0 4px; font-size: 11px; }
.filter-bar select, .filter-bar > div > input { width: auto; min-width: 150px; }
.filter-bar .row { gap: 10px; margin: 0; }
.filter-bar .row > div { display: flex; flex-direction: column; flex: none; }
.filter-bar .row input { min-width: 140px; }
.voided-toggle {
  display: flex; align-items: center; gap: 6px; margin: 0 0 4px; font-size: 12px;
  font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.voided-toggle input { width: auto; min-width: 0; cursor: pointer; }
/* Small read-only summary, tucked into the same card as the filters —
   pushed to the far right when there's room, wraps below on narrow screens. */
.trade-stats-inline {
  display: flex; flex-direction: row !important; flex-wrap: wrap; gap: 4px 16px;
  margin-left: auto; align-self: center; font-size: 12px; color: var(--muted);
}
.trade-stats-inline b { color: var(--ink); font-weight: 700; }
.trade-stats-inline .accent b { color: var(--accent); }
.trade-stats-inline .net b { font-weight: 800; }
.trade-stats-inline .net.positive b { color: var(--green); }
.trade-stats-inline .net.negative b { color: var(--red); }

/* ---------- Cards ---------- */
.card {
  background: var(--card-bg); border: 1px solid var(--border); border-left: 5px solid var(--border);
  border-radius: 10px 12px 12px 10px; padding: 14px 16px; margin-bottom: 10px;
}
/* Each order's left stripe matches its status color — same system as the badge. */
.card.status-Awaiting-Payment { border-left-color: var(--red); }
.card.status-Ready-to-Ship { border-left-color: var(--amber); }
.card.status-Label-Created { border-left-color: var(--info); }
.card.status-Label-Printed { border-left-color: var(--wine); }
.card.status-Tracking-Shared, .card.status-Delivered { border-left-color: var(--green); }
.card.status-Expense { border-left-color: var(--red); }
.card.status-Voided { border-left-color: var(--muted); opacity: .7; }

.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-title { font-weight: 700; font-size: 13.5px; }
.card-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 12px; color: var(--ink); }
.card-meta span b { color: var(--ink); font-weight: 600; }
.card-meta a { color: var(--accent); font-weight: 600; text-decoration: none; }
.card-meta a:hover { text-decoration: underline; }
.card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; align-items: center; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; color: #fff; }
.badge.status-Awaiting-Payment { background: var(--red); }
.badge.status-Ready-to-Ship { background: var(--amber); }
.badge.status-Label-Created { background: var(--info); }
.badge.status-Label-Printed { background: var(--wine); }
.badge.status-Tracking-Shared, .badge.status-Delivered { background: var(--green); }
.badge.status-Expense { background: var(--red); }
.badge.status-Voided { background: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--spinner-track); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.banner { border-radius: 8px; padding: 10px 12px; font-size: 12.5px; margin-bottom: 12px; }
.banner.error { background: var(--red-bg); color: var(--red); }
.banner.success { background: var(--green-bg); color: var(--green); }
.rate-list { border-top: 1px dashed var(--border); margin-top: 12px; padding-top: 10px; width: 100%; }
.rate-option { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; }
.rate-option .info { font-size: 12.5px; }
.rate-option .info b { font-size: 13px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay);
  display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background-color: var(--card-bg);
  background-image: url('logo-watermark.png');
  background-repeat: no-repeat;
  background-position: center 120px;
  background-size: 240px;
  border-radius: 14px; width: 100%; max-width: 560px;
  padding: 22px 24px 24px; box-shadow: 0 20px 60px var(--shadow);
}
/* The baked-in watermark alpha reads faint against a dark background, so
   dark mode swaps in a brighter, higher-alpha version of the same PNG. */
:root[data-theme="dark"] body,
:root[data-theme="dark"] .modal {
  background-image: url('logo-watermark-dark.png');
}
.modal.password-gate { max-width: 380px; }

/* ---------- Shippo mode switch + warning ---------- */
.mode-switch-row { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 400; }
.mode-switch { position: relative; display: inline-block; }
.mode-switch input { position: absolute; opacity: 0; width: 40px; height: 22px; margin: 0; cursor: pointer; }
.mode-switch-track {
  display: block; width: 40px; height: 22px; border-radius: 999px;
  background: var(--border); transition: background .15s ease; position: relative;
}
.mode-switch-thumb {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--card-bg); box-shadow: 0 1px 3px var(--shadow); transition: transform .15s ease;
}
.mode-switch input:checked + .mode-switch-track { background: var(--amber); }
.mode-switch input:checked + .mode-switch-track .mode-switch-thumb { transform: translateX(18px); }
.mode-switch input:focus-visible + .mode-switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.callout-warn {
  background: var(--amber-bg); color: var(--amber); border-radius: 8px;
  padding: 10px 12px; font-size: 12.5px; margin-top: 10px; line-height: 1.5;
}
