:root {
  --bg: #fff8f8;
  --bg-primary: #fff8f8;
  --card: #ffffff;
  --bg-soft: #fff0f4;
  --blush: #f8dce4;
  --pink: #d85b82;
  --accent-hover: #c74b73;
  --wine: #8d304f;
  --ink: #30262b;
  --muted: #81747b;
  --good: #2e9463;
  --bad: #d94d61;
  --warning: #d99636;
  --line: #f0e4e8;
  --app-bg: #fff8f8;
  --card-bg: #ffffff;
  --soft-pink: #fff0f4;
  --accent-pink: #d85b82;
  --accent-burgundy: #8d304f;
  --text-primary: #30262b;
  --text-secondary: #81747b;
  --border-soft: #f0e4e8;
  --positive: #2e9463;
  --negative: #d94d61;
  --radius-card: 18px;
  --shadow: 0 4px 20px rgba(141, 48, 79, 0.06);
  --shadow-card: 0 4px 20px rgba(141, 48, 79, 0.06);
  --radius: 18px;
  --radius-input: 12px;
  --radius-button: 12px;
  --nav: 74px;
  --sidebar: 232px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; max-width: 100%; overflow-x: hidden; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(248, 220, 228, 0.65), transparent 32%),
    var(--bg);
  color: var(--ink);
  line-height: 1.45;
  min-height: 100vh;
}
a { color: var(--wine); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg, canvas { max-width: 100%; }
[x-cloak] { display: none !important; }

.app-shell { min-height: 100vh; }
.main-col { min-width: 0; }
.topbar, .content { width: min(1120px, calc(100% - 24px)); margin: 0 auto; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 0 8px;
}
.eyebrow { color: var(--muted); font-size: 0.8rem; letter-spacing: 0.01em; }
h1, h2, .section-title { letter-spacing: -0.01em; }
.user-chip, .btn, .btn-secondary, .icon-btn {
  min-height: 48px;
  border-radius: var(--radius-button);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 0;
  cursor: pointer;
  text-align: center;
}
.user-chip { background: white; border: 1px solid var(--line); }
.btn { background: var(--pink); color: white; font-weight: 650; }
.btn:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--blush); color: var(--wine); }
.btn-secondary:hover { background: #f3cdda; }
.btn:disabled, .btn-secondary:disabled { opacity: 0.65; cursor: progress; }
.btn-small { min-height: 44px; padding: 0 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.content { padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom) + 28px); }
.page-intro { color: var(--muted); margin: 0 0 12px; }

