:root {
  /* Light palette — mirror of the mobile-pos app tokens. */
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-alt: #edf2f8;
  --ink: #0e1a2b;
  --muted: #5e6c80;
  --line: #e3e9f2;
  --accent: #0876ad;
  --accent-pressed: #065e8c;
  --accent-soft: #e6f3fa;
  --accent-text: #076a97;
  --success: #12805c;
  --success-soft: #e7f6f0;
  --success-text: #0e6b4c;
  --warning: #b45309;
  --warning-soft: #fff4e5;
  --warning-text: #8a4a00;
  --danger: #d14336;
  --danger-soft: #fdecea;
  --danger-text: #b23a2e;
  --on-accent: #ffffff;

  --radius-sm: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --gutter: 16px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  padding: 16px 16px 28px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--accent-text); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- App shell ---------- */
.app {
  max-width: 1280px;
  margin: 0 auto;
  height: calc(100vh - 44px);
  min-height: 640px;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg);
}

.sidebar {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 16px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
}
.brand-mark-img {
  display: block;
  object-fit: cover;
  background: var(--surface-alt);
}
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.2px; }
.brand-sub {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.nav-wrap { min-height: 0; }
.nav-label {
  margin: 14px 10px 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; }
.nav-item:hover { background: var(--surface-alt); color: var(--ink); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 700;
}
.sidebar-foot { margin-top: auto; padding-top: 12px; }
.store-card {
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}
.store-name { font-size: 12px; font-weight: 700; }
.store-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}
.dot {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: var(--success);
}
.user-row { display: flex; align-items: center; gap: 9px; padding: 2px 2px 0; }
.avatar {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 800;
}
.user-copy { min-width: 0; flex: 1; }
.user-name { font-size: 12px; font-weight: 700; }
.user-role { color: var(--muted); font-size: 11px; font-weight: 500; }
.logout-form { margin: 0; }

