:root {
  --bg: #fafafa;
  --fg: #0a0a0a;
  --muted: #666666;
  --fg-muted: var(--muted);
  --fg-dim: #999999;
  --border: #eaeaea;
  --card: #ffffff;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --accent: #0a0a0a;
  --gold: #c9a227;
  --gold-light: #f5e6b8;
  --gold-soft: rgba(201, 162, 39, 0.12);
  --gold-dark: #9a7b1a;
  --danger: #e5484d;
  --success: #3dd68c;
  --warn: #f5a524;
  --info: #0091ff;
  --radius: 8px;
  --tap: 40px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --nav-h: 56px;
  --font: "Saira", system-ui, sans-serif;
  --menu-bg: #ffffff;
  --shadow: 0 0 0 1px rgba(0, 0, 0, 0.04);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
}

.hidden {
  display: none !important;
}

.icon {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  stroke: currentColor;
}

.icon-sm {
  width: 0.95rem;
  height: 0.95rem;
}

.icon-lg {
  width: 1.35rem;
  height: 1.35rem;
}

/* ── Shell ── */
.shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

.shell-top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  padding-top: calc(0.75rem + env(safe-area-inset-top));
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(12, 18, 34, 0.04);
}

.shell-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.shell-brand img {
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
  padding: 2px;
}

.shell-brand-title {
  margin: 0;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shell-brand-title span {
  color: var(--gold-dark);
}

.shell-actions {
  display: flex;
  gap: 0.4rem;
}

.page {
  flex: 1;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0.85rem 1rem 1.25rem;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -1px 0 rgba(12, 18, 34, 0.04);
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  color: var(--fg-dim);
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: color 180ms var(--ease);
}

.bottom-nav a.is-active {
  color: var(--fg);
}

.bottom-nav a:active {
  transform: scale(0.96);
}

@media (min-width: 900px) {
  .shell {
    flex-direction: row;
    padding-bottom: 0;
  }

  .shell-top {
    display: none;
  }

  .side-nav {
    display: flex !important;
    position: sticky;
    top: 0;
    height: 100dvh;
    width: 220px;
    flex-direction: column;
    padding: 1.25rem 0.85rem;
    background: var(--card);
    border-right: 1px solid var(--border);
    box-shadow: 2px 0 16px rgba(12, 18, 34, 0.04);
  }

  .side-nav-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.35rem 0.5rem 1.25rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
  }

  .side-nav-brand img {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 10px;
  }

  .side-nav-brand strong {
    display: block;
    font-size: 0.95rem;
    letter-spacing: -0.02em;
  }

  .side-nav-brand span {
    color: var(--gold-dark);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .side-nav a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 0.75rem;
    margin-bottom: 0.2rem;
    border-radius: 10px;
    color: var(--fg-muted);
    text-decoration: none;
    font-weight: 500;
    transition: background 180ms, color 180ms;
  }

  .side-nav a:hover {
    background: var(--bg);
    color: var(--fg);
  }

  .side-nav a.is-active {
    background: #0a0a0a;
    color: #fff;
    font-weight: 600;
  }

  .side-nav a.is-active .icon {
    color: #fff;
  }

  .side-nav-foot {
    margin-top: auto;
    padding-top: 1rem;
  }

  .bottom-nav {
    display: none;
  }

  .page {
    padding: 1.5rem 1.75rem 2rem;
    max-width: 1100px;
  }
}

.side-nav {
  display: none;
}