.card, .stat, .list-item, .empty, .sheet, .form, .chart-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { padding: 14px; min-width: 0; }
.stat span, .muted { color: var(--muted); }
.stat strong, .amount { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; margin-top: 4px; overflow-wrap: anywhere; }
.stat small { display: block; color: var(--muted); margin-top: 4px; }
.stat-hero { grid-column: 1 / -1; background: linear-gradient(180deg, #fff, var(--bg-soft)); }
.stat-hero strong { font-size: 1.85rem; color: var(--wine); }
.is-good { color: var(--good); }
.is-bad { color: var(--bad); }
.grid-2 { display: grid; gap: 12px; margin-top: 8px; }
.section-title { margin: 20px 0 10px; font-size: 1.05rem; }
.list { display: grid; gap: 10px; }
.list-item, .empty { padding: 14px 16px; }
.list-item { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.list-item .name { min-width: 0; overflow-wrap: anywhere; }
.amounts { display: grid; justify-items: end; gap: 2px; text-align: right; flex: 0 0 auto; }
.amounts small { color: var(--muted); font-size: 0.75rem; }
.amounts strong { font-variant-numeric: tabular-nums; font-size: 0.98rem; }
.person { display: grid; gap: 8px; }
.card.person { padding: 14px 16px; }
.person-lines { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.person-lines div { min-width: 0; }
.person-lines span { display: block; color: var(--muted); font-size: 0.78rem; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; }
.filters a, .chip {
  background: white;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 12px;
  white-space: nowrap;
  color: var(--ink);
}
.filters a.active, .chip.active { background: var(--wine); color: white; }
.date-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.form { padding: 16px; display: grid; gap: 12px; margin-bottom: 12px; }
.field { display: grid; gap: 6px; }
.field span { font-size: 0.92rem; font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%;
  min-height: 48px;
  border-radius: var(--radius-input);
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px 12px;
  font-size: 16px;
}
textarea.input { min-height: 96px; }
.input:focus { border-color: var(--pink); outline: none; }
.help, .errorlist { margin: 0; color: var(--muted); font-size: 0.85rem; }
.errorlist { color: var(--bad); list-style: none; padding: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { width: 22px; height: 22px; margin-top: 2px; flex: 0 0 auto; }
.total-preview {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 0;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--bg-soft);
  border: 1px solid var(--blush);
}
.total-preview strong { font-size: 1.45rem; color: var(--wine); font-variant-numeric: tabular-nums; }

.messages { display: grid; gap: 8px; margin-bottom: 12px; }
.message { padding: 12px 14px; border-radius: var(--radius-input); background: var(--blush); color: var(--wine); }
.message.error { background: #ffe4e8; color: #8d3040; }
.message.success { background: #e5f6ee; color: #1d6b45; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.78rem;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  white-space: nowrap;
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-paid::before, .status-settled::before { background: var(--good); }
.status-partial::before { background: var(--warning); }
.status-accrued::before { background: var(--pink); }
.status-overdue::before { background: var(--bad); }
.status-void::before { background: var(--muted); }

.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  min-height: var(--nav);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
.admin-nav { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.admin-nav a { font-size: 0.64rem; }
.bottom-nav a, .plus {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  font-size: 0.72rem;
  min-height: 48px;
  background: transparent;
}
.bottom-nav a.active { color: var(--pink); font-weight: 700; }
.nav-ico { width: 18px; height: 18px; display: block; }
.bottom-nav a span { max-width: 100%; text-align: center; line-height: 1.05; }
.plus-wrap { position: relative; display: flex; justify-content: center; }
.plus {
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--pink); color: white; border: 4px solid var(--bg);
  font-size: 2rem; line-height: 1; margin-top: -16px; box-shadow: var(--shadow);
}
.sheet[hidden], .sheet-backdrop[hidden] { display: none !important; }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(48, 38, 43, 0.28); z-index: 25; }
.sheet {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--nav) + env(safe-area-inset-bottom) + 10px);
  width: auto;
  max-height: min(70vh, 420px);
  overflow: auto;
  padding: 10px;
  display: grid;
  gap: 6px;
  z-index: 30;
}
.sheet a { padding: 14px; border-radius: var(--radius-input); background: var(--bg-soft); color: var(--ink); font-weight: 650; }

.sidebar { display: none; }
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px 40px;
}
.login-card { width: min(440px, 100%); padding: 28px 22px; }
.brand { display: flex; gap: 12px; align-items: center; }
.flower { width: 54px; height: 54px; flex: 0 0 auto; }
.portal-balance { font-size: clamp(1.8rem, 8vw, 2.4rem); font-variant-numeric: tabular-nums; color: var(--wine); margin: 4px 0 8px; }
.balance-card { padding: 18px; margin-bottom: 12px; }
.table-wrap, .chart-card { overflow-x: auto; }
.chart-card { padding: 12px; margin-top: 12px; }
.focus-ring:focus-visible, a:focus-visible, button:focus-visible, .input:focus-visible {
  outline: 3px solid var(--wine);
  outline-offset: 2px;
}
.badge { background: var(--bad); color: white; border-radius: 999px; padding: 2px 7px; font-size: 0.75rem; }
.waste-note { border-left: 4px solid var(--bad); }

@media (max-width: 359px) {
  .stats, .date-row, .person-lines { grid-template-columns: 1fr; }
}
@media (min-width: 768px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: 1.2fr 0.8fr; }
  .topbar, .content { width: min(1200px, calc(100% - 40px)); }
}
@media (min-width: 1100px) {
  .app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
  .sidebar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
    padding: 18px 14px;
    background: white;
    border-right: 1px solid var(--line);
  }
  .sidebar a { padding: 10px 12px; border-radius: var(--radius-input); color: var(--ink); }
  .sidebar a.active, .sidebar a:hover { background: var(--blush); color: var(--wine); }
  .sidebar .brand { margin-bottom: 8px; }
  .bottom-nav:not(.portal-nav), .sheet, .sheet-backdrop { display: none; }
  .portal-nav { display: grid; position: fixed; left: 0; right: 0; bottom: 0; }
  .app-shell:not(:has(.sidebar)) .content { padding-bottom: calc(var(--nav) + env(safe-area-inset-bottom) + 28px); }
  .app-shell:has(.sidebar) .content { padding-bottom: 40px; }
  .stats { grid-template-columns: repeat(4, 1fr); }
  .stat-hero { grid-column: span 2; }
}
@media (min-width: 1600px) {
  .topbar, .content { width: min(1480px, calc(100% - 56px)); }
}

