:root {
  --red: #C3161F; --red-deep: #8E0E17; --maroon: #3B0910; --yellow: #FFC81E; --saffron: #F7A31B;
  --paper: #FFFBF2; --cream: #FFF4DE; --text: #2A140E; --muted: #7A5A4C; --line: rgba(42, 20, 14, .12);
  --s-new: #C3161F; --s-confirmed: #B26A00; --s-packed: #6B4BB8; --s-shipped: #1F6FB2; --s-delivered: #2F7D32; --s-cancelled: #7A7A7A;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 400 15px/1.5 'DM Sans', system-ui, sans-serif; color: var(--text); background: var(--paper); }
h1, h2, h3 { font-family: 'Baloo 2', system-ui, sans-serif; color: var(--maroon); line-height: 1.1; }
a { color: var(--red); }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--text); font: 700 .88rem/1 'DM Sans', sans-serif; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--saffron); }
.btn--primary { background: linear-gradient(180deg, #FFE07A, var(--yellow) 50%, var(--saffron)); color: var(--maroon); border: 0; padding: 13px 18px; font-size: 1rem; justify-content: center; }
.btn--ghost { background: transparent; color: #FFE9B8; border-color: rgba(255, 233, 184, .35); }
.btn--red { background: var(--red); color: #fff; border-color: var(--red); }
.err { color: var(--red); font-weight: 600; min-height: 1.2em; margin: 0; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 50% 30%, #5E1220, var(--maroon) 60%, #1E0507); }
.login__card { width: min(380px, 100%); background: var(--paper); border-radius: 26px; padding: 30px; display: grid; gap: 14px; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .6); }
.login__card img { width: 170px; height: auto; margin: 0 auto; }
.login__card h1 { text-align: center; margin: 0; font-size: 1.6rem; }
.login__card label { display: grid; gap: 6px; font-weight: 700; font-size: .9rem; }
input, select, textarea { font: inherit; color: inherit; padding: 10px 12px; border-radius: 12px; border: 1.5px solid #E8D9C2; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--saffron); box-shadow: 0 0 0 3px rgba(247, 163, 27, .2); }

/* top bar */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 10px 24px; background: var(--maroon); color: #FFE9B8; }
.top__logo { height: 40px; width: auto; }
.top h1 { color: #fff; margin: 0; font-size: 1.4rem; }
.top__sync { font-size: .8rem; opacity: .7; }
.top__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.wrap { width: min(1320px, 100%); margin: 0 auto; padding: 22px 24px 60px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; }
.stat b { display: block; font: 800 2rem/1.1 'Baloo 2', sans-serif; color: var(--maroon); font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat--hot { background: var(--red); border-color: var(--red); }
.stat--hot b, .stat--hot span { color: #FFE9B8; }
.stat--hot b { color: var(--yellow); }
.packs-sum { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; font-size: .9rem; color: var(--muted); }
.packs-sum .chip { background: var(--cream); border: 1px solid var(--line); color: var(--text); border-radius: 999px; padding: 6px 12px; font-weight: 600; }
.packs-sum .chip b { color: var(--red); }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { border: 0; background: transparent; padding: 8px 12px; border-radius: 999px; font: 700 .85rem/1 'DM Sans', sans-serif; color: var(--muted); cursor: pointer; text-transform: capitalize; }
.tab[aria-selected="true"] { background: var(--maroon); color: #fff; }
.tab small { opacity: .7; margin-left: 4px; }
.search { width: min(340px, 100%); }
.table-wrap { overflow-x: auto; }
.orders { width: 100%; border-collapse: collapse; }
.orders th { text-align: left; font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 10px 14px; background: var(--cream); white-space: nowrap; }
.orders td { padding: 12px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.orders tbody tr { cursor: pointer; transition: background .15s; }
.orders tbody tr:hover { background: #FFF8EC; }
.orders tr.is-new td:first-child { box-shadow: inset 4px 0 0 var(--red); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.oid { font-weight: 800; color: var(--maroon); white-space: nowrap; }
.sub { display: block; color: var(--muted); font-size: .8rem; }
.items { font-size: .88rem; }
.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--cream); }
select.status { font-weight: 700; padding: 6px 10px; border-radius: 999px; text-transform: capitalize; border-width: 2px; }
.st-new { border-color: var(--s-new); color: var(--s-new); }
.st-confirmed { border-color: var(--s-confirmed); color: var(--s-confirmed); }
.st-packed { border-color: var(--s-packed); color: var(--s-packed); }
.st-shipped { border-color: var(--s-shipped); color: var(--s-shipped); }
.st-delivered { border-color: var(--s-delivered); color: var(--s-delivered); }
.st-cancelled { border-color: var(--s-cancelled); color: var(--s-cancelled); }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; margin: 0; }

/* drawer */
.drawer { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.drawer__scrim { position: absolute; inset: 0; background: rgba(30, 6, 4, .5); opacity: 0; transition: opacity .25s; }
.drawer__panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--paper); padding: 26px 24px 40px; overflow-y: auto; transform: translateX(100%); transition: transform .3s cubic-bezier(.2, .8, .2, 1); box-shadow: -20px 0 40px rgba(0, 0, 0, .2); }
.drawer.is-open { pointer-events: auto; }
.drawer.is-open .drawer__scrim { opacity: 1; }
.drawer.is-open .drawer__panel { transform: none; }
.drawer__x { position: absolute; top: 14px; right: 14px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--cream); font-size: 1.4rem; cursor: pointer; }
.d-head h2 { margin: 0; font-size: 1.7rem; }
.d-head p { margin: 2px 0 14px; color: var(--muted); }
.d-sec { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; }
.d-sec h3 { margin: 0 0 8px; font-size: 1.05rem; }
.d-sec p { margin: 2px 0; }
.d-line { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.d-line.t { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px; font-weight: 800; }
.d-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 14px; }
.d-hist { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
.d-hist li { padding: 3px 0 3px 16px; position: relative; text-transform: capitalize; }
.d-hist li::before { content: ''; position: absolute; left: 0; top: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--saffron); }
.d-note textarea { width: 100%; min-height: 80px; resize: vertical; }
.gift { background: var(--cream); border-left: 4px solid var(--yellow); padding: 8px 12px; border-radius: 8px; font-style: italic; }
.saved { color: #2F7D32; font-weight: 700; font-size: .85rem; margin-left: 8px; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .top { padding: 10px 16px; }
  .wrap { padding: 16px 16px 60px; }
  .orders thead { display: none; }
  .orders, .orders tbody, .orders tr, .orders td { display: block; width: 100%; }
  .orders tr { padding: 12px 14px; border-top: 1px solid var(--line); }
  .orders td { border: 0; padding: 3px 0; }
  .orders td.num { text-align: left; font-weight: 800; }
  .orders tr.is-new { box-shadow: inset 4px 0 0 var(--red); }
  .orders tr.is-new td:first-child { box-shadow: none; }
}

/* packing slip */
@media print {
  body > *:not(.drawer) { display: none !important; }
  .drawer, .drawer__panel { position: static; transform: none !important; box-shadow: none; width: 100%; padding: 0; }
  .drawer__scrim, .drawer__x, .d-actions, .d-note, .no-print { display: none !important; }
  .d-sec { break-inside: avoid; }
}
