/* Trusted Web Studio billing UI. Light theme only. */

:root {
  color-scheme: light;
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --surface-2: #F9FAFB;
  --border: #E5E7EB;
  --border-strong: #D1D5DB;
  --text: #111827;
  --text-2: #4B5563;
  --text-3: #6B7280;
  --text-4: #9CA3AF;

  --primary: #007AC9;
  --primary-hover: #0062A3;
  --primary-soft: #E6F2FA;
  --primary-ring: rgba(0, 122, 201, .18);

  --success: #067647; --success-soft: #ECFDF3; --success-border: #ABEFC6;
  --warning: #B54708; --warning-soft: #FFFAEB; --warning-border: #FEDF89;
  --danger: #B42318;  --danger-soft: #FEF3F2;  --danger-border: #FECDCA;
  --info: #175CD3;    --info-soft: #EFF8FF;    --info-border: #B2DDFF;
  --neutral-soft: #F2F4F7; --neutral-border: #E4E7EC;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 24px -4px rgba(16, 24, 40, .10), 0 4px 8px -2px rgba(16, 24, 40, .05);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); font-feature-settings: 'cv11', 'ss01'; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
h1, h2, h3 { margin: 0; color: var(--text); }
p { margin: 0 0 12px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--neutral-soft); border-radius: 4px; padding: 1px 5px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.icon { flex: none; display: inline-block; vertical-align: middle; }

.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-link { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; font-weight: 500; cursor: pointer; }
.text-link:hover { color: var(--primary-hover); text-decoration: underline; }
.text-link.danger { color: var(--danger); }
.footnote { margin: 12px 4px 0; }
.prose { color: var(--text-2); }

/* ---------------------------------------------------------------- Brand */
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { display: block; height: 40px; width: auto; max-width: 100%; }
.brand-logo-mark { display: none; width: 32px; height: 32px; }
.brand-mark-img { display: block; }
.brand-link { color: inherit; }
.brand-link:hover { color: inherit; }

/* -------------------------------------------------------------- Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 500 14px/1 var(--font); white-space: nowrap; cursor: pointer; text-decoration: none; box-shadow: var(--shadow-xs); transition: background .15s, border-color .15s, color .15s, box-shadow .15s; }
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:active { transform: translateY(.5px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--neutral-soft); color: var(--text); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; font-weight: 600; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn[disabled], .btn.is-loading { opacity: .65; cursor: not-allowed; }
.spinner { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------- Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap; border: 1px solid; vertical-align: middle; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.tone-success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.tone-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.tone-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: var(--danger-border); }
.tone-info    { background: var(--info-soft);    color: var(--info);    border-color: var(--info-border); }
.tone-neutral { background: var(--neutral-soft); color: var(--text-2);  border-color: var(--neutral-border); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; border: 0; }
.dot.tone-danger { background: var(--danger); }
.dot.tone-warning { background: #F79009; }

/* ---------------------------------------------------------------- Forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 13px; font-weight: 500; color: var(--text); }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.label-row .text-link { font-size: 13px; }
.hint { font-size: 12.5px; color: var(--text-3); }
.input, .select, .textarea { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: #fff; color: var(--text); font: 14px var(--font); box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s; }
.textarea { height: auto; padding: 10px 12px; line-height: 1.55; resize: vertical; min-height: 96px; }
.mono-area { font-family: var(--mono); font-size: 13px; }
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-ring); }
.input[readonly] { background: var(--surface-2); color: var(--text-2); }
.select { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.select-auto { width: auto; }
.input-narrow { width: 90px; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-addon { display: inline-flex; align-items: center; padding: 0 12px; border: 1px solid var(--border-strong); border-right: 0; border-radius: var(--radius) 0 0 var(--radius); background: var(--surface-2); color: var(--text-3); font-weight: 500; }
.inline-fields { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: flex-start; gap: 10px; cursor: pointer; color: var(--text-2); line-height: 1.45; }
.check input, .consent input { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--primary); flex: none; cursor: pointer; }
.check-box { height: 40px; align-items: center; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: 1 / -1; }
.stack-form { display: flex; flex-direction: column; gap: 16px; }
.inline-form { display: inline; margin-left: 8px; }
.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 20px; flex-wrap: wrap; }

.form-card { padding: 0 24px; }
.form-section { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 32px; padding: 28px 0; border-bottom: 1px solid var(--border); }
.form-section:last-of-type { border-bottom: 0; }
.form-section-head h3 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.form-section-head p { color: var(--text-3); font-size: 13px; margin: 0; }
.settings-card { padding: 0 24px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 0 20px; border-top: 1px solid var(--border); }
.form-card .form-actions { position: sticky; bottom: 0; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); margin: 0 -24px; padding: 14px 24px; border-radius: 0 0 var(--radius-lg) var(--radius-lg); z-index: 5; }

.choices { display: grid; gap: 10px; }
.choices-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choices-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1280px) { .choices-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.choice { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: #fff; cursor: pointer; transition: border-color .15s, box-shadow .15s, background .15s; }
.choice:hover { border-color: #B6BDC9; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-row { flex-direction: row; align-items: center; gap: 14px; }
.choice-row > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.choice-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--neutral-soft); color: var(--text-2); flex: none; margin-bottom: 4px; }
.choice-row .choice-icon { margin-bottom: 0; }
.choice-title { font-weight: 600; color: var(--text); }
.choice-desc { font-size: 12.5px; color: var(--text-3); line-height: 1.4; }
.choice:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); background: #FAFCFE; }
.choice:has(input:checked) .choice-icon { background: var(--primary-soft); color: var(--primary); }
.choice:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }

.segmented { display: inline-flex; padding: 3px; background: var(--neutral-soft); border-radius: var(--radius); gap: 2px; width: fit-content; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: inline-flex; align-items: center; height: 32px; padding: 0 16px; border-radius: 6px; color: var(--text-2); font-weight: 500; }
.segmented input:checked + span { background: #fff; color: var(--text); box-shadow: var(--shadow-sm); }
.total-box { display: flex; align-items: baseline; gap: 10px; padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px dashed var(--border-strong); }
.total-box strong { font-size: 20px; font-weight: 650; letter-spacing: -.01em; }

/* --------------------------------------------------------------- Alerts */
.alert { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid; border-radius: var(--radius); margin-bottom: 20px; }
.alert-icon { margin-top: 1px; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; margin-bottom: 1px; }
.alert-text { color: inherit; opacity: .92; }
.alert-action { flex: none; align-self: center; }
.alert-action form { margin: 0; }
.alert-close { background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; padding: 2px; border-radius: 4px; }
.alert-close:hover { opacity: 1; }

/* ---------------------------------------------------------------- Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); min-width: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 15px; font-weight: 600; }
.card-sub { color: var(--text-3); font-size: 13px; margin: 2px 0 0; }
.card-body { padding: 20px; }
.card-footer { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card > .card-header:last-child { border-bottom: 0; }
.collapsible > summary { list-style: none; cursor: pointer; justify-content: flex-start; }
.collapsible > summary::-webkit-details-marker { display: none; }
.collapsible > summary .chev { margin-left: auto; color: var(--text-3); transition: transform .2s; }
.collapsible[open] > summary .chev { transform: rotate(180deg); }
.collapsible:not([open]) > summary { border-bottom: 0; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { padding: 18px 20px; }
.stat-label { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.stat-icon { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--neutral-soft); color: var(--text-2); }
.stat-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 12px; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-sub { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.stat-danger .stat-icon { background: var(--danger-soft); color: var(--danger); }
.stat-danger .stat-value { color: var(--danger); }

.grid-main { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* --------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--text-3); background: var(--surface-2); padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #FCFCFD; }
.table tr.is-flagged td:first-child { box-shadow: inset 3px 0 0 #F79009; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { width: 1%; text-align: right; white-space: nowrap; }
.card > .table-wrap:last-child .table tbody tr:last-child td:first-child { border-bottom-left-radius: var(--radius-lg); }
.cell-link { color: var(--text); font-weight: 500; }
.cell-link:hover { color: var(--primary); }
.cell-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.num-strong { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }

.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person-text { min-width: 0; }
.person-name { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-sub { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 600; font-size: 12.5px; flex: none; letter-spacing: .02em; }
.avatar-sm { width: 30px; height: 30px; font-size: 11.5px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.filters { display: flex; gap: 4px; flex-wrap: wrap; }
.filters a { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: var(--radius); color: var(--text-2); font-weight: 500; font-size: 13px; border: 1px solid transparent; }
.filters a:hover { background: var(--neutral-soft); color: var(--text); }
.filters a.active { background: #fff; border-color: var(--border); box-shadow: var(--shadow-xs); color: var(--text); }
.filter-count { font-size: 11.5px; color: var(--text-3); background: var(--neutral-soft); border-radius: 999px; padding: 1px 7px; }
.search { position: relative; margin: 0; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-4); pointer-events: none; }
.search .input { height: 36px; width: 260px; padding-left: 36px; }

.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border); margin-bottom: 24px; overflow-x: auto; }
.tabs a { padding: 10px 2px; color: var(--text-3); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--primary); border-color: var(--primary); }

.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); color: inherit; }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--surface-2); color: inherit; }
.list-icon { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--neutral-soft); color: var(--text-2); flex: none; }
.list-text { flex: 1; min-width: 0; }
.list-title { color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dl { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 12px 16px; margin: 20px 0 0; }
.dl dt { color: var(--text-3); }
.dl dd { margin: 0; color: var(--text); font-weight: 500; }
.dl-tight { grid-template-columns: 110px minmax(0, 1fr); margin: 16px 0; }

.lines { display: flex; flex-direction: column; }
.line { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; color: var(--text-2); font-variant-numeric: tabular-nums; }
.line-total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 12px; color: var(--text); font-weight: 600; }

.empty { text-align: center; padding: 44px 24px; }
.empty-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--neutral-soft); color: var(--text-2); margin: 0 auto 12px; }
.empty h3 { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.empty p { color: var(--text-3); margin: 0 auto 16px; max-width: 360px; }

.card-chip { display: inline-flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; color: var(--text); white-space: nowrap; }
.card-brand { display: inline-grid; place-items: center; min-width: 38px; height: 24px; padding: 0 6px; border-radius: 4px; background: #374151; color: #fff; font-size: 10px; font-weight: 700; letter-spacing: .05em; }
.brand-visa { background: #1A1F71; }
.brand-mastercard { background: #1C1C1C; }
.brand-amex { background: #2E77BC; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 16px; }
.chip { border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); border-radius: 6px; padding: 4px 8px; font: 12px var(--mono); cursor: pointer; }
.chip:hover { border-color: var(--primary); color: var(--primary); }
.copy-field { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.copy-field code { flex: 1; min-width: 0; background: none; padding: 0; overflow-x: auto; white-space: nowrap; color: var(--text); }
.steps { margin: 0; padding-left: 20px; color: var(--text-2); display: flex; flex-direction: column; gap: 6px; }
.status-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.status-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 0; }
.status-title { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.status-card { margin-bottom: 20px; }
.settings-card + .card, .status-card + .settings-card { margin-top: 20px; }
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 32px 20px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface-2); color: var(--text-2); text-align: center; cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover { border-color: var(--primary); background: #FAFCFE; }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone-title { font-weight: 600; color: var(--text); }

/* ---------------------------------------------------------------- Menus */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; padding: 4px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 40; text-align: left; }
.menu-pop form { margin: 0; }
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 6px; color: var(--text); font: 14px var(--font); text-align: left; cursor: pointer; white-space: nowrap; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--neutral-soft); color: var(--text); }
.menu-pop .icon { color: var(--text-3); }
.menu-pop .danger, .menu-pop .danger .icon { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }

/* ---------------------------------------------------------------- Chart */
.chart { width: 100%; height: 220px; display: block; }
.chart .grid { stroke: var(--border); stroke-dasharray: 3 4; }
.chart .bar { fill: #CCE4F4; }
.chart .bar-current { fill: var(--primary); }
.chart .axis { fill: var(--text-3); font-size: 12px; text-anchor: middle; font-family: var(--font); }
.chart .value { fill: var(--text-2); font-size: 11.5px; font-weight: 500; text-anchor: middle; font-family: var(--font); }

/* ------------------------------------------------------------ Admin app */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 12px 12px; background: var(--surface); border-right: 1px solid var(--border); }
.sidebar .brand { padding: 0 8px 14px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 18px 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-4); }
.nav a { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: var(--radius); color: var(--text-2); font-weight: 500; }
.nav a .icon { color: var(--text-3); }
.nav a:hover { background: var(--neutral-soft); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav a.active .icon { color: var(--primary); }
.nav-count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 600; display: inline-grid; place-items: center; }
.sidebar-footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 6px 0; border-top: 1px solid var(--border); }
.main { min-width: 0; }
.content { max-width: 1280px; margin: 0 auto; padding: 32px 32px 64px; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-heading { min-width: 0; }
.page-title { font-size: 24px; font-weight: 650; letter-spacing: -.02em; line-height: 1.25; }
.page-subtitle { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text-3); margin: 6px 0 0; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-actions form { margin: 0; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); font-weight: 500; font-size: 13px; margin-bottom: 10px; }
.back-link:hover { color: var(--text); }

