/* Shared base: reset, primitives, admin shell. Themes set the variables below. */
:root {
  --bg: #fff; --ink: #14181f; --ink-2: #3a424f; --muted: #667085; --line: #e4e7ec; --line-2: #eef0f3;
  --soft: #f6f7f9; --accent: #1f4fd8; --accent-ink: #fff; --accent-soft: #eaf0fe; --accent-2: #14181f;
  --ok: #107a4a; --ok-soft: #e6f5ee; --warn: #a15c00; --warn-soft: #fdf1dc; --danger: #b42318; --danger-soft: #fdeceb;
  --radius: 8px; --radius-lg: 14px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 8px 24px -12px rgba(16,24,40,.12);
  --font-head: 'Inter', system-ui, sans-serif; --font-body: 'Inter', system-ui, sans-serif;
  --max: 1180px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.55 var(--font-body); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; font-feature-settings: 'cv11', 'ss01'; }
body.noscroll { overflow: hidden; }
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; line-height: 1.15; color: var(--ink); }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-soft); }
.ic { flex: none; vertical-align: -3px; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 24px; }
.pad { padding-top: 48px; padding-bottom: 64px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrapx { flex-wrap: wrap; }
.stack > * + * { margin-top: 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
#view.loading { opacity: .55; transition: opacity .15s .15s; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: 14px; color: var(--ink); white-space: nowrap; transition: background .12s, border-color .12s, transform .06s; text-decoration: none !important; }
.btn:hover { background: var(--soft); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.dark { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.dark:hover { filter: brightness(1.2); background: var(--accent-2); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--soft); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { color: var(--danger); border-color: transparent; background: transparent; }
.btn.danger-ghost:hover { background: var(--danger-soft); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.lg { height: 48px; padding: 0 24px; font-size: 15px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy::after { content: ''; position: absolute; width: 16px; height: 16px; border: 2px solid currentColor; border-color: rgba(128,128,128,.4); border-top-color: var(--ink); border-radius: 50%; animation: spin .7s linear infinite; }
.btn.primary.busy::after, .btn.dark.busy::after { border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.span2 { grid-column: 1 / -1; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field > label i { color: var(--danger); font-style: normal; margin-left: 2px; }
.field small { color: var(--muted); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=url], input[type=search], input[type=tel], input[type=time], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid #d0d5dd; border-radius: var(--radius); background: #fff; transition: border-color .12s, box-shadow .12s; }
textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=color] { width: 56px; height: 40px; padding: 3px; border: 1px solid #d0d5dd; border-radius: var(--radius); background: #fff; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .knob { width: 38px; height: 22px; border-radius: 12px; background: #d0d5dd; position: relative; transition: .15s; flex: none; }
.switch .knob::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .knob { background: var(--accent); }
.switch input:checked + .knob::after { left: 18px; }
.switch input:focus-visible + .knob { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-l { font-size: 14px; }
.search { position: relative; display: block; flex: 1; max-width: 320px; }
.search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 34px; height: 36px; }

/* surfaces */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; }
.card.flush { padding: 0; overflow: hidden; }
.card.soft { background: var(--soft); border-color: var(--line-2); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-h h3 { font-size: 16px; font-weight: 700; }
.notice { padding: 12px 16px; border-radius: var(--radius); background: var(--accent-soft); color: var(--ink-2); font-size: 14px; border: 1px solid transparent; }
.notice.err { background: var(--danger-soft); color: var(--danger); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 11px; background: var(--soft); color: var(--ink-2); font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok, .pill.approved, .pill.paid, .pill.completed, .pill.active, .pill.published { background: var(--ok-soft); color: var(--ok); }
.pill.warn, .pill.submitted, .pill.held, .pill.pending, .pill.offered, .pill.live { background: var(--warn-soft); color: var(--warn); }
.pill.bad, .pill.rejected, .pill.cancelled, .pill.failed, .pill.suspended { background: var(--danger-soft); color: var(--danger); }
.pill.info, .pill.scheduled, .pill.upcoming, .pill.waitlist { background: var(--accent-soft); color: var(--accent); }
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; letter-spacing: .02em; flex: none; }
.avatar.lg { width: 72px; height: 72px; font-size: 24px; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.empty { display: grid; gap: 4px; justify-items: center; text-align: center; padding: 40px 20px; color: var(--muted); }
.empty strong { color: var(--ink); }
.empty-chart { display: grid; place-items: center; height: 120px; color: var(--muted); font-size: 14px; }

/* tables */
.tbl-tools { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.tbl-scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; padding: 0; border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 0; white-space: nowrap; }
.tbl th button { all: unset; cursor: pointer; padding: 11px 16px; display: inline-flex; align-items: center; gap: 4px; }
.tbl th button:disabled { cursor: default; }
.tbl th.num { text-align: right; }
.tbl td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #fafbfc; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-top: 1px solid var(--line); }

/* modal + toast + tooltip */
.modal-back { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: grid; place-items: center; padding: 20px; z-index: 100; opacity: 0; transition: opacity .15s; overflow-y: auto; }
.modal-back.in { opacity: 1; }
.modal { background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 480px; box-shadow: 0 24px 64px -16px rgba(16,24,40,.35); transform: translateY(8px); transition: transform .15s; max-height: calc(100vh - 40px); display: flex; flex-direction: column; }
.modal.wide { max-width: 720px; }
.modal-back.in .modal { transform: none; }
.modal form { display: flex; flex-direction: column; min-height: 0; }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 0; }
.modal-h h3 { font-size: 18px; }
.modal-h .x { all: unset; cursor: pointer; padding: 6px; border-radius: 6px; color: var(--muted); }
.modal-h .x:hover { background: var(--soft); }
.modal-b { padding: 16px 24px; overflow-y: auto; }
.modal-b.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.modal-f { display: flex; gap: 8px; padding: 14px 24px 20px; border-top: 1px solid var(--line-2); }
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 200; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: var(--radius); font-size: 14px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: .2s; }
.toast.in { opacity: 1; transform: none; }
.toast.err { background: var(--danger); }
#tip { position: absolute; z-index: 150; background: var(--ink); color: #fff; font-size: 12px; padding: 5px 9px; border-radius: 6px; pointer-events: none; opacity: 0; transition: opacity .1s; white-space: nowrap; }
#tip.on { opacity: 1; }

/* charts */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--line-2); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 11px; font-family: var(--font-body); font-variant-numeric: tabular-nums; }
.chart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .08; }
.chart .dot { fill: #fff; stroke-width: 2; }
.chart .hit { fill: transparent; cursor: default; }
.chart .bar { transition: opacity .12s; }
.chart .bar:hover { opacity: .8; }
.donut-c { font: 700 20px var(--font-head); fill: var(--ink); }
.spark { display: block; }

/* admin shell */
.admin { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; background: var(--soft); }
.side { background: #fff; border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; font: 700 15px var(--font-head); color: var(--ink); text-decoration: none !important; }
.side-brand small { display: block; font: 500 11px var(--font-body); color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.side h6 { margin: 18px 10px 6px; font: 600 11px var(--font-body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.side a.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; color: var(--ink-2); font-weight: 500; font-size: 14px; text-decoration: none !important; }
.side a.nav:hover { background: var(--soft); }
.side a.nav.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side a.nav .badge { margin-left: auto; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 9px; }
.side-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); display: grid; gap: 4px; }
.admin-main { min-width: 0; }
.admin-top { display: none; }
.admin-body { padding: 28px 32px 64px; max-width: 1280px; }
.page-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-h h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.page-h p { margin: 4px 0 0; }
.page-h-r { display: flex; gap: 8px; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; }
.kpi span { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi b { display: block; font: 700 28px/1.2 var(--font-head); margin-top: 4px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs button, .tabs a { all: unset; cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs .on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button:hover, .tabs a:hover { color: var(--ink); }
.seg { display: inline-flex; background: var(--soft); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { all: unset; cursor: pointer; padding: 6px 14px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(16,24,40,.1); }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: 14px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid4 { grid-template-columns: repeat(2, 1fr); }
  .grid3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .admin { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 90; left: 0; top: 0; width: 264px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  body.menu-open .side { transform: none; }
  body.menu-open::after { content: ''; position: fixed; inset: 0; background: rgba(16,24,40,.35); z-index: 80; }
  .admin-top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 70; font-weight: 700; }
  .admin-body { padding: 20px 16px 64px; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .pad { padding-top: 32px; padding-bottom: 48px; }
  .grid2, .grid3, .grid4, .modal-b.grid2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi b { font-size: 22px; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 10px; }
  .modal-back { padding: 0; align-items: end; }
  .modal { max-width: none; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92vh; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
