:root {
  --brand: #d62e36;
  --brand-dark: #b1222a;
  --ink: #17191d;
  --ink-2: #4b5059;
  --muted: #7b818b;
  --line: #e6e8ec;
  --bg: #f4f5f7;
  --card: #fff;
  --side: #191b1f;
  --side-2: #24272d;
  --ok: #148a4a;
  --warn: #b56a00;
  --bad: #c42b2b;
  --r: 12px;
  --shadow: 0 1px 2px rgb(20 22 26 / 6%), 0 4px 14px rgb(20 22 26 / 5%);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.i { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 8px; color: var(--muted); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; border: 1px solid var(--line); border-radius: 9px; background: #fff; font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s; }
.btn:hover:not(:disabled) { border-color: #c9cdd3; background: #fafafa; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.danger { color: var(--bad); border-color: #f0c9c9; }
.btn.danger:hover:not(:disabled) { background: #fdf2f2; }
.btn.wide { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; color: inherit; }
.icon-btn:hover { background: rgb(127 127 127 / 14%); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* forms */
label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
input, select, textarea { width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid #d5d8de; border-radius: 9px; background: #fff; font-weight: 400; color: var(--ink); }
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgb(214 46 54 / 14%); }
input:disabled { background: var(--bg); color: var(--muted); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
form.card, .edit { display: grid; gap: 14px; align-content: start; }
.err { margin: 0; min-height: 1em; color: var(--bad); font-size: 13px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(circle at 20% 0%, #2b1214 0, var(--side) 55%); }
.login-card { width: min(400px, 100%); display: grid; gap: 14px; padding: 32px 28px; background: #fff; border-radius: 18px; box-shadow: 0 20px 60px rgb(0 0 0 / 35%); }
.login-card img { margin-bottom: 4px; }
.login-card h1 { font-size: 22px; }
.login-card p { margin: -6px 0 4px; color: var(--muted); }
.login-card small { color: var(--muted); text-align: center; font-size: 12px; }

/* shell */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--side); color: #c9ccd2; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-size: 17px; font-weight: 700; }
.brand b { color: #ff5a62; }
.brand small { display: block; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #8b9099; }
.brand .icon-btn { margin-left: auto; }
.side nav { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 38px; border-radius: 8px; color: #b9bdc5; font-weight: 500; }
.side nav > a:first-child { padding-left: 10px; margin-bottom: 4px; }
.side nav > a:first-child .i { margin-right: 0; }
.side nav a:hover { background: var(--side-2); color: #fff; }
.side nav a.on { background: rgb(214 46 54 / 18%); color: #fff; box-shadow: inset 3px 0 0 var(--brand); }
.nav-group { display: flex; align-items: center; gap: 10px; margin: 16px 0 4px; padding: 0 10px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #737882; }
.who { display: flex; align-items: center; gap: 10px; padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid #2c3036; }
.who > span:nth-child(2) { flex: 1; min-width: 0; }
.who b { display: block; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who small { color: #8b9099; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; text-transform: uppercase; }
.scrim { display: none; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; display: flex; align-items: center; gap: 10px; min-height: 62px; padding: 10px 28px; background: rgb(244 245 247 / 88%); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 20px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { display: grid; gap: 18px; padding: 22px 28px 40px; align-content: start; }
.only-mobile { display: none !important; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 16px; margin-bottom: 12px; }
.card p.muted { margin: -4px 0 12px; }
form.card p.muted { margin: -8px 0 0; }
.card.flush { padding: 0; overflow: hidden; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.tile { display: grid; gap: 4px; padding: 18px 20px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); transition: transform .15s, border-color .15s; }
.tile:hover { transform: translateY(-2px); border-color: #f0b7ba; }
.tile span { color: var(--muted); font-size: 13px; font-weight: 600; }
.tile strong { font-size: 26px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.tile small { color: var(--muted); }
.tile:first-child { background: linear-gradient(135deg, var(--brand), #9e1d24); border-color: transparent; color: #fff; }
.tile:first-child span, .tile:first-child small { color: rgb(255 255 255 / 80%); }

.todo { display: grid; gap: 2px; }
.todo a { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-radius: 9px; color: var(--ink-2); }
.todo a:hover { background: var(--bg); }
.todo b { min-width: 30px; padding: 2px 9px; border-radius: 99px; background: var(--bg); text-align: center; font-variant-numeric: tabular-nums; }
.todo a.hot { color: var(--ink); font-weight: 600; }
.todo a.hot b { background: var(--brand); color: #fff; }
.feed { list-style: none; margin: 0; padding: 0; display: grid; }
.feed li { padding: 9px 0; border-bottom: 1px solid var(--line); color: var(--ink-2); }
.feed li:last-child { border: 0; }
.feed li b { color: var(--ink); }
.feed small { display: block; color: var(--muted); font-size: 12px; }
.roles { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 10px; }
.roles li { display: grid; gap: 2px; padding: 10px 12px; border-radius: 9px; background: var(--bg); }
.roles span { color: var(--muted); font-size: 13px; }

/* toolbar & tables */
.toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.search { position: relative; flex: 1 1 260px; display: block; }
.search .i { position: absolute; left: 11px; top: 11px; color: var(--muted); }
.search input { padding-left: 36px; }
.filter { flex: 0 1 170px; gap: 3px; font-size: 12px; }
.count { margin-left: auto; padding-bottom: 10px; color: var(--muted); font-size: 13px; white-space: nowrap; }
table.data { width: 100%; border-collapse: collapse; }
.data th { position: sticky; top: 0; padding: 0; background: #fafbfc; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.data th button { width: 100%; padding: 11px 14px; border: 0; background: none; text-align: left; font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); cursor: pointer; }
.data th button.on, .data th button:hover { color: var(--ink); }
.data.mini th, .data.mini td { padding: 8px 10px; font-size: 13px; }
.data.mini th { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.data td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.data tbody tr:last-child td { border-bottom: 0; }
.data tbody tr[data-open], .data tbody tr[data-admin] { cursor: pointer; }
.data tbody tr[data-open]:hover, .data tbody tr[data-admin]:hover { background: #fdf6f6; }
.data td.first { font-weight: 600; }
.empty { margin: 0; padding: 40px 20px; text-align: center; color: var(--muted); }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; color: var(--muted); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; background: #eef0f3; color: var(--ink-2); font-size: 12px; font-weight: 600; text-transform: capitalize; white-space: nowrap; }
.b-pending, .b-processing, .b-held { background: #fff4e0; color: var(--warn); }
.b-paid, .b-approved, .b-completed, .b-credited, .b-fulfilled, .b-active, .b-yes, .b-on, .b-verified, .b-delivered, .b-success { background: #e4f5eb; color: var(--ok); }
.b-rejected, .b-cancelled, .b-failed, .b-disabled, .b-no, .b-off, .b-reversed { background: #fde8e8; color: var(--bad); }
.b-shipped, .b-income, .b-admin { background: #e6efff; color: #2453b8; }
.b-cashback, .b-fund { background: #f1e9ff; color: #6a3bc0; }

/* images, edit affordance */
.thumb { display: block; width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--bg); border: 1px solid var(--line); }
.thumb.big { width: 140px; height: 140px; border-radius: 12px; }
.data td.img-col, .data th.img-col { width: 60px; padding-right: 0; }
.data td.go-col, .data th.go-col { width: 1%; text-align: right; white-space: nowrap; }
.go { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 7px; color: var(--brand); font-size: 13px; font-weight: 600; }
.go .i { width: 15px; height: 15px; }
tr:hover .go { background: #fde9ea; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.top-actions .btn .i { width: 17px; height: 17px; }
.img-field { display: flex; gap: 14px; align-items: center; font-weight: 400; }
.img-field > span:last-child { display: grid; gap: 6px; min-width: 0; flex: 1; }
.img-box { flex: none; display: grid; place-items: center; width: 92px; height: 92px; border-radius: 12px; border: 1px dashed #c9cdd3; background: var(--bg); color: var(--muted); overflow: hidden; }
.img-box img { width: 100%; height: 100%; object-fit: cover; }
.img-box .i { width: 28px; height: 28px; }
.img-field.busy .img-box { opacity: .4; }
.img-field input[type=file] { min-height: 0; padding: 7px; font-size: 13px; }
label small.muted { font-weight: 400; font-size: 12px; }

/* drawer */
.drawer-scrim { position: fixed; inset: 0; z-index: 20; background: rgb(15 17 20 / 45%); animation: fade .15s; }
.drawer { position: fixed; z-index: 21; top: 0; right: 0; bottom: 0; width: min(560px, 100%); display: flex; flex-direction: column; background: var(--bg); box-shadow: -10px 0 40px rgb(0 0 0 / 18%); animation: slide .2s ease-out; }
.drawer header { display: flex; align-items: flex-start; gap: 10px; padding: calc(18px + env(safe-area-inset-top, 0px)) 20px 16px; background: #fff; border-bottom: 1px solid var(--line); }
.drawer header div { flex: 1; min-width: 0; }
.drawer header small { color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; font-size: 11px; }
.drawer header h2 { font-size: 19px; margin-top: 2px; overflow-wrap: anywhere; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px calc(30px + env(safe-area-inset-bottom, 0px)); }
.sect + .sect { margin-top: 14px; }
.sect { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 16px; overflow-x: auto; }
.sect h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 12px; }
.action { display: grid; gap: 8px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.action + .action { margin-top: 10px; }
.fields { margin: 0; display: grid; }
.f { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.f:last-child { border: 0; }
.f dt { color: var(--muted); font-size: 13px; }
.f dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.json { display: grid; gap: 3px; white-space: normal; }
.kv { font-size: 13px; }
.kv b { color: var(--muted); font-weight: 600; margin-right: 4px; }
body.drawer-open { overflow: hidden; }

#toast { position: fixed; z-index: 40; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 30px); max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 10px; background: var(--ink); color: #fff; font-weight: 500; box-shadow: 0 10px 30px rgb(0 0 0 / 25%); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--bad); }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }

/* tablet & phone */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .only-mobile { display: inline-grid !important; }
  .side { position: fixed; z-index: 30; left: 0; top: 0; bottom: 0; width: min(290px, 86vw); height: auto; padding-top: env(safe-area-inset-top, 0px); transform: translateX(-100%); transition: transform .22s ease-out; }
  body.menu-open .side { transform: none; box-shadow: 10px 0 40px rgb(0 0 0 / 30%); }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 29; background: rgb(15 17 20 / 45%); }
  body.menu-open { overflow: hidden; }
  .top { padding: 8px 16px; min-height: 56px; }
  .top h1 { font-size: 18px; }
  .content { padding: 16px 16px 32px; gap: 14px; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile { padding: 14px; }
  .tile strong { font-size: 20px; }
  .card { padding: 16px; }
  .filter { flex: 1 1 calc(50% - 5px); }
  .count { width: 100%; margin: 0; padding: 0; }
  /* list tables become stacked cards */
  .card.flush { background: none; border: 0; box-shadow: none; overflow: visible; }
  .card.flush table.data, .card.flush .data tbody, .card.flush .data tr, .card.flush .data td { display: block; }
  .card.flush .data thead { display: none; }
  .card.flush .data tr { margin-bottom: 10px; padding: 6px 14px; background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
  .card.flush .data td { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px solid var(--line); text-align: right; overflow-wrap: anywhere; }
  .card.flush .data td::before { content: attr(data-label); flex: none; color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; }
  .card.flush .data td:last-child { border: 0; }
  .card.flush .data td.first { font-size: 15px; }
  .card.flush .data td.img-col { float: left; width: auto; margin: 4px 12px 4px 0; padding: 0; border: 0; }
  .card.flush .data td.img-col::before, .card.flush .data td.go-col::before { content: none; }
  .card.flush .data td.go-col { justify-content: flex-end; width: auto; padding-top: 8px; }
  .top-actions .btn span { display: none; }
  .top-actions .btn { padding: 0 11px; }
  .f { grid-template-columns: 1fr; gap: 2px; }
  .drawer header { padding-left: 16px; padding-right: 12px; }
  .drawer-body { padding-left: 12px; padding-right: 12px; }
  .pager .btn { padding: 0 12px; }
}
