/* Shared cabinet foundation. Forms, navigation and data views use the same tokens. */
:root {
  --primary: #5551d8;
  --hover: #4540be;
  --soft: #eeedfc;
  --ink: #242b3a;
  --muted: #647084;
  --border: #e3e6ec;
  --bg: #f7f8fa;
  --surface: #fff;
  --green: #17724d;
  --red: #b23445;
  --amber: #89600a;
  --radius: 7px;
  --shadow: 0 12px 40px #202b3d1f;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, a { touch-action: manipulation; }
button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid #d4d9e2;
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  cursor: pointer;
  text-decoration: none;
  transition: background 150ms, border-color 150ms, color 150ms;
}
button:hover, .btn:hover { background: var(--bg); border-color: #b8bfcb; text-decoration: none; }
button:active, .btn:active { background: #eef0f4; }
button:disabled { opacity: .45; cursor: default; }
button.primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover, .btn.primary:hover { background: var(--hover); border-color: var(--hover); }
button.danger { color: var(--red); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
svg.icon {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 0; font-size: 26px; line-height: 1.3; font-weight: 650; letter-spacing: -.7px; }
h2 { font-size: 16px; font-weight: 600; letter-spacing: -.2px; }
h3 { font-size: 14px; font-weight: 600; }
small, .muted { color: var(--muted); }

/* Persistent navigation. The white work area starts at a single continuous rule. */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  width: 208px;
  padding: 25px 14px 18px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 8px; padding: 0 12px; font-size: 22px; font-weight: 750; letter-spacing: -.9px; }
.brand img { width: 25px; height: 25px; }
.brand .muted { margin-left: -8px; }
.workspace { padding: 2px 12px 28px; color: var(--muted); font-size: 12px; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav button { width: 100%; min-height: 38px; justify-content: flex-start; gap: 10px; padding: 8px 12px; border: 0; background: transparent; color: #505b70; font-weight: 500; }
.sidebar nav button:hover { background: #edf0f4; }
.sidebar nav button.active { background: #eae9f9; color: var(--primary); font-weight: 600; }
.sidebar-bottom { margin-top: auto; padding: 20px 10px 0; }
.profile { display: flex; align-items: center; gap: 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.avatar { display: grid; flex: none; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #e3e7ed; color: #505b70; font-size: 12px; font-weight: 600; }
.profile > div { min-width: 0; }
.profile strong { display: block; max-width: 128px; overflow: hidden; text-overflow: ellipsis; font-size: 12px; font-weight: 600; }
.profile small { display: block; font-size: 11px; }
.main { min-width: 0; min-height: 100dvh; margin-left: 208px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 56px; padding: 0 32px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.topbar > span > span[aria-hidden] { margin: 0 10px; color: #adb4c1; }
#breadcrumb { color: var(--ink); }
.topbar .right { display: flex; align-items: center; gap: 14px; }
.topbar button { min-height: 32px; padding: 5px 8px; border-color: transparent; background: transparent; color: var(--muted); font-size: 12px; }
.topbar button:hover { background: var(--bg); }
.test-badge { padding: 3px 7px; border: 1px solid #ecdbb2; border-radius: 4px; background: #fffaed; color: var(--amber); font-size: 11px; font-weight: 500; white-space: nowrap; }
.content { max-width: 1600px; padding: 24px 32px 40px; margin: 0 auto; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-title > div { min-width: 0; }
.page-title p { margin: 6px 0 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }

/* Summary numbers share one baseline instead of competing cards. */
.stats { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 24px; margin-bottom: 20px; padding: 0 0 16px; border-bottom: 1px solid var(--border); }
.stat { min-width: 0; padding-right: 20px; }
.stat + .stat { padding-left: 24px; border-left: 1px solid var(--border); }
.stat-label { margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.stat strong { display: block; font-size: 24px; line-height: 1.3; font-weight: 600; letter-spacing: -.55px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.panel { min-width: 0; background: var(--surface); }
.panel-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.panel-title h2 { margin: 0; line-height: 1.4; }
.subtle-count { color: var(--muted); font-size: 12px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.search { position: relative; flex: 1; max-width: 340px; }
.search svg { position: absolute; top: 10px; left: 10px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 33px; }
.toolbar select { width: 182px; }
#reload { width: 36px; padding: 7px; margin-left: auto; }
.table-wrap { position: relative; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
th { padding: 10px 12px; border-block: 1px solid var(--border); background: var(--bg); color: #596579; font-size: 12px; font-weight: 500; }
td { padding: 8px 12px; border-bottom: 1px solid #edf0f4; font-size: 13px; vertical-align: middle; }
th:first-child, td:first-child { padding-left: 12px; }
tbody tr:hover { background: #fafbfc; }
.order-link { min-height: 24px; padding: 0; border: 0; background: transparent; font-size: 13px; font-weight: 600; }
.order-link:hover { background: transparent; color: var(--primary); }
.order-link svg { width: 16px; height: 16px; }
td:last-child .order-link { min-width: 30px; min-height: 32px; }
.amount { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.payments-panel td:first-child { min-width: 190px; }
.buyer-email { display: block; max-width: 280px; margin-top: 1px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; white-space: normal; }
.row-client { display: block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.status { display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px; border-radius: 4px; background: #edf0f4; color: #596579; font-size: 11px; font-weight: 500; line-height: 1.6; white-space: nowrap; }
.status.successful { background: #e7f4ed; color: var(--green); }
.status.pending, .status.creating, .status.incomplete { background: #fff4dc; color: var(--amber); }
.status.failed, .status.error { background: #fcecef; color: var(--red); }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; color: var(--muted); font-size: 12px; }
.pager { display: flex; gap: 8px; }
.pager button { min-height: 30px; padding: 4px 10px; font-size: 12px; }
.empty { padding: 52px 24px; text-align: center; border-block: 1px solid var(--border); }
.empty-icon { display: grid; place-items: center; width: 36px; height: 36px; margin: 0 auto 12px; color: var(--muted); }
.empty h3 { margin-bottom: 6px; font-size: 16px; }
.empty p { max-width: 440px; margin: 0 auto 18px; color: var(--muted); font-size: 13px; }
.skeleton { padding: 48px 20px; text-align: center; color: var(--muted); font-size: 13px; }

/* A single field and feedback system for every form. */
label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; }
input, select, textarea { width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid #cdd3de; border-radius: 6px; outline: none; background: var(--surface); color: var(--ink); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px #5551d818; }
input::placeholder, textarea::placeholder { color: #7a8495; }
textarea { resize: vertical; min-height: 88px; max-height: 180px; }
.field { margin-bottom: 18px; }
.field small { display: block; margin-top: 5px; font-size: 12px; line-height: 1.5; }
.error-box { margin: 14px 0; padding: 10px 12px; border: 1px solid #f0cbd1; border-radius: 6px; background: #fdf1f3; color: var(--red); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.error-box:empty { display: none; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 6px; }
.full { width: 100%; }
.permission-toggle { display: flex; align-items: center; gap: 8px; min-height: 36px; margin: 0; font-size: 13px; font-weight: 400; cursor: pointer; }
.permission-toggle input { flex: none; width: 16px; height: 16px; min-height: 16px; margin: 0; accent-color: var(--primary); }
.inline-actions { display: flex; gap: 8px; }
.inline-actions button { min-height: 30px; padding: 4px 9px; font-size: 12px; }
.settings-form { max-width: 440px; }
.settings-form.dialog-body { padding: 8px 0 0; overflow: visible; }
.callout { padding: 8px 0; margin: 8px 0; color: var(--muted); font-size: 12px; line-height: 1.6; }

/* Modal forms; the payment drawer is defined in payment-dialog.css. */
dialog { width: min(500px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: #18233666; }
#modal-content { display: flex; flex-direction: column; max-height: calc(100dvh - 34px); min-height: 0; }
.dialog-head { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 24px; border-bottom: 1px solid var(--border); }
.dialog-head > div { min-width: 0; }
.dialog-head h2 { margin: 0; font-size: 18px; line-height: 1.4; overflow-wrap: anywhere; }
.dialog-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.close { flex: none; width: 36px; min-height: 36px; padding: 0; border-color: transparent; background: transparent; color: var(--muted); font-size: 25px; font-weight: 400; line-height: 1; }
.dialog-body { min-height: 0; padding: 24px; overflow: auto; overscroll-behavior: contain; }
body:has(dialog[open]) { overflow: hidden; }

/* Neutral sign-in, with no promotional or environment content. */
.login-page { display: grid; place-items: center; min-height: 100dvh; padding: 24px; background: var(--bg); }
.login-form { width: 100%; max-width: 360px; }
.login-card { padding: 30px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.login-card .field { margin-bottom: 20px; }
.login-card input, .login-card button.primary { min-height: 42px; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 46px; }
.password-wrap button { position: absolute; top: 1px; right: 1px; width: 40px; min-height: 40px; padding: 6px; border: 0; background: transparent; color: var(--muted); }
.initial { display: grid; place-content: center; gap: 16px; min-height: 100dvh; text-align: center; }
.initial span { color: var(--muted); font-size: 13px; }
.loading-dot { display: block; width: 10px; height: 10px; border-radius: 50%; background: #cdd3de; }
#toast { position: fixed; bottom: 24px; left: 50%; z-index: 100; display: none; max-width: calc(100vw - 32px); padding: 11px 16px; border-radius: 6px; transform: translateX(-50%); background: var(--ink); color: #fff; box-shadow: var(--shadow); font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 1100px) {
  .sidebar { width: 184px; padding-inline: 10px; }
  .main { margin-left: 184px; }
  .content { padding: 24px; }
  .topbar { padding-inline: 24px; }
  .stat strong { font-size: 23px; }
  .stats { gap: 16px; }
  .stat + .stat { padding-left: 16px; }
}

@media (max-width: 760px) {
  body { font-size: 16px; }
  button, .btn { min-height: 44px; }
  .sidebar { position: static; width: 100%; padding: 16px 16px 0; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding: 0; font-size: 21px; }
  .brand img { width: 24px; height: 24px; }
  .workspace, .sidebar-bottom { display: none; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 12px; padding-bottom: 8px; }
  .sidebar nav button { width: auto; min-height: 44px; gap: 6px; padding: 8px 10px; font-size: 13px; }
  .sidebar nav .icon { width: 16px; height: 16px; }
  .main { margin-left: 0; }
  .topbar { height: 50px; padding-inline: 16px; font-size: 11px; }
  .topbar > span > span[aria-hidden] { margin-inline: 5px; }
  .topbar .right { gap: 4px; }
  .topbar button { min-height: 44px; padding-inline: 4px; }
  .test-badge { padding: 2px 5px; font-size: 10px; }
  .content { padding: 22px 16px 32px; }
  h1 { font-size: 24px; }
  .page-title { gap: 12px; margin-bottom: 22px; }
  .page-title > button { padding-inline: 10px; font-size: 12px; }
  .page-title > button .icon { width: 16px; height: 16px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 12px 16px; padding-bottom: 20px; margin-bottom: 20px; }
  .stat { padding: 0; }
  .stat:first-child { grid-column: 1 / -1; }
  .stat + .stat { padding-left: 0; border-left: 0; }
  .stat strong { font-size: 24px; }
  .stat:first-child strong { font-size: 28px; }
  .stat-label { font-size: 12px; }
  .toolbar { flex-wrap: wrap; gap: 8px; }
  .search { flex-basis: 100%; max-width: none; }
  .search svg { top: 14px; }
  .toolbar select { flex: 1; width: auto; }
  #reload { width: 44px; }
  input, select, textarea { min-height: 44px; font-size: 16px; }
  td, th { padding: 10px; }
  .order-link { min-height: 32px; }
  td:last-child .order-link { min-width: 44px; min-height: 44px; }
  .table-footer { align-items: center; gap: 8px; font-size: 11px; }
  .pager { gap: 6px; }
  .pager button { min-height: 44px; padding-inline: 9px; }
  .inline-actions { flex-wrap: wrap; }
  .inline-actions button, .permission-toggle { min-height: 44px; }
  .dialog-head { padding: 16px 20px; }
  .dialog-body { padding: 20px; }
  .close { width: 44px; min-height: 44px; }
  .login-card { padding: 26px 22px; }
  .login-card input, .login-card button.primary { min-height: 44px; }
  .password-wrap button { min-height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
