/*
 * Billing app styles. iOS look: grey page, white rounded cards, blue accent.
 * Class reference for views: docs/ui.md.
 */

:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --ink: #111111;
  --ink-2: #3c3c43;
  --muted: #6e6e73;
  --line: #e5e5ea;
  --accent: #2563eb;
  --accent-soft: #e8f0fe;
  --info: #4f46e5;
  --info-soft: #eef0ff;
  --success: #1f7f38;
  --success-soft: #e6f4ea;
  --warn: #a65c00;
  --warn-soft: #fdf1e2;
  --danger: #d70015;
  --danger-soft: #fdecee;
  --radius: 14px;
  --shadow-card: 0 0 0 1px rgba(17, 17, 17, 0.04), 0 1px 2px rgba(17, 17, 17, 0.04), 0 8px 24px -12px rgba(17, 17, 17, 0.1);
  --shadow-float: 0 0 0 1px rgba(17, 17, 17, 0.05), 0 12px 32px -8px rgba(17, 17, 17, 0.22), 0 32px 64px -24px rgba(17, 17, 17, 0.18);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --tabbar-h: 0px;
  --fab-clear: 0px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  color: var(--ink);
  background-color: var(--bg);
  background-image: radial-gradient(80% 36rem at 50% -10rem, rgba(37, 99, 235, 0.075), transparent 70%), linear-gradient(180deg, #eef0f7 0%, var(--bg) 28rem);
  background-repeat: no-repeat;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(37, 99, 235, 0.18); }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.danger-text { color: var(--danger); }
.success-text { color: var(--success); }
.warn-text { color: var(--warn); }
.accent-text { color: var(--accent); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.small { font-size: 14px; }
.tiny { font-size: 13px; }
.bold { font-weight: 600; }
.pre { white-space: pre-line; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--card); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 8px; }
.icon { width: 24px; height: 24px; flex-shrink: 0; }
.icon-sm { width: 18px; height: 18px; }
.icon-lg { width: 32px; height: 32px; }
.stack > * + * { margin-top: 12px; }
.stack-sm > * + * { margin-top: 6px; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt { margin-top: 16px; }
.mt-sm { margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ───────────── Shell ───────────── */

body.with-tabbar { --tabbar-h: calc(56px + env(safe-area-inset-bottom)); }
body.with-fab { --fab-clear: 4.5rem; }

.content {
  margin: 0 auto;
  width: 100%;
  max-width: 28rem;
  min-height: 100dvh;
  padding-bottom: max(calc(var(--tabbar-h) + var(--fab-clear) + 2rem), calc(env(safe-area-inset-bottom) + 2rem));
  display: flex;
  flex-direction: column;
}
@media (min-width: 40rem) { .content { max-width: 42rem; } }

.sidebar { display: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around;
  height: var(--tabbar-h); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(249, 249, 249, 0.92); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid rgba(0, 0, 0, 0.15);
}
.tab {
  position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 10.5px; font-weight: 500; color: #8e8e93; min-height: 44px;
}
.tab.active { color: var(--accent); }
.tab-dot { position: absolute; top: 6px; left: calc(50% + 8px); width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
body.with-fab .header-new { display: none; }

.menu.fab-menu { position: fixed; right: 16px; bottom: calc(var(--tabbar-h) + 16px); z-index: 45; }
.fab {
  list-style: none; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff; cursor: pointer;
  box-shadow: 0 10px 28px -8px rgba(37, 99, 235, 0.65), 0 2px 6px -2px rgba(37, 99, 235, 0.4);
  transition: transform 200ms var(--ease);
}
.fab::-webkit-details-marker { display: none; }
.fab-menu[open] .fab { transform: rotate(45deg); }

@media (min-width: 64rem) {
  body.with-tabbar { --tabbar-h: 0px; }
  body.with-fab { --fab-clear: 0px; }
  body.app { padding-left: 16rem; }
  .tabbar, .fab-menu { display: none; }
  body.with-fab .header-new { display: inline-flex; }
  .content { max-width: 48rem; padding: 16px 24px 48px; }
  .content.wide { max-width: 72rem; }
  .sidebar {
    display: flex; flex-direction: column; gap: 12px;
    position: fixed; top: 0; bottom: 0; left: 0; width: 16rem; padding: 20px 12px; overflow-y: auto;
    background: rgba(255, 255, 255, 0.6); border-right: 1px solid var(--line);
  }
  .mobile-only { display: none !important; }
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; color: var(--ink); padding: 4px 8px; }
.sidebar-brand > span { display: flex; flex-direction: column; min-width: 0; }
.sidebar-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-email { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-new { position: relative; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-group { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 4px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 10px;
  color: var(--ink-2); font-size: 15px; font-weight: 500; background: none; border: 0; cursor: pointer; text-align: left;
}
.sidebar-link .icon { width: 20px; height: 20px; color: var(--muted); }
.sidebar-link:hover { background: rgba(0, 0, 0, 0.04); }
.sidebar-link.active { background: var(--accent-soft); color: var(--accent); }
.sidebar-link.active .icon { color: var(--accent); }
.dot-count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 12px; font-weight: 600; text-align: center; }

/* ───────────── Page structure ───────────── */

.page-header { padding: 16px 20px 12px; }
@media (min-width: 64rem) { .page-header { padding: 24px 16px 16px; } }
.back-link { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; margin-left: -4px; margin-bottom: 4px; font-size: 17px; color: var(--accent); max-width: 100%; }
.back-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-header h1 { min-width: 0; font-size: 32px; line-height: 1.1; font-weight: 700; letter-spacing: -0.025em; overflow-wrap: anywhere; }
@media (min-width: 64rem) { .page-header h1 { font-size: 30px; } }
.page-header-action { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.page-subtitle { margin-top: 6px; font-size: 15px; color: var(--muted); }

.section { padding: 8px 16px; }
.section-title {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; min-height: 28px;
  padding: 0 16px 6px; font-size: 12.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.section-title h2 { font-size: inherit; font-weight: inherit; }
.section-title span { text-transform: none; letter-spacing: 0; font-size: 14px; }
.section-footer { padding: 8px 16px 0; font-size: 13px; color: var(--muted); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-card); overflow: hidden; }
.card-pad { padding: 16px; }
.card + .card { margin-top: 12px; }
a.card { display: block; color: inherit; transition: box-shadow 200ms ease, transform 160ms var(--ease); }
a.card:active { transform: scale(0.98); }

/* Two columns on desktop: main + aside. */
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }
@media (min-width: 64rem) { .split { grid-template-columns: minmax(0, 1fr) 20rem; gap: 8px; align-items: start; } }

/* ───────────── Lists ───────────── */

.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-card); overflow: visible; }
.row { position: relative; display: flex; align-items: center; min-height: 56px; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--line); }
.row:first-child .row-link { border-top-left-radius: var(--radius); border-top-right-radius: var(--radius); }
.row:last-child .row-link { border-bottom-left-radius: var(--radius); border-bottom-right-radius: var(--radius); }
.row-link, .row-static { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 16px; color: var(--ink); }
.row-link:hover { background: rgba(0, 0, 0, 0.025); }
.row-link:active { background: rgba(0, 0, 0, 0.05); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-size: 16px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-aside { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; font-size: 16px; font-weight: 600; }
.row-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.row .menu { margin-right: 8px; }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 12px 16px; font-size: 16px; }
.kv + .kv { border-top: 0.5px solid var(--line); }
.kv dt, .kv .k { color: var(--muted); }
.kv dd, .kv .v { margin: 0; text-align: right; overflow-wrap: anywhere; }

.avatar {
  --hue: 215;
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: hsl(var(--hue) 70% 92%); color: hsl(var(--hue) 55% 32%); font-weight: 600; font-size: 15px;
}
.avatar-sm { width: 32px; height: 32px; font-size: 13px; }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }

