:root {
  --bg: #f5f5f7;
  --panel: rgba(255, 255, 255, 0.96);
  --panel-soft: rgba(255, 255, 255, 0.98);
  --line: rgba(15, 23, 42, 0.08);
  --text: #111827;
  --muted: #6b7280;
  --primary: #38bdf8;
  --primary-dark: #0284c7;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #f87171;
  --radius: 20px;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: linear-gradient(180deg, #ffffff 0%, #f5f5f7 100%);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}
button, input, textarea, select { font: inherit; }
.app-shell {
  width: min(1320px, calc(100% - 24px));
  margin: 0 auto;
  padding: 20px 0 80px;
}
.auth-locked .requires-auth {
  display: none !important;
}
.auth-locked .app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}
.auth-locked .hero {
  margin-top: 24px;
}
.hero, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}
.hero {
  padding: 28px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  background: radial-gradient(circle at top left, rgba(56,189,248,.08), transparent 24%), linear-gradient(145deg, rgba(255,255,255,.98), rgba(248,250,252,.96));
}
.hero h1, .card h2 { margin: 0; }
.hero-copy { max-width: 720px; color: var(--muted); line-height: 1.6; margin-top: 8px; }
.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: #0284c7;
}
.hero-actions, .toolbar { display: flex; gap: 10px; flex-wrap: wrap; }
.login-card, .toolbar, .card { padding: 20px; margin-top: 16px; }
.compact { align-items: end; }
.inline-notice {
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #ffffff;
  box-shadow: var(--shadow);
  font-weight: 600;
}
.inline-notice.success {
  background: rgba(34, 197, 94, 0.10);
  border-color: rgba(34, 197, 94, 0.24);
  color: #166534;
}
.inline-notice.error {
  background: rgba(248, 113, 113, 0.10);
  border-color: rgba(248, 113, 113, 0.24);
  color: #991b1b;
}
.inline-notice.info {
  background: rgba(56, 189, 248, 0.10);
  border-color: rgba(56, 189, 248, 0.22);
  color: #0c4a6e;
}
.view-mode-banner {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px solid rgba(245, 158, 11, 0.28);
  background: rgba(255, 251, 235, 0.92);
  color: #78350f;
  box-shadow: var(--shadow);
}
.view-mode-banner strong {
  font-weight: 900;
}
.view-mode-banner span {
  color: #92400e;
  font-weight: 650;
}
.archive-readonly input:disabled,
.archive-readonly textarea:disabled,
.archive-readonly select:disabled {
  color: #64748b;
  background: #f8fafc;
  opacity: 1;
}
.archive-readonly .bill-card,
.archive-readonly .entry-card {
  background: linear-gradient(180deg, #ffffff, #fafafa);
}
.sync-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.sync-meta-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: #ffffff;
}
.sync-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 8px;
}
.sync-meta-card strong {
  display: block;
  font-size: 16px;
}
.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { cursor: not-allowed; opacity: .58; transform: none; }
.btn-primary { background: linear-gradient(180deg, var(--primary), var(--primary-dark)); color: #03131f; }
.btn-secondary { background: #ffffff; color: var(--text); border: 1px solid var(--line); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
.btn-save {
  background: linear-gradient(180deg, #34d399, #10b981);
  color: #052e16;
  box-shadow: 0 12px 26px rgba(16, 185, 129, .22);
}
.btn-load {
  background: linear-gradient(180deg, #dbeafe, #bfdbfe);
  color: #1e3a8a;
  border-color: rgba(59, 130, 246, .24);
}
.btn-copy {
  background: linear-gradient(180deg, #fffbeb, #fef3c7);
  color: #92400e;
  border-color: rgba(245, 158, 11, .28);
}
.btn-view {
  background: linear-gradient(180deg, #f0f9ff, #e0f2fe);
  color: #075985;
  border-color: rgba(14, 165, 233, .22);
}
.btn-current {
  background: linear-gradient(180deg, #ecfdf5, #d1fae5);
  color: #065f46;
  border-color: rgba(16, 185, 129, .24);
}
.btn-download {
  background: linear-gradient(180deg, #f8fafc, #eef2ff);
  color: #334155;
  border-color: rgba(99, 102, 241, .18);
}
.btn-install {
  background: linear-gradient(180deg, #ede9fe, #ddd6fe);
  color: #5b21b6;
  border-color: rgba(124, 58, 237, .20);
}
.btn-reset {
  background: #ffffff;
  color: #b91c1c;
  border-color: rgba(185, 28, 28, .22);
}
.btn-reset:hover:not(:disabled) {
  background: rgba(254, 226, 226, .60);
}
.hidden { display: none !important; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 180px; }
label { color: var(--muted); font-size: 13px; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
}
input[type="date"] {
  color-scheme: light;
}
textarea { min-height: 120px; resize: vertical; }
.stats-grid, .two-col, .bill-grid, .entry-grid {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two-col { grid-template-columns: 1.2fr .8fr; }
.two-col.lower { grid-template-columns: 1fr 1fr; }
.stat-card {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
}
.stat-label, .stat-foot, .muted, .login-note, .login-status { color: var(--muted); }
.stat-value { display: block; font-size: 30px; margin: 10px 0 6px; }
.progress {
  margin-top: 10px;
  height: 10px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress > div { height: 100%; width: 0%; background: linear-gradient(90deg, var(--primary), var(--success)); }
.section-heading { display: flex; justify-content: space-between; align-items: start; gap: 10px; margin-bottom: 12px; }
.recurring-heading {
  align-items: center;
  flex-wrap: wrap;
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(56,189,248,.10);
  color: #0369a1;
  font-size: 12px;
  font-weight: 700;
}
.chip-paid {
  background: rgba(34, 197, 94, 0.14);
  color: #15803d;
}
.chip-pending {
  background: rgba(248, 113, 113, 0.14);
  color: #b91c1c;
}
.chip-skipped {
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
}
.bill-grid { grid-template-columns: 1fr; }
.bill-accordion {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #f8fafc;
  overflow: hidden;
}
.bill-accordion summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  font-weight: 800;
}
.bill-accordion summary::-webkit-details-marker { display: none; }
.accordion-count {
  min-width: 28px;
  text-align: center;
  border-radius: 999px;
  background: rgba(56,189,248,.12);
  color: #0369a1;
  padding: 4px 10px;
  font-size: 12px;
}
.accordion-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.accordion-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: var(--muted);
  transition: transform .18s ease;
}
.bill-accordion:not([open]) .accordion-arrow {
  transform: rotate(-90deg);
}
.accordion-grid {
  padding: 0 16px 16px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.bill-card, .entry-card, .pending-card, .category-row {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 18px;
}
.bill-card { padding: 16px; }
.bill-card-archived {
  background: #fcfcfd;
  border-style: dashed;
}
.bill-top, .row-between { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.bill-header-main { flex: 1; min-width: 0; }
.bill-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.bill-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}
.bill-config-row {
  display: grid;
  grid-template-columns: 1fr;
  align-items: end;
  gap: 12px;
  margin-top: 12px;
}
.slim-field {
  min-width: 0;
  max-width: none;
}
.toggle-inline {
  grid-column: auto;
  width: fit-content;
}
.archive-toggle {
  font-size: 12px;
  font-weight: 600;
}
.bill-title { font-size: 17px; font-weight: 700; }
.bill-title-edit-wrap { display: grid; gap: 8px; }
.bill-meta-edit-wrap { margin-top: 8px; }
.bill-edit-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bill-edit-link {
  border: none;
  background: transparent;
  color: #2563eb;
  font-weight: 700;
  padding: 0;
  cursor: pointer;
}
.bill-edit-link.is-primary {
  background: #2563eb;
  color: #fff;
  border-radius: 999px;
  padding: 6px 12px;
}
.bill-title-input {
  width: 100%;
  font-size: 17px;
  font-weight: 700;
  border-radius: 14px;
  padding: 10px 12px;
  background: #ffffff;
}
.bill-meta-input {
  width: 100%;
  border-radius: 14px;
  padding: 10px 12px;
  background: #ffffff;
}
.bill-sub, .item-note { color: var(--muted); font-size: 13px; margin-top: 8px; }
.bill-body, .entry-grid { display: grid; gap: 10px; margin-top: 12px; }
.bill-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.bill-body.compact-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.entry-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.entry-grid .field,
.bill-body .field {
  min-width: 0;
}
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  background: #ffffff;
  font-size: 13px;
}
.pill input { width: auto; accent-color: var(--success); }
.bill-archive-row {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.bill-archive-btn {
  width: fit-content;
  border: 1px solid rgba(185, 28, 28, 0.18);
  background: rgba(254, 226, 226, 0.6);
  color: #b91c1c;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}
.bill-archive-btn.is-restore {
  border-color: rgba(21, 128, 61, 0.18);
  background: rgba(220, 252, 231, 0.7);
  color: #15803d;
}
.bill-archive-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.entry-card { padding: 14px; margin-top: 12px; }
.money-input {
  position: relative;
  width: 100%;
}
.money-input span {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-weight: 600;
}
.money-input input {
  padding-left: 30px;
}
.summary-table { width: 100%; border-collapse: collapse; }
.summary-table th, .summary-table td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
}
.category-list { display: grid; gap: 10px; margin-bottom: 14px; }
.category-row { padding: 14px; }
.category-row strong { display: block; margin-bottom: 6px; }
.pending-card { padding: 14px; margin-top: 10px; }
.subsection-block {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 18px;
  background: #fcfcfd;
  margin-bottom: 18px;
}
.subsection-kicker {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #2563eb;
  font-weight: 700;
}
.subsection-block h3 {
  margin: 0 0 14px;
  font-size: 20px;
}
.attention-block {
  margin: 0 0 18px;
}
.attention-block h3 {
  margin: 0 0 10px;
}
.summary-grid {
  grid-template-columns: 1.05fr .95fr;
}
.summary-bars {
  display: grid;
  gap: 14px;
}
.bar-row {
  display: grid;
  gap: 8px;
}
.bar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}
.bar-track {
  width: 100%;
  height: 12px;
  background: #eef2f7;
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  min-width: 6px;
}
.bar-fill.income { background: linear-gradient(90deg, #34d399, #10b981); }
.bar-fill.fixed { background: linear-gradient(90deg, #60a5fa, #3b82f6); }
.bar-fill.dynamic { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.bar-fill.variable { background: linear-gradient(90deg, #fb7185, #f43f5e); }
.bar-fill.total { background: linear-gradient(90deg, #818cf8, #6366f1); }
.bar-fill.net.positive { background: linear-gradient(90deg, #22c55e, #16a34a); }
.bar-fill.net.negative { background: linear-gradient(90deg, #f87171, #ef4444); }
.empty-bars {
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 16px;
  color: var(--muted);
}
.empty-state {
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}
@media (max-width: 1080px) {
  .stats-grid, .two-col, .two-col.lower, .bill-grid, .accordion-grid, .entry-grid, .bill-body, .bill-config-row { grid-template-columns: 1fr; }
  .sync-meta-grid { grid-template-columns: 1fr 1fr; }
  .hero { flex-direction: column; }
}

.auth-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 12px;
}
.signed-in-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  max-width: 100%;
  border: 1px solid rgba(21, 128, 61, 0.18);
  background: rgba(220, 252, 231, 0.7);
  color: #14532d;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}
.signed-in-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.14);
}
.signed-in-label {
  font-weight: 800;
}
.signed-in-pill strong {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.signout-icon {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}
.signout-icon:hover {
  color: #b91c1c;
  border-color: rgba(185, 28, 28, 0.22);
  background: rgba(254, 226, 226, 0.45);
}
.auth-status {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.auth-status.success { color: #15803d; }
.auth-status.error { color: #b91c1c; }
.auth-status.info { color: var(--muted); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
@media (max-width: 760px) {
  .auth-topbar {
    justify-content: flex-start;
  }
}