.admin-nav a { font-size: 0.6rem; min-width: 0; padding: 6px 1px 8px; }
.admin-nav .plus { width: 50px; height: 50px; margin-top: -18px; font-size: 1.8rem; border-width: 3px; }
.portal-nav a { font-size: 0.68rem; min-width: 0; }

.home { display: grid; gap: 10px; width: min(1040px, 100%); margin: 0 auto; }
.home-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.shop-brand { display: flex; align-items: center; gap: 8px; color: inherit; min-width: 0; }
.brand-mark { width: 42px; height: 42px; flex: 0 0 auto; }
.shop-brand strong { display: block; color: var(--wine); font-size: 1.12rem; line-height: 1.1; }
.shop-brand small { display: block; color: var(--muted); font-size: 0.7rem; font-weight: 500; }
.home-tools { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.date-form { margin: 0; }
.date-chip, .bell, .who {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: white;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.date-chip {
  gap: 6px;
  border-radius: 999px;
  min-height: 36px;
  padding: 4px 10px;
  color: var(--ink);
  font-size: 0.68rem;
}
.date-chip svg, .bell svg, .period-fold summary svg { width: 16px; height: 16px; }
.date-chip input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.bell {
  width: 38px; height: 38px; border-radius: 50%; justify-content: center; color: var(--ink);
}
.bell .badge { position: absolute; top: -4px; right: -4px; }
.who { gap: 6px; border-radius: 999px; padding: 3px 10px 3px 3px; color: inherit; min-height: 40px; }
.who strong, .who small { display: block; line-height: 1.15; }
.who strong { font-size: 0.78rem; }
.who small { color: var(--muted); font-size: 0.64rem; font-weight: 500; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--pink); color: white; font-weight: 700;
}

.hello {
  position: relative;
  display: block;
  min-height: 118px; padding: 14px 108px 12px 14px; overflow: hidden;
  border-radius: 22px; border: 1px solid #f6e4ea;
  background: linear-gradient(105deg, #fff 0%, #fff7f8 42%, #fde8ef 100%);
  box-shadow: var(--shadow);
}
.hello h1 { margin: 0; color: var(--wine); font-size: 1.22rem; line-height: 1.15; letter-spacing: -0.02em; }
.hello p { margin: 6px 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.35; max-width: 32ch; }
.hello img { position: absolute; right: -6px; bottom: 0; width: 136px; height: 112px; object-fit: contain; pointer-events: none; }
.home > .message { margin: 0; padding: 8px 12px; font-size: 0.78rem; }

.kpi-row, .mid-row, .chart-grid, .list-grid, .foot-row, .pair-row, .trio-row { display: grid; gap: 8px; }
.kpi-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mid-row { grid-template-columns: 1.25fr 0.9fr 0.95fr; }
.chart-grid, .list-grid, .pair-row, .foot-row { grid-template-columns: 1fr 1fr; }
.trio-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.kpi, .panel-card, .balance-hero {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  min-width: 0;
  color: inherit;
}
.kpi { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 8px; }
.tone-blue { background: #f7f9fd; }
.kpi-label { color: var(--muted); font-size: 0.68rem; line-height: 1.2; overflow-wrap: anywhere; }
@media (max-width: 700px) {
  .kpi-row.secondary { grid-template-columns: 1fr 1fr; }
}
.kpi-label em { font-style: normal; }
.kpi strong, .panel-copy strong, .balance-copy strong { font-variant-numeric: tabular-nums; letter-spacing: -0.03em; }
.kpi strong { font-size: clamp(0.78rem, 2.7vw, 1.15rem); color: var(--ink); }
.kpi-note { display: block; color: var(--muted); font-size: 0.62rem; line-height: 1.25; overflow-wrap: anywhere; }
.kpi-note em { font-style: normal; }
.delta-up { color: var(--positive); }
.delta-down { color: var(--negative); }
.kpi-ico {
  width: 28px; height: 28px; border-radius: 9px;
  display: grid; place-items: center; flex: 0 0 auto;
}
.kpi-ico svg { width: 16px; height: 16px; }
.kpi-ico.pink { background: #fde7ee; color: #d85b82; }
.kpi-ico.rose { background: #fff0f4; color: #c74b73; }
.kpi-ico.blue { background: #eef3fb; color: #5c7ea8; }
.kpi-ico.mint { background: #e7f6ef; color: #2e9463; }
.kpi-ico.sand { background: #fbf3e8; color: #c4843a; }

.panel-card { padding: 12px; }
a.panel-card, .foot-card { display: flex; gap: 8px; align-items: flex-start; }
.panel-copy { min-width: 0; display: grid; gap: 2px; }
.panel-copy strong { font-size: clamp(0.82rem, 3.2vw, 1.05rem); white-space: nowrap; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 8px; }
.panel-head h2 { margin: 0; font-size: 0.92rem; }
.panel-head a, .panel-head select, .chip {
  color: var(--pink); font-size: 0.72rem; background: white;
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px;
}
.chev { margin-left: auto; color: #e7b7c6; font-size: 1.5rem; line-height: 1; }
.bar { display: block; height: 6px; margin-top: 8px; border-radius: 99px; background: #f8eef2; overflow: hidden; }
@media (max-width: 700px) {
  .chart-panel .panel-head, .list-grid .panel-head { flex-direction: column; align-items: flex-start; }
  .panel-head h2 { font-size: 0.84rem; line-height: 1.25; }
}
.bar i { display: block; height: 100%; width: var(--w); background: linear-gradient(90deg, #f3b7c9, #d85b82); }
.chart-box { position: relative; height: 168px; }
.chart-box canvas { width: 100% !important; height: 100% !important; }
.chart-custom { display: flex; flex-wrap: wrap; gap: 6px; align-items: end; margin-top: 8px; color: var(--muted); font-size: 0.75rem; max-width: 100%; }
.chart-custom label { min-width: 0; flex: 1 1 8rem; }
.chart-custom .input { width: 100%; max-width: 100%; min-height: 36px; box-sizing: border-box; }
.mini-list { display: grid; }
.mini-row {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto;
  gap: 6px; align-items: center; padding: 8px 0;
  border-top: 1px solid var(--line); color: inherit;
}
.mini-copy { min-width: 0; }
.mini-copy strong, .mini-copy small { display: block; }
.mini-copy strong { font-size: 0.78rem; }
.mini-copy small { color: var(--muted); font-size: 0.68rem; overflow-wrap: anywhere; }
.mini-sum, .move-plus, .move-minus { font-size: 0.78rem; font-weight: 700; white-space: nowrap; }
.move-plus { color: var(--positive); }
.move-minus { color: var(--negative); }
.pay-state { font-size: 0.66rem; font-weight: 700; white-space: nowrap; }
.pay-state.unpaid { color: var(--pink); }
.pay-state.paid { color: var(--positive); }
.pay-state.partial { color: var(--warning); }
.pay-state.void { color: var(--muted); }
.balance-hero { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: 22px; }
.balance-copy { display: grid; gap: 2px; min-width: 0; }
.balance-copy .kpi-label { font-size: 0.8rem; }
.balance-copy strong { color: var(--wine); font-size: clamp(1.8rem, 8vw, 2.6rem); }
.balance-copy small { color: var(--text-secondary); }
.balance-hero .kpi-ico, .balance-hero .kpi-ico svg { width: 46px; height: 46px; }
.balance-hero .kpi-ico svg { width: 22px; height: 22px; }
.balance-copy abbr { text-decoration: none; border: 1px solid var(--line); border-radius: 50%; width: 16px; height: 16px; display: inline-grid; place-items: center; font-size: 0.65rem; }
.fine { margin: 0; color: var(--muted); font-size: 0.75rem; }
.portal-home { width: min(720px, 100%); }
.portal-home .mini-row { grid-template-columns: 32px minmax(0, 1fr) auto; }
.plan-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.plan-row .mini-copy { min-width: 0; flex: 1 1 auto; }
.plan-row .mini-copy strong,
.plan-row .mini-copy small {
  display: block;
  overflow-wrap: normal;
  word-break: normal;
  white-space: normal;
}
.plan-row .mini-sum {
  flex: 0 0 auto;
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
}
.period-fold summary { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.82rem; margin-top: 8px; list-style: none; }
.period-fold summary::-webkit-details-marker { display: none; }

@media (max-width: 359px) {
  .kpi-row, .pair-row { grid-template-columns: 1fr 1fr; }
  .mid-row, .chart-grid, .list-grid, .trio-row { grid-template-columns: 1fr; }
  .hello { padding-right: 96px; }
  .hello img { width: 112px; }
}
@media (min-width: 768px) {
  .chart-box { height: 220px; }
  .foot-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .portal-home { width: min(960px, 100%); }
  .kpi strong { font-size: 1.15rem; }
}
@media (min-width: 1100px) {
  .home { width: min(1100px, 100%); }
  .chart-box { height: 250px; }
  .hello { min-height: 132px; }
}