/* ── Typography / layout ── */
.hero-title {
  margin: 0 0 0.25rem;
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

.hero-title em {
  font-style: normal;
  color: var(--fg);
}

.hero-sub {
  margin: 0 0 1.25rem;
  color: var(--fg-muted);
  font-size: 0.9rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.page-head--flush {
  margin-bottom: 1rem;
}

.page-head h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.page-head p,
.page-head-meta {
  margin: 0.2rem 0 0;
  color: var(--fg-muted);
  font-size: 0.8125rem;
  line-height: 1.35;
}

.page-head-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.field-search {
  max-width: 100%;
}

/* Status filter chips */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2rem;
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--fg-muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 550;
  cursor: pointer;
  transition: background 140ms, color 140ms, border-color 140ms;
}

.filter-chip:hover {
  color: var(--fg);
  border-color: #d4d4d4;
}

.filter-chip.is-active {
  background: #0a0a0a;
  border-color: #0a0a0a;
  color: #fff;
}

.filter-chip-count {
  font-size: 0.7rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
}

.filter-chip.is-active .filter-chip-count {
  opacity: 0.85;
}

/* Stats — Vercel-like clickable cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}

@media (min-width: 720px) {
  .stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .stat-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

.stat-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem 0.85rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  min-height: 0;
  transition: border-color 140ms, background 140ms;
}

a.stat-card:hover {
  border-color: #cfcfcf;
  background: #fff;
}

.stat-card--static {
  cursor: default;
}

.stat-card-arrow {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  color: var(--fg-dim);
  opacity: 0;
  transition: opacity 140ms;
}

a.stat-card:hover .stat-card-arrow {
  opacity: 1;
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg-dim);
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.stat-value.is-accent {
  color: var(--fg);
}

.stat-value.is-warn {
  color: #a15c00;
}

.stat-value.is-danger {
  color: var(--danger);
}

.stat-hint {
  font-size: 0.72rem;
  color: var(--fg-dim);
}

.skeleton-card .skeleton-line {
  display: block;
  height: 0.7rem;
  width: 40%;
  margin-bottom: 0.65rem;
  border-radius: 4px;
  background: linear-gradient(90deg, #f0f0f0, #f7f7f7, #f0f0f0);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease infinite;
}

.skeleton-card .skeleton-line.short {
  width: 55%;
  height: 1.1rem;
  margin-bottom: 0;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Legacy metrics (keep for other pages) */
.metrics-board {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.metric {
  background: var(--card);
  padding: 1rem 1rem 0.9rem;
  min-height: 92px;
}

.metric-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 0.35rem;
}

.metric-value {
  font-size: 1.55rem;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.metric-value.is-gold {
  color: var(--gold-dark);
}

.metric-hint {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--fg-dim);
}

@media (min-width: 640px) {
  .metrics-board {
    grid-template-columns: repeat(5, 1fr);
  }
}

.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 0.85rem;
  box-shadow: none;
}

.panel--table {
  padding: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
}

.panel--table .panel-title {
  margin: 0;
}

.panel-title {
  margin: 0 0 0.65rem;
  font-size: 0.875rem;
  font-weight: 650;
  color: var(--fg);
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 550;
}

.text-link:hover {
  color: var(--fg);
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: 0.5rem 0.9rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--fg-dim);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.data-table td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr.is-clickable {
  cursor: pointer;
}

.data-table tr.is-clickable:hover td {
  background: #fafafa;
}