/* --------------------------------------------------------------- Portal */
.portal-header { position: sticky; top: 0; z-index: 30; background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.portal-header-inner { max-width: 1080px; margin: 0 auto; height: 64px; padding: 0 24px; display: flex; align-items: center; gap: 32px; }
.portal-nav { display: flex; gap: 4px; }
.portal-nav a { display: inline-flex; align-items: center; height: 36px; padding: 0 12px; border-radius: var(--radius); color: var(--text-2); font-weight: 500; white-space: nowrap; }
.portal-nav a:hover { background: var(--neutral-soft); color: var(--text); }
.portal-nav a.active { background: var(--neutral-soft); color: var(--text); }
.user-menu { margin-left: auto; }
.user-trigger { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 8px 0 4px; border-radius: 999px; cursor: pointer; color: var(--text-2); }
.user-trigger:hover { background: var(--neutral-soft); }
.user-name { font-weight: 500; color: var(--text); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-main { max-width: 1080px; margin: 0 auto; padding: 36px 24px 48px; }
.portal-head { margin-bottom: 24px; }
.portal-head h1 { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-bottom: 4px; }
.portal-footer { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 24px; color: var(--text-4); font-size: 12.5px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 32px 0 12px; }
.section-head h2 { font-size: 16px; font-weight: 600; }

.services { display: flex; flex-direction: column; gap: 14px; }
.services.is-muted { opacity: .7; }
.service-main { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 20px; }
.service-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 11px; background: var(--primary-soft); color: var(--primary); flex: none; }
.service-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 15px; font-weight: 600; color: var(--text); }
.service-meta { color: var(--text-3); margin-top: 2px; }
.service-lines { color: var(--text-3); font-size: 12.5px; margin-top: 6px; }
.service-price { text-align: right; }
.price { font-size: 20px; font-weight: 650; letter-spacing: -.01em; color: var(--text); font-variant-numeric: tabular-nums; }
.service-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); flex-wrap: wrap; }
.service-status { display: flex; align-items: center; gap: 8px; font-weight: 500; min-width: 0; }
.service-status.muted { color: var(--text-2); }
.service-actions { display: flex; gap: 8px; }