.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap; line-height: 1.5; }
.badge-neutral { background: #ececf0; color: var(--ink-2); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: #f2f2f4; color: var(--muted); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; padding: 7px 14px; border-radius: 999px; background: var(--card); color: var(--ink-2); font-size: 14px; font-weight: 500; box-shadow: var(--shadow-card); }
.chip.active { background: var(--ink); color: #fff; }
.chip-count { opacity: 0.6; margin-left: 2px; }

.search { display: flex; align-items: center; gap: 8px; margin: 0 16px 8px; padding: 0 12px; height: 40px; border-radius: 12px; background: rgba(118, 118, 128, 0.12); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 16px; color: var(--ink); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px; font-size: 14px; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 40px 24px; gap: 6px; }
.empty-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--accent-soft); color: var(--accent); margin-bottom: 8px; }
.empty h3 { font-size: 19px; font-weight: 600; }
.empty p { color: var(--muted); max-width: 22rem; font-size: 15px; }
.empty-action { margin-top: 12px; }
.error-page { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 80px 24px; }

/* ───────────── Stats ───────────── */

.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 64rem) { .stat-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { padding: 14px 16px; }
.stat + .stat { margin-top: 0; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.stat-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat.danger .stat-value { color: var(--danger); }
.stat.success .stat-value { color: var(--success); }
.big-amount { font-size: 40px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.big-amount.struck { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 2px; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding: 12px 16px 4px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; min-width: 0; }
.bar { width: 100%; max-width: 36px; border-radius: 6px 6px 2px 2px; background: var(--accent); min-height: 2px; }
.bar.muted-bar { background: #d7dbe6; }
.bar-label { font-size: 11px; color: var(--muted); }
.progress { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* ───────────── Buttons ───────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px;
  border-radius: 12px; border: 0; cursor: pointer; font-size: 16px; font-weight: 600; white-space: nowrap; text-decoration: none;
  transition: transform 160ms var(--ease), opacity 160ms, background-color 160ms;
}
.btn:active { transform: scale(0.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-secondary { background: var(--card); color: var(--accent); box-shadow: var(--shadow-card); }
.btn-tinted { background: var(--accent-soft); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-success { background: var(--success); color: #fff; }
.btn-plain { background: transparent; color: var(--accent); padding: 0 8px; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 15px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row > * { flex: 1 1 auto; }
.btn-row .btn, .btn-row form .btn { width: 100%; }
.inline-form { display: inline; margin: 0; }
.btn-row .inline-form { display: block; }

/* Sticky action bar at the bottom of editors and detail pages. */
.actionbar {
  position: sticky; bottom: var(--tabbar-h); z-index: 30; margin-top: auto;
  display: flex; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(242, 242, 247, 0.88); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid rgba(0, 0, 0, 0.08);
}
body.with-tabbar .actionbar { padding-bottom: 12px; }
.actionbar > *, .actionbar > form { flex: 1; }
.actionbar .btn { width: 100%; }
@media (min-width: 64rem) { .actionbar { position: static; background: transparent; border: 0; backdrop-filter: none; padding: 16px; justify-content: flex-end; } .actionbar > *, .actionbar > form { flex: 0 0 auto; } }

/* ───────────── Menus ───────────── */

.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-trigger { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--muted); }
.menu-trigger:hover { background: rgba(0, 0, 0, 0.05); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 13rem; padding: 6px;
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow-float); animation: pop 180ms var(--ease);
}
.sidebar-new .menu-panel { left: 0; right: 0; }
.menu-up { top: auto; bottom: calc(100% + 10px); }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 9px; border: 0; background: none;
  color: var(--ink); font-size: 15px; font-weight: 500; text-align: left; cursor: pointer;
}
.menu-item:hover { background: rgba(0, 0, 0, 0.05); }
.menu-item.danger { color: var(--danger); }
.menu-item .icon { color: var(--accent); }
.menu-form { display: block; margin: 0; }
.menu-form button { width: 100%; }
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(-4px); } to { opacity: 1; transform: none; } }

/* ───────────── Forms ───────────── */

.form-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 4px 16px; }
.form-card > .field, .form-card > .switch-row, .form-card > .grid-2 { padding: 12px 0; }
.form-card > * + * { border-top: 0.5px solid var(--line); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field-hint { font-size: 13px; color: var(--muted); }
.field-error { font-size: 13px; color: var(--danger); font-weight: 500; }
.field.has-error .input { box-shadow: inset 0 0 0 1.5px var(--danger); }
.input {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 0; outline: none;
  background: rgba(118, 118, 128, 0.1); font-size: 16px; color: var(--ink);
}
.input:focus { box-shadow: inset 0 0 0 2px var(--accent); background: #fff; }
textarea.input { resize: vertical; min-height: 80px; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; padding-right: 34px; }
/* Searchable dropdown (app.js initCombo) over a hidden native <select> */
.combo { position: relative; min-width: 0; }
.combo-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.combo-button {
  display: block; text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; padding-right: 34px;
}
.combo-button.combo-empty { color: var(--muted); }
.combo.open .combo-button { box-shadow: inset 0 0 0 2px var(--accent); background-color: #fff; }
.combo-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 12rem; padding: 6px;
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow-float); animation: pop 180ms var(--ease);
}
.combo-search { min-height: 38px; padding: 8px 10px; margin-bottom: 6px; }
.combo-list { list-style: none; margin: 0; padding: 0; max-height: 16rem; overflow-y: auto; }
.combo-option, .combo-none { padding: 10px 12px; border-radius: 9px; font-size: 15px; color: var(--ink); }
.combo-option { cursor: pointer; }
.combo-option.active { background: rgba(118, 118, 128, 0.12); }
.combo-option.selected { color: var(--accent); font-weight: 600; }
.combo-none { color: var(--muted); }
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-prefix > .input { padding-left: 26px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 30rem) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch { appearance: none; position: relative; width: 51px; height: 31px; border-radius: 16px; background: #e9e9eb; cursor: pointer; flex-shrink: 0; transition: background 200ms; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15); transition: transform 200ms var(--ease); }
.switch:checked { background: #34c759; }
.switch:checked::after { transform: translateX(20px); }
.segmented { display: inline-flex; padding: 2px; border-radius: 9px; background: rgba(118, 118, 128, 0.12); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: block; padding: 6px 12px; border-radius: 7px; font-size: 14px; font-weight: 500; cursor: pointer; }
.segmented input:checked + span { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.color-swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.color-swatches label { position: relative; }
.color-swatches input { position: absolute; opacity: 0; }
.color-swatches span { display: block; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1); }
.color-swatches input:checked + span { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }

/* Line items editor (partials/line_items_editor). */
.line-editor .line { padding: 12px 16px; position: relative; }
.line-editor .line + .line { border-top: 0.5px solid var(--line); }
.line-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 8px; }
.line-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 14px; }
.line-amount { font-weight: 600; font-size: 16px; }
.line-remove { border: 0; background: none; color: var(--danger); font-size: 14px; cursor: pointer; padding: 6px; }
.totals { font-size: 15px; }
.totals .t-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; color: var(--ink-2); }
.totals .t-row > span:first-child { color: var(--muted); }
.totals .t-total { display: flex; justify-content: space-between; border-top: 0.5px solid var(--line); margin-top: 6px; padding-top: 8px; font-size: 17px; font-weight: 700; }
.totals .t-paid { color: var(--success); }

/* Read-only line table on detail / client pages. */
.doc-lines .doc-line { padding: 12px 16px; }
.doc-lines .doc-line + .doc-line { border-top: 0.5px solid var(--line); }
.doc-line-top { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
.doc-line-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ───────────── Dialogs, toasts, celebration ───────────── */

dialog { border: 0; padding: 0; background: transparent; max-width: calc(100vw - 32px); }
dialog::backdrop { background: rgba(0, 0, 0, 0.35); backdrop-filter: blur(2px); }
.dialog-card { width: min(24rem, calc(100vw - 32px)); background: var(--card); border-radius: 18px; box-shadow: var(--shadow-float); padding: 20px; animation: pop 220ms var(--ease); }
.dialog-card h2 { font-size: 19px; font-weight: 700; }
.dialog-card p { margin-top: 6px; color: var(--ink-2); font-size: 15px; }
.dialog-actions { display: flex; gap: 8px; margin-top: 18px; }
.dialog-actions .btn { flex: 1; }
.sheet { width: min(32rem, 100vw); max-height: 90dvh; overflow-y: auto; margin: auto auto 0; }
.sheet .dialog-card { width: 100%; border-radius: 18px 18px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 40rem) { .sheet { margin: auto; } .sheet .dialog-card { border-radius: 18px; } }

.toasts { position: fixed; z-index: 200; left: 50%; top: calc(env(safe-area-inset-top) + 12px); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(26rem, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 14px; background: rgba(30, 30, 32, 0.94); color: #fff; box-shadow: var(--shadow-float); animation: toast-in 320ms var(--ease) both; font-size: 15px; }
.toast.out { animation: toast-out 180ms ease-in both; }
.toast .icon { width: 20px; height: 20px; margin-top: 1px; }
.toast-success .icon { color: #30d158; }
.toast-error .icon { color: #ff453a; }
.toast-info .icon { color: #64d2ff; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; }
.toast-desc { opacity: 0.8; font-size: 14px; margin-top: 2px; }
.toast-action { color: #64d2ff; font-weight: 600; background: none; border: 0; cursor: pointer; padding: 0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-16px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: scale(0.94); } }

.celebrate { text-align: center; }
.celebrate-check { width: 72px; height: 72px; margin: 4px auto 10px; color: var(--success); }
.celebrate-check circle { stroke-dasharray: 70; stroke-dashoffset: 70; animation: draw 480ms var(--ease) forwards; }
.celebrate-check path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: draw 420ms var(--ease) 160ms forwards; }
.celebrate-amount { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; margin-top: 4px; }
.celebrate .dialog-actions { flex-direction: column; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ───────────── Banners ───────────── */

.banner { margin: 8px 16px; padding: 12px 16px; border-radius: 14px; font-size: 15px; }
.banner-info { background: var(--accent-soft); color: var(--accent); }
.banner-success { background: var(--success-soft); color: var(--success); }
.banner-warn { background: var(--warn-soft); color: var(--warn); }
.banner-danger { background: var(--danger-soft); color: var(--danger); }
.banner-muted { background: rgba(229, 229, 234, 0.6); color: var(--ink-2); }

/* ───────────── Public (client-facing) pages ───────────── */

.public-main { width: 100%; max-width: 42rem; margin: 0 auto; padding: 24px 16px 24px; min-height: 100dvh; display: flex; flex-direction: column; }
.public-main.wide, body.public .doc-wide { max-width: 56rem; }
.brand-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.brand-header img { max-height: 44px; max-width: 160px; object-fit: contain; }
.brand-header .brand-name { font-size: 17px; font-weight: 700; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 700; }
.preview-pill { display: inline-flex; align-items: center; gap: 6px; margin: 0 auto 16px; padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600; }
.public-footer { margin-top: auto; padding: 32px 24px 8px; text-align: center; font-size: 13px; color: var(--muted); }
.doc-eyebrow { font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.doc-title { font-size: 28px; font-weight: 700; line-height: 1.15; letter-spacing: -0.025em; margin-top: 8px; }
.doc-grid { display: grid; gap: 16px; margin-top: 20px; }
@media (min-width: 40rem) { .doc-grid { grid-template-columns: minmax(0, 1fr) 16rem; align-items: start; } .doc-grid > .doc-aside { order: 2; } }
.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 16px; font-size: 14px; }
.parties .label { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }

/* ───────────── Auth ───────────── */

/* Form column (brand bar, form, footer) + blue product panel from 64rem. Screenshots live in assets/site. */
.auth-shell { min-height: 100dvh; display: grid; }
.auth-col { display: flex; flex-direction: column; min-height: 100dvh; padding: 0 16px; }
.auth-top { display: flex; align-items: center; height: 64px; width: 100%; max-width: 24rem; margin: 0 auto; }
.auth-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; font-size: 19px; letter-spacing: -0.01em; }
.auth-brand img { border-radius: 7px; }
.auth-main { width: 100%; max-width: 24rem; margin: auto; padding: 32px 0 40px; }
.auth-main h1 { font-size: 32px; font-weight: 750; line-height: 1.1; letter-spacing: -0.03em; }
.auth-sub { margin-top: 8px; font-size: 17px; }
.auth-main .form-card { margin-top: 24px; }
.auth-switch { margin-top: 16px; text-align: center; font-size: 15px; color: var(--muted); }
.auth-perks { list-style: none; margin: 32px 0 0; padding: 20px 0 0; border-top: 0.5px solid var(--line); display: grid; gap: 12px; font-size: 15px; color: var(--ink-2); }
.auth-perks li { display: flex; align-items: center; gap: 12px; }
.auth-perks .icon { color: var(--accent); }
.auth-foot { display: flex; justify-content: space-between; width: 100%; max-width: 24rem; margin: 0 auto; padding: 16px 0 24px; font-size: 13px; color: var(--muted); }
.auth-foot a { color: var(--muted); }
.auth-foot a:hover { color: var(--ink); }
.auth-panel { display: none; }
@media (min-width: 64rem) {
  .auth-shell { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
  .auth-col { padding: 0 48px; }
  .auth-top { max-width: none; margin: 0; height: 80px; }
  .auth-foot { max-width: none; margin: 0; }
  .auth-panel {
    position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; overflow: hidden;
    margin: 0; padding: 12px 12px 12px 0;
  }
  .auth-panel::before { content: ""; position: absolute; inset: 12px 12px 12px 0; border-radius: 28px; background: radial-gradient(120% 90% at 100% 0%, #3b82f6 0%, #2563eb 45%, #1d4ed8 100%); }
  .auth-panel-copy { position: relative; padding: 64px 56px 0; color: #fff; max-width: 34rem; }
  .auth-panel h2 { font-size: 40px; font-weight: 750; line-height: 1.08; letter-spacing: -0.03em; }
  .auth-panel p { margin-top: 16px; font-size: 18px; line-height: 1.45; color: rgba(255, 255, 255, 0.86); }
  .auth-phone {
    position: relative; margin: 48px auto -120px; width: 300px; aspect-ratio: 390 / 844; flex-shrink: 0;
    padding: 9px; border-radius: 46px; background: #1c1c21;
    box-shadow: 0 40px 80px -24px rgba(10, 20, 60, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  }
  .auth-phone img { width: 100%; height: 100%; object-fit: cover; object-position: top; border-radius: 37px; }
  .auth .toasts { left: calc(100% / 2.05 / 2); width: 22rem; } /* centre of the form column (1fr of 1fr + 1.05fr) */
}
@media (min-width: 64rem) and (max-height: 760px) { .auth-phone { width: 250px; margin-top: 36px; } .auth-panel-copy { padding-top: 48px; } }
@media (min-width: 64rem) and (prefers-reduced-motion: no-preference) {
  .auth-phone { animation: auth-phone-in 1s var(--ease) both 0.1s; }
}
@keyframes auth-phone-in { from { opacity: 0; translate: 0 48px; } to { opacity: 1; translate: 0 0; } }

/* quotes & portal */
.public-main:has(> .doc-wide) { max-width: 56rem; }
.center-note { padding: 24px 32px; text-align: center; font-size: 15px; }
.struck-text { text-decoration: line-through; }
.status-line { padding: 0 20px 8px; }
.block-form { display: block; margin: 0; }
.block-form .btn { width: 100%; }
.dialog-actions > form { flex: 1; }
.btn-grid { gap: 12px; }
.quote-reason { margin-top: 12px; padding: 8px 12px; border-radius: 12px; background: var(--bg); font-size: 15px; }
.manage-row { padding: 10px 16px; }
.manage-row + .manage-row { border-top: 0.5px solid var(--line); }
@media (min-width: 64rem) { .split > .q-aside { order: 2; position: sticky; top: 16px; } }
.doc-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); gap: 8px 16px; margin: 0; padding: 12px 16px 16px; border-top: 0.5px solid var(--line); font-size: 14px; }
.doc-meta dt { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.doc-meta dd { margin: 0; font-weight: 500; }
@media (min-width: 40rem) {
  .doc-grid-3 { grid-template-rows: auto 1fr; }
  .doc-grid-3 > .doc-main { grid-column: 1; grid-row: 1 / span 2; }
  .doc-grid-3 > .doc-aside { grid-column: 2; grid-row: 1; }
  .doc-grid-3 > .doc-respond { grid-column: 2; grid-row: 2; }
}
.signature-pad { padding: 12px 0 14px; }
.signature { height: 52px; display: flex; align-items: flex-end; overflow: hidden; white-space: nowrap; font-size: 30px; line-height: 1; border-bottom: 1px solid rgba(17, 17, 17, 0.3); font-family: "Snell Roundhand", "Apple Chancery", "Brush Script MT", "Segoe Script", "Lucida Handwriting", cursive; }
.respond-bar { position: sticky; bottom: 0; z-index: 10; margin: 16px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(20px); border-top: 0.5px solid var(--line); }
@media (min-width: 40rem) { .respond-bar { display: none; } }
.portal-due { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--bg); }
.pill-link { display: inline-flex; align-items: center; min-height: 34px; padding: 6px 14px; border: 0; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; flex-shrink: 0; }
.row > .pill-link { margin-right: 12px; }
.pill-solid { background: var(--accent); color: #fff; }
.portal-row { padding: 12px 16px; }
.portal-row + .portal-row { border-top: 0.5px solid var(--line); }
.portal-row-main { gap: 12px; color: inherit; min-width: 0; }
.portal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; padding-left: 52px; }

/* invoices */
.totals [hidden] { display: none; } /* .t-row's display:flex otherwise beats the hidden attribute (partials/totals_live) */
.inv-status { padding: 0 20px 8px; }
.inv-empty-filter { padding: 32px; text-align: center; font-size: 15px; }
.inv-struck { text-decoration: line-through; }
.inv-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.inv-actions > a, .inv-action-btn { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 0 16px; background: none; color: var(--accent); font: inherit; font-size: 16px; font-weight: 500; text-align: left; cursor: pointer; }
.inv-action-btn { border: 0; }
.inv-action-btn:disabled { color: var(--muted); cursor: default; }
.inv-actions > * + * { border-top: 0.5px solid var(--line); }
.inv-action-form { display: block; margin: 0; }
.inv-payment { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.inv-payment + .inv-payment, .inv-top-line, .inv-reminder-row + .inv-reminder-row, .inv-reminder-row + .kv { border-top: 0.5px solid var(--line); }
.inv-reminder-row { padding: 12px 16px; }
.inv-reminder-row .inv-action-btn { padding: 0; min-height: 40px; }
.inv-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-manage { padding: 12px 16px; }
.inv-manage + .inv-manage { border-top: 0.5px solid var(--line); }
.inv-hint { margin-top: 8px; text-align: center; font-size: 13px; color: var(--muted); }
.inv-progress > span { background: var(--success); }
.inv-center { text-align: center; }
.inv-caps { text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.inv-card-label { padding: 12px 16px 0; }
.inv-sheet-head { display: flex; align-items: center; justify-content: space-between; }
.inv-sheet-head h2 { font-size: 17px; }
.inv-amount { display: block; text-align: center; }
.inv-amount.has-error { box-shadow: 0 0 0 2px var(--danger); }
.inv-amount input { width: 100%; border: 0; outline: none; background: transparent; text-align: center; font-size: 40px; font-weight: 700; color: var(--ink); }
.inv-quick { justify-content: center; margin-top: 8px; }
.inv-quick .chip { border: 0; cursor: pointer; font: inherit; font-size: 14px; }
.inv-banner { margin: 16px 0 0; }
.inv-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; margin: 0 16px; padding: 12px 0 16px; border-top: 0.5px solid var(--line); font-size: 14px; }
.inv-meta dt { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.inv-meta dd { margin: 0; font-weight: 500; }
.inv-balance-row { background: rgba(229, 229, 234, 0.3); }
.inv-desktop-only { display: none; }
@media (min-width: 40rem) { .inv-meta { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 39.99rem) { .inv-hide-sm { display: none; } }
@media (min-width: 64rem) {
  .inv-split > .inv-aside { order: 2; position: sticky; top: 16px; }
  .inv-split > .inv-main { order: 1; }
  .inv-editor .inv-aside { position: sticky; top: 16px; }
  .inv-desktop-only { display: block; }
  .inv-mobile-only { display: none; }
}

/* clients, items, expenses, activity */
.block-form { display: block; margin: 0; }
.editor-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 8px; font-size: 17px; }
.editor-topbar h1 { font-size: 17px; font-weight: 600; }
.editor-topbar .btn-plain { font-size: 17px; min-height: 36px; }
.more-fields > summary { list-style: none; cursor: pointer; padding: 12px 16px 0; font-size: 15px; color: var(--accent); }
.more-fields > summary::-webkit-details-marker { display: none; }
.more-fields[open] > summary { display: none; }
@media (min-width: 64rem) { .split > .split-aside { order: 2; position: sticky; top: 16px; } .split > .split-main { order: 1; } }
.client-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.client-stats .stat-value { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 64rem) { .client-stats { grid-template-columns: 1fr; } .client-stats .stat { display: flex; align-items: baseline; justify-content: space-between; } }
.stat.warn .stat-value { color: var(--warn); }
.stat.accent .stat-value { color: var(--accent); }
.client-new-buttons { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
@media (min-width: 64rem) { .client-new-buttons { grid-template-columns: 1fr; } }
.exp-date { display: flex; flex-direction: column; align-items: center; width: 40px; flex-shrink: 0; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.exp-date b { font-size: 18px; line-height: 1; color: var(--ink); }
.receipt-clip { vertical-align: -3px; margin-left: 6px; }
.receipt { display: flex; align-items: flex-start; gap: 12px; }
.receipt-thumb { width: 96px; height: 112px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.receipt-add { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px; border-radius: 12px; background: var(--bg); color: var(--accent); font-weight: 600; cursor: pointer; }
.receipt-add input { font-size: 14px; color: var(--muted); max-width: 100%; }
.card.has-error { box-shadow: inset 0 0 0 1.5px var(--danger), var(--shadow-card); }
.category-chips { padding: 8px 0 0; }
.category-chips .chip { border: 0; cursor: pointer; font-size: 13px; padding: 5px 12px; }
.check-row { gap: 12px; padding: 10px 16px; cursor: pointer; }
.check-row > input { width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--accent); margin: 0; }
.link-button { border: 0; background: none; cursor: pointer; font: inherit; color: var(--accent); padding: 0; }
.activity-feed { list-style: none; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.activity-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; }
.activity-row + .activity-row { margin-top: 0; }
.activity-title { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-message { margin-top: 2px; font-size: 15px; line-height: 1.35; color: var(--ink-2); }
.act-tile { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; }
.act-tile.tone-neutral { background: #ececf0; color: var(--ink-2); }
.act-tile.tone-accent { background: var(--accent-soft); color: var(--accent); }
.act-tile.tone-info { background: var(--info-soft); color: var(--info); }
.act-tile.tone-success { background: var(--success-soft); color: var(--success); }
.act-tile.tone-warn { background: var(--warn-soft); color: var(--warn); }
.act-tile.tone-danger { background: var(--danger-soft); color: var(--danger); }
.act-tile.tone-muted { background: var(--bg); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.history-list { list-style: none; margin: 0; padding: 0; }
.history-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; }
.history-row + .history-row { border-top: 1px solid var(--line); }
.history-row .activity-title { font-size: 14px; }
.act-tile-sm { width: 30px; height: 30px; border-radius: 8px; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.migrations-list { list-style: none; margin: 12px 0; padding: 0; }
.migrations-list li { padding: 6px 0; gap: 8px; }
.migrations-list li + li { border-top: 1px solid var(--line); }
.migrations-list code { overflow-wrap: anywhere; }

/* dashboard, recurring, settings, reports */
.stat-grid .stat-hero { grid-column: span 2; }
.stat-hero .stat-value { font-size: 30px; }
.row-icon.tone-neutral { background: #ececf0; color: var(--ink-2); }
.row-icon.tone-info { background: var(--info-soft); color: var(--info); }
.row-icon.tone-success { background: var(--success-soft); color: var(--success); }
.row-icon.tone-warn { background: var(--warn-soft); color: var(--warn); }
.row-icon.tone-danger { background: var(--danger-soft); color: var(--danger); }
.row-icon.tone-muted { background: var(--bg); color: var(--muted); }
.caught-up { display: flex; align-items: center; gap: 8px; padding: 12px 32px; font-size: 14px; font-weight: 500; color: var(--success); }
.caught-up-check { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--success-soft); }
.mini-bars { display: flex; align-items: flex-end; justify-content: center; gap: 3px; width: 48px; height: 48px; padding: 0 10px 10px; border-radius: 16px; background: var(--bg); flex-shrink: 0; }
.mini-bars i { width: 5px; border-radius: 2px 2px 0 0; background: var(--accent); opacity: 0.7; }
.setup-hero { position: relative; overflow: hidden; padding: 20px; border-radius: 24px; color: #fff; background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 55%, #1e3fae 100%); box-shadow: 0 16px 40px -16px rgba(37, 99, 235, 0.7); }
.setup-hero h2 { margin-top: 8px; font-size: 26px; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; }
.setup-eyebrow { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.8; }
.setup-sub { margin-top: 6px; font-size: 15px; opacity: 0.88; }
.setup-progress { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.22); overflow: hidden; }
.setup-progress > span { display: block; height: 100%; border-radius: 4px; background: #fff; }
.setup-steps { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 12px; }
@media (min-width: 40rem) { .setup-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 64rem) { .setup-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.setup-steps .card + .card { margin-top: 0; }
.setup-step { display: flex; align-items: center; gap: 14px; height: 100%; min-height: 88px; padding: 14px 16px; }
.setup-step.is-next { box-shadow: 0 0 0 2px var(--accent), var(--shadow-card); }
.setup-step-icon, .hero-mark { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; flex-shrink: 0; background: var(--accent-soft); color: var(--accent); }
.setup-step.is-next .setup-step-icon, .hero-mark { background: var(--accent); color: #fff; }
.setup-step.is-done .setup-step-icon { background: var(--success-soft); color: var(--success); }
.setup-step-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-weight: 600; line-height: 1.25; }
.setup-step.is-done .setup-step-title { color: var(--ink-2); }
.setup-check { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--success); color: #fff; flex-shrink: 0; }
.finish-setup { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; }
.finish-setup-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; color: var(--ink); }
.finish-setup .hero-mark { width: 40px; height: 40px; border-radius: 12px; }
.icon-btn { width: 40px; height: 40px; padding: 0; border-radius: 50%; color: var(--muted); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 0 16px 4px; font-size: 13px; color: var(--ink-2); }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: #2563eb; }
.bars.chart { height: 170px; padding-top: 24px; border-bottom: 0; }
.bar-group { display: flex; align-items: flex-end; justify-content: center; gap: 2px; width: 100%; flex: 1; border-bottom: 1px solid #c7c7cc; }
.bar-group .bar { position: relative; max-width: 24px; }
.bar-group .bar + .bar { max-width: 14px; }
.bar-group .bar:first-child:nth-last-child(2) { max-width: 14px; }
.bar.series-1, .chart-swatch.series-1 { background: #eb6834; }
.bar-col.dim .bar { opacity: 0.78; }
.bar-peak { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 3px; font-size: 11px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.share-row { padding: 12px 16px; }
.share-row + .share-row { border-top: 0.5px solid var(--line); }
.share-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; font-weight: 500; }
.share-pct { width: 3.5rem; text-align: right; }
.range-form { display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.range-form .input { min-height: 36px; padding: 6px 8px; font-size: 14px; }
.empty-compact { padding: 24px 16px; }
.empty-compact .empty-icon { width: 44px; height: 44px; border-radius: 14px; }
.empty-compact h3 { font-size: 16px; }
.table-scroll { overflow-x: auto; }
.report-table { width: 100%; border-collapse: collapse; white-space: nowrap; font-size: 14px; font-variant-numeric: tabular-nums; }
.report-table th { padding: 8px 12px; font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); text-align: right; }
.report-table td { padding: 8px 12px; text-align: right; border-top: 0.5px solid var(--line); }
.report-table th:first-child, .report-table td:first-child { text-align: left; }
.report-table tfoot td { font-weight: 600; }
.run-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.run-chip { padding: 4px 10px; border-radius: 999px; background: var(--bg); color: var(--ink-2); font-size: 13px; font-weight: 600; }
.run-chip.first { background: var(--accent-soft); color: var(--accent); }
.segmented-fill { display: flex; }
.segmented-fill label { flex: 1; text-align: center; }
.interval-input { width: 5.5rem; }
.check-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chips label { position: relative; }
.check-chips input { position: absolute; opacity: 0; }
.check-chips span { display: block; padding: 7px 14px; border-radius: 999px; background: var(--bg); color: var(--ink-2); font-size: 14px; font-weight: 500; cursor: pointer; }
.check-chips input:checked + span { background: var(--ink); color: #fff; }
.check-chips input:focus-visible + span, .color-custom input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.timeline { list-style: none; margin: 0; padding: 8px; }
.timeline li { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; }
.timeline li.active { background: var(--accent-soft); }
.timeline-link { flex: 1; display: flex; align-items: center; gap: 12px; color: inherit; }
.timeline-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 4px var(--card); }
.is-disabled { opacity: 0.45; }
.logo-box { display: grid; place-items: center; width: 112px; height: 64px; border-radius: 12px; background: var(--bg); flex-shrink: 0; }
.logo-box img { max-width: 96px; max-height: 56px; object-fit: contain; }
.color-custom { position: relative; }
.color-custom input { position: absolute; opacity: 0; }
.color-custom span { display: block; padding: 7px 12px; border-radius: 999px; background: var(--bg); font-size: 14px; font-weight: 500; cursor: pointer; }
.color-custom input:checked + span { background: var(--ink); color: #fff; }
input[type="color"][data-color-picker] { width: 44px; height: 40px; padding: 0; border: 0; background: none; cursor: pointer; }
.hex-input { width: 7.5rem; font-family: ui-monospace, Menlo, monospace; text-transform: uppercase; }
.row-static > input.radio { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex-shrink: 0; }
.brand-preview { --brand: var(--accent); padding: 12px; border-radius: 16px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.brand-preview-doc { padding: 16px; border-radius: 12px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); overflow: hidden; }
.brand-preview-band { margin-bottom: 16px; }
.brand-preview-band .brand-header { padding: 0; justify-content: flex-start; }
.tpl-modern .brand-preview-band { margin: -16px -16px 16px; padding: 16px; background: var(--brand); color: #fff; }
.tpl-modern .brand-preview-band .brand-name { color: #fff; }
.brand-preview-amount { font-size: 30px; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.tpl-minimal .brand-preview-amount { color: var(--accent); }
.brand-preview-lines { display: grid; grid-template-columns: 1fr auto; gap: 4px; margin-top: 12px; padding-top: 8px; border-top: 2px solid var(--brand); font-size: 12px; }
.tpl-modern .brand-preview-lines { padding: 8px; border: 0; border-radius: 8px; background: var(--accent-soft); }
.tpl-minimal .brand-preview-lines { border-top-color: var(--line); }
.brand-preview-pay { display: grid; place-items: center; height: 40px; margin-top: 12px; border-radius: 12px; background: var(--brand); color: #fff; font-size: 14px; font-weight: 600; }
.sign-out-row { width: 100%; border: 0; background: none; cursor: pointer; font-size: 16px; min-height: 52px; justify-content: center; }

/* Charts on phones: 12 columns must fit a 390px card. */
.bar-label { max-width: 100%; overflow: hidden; text-align: center; line-height: 1.2; }
@media (max-width: 30rem) {
  .bars.chart { gap: 3px; padding-left: 10px; padding-right: 10px; }
  .bars.chart .bar-label { font-size: 9.5px; letter-spacing: -0.02em; }
}