.table-link {
  color: var(--fg);
  font-weight: 600;
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

.shop-cell {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.shop-cell-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shop-avatar {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.shop-avatar--fallback {
  display: grid;
  place-items: center;
  background: var(--surface-2);
  font-weight: 700;
  font-size: 0.75rem;
}

.shop-slug {
  color: var(--fg-dim);
  font-weight: 500;
  font-size: 0.8rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.shop-cell .shop-slug {
  margin-left: 0.15rem;
}

.list-row-title .shop-slug {
  margin-left: 0.35rem;
  font-weight: 500;
}

.shop-meta {
  margin: 0.1rem 0 0;
  font-size: 0.75rem;
  color: var(--fg-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 18rem;
}

.list--mobile-only {
  display: none !important;
}

@media (max-width: 719px) {
  .panel--table .table-wrap {
    display: none;
  }
  .list--mobile-only {
    display: flex !important;
  }
}

.empty--compact {
  padding: 1.5rem 1rem;
}

.empty-title {
  margin: 0 0 0.35rem;
  font-weight: 650;
}

.empty-msg {
  margin: 0 0 0.85rem;
  font-size: 0.875rem;
}

.pad-sm {
  padding: 0.75rem 0;
}

.pager-meta {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

/* ── Forms / buttons ── */
.field-group {
  margin-bottom: 0.7rem;
}

.field-label {
  display: block;
  margin-bottom: 0.28rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--fg-muted);
}

.form-stack {
  display: grid;
  gap: 0 0.75rem;
}
.form-stack--2col {
  grid-template-columns: 1fr;
}
.form-stack .field-group {
  margin-bottom: 0.6rem;
}
@media (min-width: 640px) {
  .form-stack--2col {
    grid-template-columns: 1fr 1fr;
  }
  .form-stack--2col .field-span-2 {
    grid-column: 1 / -1;
  }
}
.owner-list {
  display: grid;
  gap: 0.5rem;
}
.owner-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.owner-row strong {
  font-weight: 650;
}

.field-required {
  color: var(--danger);
  margin-left: 0.15rem;
}

.field,
.select,
.textarea {
  width: 100%;
  min-height: var(--tap);
  height: var(--tap);
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--fg);
  font: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 160ms, box-shadow 160ms;
}

.textarea {
  min-height: 88px;
  height: auto;
  resize: vertical;
  padding: 0.55rem 0.75rem;
}

.field:focus,
.select:focus,
.textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.15);
}

.field::placeholder {
  color: var(--fg-dim);
}

.form-grid {
  display: grid;
  gap: 0 0.75rem;
}

@media (min-width: 560px) {
  .form-grid.cols-2 {
    grid-template-columns: 1fr 1fr;
  }
  .form-grid.cols-3 {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: var(--tap);
  height: var(--tap);
  padding: 0 0.9rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  transition: transform 120ms var(--ease), background 160ms, border-color 160ms, opacity 160ms;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: #1a2540;
}

.btn-secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--fg);
}

.btn-secondary:hover {
  border-color: var(--gold);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--fg);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn-sm {
  min-height: 34px;
  height: 34px;
  padding: 0 0.7rem;
  font-size: 0.82rem;
}

.btn-icon {
  width: var(--tap);
  padding: 0;
}

.btn-block {
  width: 100%;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ── Badges / lists ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.badge-trial {
  background: #dbeafe;
  color: var(--info);
  border-color: #bfdbfe;
}

.badge-active {
  background: #dcfce7;
  color: var(--success);
  border-color: #bbf7d0;
}

.badge-grace,
.badge-past_due,
.badge-open {
  background: var(--gold-light);
  color: var(--gold-dark);
  border-color: rgba(201, 162, 39, 0.35);
}

.badge-locked,
.badge-failed,
.badge-void,
.badge-overdue {
  background: #fee2e2;
  color: var(--danger);
  border-color: #fecaca;
}

.badge-archived,
.badge-canceled,
.badge-paid {
  background: #f1f5f9;
  color: var(--muted);
  border-color: var(--border);
}

/* Billing invoice / payment rows — one compact band */
.billing-row {
  display: grid;
  grid-template-columns: minmax(9rem, 1.1fr) minmax(0, 1.6fr) auto;
  align-items: center;
  gap: 0.55rem 1rem;
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--card);
}

.billing-row:first-child {
  border-top: 0;
}

.billing-row.is-overdue {
  background: linear-gradient(90deg, #fff5f5 0%, var(--card) 28%);
  box-shadow: inset 3px 0 0 var(--danger);
}

.billing-row-identity {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.55rem;
}

.billing-row-shop {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.billing-row-slug {
  margin-left: 0.3rem;
  font-weight: 500;
  color: var(--fg-dim);
  font-size: 0.8rem;
}

.billing-row-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.billing-row-facts {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.85rem;
  min-width: 0;
}

.billing-fact {
  font-size: 0.84rem;
  font-weight: 550;
  color: var(--fg-muted);
  line-height: 1.3;
  white-space: nowrap;
}

.billing-fact--amount {
  font-size: 0.95rem;
  font-weight: 750;
  color: var(--fg);
  letter-spacing: -0.02em;
}

.billing-fact.is-overdue {
  color: var(--danger);
  font-weight: 700;
}

.billing-row-note {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.78rem;
  color: var(--fg-muted);
}

.billing-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
  flex: 0 0 auto;
}

@media (max-width: 720px) {
  .billing-row {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .billing-row-actions {
    justify-content: flex-start;
  }
}

.list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 160ms, border-color 160ms, box-shadow 160ms;
}

.list-row--compact {
  padding: 0.6rem 0.75rem;
}

.list-row:hover {
  background: #fffdf4;
  border-color: rgba(201, 162, 39, 0.35);
  box-shadow: var(--shadow);
}

.list-row-main {
  flex: 1;
  min-width: 0;
}

.list-row-title {
  margin: 0;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.list-row-meta {
  margin: 0.1rem 0 0;
  font-size: 0.75rem;
  color: var(--fg-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-row-end {
  text-align: right;
  flex-shrink: 0;
}

.list-row-end .badge {
  margin-bottom: 0.15rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.65rem;
  margin-bottom: 0.85rem;
  width: 100%;
  min-width: 0;
}

.toolbar .filter-chips,
.toolbar #status-chips {
  flex: 1 1 auto;
  min-width: 0;
}

.toolbar .field,
.toolbar .field-search {
  flex: 1 1 12rem;
  min-width: 0;
  width: auto;
  max-width: 16rem;
}

.toolbar .select,
.toolbar .ui-select,
.toolbar .select-sm {
  flex: 0 0 auto;
  width: auto;
  min-width: 8.5rem;
  max-width: 11rem;
}

.toolbar .ui-select .ui-select-trigger {
  width: 100%;
  min-width: 8.5rem;
}

@media (max-width: 560px) {
  .toolbar .field,
  .toolbar .field-search {
    flex: 1 1 100%;
    max-width: none;
  }
  .toolbar .select,
  .toolbar .ui-select,
  .toolbar .select-sm {
    flex: 1 1 calc(50% - 0.25rem);
    max-width: none;
  }
}

.empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--fg-dim);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.85rem;
  color: var(--fg-muted);
  font-size: 0.85rem;
}

.pagination-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 1rem 1rem;
  border-top: 1px solid var(--border);
}
.pagination-meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--fg-muted);
}
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}
.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.1rem;
  height: 2.1rem;
  padding: 0 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--fg);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
}
.pagination-btn:hover {
  border-color: var(--gold);
}
.pagination-btn.is-active {
  background: var(--gold-light);
  border-color: var(--gold);
  color: var(--gold-dark);
}
.pagination-ellipsis {
  color: var(--fg-dim);
  padding: 0 0.2rem;
}

.tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.35rem;
}
.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fg-muted);
  font: inherit;
  font-weight: 650;
  padding: 0.55rem 0.85rem;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
}
.tab.is-active {
  color: var(--gold-dark);
  background: var(--gold-light);
}
.tab-panel.hidden {
  display: none;
}

.panel-flush {
  padding: 0;
  overflow: hidden;
}
.panel-flush > .panel-title {
  padding: 0.9rem 1rem 0.65rem;
}
.panel-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem 0.65rem;
  border-bottom: 1px solid var(--border);
}
.panel-head-row .select,
.panel-head-row .ui-select,
.panel-head-row .select-sm {
  flex: 0 0 auto;
  width: auto;
  min-width: 7.5rem;
  max-width: 10rem;
}
.select-sm {
  min-height: 2.25rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.page-head > div:first-child {
  flex: 1 1 auto;
  min-width: 0;
}
.page-head-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 auto;
  justify-content: flex-end;
  min-width: 0;
  max-width: 100%;
}
.page-head-tools .field {
  flex: 1 1 12rem;
  min-width: 0;
  max-width: 18rem;
}
.page-head-tools .btn {
  flex: 0 0 auto;
}

.data-list {
  display: flex;
  flex-direction: column;
}
.data-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.9rem;
  border-top: 1px solid var(--border);
}
.data-row:first-child {
  border-top: 0;
}
.data-row-main {
  flex: 1;
  min-width: 0;
}
.data-row-title {
  margin: 0;
  font-weight: 650;
  line-height: 1.3;
}
.data-row-title .muted {
  font-weight: 500;
  font-size: 0.85rem;
  margin-left: 0.35rem;
}
.data-row-meta {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: var(--fg-dim);
  line-height: 1.35;
}
.data-row-end {
  text-align: right;
  flex-shrink: 0;
}

.period-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.65rem;
}
.period-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--fg);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
}
.period-chip.is-active {
  background: var(--gold-light);
  border-color: var(--gold);
  color: var(--gold-dark);
}
.mark-paid-months-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.mark-paid-months-row .field {
  max-width: 6.5rem;
}
.field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--fg-dim);
}

.detail-grid {
  display: grid;
  gap: 0.75rem;
  align-items: start;
  margin-bottom: 1rem;
}

@media (min-width: 640px) {
  .detail-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.9fr);
  }
}

.detail-aside {
  display: grid;
  gap: 0.75rem;
  align-content: start;
}

.detail-aside-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.7rem;
}

.panel-compact {
  padding: 0.9rem 1rem;
}

.detail-grid > .panel,
.detail-aside > .panel {
  margin-bottom: 0;
}

.kv {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 0.35rem 0.75rem;
  font-size: 0.9rem;
}

.kv-compact {
  grid-template-columns: 72px 1fr;
  gap: 0.4rem 0.65rem;
  font-size: 0.84rem;
}

.kv dt {
  margin: 0;
  color: var(--fg-dim);
  font-weight: 600;
}

.kv dd {
  margin: 0;
  word-break: break-word;
}

.btn-row-wrap {
  flex-wrap: wrap;
}

/* ── Login ── */
.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  position: relative;
  z-index: 1;
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 1.75rem 1.35rem 1.5rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
}

.login-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-brand img {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  margin-bottom: 0.75rem;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.login-brand h1 span {
  color: var(--gold-dark);
}

.login-brand p {
  margin: 0.35rem 0 0;
  color: var(--fg-muted);
  font-size: 0.9rem;
}

/* ── Modal / toast ── */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: end center;
  padding: 0;
  background: rgba(0, 0, 0, 0.55);
}