/* ---------- Top bar ---------- */
.main { min-width: 0; min-height: 0; overflow-y: auto; background: var(--bg); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.topbar .menu-btn { display: none; }
.topbar-brand {
  display: none;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.topbar-brand-name {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.2px;
  white-space: nowrap;
}
.brand-mark-sm {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 8px;
}
.crumbs {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.crumbs strong { color: var(--ink); font-weight: 700; }
.crumb-sep { margin: 0 6px; }
.top-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--success-soft);
  color: var(--success-text);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
}
.icon-btn:hover { background: var(--surface-alt); color: var(--ink); }
.icon-btn.sm { width: 44px; height: 44px; }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- Mobile drawer ---------- */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(14, 26, 43, 0.38);
}
.drawer-panel {
  display: none;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  width: min(300px, 84vw);
  flex-direction: column;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.drawer-panel.open { animation: drawer-in 0.18s ease-out; }
.drawer-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.drawer-head .brand {
  flex: 1;
  padding: 0;
  margin: 0;
  border: 0;
}
.drawer-scroll {
  flex: 1;
  overflow-y: auto;
  padding-top: 4px;
}
.drawer-scroll .nav-label:first-child { margin-top: 10px; }
.drawer-foot {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
body.drawer-open { overflow: hidden; }
@keyframes drawer-in {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

/* ---------- Page primitives ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 22px 22px 36px; }
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.eyebrow {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
h1 {
  margin: 0;
  color: var(--ink);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.6px;
}
.page-head h1 { overflow-wrap: anywhere; }
.page-sub {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
}
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.card + .card { margin-top: 12px; }
.stat-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.stat-grid.two { grid-template-columns: 1.6fr 1fr; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 500; }
.stat-value {
  margin-top: 2px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.stat.hero .stat-value { font-size: 30px; letter-spacing: -0.8px; }
.stat-note { margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 500; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.section-head h2,
.section-head h3 { margin: 0; color: var(--ink); font-size: 15px; font-weight: 700; }
.section-note { color: var(--muted); font-size: 12px; font-weight: 500; }
.money { font-variant-numeric: tabular-nums; }

/* ---------- Empty / loading / error ---------- */
.state-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 44px 20px;
  text-align: center;
}
.state-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  color: var(--accent);
}
.state-icon.danger { background: var(--danger-soft); color: var(--danger); }
.state-title { color: var(--ink); font-size: 14px; font-weight: 700; }
.state-message {
  max-width: 320px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
}
.state-card .btn { margin-top: 14px; }
.spinner {
  width: 28px;
  height: 28px;
  margin-bottom: 12px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */
.login-screen {
  min-height: calc(100vh - 44px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: var(--bg);
}
.login-inner { width: 100%; max-width: 420px; }
.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
}
.login-card { padding: 24px; }
.login-card h1 { margin: 0; font-size: 28px; letter-spacing: -0.6px; }
.field-label {
  display: block;
  margin: 20px 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.text-input {
  width: 100%;
  height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
}
.text-input:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.field-error {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: var(--danger-text);
  font-size: 12px;
  font-weight: 500;
}
.login-card .btn { margin-top: 16px; }
.login-note {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
}
.login-foot {
  margin-top: 16px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

/* ---------- Controls and data ---------- */
.btn {
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}
.btn:hover { background: var(--accent-pressed); }
.btn.secondary { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.btn.secondary:hover { background: var(--surface-alt); }
.btn.block { width: 100%; }
.btn:disabled { background: var(--surface-alt); color: var(--muted); cursor: not-allowed; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge.success { background: var(--success-soft); color: var(--success-text); }
.badge.info { background: var(--accent-soft); color: var(--accent-text); }
.badge.warning { background: var(--warning-soft); color: var(--warning-text); }
.badge.danger { background: var(--danger-soft); color: var(--danger-text); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; min-width: 640px; border-collapse: collapse; }
.table th {
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}
.table td {
  height: 56px;
  padding: 0 10px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.table tbody tr:first-child td { border-top: 0; }
.table .num { text-align: right; }

/* ---------- Report controls ---------- */
.date-nav { display: flex; align-items: center; gap: 2px; }
.date-picker { position: relative; }
.date-picker > summary { list-style: none; cursor: pointer; }
.date-picker > summary::-webkit-details-marker { display: none; }
.date-pill {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.date-pill > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.date-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  width: min(320px, calc(100vw - 40px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.date-picker:not([open]) > .date-menu { display: none; }
.date-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.date-field .text-input { height: 44px; }
.date-menu .btn { width: 100%; }

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 50px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
}
.seg-item {
  height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.seg-item:hover { color: var(--ink); }
.seg-item.active {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}
.segmented.compact { height: 50px; }
.segmented.compact .seg-item { height: 44px; padding: 0 11px; font-size: 11px; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}
.filter-wrap { position: relative; }
.chip {
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
  white-space: nowrap;
}
.chip::-webkit-details-marker { display: none; }
.chip:hover { background: var(--surface-alt); }
.chip > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.filter-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  min-width: 200px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.filter-wrap:not([open]) > .filter-menu { display: none; }
.filter-option {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.filter-option:hover { background: var(--surface-alt); }
.filter-option.active { background: var(--accent-soft); color: var(--accent-text); }

/* ---------- Ranked rows and bars ---------- */
.ranked-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: flex-start;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.section-head + .ranked-row { border-top: 0; padding-top: 6px; }
.rank {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 800;
}
.ranked-main { min-width: 0; }
.ranked-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.ranked-title > span:first-child {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.ranked-title .money { flex: 0 0 auto; font-size: 14px; font-weight: 700; }
.ranked-sub { margin-top: 1px; color: var(--muted); font-size: 12px; font-weight: 500; }
.ranked-share { margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 600; text-align: right; }
.row-sub { color: var(--muted); font-size: 12px; font-weight: 500; }
.bar-track {
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--surface-alt);
  margin-top: 6px;
}
.bar-graphic { display: block; width: 100%; height: 100%; }
.bar-fill { fill: var(--accent); }
.bar-fill.zero { fill: var(--muted); }

/* ---------- Daily breakdown ---------- */
.breakdown-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 96px;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-top: 1px solid var(--line);
}
.section-head + .breakdown-row { border-top: 0; }
.breakdown-day { color: var(--ink); font-size: 12px; font-weight: 600; }
.breakdown-row .bar-track { margin-top: 0; }
.breakdown-values { text-align: right; }
.breakdown-values .money { color: var(--ink); font-size: 13px; font-weight: 700; }
.breakdown-values .row-sub { font-size: 11px; }

/* ---------- Hourly ---------- */
.hour-scroll { overflow-x: auto; padding: 4px 0 8px; }
.hour-chart { display: flex; gap: 4px; align-items: flex-end; width: max-content; }
.hour-col {
  width: 56px;
  flex: 0 0 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.hour-value {
  height: 14px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  white-space: nowrap;
}
.hour-value.peak { color: var(--accent-text); font-weight: 800; }
.hour-bar-area {
  width: 100%;
  height: 140px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.hour-graphic { width: 24px; height: 100%; display: block; }
.hour-bar { fill: var(--accent-soft); }
.hour-bar.peak { fill: var(--accent); }
.hour-label { color: var(--muted); font-size: 9px; font-weight: 600; white-space: nowrap; }
.hour-label.peak { color: var(--accent-text); font-weight: 800; }
.chart-hint {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}
.hour-table { min-width: 0; }
.peak-row { background: var(--accent-soft); }
.peak-row td { color: var(--accent-text) !important; font-weight: 700; }

/* ---------- Payment cards ---------- */
.payment-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.payment-grid .card + .card { margin-top: 0; }
.payment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.payment-name { color: var(--ink); font-size: 14px; font-weight: 700; }
.payment-value {
  margin-top: 2px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.payment-meta { margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 500; }

.empty-row { padding: 24px 0; color: var(--muted); font-size: 12px; text-align: center; }
.table .money { font-weight: 700; }

/* ---------- Orders ---------- */
.search-form {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  flex-wrap: wrap;
}
.search-field {
  height: 44px;
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
}
.search-field:focus-within { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.search-field svg { width: 16px; height: 16px; flex: 0 0 16px; }
.search-field input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
}
.search-field input::placeholder { color: var(--muted); }
.toolbar .search-field { min-width: 260px; max-width: 420px; }
.search-form .btn { flex: 0 0 auto; }

.order-table { min-width: 980px; }
.order-id { color: var(--muted); font-size: 12px; font-weight: 600; }
.table .order-cell { padding: 0; }
.order-link {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  text-decoration: none;
}
.order-link:hover,
.order-link:focus { color: var(--accent-text); text-decoration: underline; }
.order-row:hover { background: var(--surface-alt); }
.order-detail-title { overflow-wrap: anywhere; }
.order-cards { display: none; }
.order-card {
  width: 100%;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
  text-decoration: none;
}
.order-card:first-child { border-top: 0; padding-top: 4px; }
.order-card:hover { background: transparent; }
.order-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.order-card-main { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.order-card-main .money { font-size: 14px; font-weight: 700; }
.order-card-sub { color: var(--muted); font-size: 12px; font-weight: 500; }
.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
}
.pager { display: flex; gap: 4px; }
.pager .icon-btn { border: 1px solid var(--line); background: var(--surface); }
.pager .icon-btn.disabled { color: var(--muted); opacity: 0.45; pointer-events: none; }
.empty-cell { text-align: center; }
.table .empty-cell { height: 96px; color: var(--muted); white-space: normal; }

/* ---------- Order detail ---------- */
.order-detail { max-width: 760px; }
.modal-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0 0 14px;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--line);
}
.meta-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.meta-value { margin-top: 2px; color: var(--ink); font-size: 13px; font-weight: 700; }
.modal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
}
.section-head + .modal-item { border-top: 0; }
.detail-item-copy { min-width: 0; }
.detail-item-name { color: var(--ink); font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.detail-item-sub { margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 500; }
.modal-totals { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.total-row.grand { padding-top: 8px; color: var(--ink); font-size: 15px; font-weight: 800; }

/* ---------- API keys ---------- */
.key-create { margin-bottom: 12px; }
.key-create-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.key-create-field { flex: 1 1 240px; min-width: 0; }
.key-create-field .field-label { margin: 0 0 6px; }
.key-create .btn { height: 44px; min-height: 44px; }
.key-create .field-error { margin-top: 10px; }
.key-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
}
.key-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.key-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.key-row-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.key-name {
  min-width: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.key-delete-form { margin: 0 0 0 auto; }
.key-secret { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.key-code {
  flex: 1 1 260px;
  min-width: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.key-copy { height: 44px; min-height: 44px; flex: 0 0 auto; }
.key-delete { height: 44px; min-height: 44px; }
.btn.danger-soft { border: 1px solid var(--danger-soft); background: var(--danger-soft); color: var(--danger-text); }
.btn.danger-soft:hover { border-color: var(--danger); background: var(--danger-soft); color: var(--danger-text); }
.btn.danger { background: var(--danger); color: var(--on-accent); }
.btn.danger:hover { background: var(--danger-text); }
.key-meta {
  display: flex;
  align-items: center;
  gap: 4px 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.key-sep { color: var(--muted); }
.key-dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
}
.key-dialog::backdrop { background: rgba(14, 26, 43, 0.38); }
.key-dialog-body { padding: 20px; }
.key-dialog h2 { margin: 0 0 6px; color: var(--ink); font-size: 16px; font-weight: 700; }
.key-dialog-message {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.key-dialog-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
}
.key-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.key-dialog-actions .btn { height: 44px; min-height: 44px; }
.copy-helper {
  position: fixed;
  top: -1000px;
  left: -1000px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .payment-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .app { height: auto; min-height: 640px; }
  .main { overflow: visible; }
  .topbar { position: static; }
}
@media (max-width: 820px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat.hero { grid-column: span 2; }
  .stat-grid.two { grid-template-columns: 1fr 1fr; }
  .stat-grid.two .stat.hero { grid-column: auto; }
}
@media (max-width: 680px) {
  body { padding: 10px 10px 20px; }
  .app { display: block; height: auto; min-height: 0; border-radius: var(--radius-md); }
  .sidebar { display: none; }
  .main { overflow: visible; }
  .topbar {
    position: static;
    height: 54px;
    padding: 0 14px;
    justify-content: flex-start;
    gap: 6px;
  }
  .topbar .menu-btn { display: grid; }
  .topbar-brand { display: flex; }
  .top-actions { margin-left: auto; }
  .crumbs { display: none; }
  .drawer-panel.open { display: flex; }
  .drawer-backdrop.open { display: block; }
  .page { padding: 16px 14px 28px; }
  .page-head { gap: 12px; }
  .page-head h1 { font-size: 24px; }
  .page-actions { width: 100%; }
  .page-actions .segmented { width: 100%; }
  .page-actions .segmented .seg-item { flex: 1; justify-content: center; }
  .page-actions .date-nav { width: 100%; justify-content: space-between; align-items: flex-start; }
  .page-actions .date-picker { flex: 1; min-width: 0; }
  .page-actions .date-picker > summary { width: 100%; }
  .date-pill { padding: 0 10px; font-size: 12px; }
  .date-menu { position: static; width: 100%; margin-top: 6px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat.hero { grid-column: span 2; }
  .stat-grid.two { grid-template-columns: 1fr; }
  .stat-grid.two .stat.hero { grid-column: auto; }
  .payment-grid { grid-template-columns: 1fr; }
  .toolbar .search-form { width: 100%; }
  .toolbar .search-field { min-width: 0; max-width: none; width: 100%; }
  .order-table-wrap { display: none; }
  .order-cards { display: flex; flex-direction: column; }
  .table-foot { flex-wrap: wrap; }
  .modal-meta { grid-template-columns: 1fr; }
  .order-detail-title { font-size: 22px; }
  .toolbar { align-items: flex-start; }
  .toolbar > .segmented { width: 100%; }
  .toolbar > .segmented .seg-item { flex: 1; justify-content: center; }
  .toolbar-right {
    width: 100%;
    margin-left: 0;
    flex-direction: column;
    align-items: stretch;
  }
  .filter-wrap { width: 100%; }
  .chip { width: 100%; }
  .filter-menu { width: 100%; min-width: 0; }
  .toolbar-right .segmented { width: 100%; }
  .toolbar-right .segmented .seg-item { flex: 1; justify-content: center; }
  .hour-table td { height: 48px; }
  .chart-hint { display: block; }
  .breakdown-row { grid-template-columns: 52px minmax(0, 1fr) 84px; }
  .ranked-title { gap: 8px; }
  .login-screen { min-height: auto; padding: 28px 12px; }
  .key-create-form { flex-direction: column; align-items: stretch; }
  .key-create .btn { width: 100%; }
  .key-row { padding: 14px; }
  .key-row-head { align-items: flex-start; }
  .key-delete-form { width: 100%; margin-left: 0; }
  .key-delete { width: 100%; }
  .key-secret { flex-direction: column; align-items: stretch; }
  .key-copy { width: 100%; }
  .key-dialog-actions { flex-direction: column-reverse; }
  .key-dialog-actions .btn { width: 100%; }
}
@media (max-width: 380px) {
  .page-head h1 { font-size: 22px; }
  .segmented { width: 100%; }
  .segmented .seg-item { flex: 1; justify-content: center; }
  .date-nav { width: 100%; justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner, .drawer-panel.open { animation: none; }
}