.checkout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); gap: 24px; align-items: start; margin-top: 8px; }
.checkout-main .card-body { padding: 28px; }
.checkout-title { font-size: 22px; font-weight: 650; letter-spacing: -.02em; margin-bottom: 6px; }
.section-label { font-size: 13px; font-weight: 600; color: var(--text); text-transform: none; margin: 28px 0 12px; padding-top: 24px; border-top: 1px solid var(--border); }
.payment-element { min-height: 120px; margin-top: 4px; }
#new-card { margin-top: 14px; }
.choices + #new-card { margin-top: 14px; }
.pe-loading { display: flex; align-items: center; gap: 10px; color: var(--text-3); padding: 24px 0; }
.consent { display: flex; align-items: flex-start; gap: 10px; margin-top: 18px; padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-2); font-size: 13px; line-height: 1.5; cursor: pointer; }
.pay-error { margin-top: 14px; padding: 10px 12px; border-radius: var(--radius); background: var(--danger-soft); border: 1px solid var(--danger-border); color: var(--danger); font-size: 13.5px; }
#checkout-submit { margin-top: 20px; }
.secure-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 14px 0 0; color: var(--text-3); font-size: 12.5px; text-align: center; }
.summary { position: sticky; top: 88px; }
.summary-service { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.due-today { display: flex; justify-content: space-between; align-items: baseline; margin-top: 16px; padding: 14px 16px; border-radius: var(--radius); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.due-today strong { font-size: 20px; letter-spacing: -.01em; }
.summary-note { margin: 12px 0 8px; line-height: 1.55; }
.pm-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pm-card { display: flex; flex-direction: column; gap: 8px; }
.pm-card .card-chip { padding: 10px 14px 10px 10px; font-size: 15px; }
.pm-card .card-brand { min-width: 46px; height: 30px; font-size: 11px; }

/* ----------------------------------------------------------------- Auth */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(900px 480px at 50% -120px, #E2F0FA 0%, rgba(227, 234, 251, 0) 70%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; padding: 32px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); }
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head .brand { justify-content: center; margin-bottom: 20px; }
.auth-head .brand-logo { height: 52px; }
.auth-head h1 { font-size: 20px; font-weight: 650; letter-spacing: -.01em; margin-bottom: 6px; }
.auth-head p { color: var(--text-3); margin: 0; }
.auth-foot { display: flex; align-items: center; gap: 6px; margin-top: 20px; color: var(--text-4); font-size: 12.5px; }

/* ------------------------------------------------------------ v5 extras */
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row form { margin: 0; }
.import-search { display: flex; align-items: flex-end; gap: 12px; }
.search-wide .input { width: 100%; height: 40px; }
.import-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.mini-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin-bottom: 10px; }
.import-btn { margin-top: 14px; }
.stack > .card + form, .stack > form { margin: 0; }
.compose { display: flex; flex-direction: column; gap: 14px; border-bottom: 1px solid var(--border); background: #FCFCFD; }
.preview-subject { padding: 12px 20px; border-bottom: 1px solid var(--border); font-weight: 500; color: var(--text); }
.preview-frame { display: block; width: 100%; height: 520px; border: 0; background: #F4F5F7; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.toggle-row > span { display: flex; flex-direction: column; gap: 2px; }
.toggle-title { font-weight: 500; color: var(--text); }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(16,24,40,.2); transition: transform .15s; }
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(16px); }
.switch:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.menu-form { width: 280px; padding: 14px; white-space: normal; }
.menu-form form { display: flex; flex-direction: column; gap: 10px; }
.menu-form-title { font-weight: 600; color: var(--text); }
.menu-form p { margin: 0; }
.menu-pop.menu-form .btn { display: inline-flex; justify-content: center; width: 100%; padding: 0 10px; border: 1px solid var(--border-strong); background: #fff; }
.menu-pop.menu-form .btn:hover { background: var(--surface-2); }
.service-actions { align-items: center; }
.card-hint { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 10px 12px; border-radius: var(--radius); background: var(--success-soft); border: 1px solid var(--success-border); color: var(--success); font-size: 13px; font-weight: 500; }
.form-actions-left { margin-right: auto; align-self: center; }
.removal-card { margin-top: 20px; }
.danger-zone { border-color: var(--danger-border); }
.danger-zone .card-header { border-bottom-color: var(--danger-border); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #912018; border-color: #912018; color: #fff; }
.removal-request > summary { list-style: none; width: fit-content; }
.removal-request > summary::-webkit-details-marker { display: none; }
.removal-request[open] > summary { display: none; }
.removal-form { margin-top: 4px; }

/* ----------------------------------------------------------- Responsive */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main, .checkout { grid-template-columns: minmax(0, 1fr); }
  .summary { position: static; }
  .form-section { grid-template-columns: minmax(0, 1fr); gap: 16px; }
}
@media (max-width: 800px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; z-index: 30; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .sidebar .brand { padding: 0 4px 0 0; }
  .nav-label, .sidebar-footer .person { display: none; }
  .sidebar .brand-logo { display: none; }
  .sidebar .brand-logo-mark { display: block; }
  .portal-header .brand-logo { height: 32px; }
  .nav { flex-direction: row; }
  .nav a span { display: none; }
  .nav a { width: 40px; justify-content: center; padding: 0; position: relative; }
  .nav-count { position: absolute; top: -2px; right: -2px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
  .sidebar-footer { margin: 0 0 0 auto; border: 0; padding: 0; }
  .content { padding: 20px 16px 48px; }
  .page-title { font-size: 21px; }
  .page-header { align-items: flex-start; }
  .stats, .stats-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .form-grid-3, .choices-3, .choices-4 { grid-template-columns: minmax(0, 1fr); }
  .form-card, .settings-card { padding: 0 16px; }
  .form-card .form-actions { margin: 0 -16px; padding: 12px 16px; }
  .search, .search .input { width: 100%; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .dl { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .dl dd { margin-bottom: 10px; }
  .portal-header-inner { height: auto; flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px; }
  .portal-nav { order: 3; width: 100%; overflow-x: auto; margin: 0 -4px; }
  .user-name { display: none; }
  .portal-main { padding: 24px 16px 40px; }
  .service-main { grid-template-columns: auto minmax(0, 1fr); }
  .service-price { grid-column: 2; text-align: left; }
  .checkout-main .card-body { padding: 20px; }
  .menu-pop { right: -4px; }
  .import-grid { grid-template-columns: minmax(0, 1fr); }
  .import-search { flex-direction: column; align-items: stretch; }
  .menu-form { width: min(280px, calc(100vw - 48px)); }
}