@media (min-width: 560px) {
  .modal-root {
    place-items: center;
    padding: 1rem;
  }
}

.modal-sheet {
  width: 100%;
  max-width: 520px;
  max-height: min(92dvh, 820px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 1.15rem 1rem 1.25rem;
  box-shadow: var(--shadow);
  animation: sheet-up 220ms var(--ease);
}

@media (min-width: 560px) {
  .modal-sheet {
    border-radius: 18px;
  }
}

@keyframes sheet-up {
  from {
    transform: translateY(24px);
    opacity: 0.6;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 750;
}

.toast-stack {
  position: fixed;
  top: calc(0.75rem + env(safe-area-inset-top));
  right: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  pointer-events: none;
}

@media (min-width: 560px) {
  .toast-stack {
    left: auto;
    width: 340px;
  }
}

.toast {
  pointer-events: auto;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-weight: 550;
  animation: toast-in 220ms var(--ease);
}

.toast.is-error {
  border-color: #fecaca;
  color: var(--danger);
  background: #fef2f2;
}

.toast.is-success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--success);
}

@keyframes toast-in {
  from {
    transform: translateY(-8px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.muted {
  color: var(--fg-muted);
}

.mono {
  font-variant-numeric: tabular-nums;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--fg-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.82rem;
  margin-bottom: 0.55rem;
}

.back-link:hover {
  color: var(--gold-dark);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 1rem 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: var(--tap);
  padding: 0.35rem 0;
}

.check-row input {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--gold);
}

.check-field {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  cursor: pointer;
  user-select: none;
  min-height: var(--tap);
}
.check-field input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.check-box {
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 5px;
  border: 2px solid var(--border);
  background: #fff;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  transition: border-color 160ms, background 160ms, box-shadow 160ms;
}
.check-field input:focus-visible + .check-box {
  box-shadow: 0 0 0 3px var(--gold-soft);
  border-color: var(--gold);
}
.check-field input:checked + .check-box {
  background: var(--gold);
  border-color: var(--gold);
}
.check-field input:checked + .check-box::after {
  content: "";
  width: 0.28rem;
  height: 0.5rem;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
  margin-bottom: 0.12rem;
}
.check-label {
  font-size: 0.9rem;
  font-weight: 550;
  color: var(--fg);
}

.ui-select {
  position: relative;
  width: 100%;
}
.toolbar .ui-select,
.panel-head-row .ui-select,
.select-sm.ui-select,
.ui-select.ui-select--compact {
  width: auto;
}
.ui-select-native {
  position: absolute !important;
  opacity: 0 !important;
  pointer-events: none !important;
  width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}
.ui-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.ui-select-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ui-select-chevron {
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--fg-muted);
  border-bottom: 2px solid var(--fg-muted);
  transform: rotate(45deg);
  margin-top: -0.2rem;
  flex: 0 0 auto;
  transition: transform 160ms;
}
.ui-select.is-open .ui-select-chevron {
  transform: rotate(-135deg);
  margin-top: 0.15rem;
}
.ui-select.is-open .ui-select-trigger {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.ui-select-menu {
  position: absolute;
  z-index: 80;
  left: 0;
  right: 0;
  top: calc(100% + 0.3rem);
  max-height: 14rem;
  overflow: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--menu-bg);
  box-shadow: var(--shadow);
  padding: 0.3rem;
}
.ui-select-menu.is-fixed {
  position: fixed;
  right: auto;
  z-index: 10050;
}
.ui-select-option {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 0.875rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
}
.ui-select-option:hover,
.ui-select-option:focus-visible {
  background: rgba(201, 162, 39, 0.16);
  outline: none;
}
.ui-select-option.is-selected {
  background: var(--gold-light);
  color: var(--gold-dark);
  font-weight: 650;
}
.ui-select.is-disabled .ui-select-trigger {
  opacity: 0.55;
  cursor: not-allowed;
}

.shop-logo-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.shop-logo-preview {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex: 0 0 auto;
}
.shop-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.shop-logo-empty {
  font-size: 0.7rem;
  color: var(--fg-muted);
  text-align: center;
  padding: 0.35rem;
}
.shop-logo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.shop-logo-actions .btn {
  border-width: 1px;
}
.file-btn {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.list-row-logo {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 6px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
  flex: 0 0 auto;
}
.list-row-logo-fallback {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 6px;
  background: var(--gold-light);
  color: var(--gold-dark);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex: 0 0 auto;
}

.skeleton {
  height: 1em;
  border-radius: 6px;
  background: linear-gradient(90deg, #f1f5f9, #e2e8f0, #f1f5f9);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}
