:root {
  color-scheme: light;
  --ink: #14110f;
  --ink-soft: #4b4742;
  --paper: #f6f2ea;
  --panel: #fffaf1;
  --line: #ded5c6;
  --muted: #8a8174;
  --mint: #30d59d;
  --mint-dark: #137a5b;
  --coral: #ff6f61;
  --plum: #5b3f8c;
  --sky: #5aa7d8;
  --gold: #d99d2b;
  --shadow: 0 18px 50px rgba(34, 28, 20, 0.13);
  --topbar-height: 150px;
  --sticky-chrome-height: 270px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--sticky-chrome-height) + 12px);
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(20, 17, 15, 0.03) 1px, transparent 1px) 0 0 / 44px 44px,
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: 0;
}

body.auth-locked .app-shell {
  filter: blur(3px);
  pointer-events: none;
  user-select: none;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(20, 17, 15, 0.38);
  backdrop-filter: blur(12px);
}

body.auth-locked .auth-gate {
  display: flex;
}

.auth-panel {
  width: min(520px, 100%);
  display: grid;
  gap: 20px;
  padding: 28px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-panel h1 {
  margin: 6px 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.98;
}

.auth-panel p {
  margin: 0;
  color: var(--ink-soft);
}

.auth-form,
.compact-form {
  display: grid;
  gap: 12px;
}

.workspace-type {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  border: 0;
  padding: 0;
  margin: 0;
}

.workspace-type legend {
  width: 100%;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.workspace-type label {
  min-height: 38px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  padding: 0 12px;
  background: var(--panel);
  font-weight: 850;
}

.auth-message {
  min-height: 0;
  color: var(--mint-dark);
  font-weight: 850;
  padding: 0;
  display: none;
}

.auth-message.error {
  color: #9d2018;
  background: #f6d8d4;
  border-left: 4px solid #9d2018;
  padding: 12px 14px;
  display: block;
}

.auth-message:not(.error):not(:empty) {
  display: block;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--mint-dark);
  padding: 0;
  font-weight: 900;
  text-align: left;
}

.password-rules,
.signed-in-label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.invite-identity {
  padding: 12px;
  border-left: 4px solid var(--mint);
  background: #e4f5ed;
  color: var(--ink);
  font-weight: 850;
}

.invite-identity small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 800;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  justify-items: center;
  padding: 18px 0;
  background: #171310;
  color: var(--panel);
  z-index: 10;
}

.brand-mark {
  width: 42px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 250, 241, 0.22);
  background: var(--mint);
  color: #0f1612;
  font-weight: 900;
}

.rail-nav {
  display: grid;
  gap: 18px;
}

.rail-nav a,
.icon-button {
  width: 48px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 250, 241, 0.16);
  background: transparent;
  color: var(--panel);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 900;
  transition: background 180ms ease, transform 180ms ease, color 180ms ease;
}

.rail-nav a:hover,
.rail-nav a.active,
.icon-button:hover {
  background: var(--panel);
  color: var(--ink);
  transform: translateY(-2px);
}

.logout-button {
  font-size: 1.25rem;
}

.workspace {
  min-width: 0;
  padding: 18px 24px 24px;
}

.topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 0 12px;
  background: rgba(246, 242, 234, 0.95);
  backdrop-filter: blur(18px);
  z-index: 9;
}

.topbar h1 {
  max-width: 760px;
  margin: 2px 0 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: clamp(1.6rem, 2.45vw, 2.45rem);
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: 0;
}

.period-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin-top: 10px;
}

.period-picker label {
  min-width: 126px;
}

.period-picker input,
.period-picker select {
  min-height: 34px;
}

.period-button {
  min-height: 34px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 0 12px;
  font-weight: 850;
}

.period-button:hover {
  background: var(--ink);
  color: var(--panel);
}

.eyebrow {
  margin: 0;
  color: var(--mint-dark);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.quick-upload input,
.file-pill input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.quick-upload,
.file-pill,
.primary-action {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  padding: 0 16px;
  background: var(--ink);
  color: var(--panel);
  font-weight: 850;
  text-decoration: none;
  box-shadow: none;
}

.export-scope {
  width: auto;
  min-width: 150px;
  min-height: 38px;
  border-color: var(--ink);
  background: var(--panel);
  font-weight: 850;
}

.file-pill {
  background: var(--mint);
  color: var(--ink);
}

.primary-action:hover,
.quick-upload:hover,
.file-pill:hover {
  filter: brightness(0.95);
}

.muted-action {
  background: #e4dacb;
  color: var(--ink);
}

.status-band {
  position: sticky;
  top: var(--topbar-height);
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  border-block: 1px solid var(--line);
  margin: 4px 0 20px;
  background: rgba(246, 242, 234, 0.95);
  backdrop-filter: blur(18px);
}

.status-band > div {
  min-height: 72px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 11px 16px;
  border-right: 1px solid var(--line);
}

.status-band > div:last-child {
  border-right: 0;
}

.status-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-label.natural-case {
  text-transform: none;
}

.status-band strong {
  font-size: clamp(1.05rem, 1.45vw, 1.38rem);
  overflow-wrap: anywhere;
}

.compare-value.up {
  color: #9d2018;
}

.compare-value.down {
  color: var(--mint-dark);
}

.compare-value.flat {
  color: var(--ink);
}

.compare-value.up::before,
.compare-value.down::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  margin-right: 10px;
  vertical-align: middle;
}

.compare-value.up::before {
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 15px solid currentColor;
}

.compare-value.down::before {
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 15px solid currentColor;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 22px;
  align-items: start;
}

.main-column {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.panel,
.alert-panel,
.mini-panel {
  border: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.68);
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel {
  padding: 22px;
  scroll-margin-top: calc(var(--sticky-chrome-height) + 12px);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.section-heading.compact {
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 5px 0 0;
  font-size: clamp(1.35rem, 2vw, 2rem);
  line-height: 1.04;
  letter-spacing: 0;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  border: 1px solid var(--ink);
}

.segment {
  min-height: 40px;
  border: 0;
  padding: 0 14px;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
}

.segment.active {
  background: var(--ink);
  color: var(--panel);
}

.bill-form,
.split-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  padding: 14px;
  background: #efe6d7;
  border: 1px solid var(--line);
}

.split-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.split-form .file-field {
  grid-column: span 1;
  min-width: 0;
}

.bill-form .file-field {
  grid-column: span 2;
}

.bill-form .primary-action {
  min-width: 150px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.checkbox-field,
.row-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  text-transform: none;
}

.checkbox-field input,
.row-check input {
  width: 18px;
  min-height: 18px;
}

.file-field {
  align-self: stretch;
  position: relative;
  min-width: 0;
  overflow: hidden;
}

.file-field input[type="file"] {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-control {
  width: 100%;
  max-width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--panel);
  padding: 0 12px;
  font-size: 0.9rem;
  font-weight: 900;
  text-transform: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-field:hover .file-control {
  background: var(--mint);
  color: var(--ink);
}

.file-name {
  min-height: 24px;
  display: block;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: none;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 1px solid #cbbfaa;
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--mint-dark);
  box-shadow: 0 0 0 3px rgba(48, 213, 157, 0.16);
}

textarea {
  min-height: 108px;
  padding: 10px;
  line-height: 1.35;
  resize: vertical;
  text-transform: none;
}

.wide {
  grid-column: span 3;
}

.split-form .primary-action {
  align-self: stretch;
}

.split-extraction {
  margin-top: 12px;
  padding: 12px 14px;
  border-left: 5px solid var(--sky);
  background: #e1f1f9;
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 750;
}

.split-extraction.error {
  border-left-color: var(--coral);
  background: #ffe4df;
}

.split-extraction.success {
  border-left-color: var(--mint);
  background: #dbf8eb;
}

.lanes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.lane {
  min-width: 0;
}

.lane-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.lane-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.lane-header span,
.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.bill-list {
  display: grid;
  gap: 10px;
  min-height: 80px;
  max-height: 500px;
  overflow-y: scroll;
  overflow-x: hidden;
  padding-top: 12px;
  padding-right: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--ink-soft) #e4dacb;
}

.bill-list::-webkit-scrollbar {
  width: 12px;
}

.bill-list::-webkit-scrollbar-track {
  background: #e4dacb;
}

.bill-list::-webkit-scrollbar-thumb {
  background: var(--ink-soft);
}

.bill-item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 86px;
  grid-template-rows: auto auto;
  gap: 10px 12px;
  align-items: stretch;
  padding: 10px;
  background: var(--panel);
  border-left: 5px solid var(--mint);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.bill-item:hover {
  transform: translateX(3px);
  box-shadow: 0 10px 24px rgba(34, 28, 20, 0.1);
}

.preview-thumb {
  width: 52px;
  height: 52px;
  border: 1px solid var(--line);
  background: #221c16;
  color: var(--panel);
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 0.78rem;
  font-weight: 900;
}

.preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bill-meta {
  grid-column: 2 / 3;
  grid-row: 1 / 3;
  min-width: 0;
  display: grid;
  gap: 8px;
}

.bill-subline {
  display: grid;
  grid-template-columns: minmax(180px, 0.9fr) minmax(150px, 1fr);
  gap: 8px;
}

.edit-name {
  font-weight: 900;
}

.bill-item input,
.bill-item select {
  min-height: 42px;
}

.stop-future-button {
  min-height: 34px;
  border: 1px solid #cbbfaa;
  background: #fff2d9;
  color: var(--ink);
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 850;
  white-space: nowrap;
}

.stop-future-button:hover {
  background: var(--gold);
}

.bill-item .edit-amount {
  grid-column: 3 / 4;
  grid-row: 1 / 2;
  align-self: start;
  height: 42px;
  font-weight: 900;
  padding-inline: 8px;
}

.bill-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.bill-actions .edit-cycle {
  width: auto;
  min-width: 130px;
  min-height: 36px;
}

.bill-actions .row-check {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid #cbbfaa;
  background: #f5eddf;
  font-size: 0.82rem;
  font-weight: 850;
}

.delete-button {
  width: 42px;
  height: 36px;
  border: 0;
  background: #f1d8d3;
  color: #7c1f18;
  font-size: 1.2rem;
  font-weight: 900;
}

.delete-button:hover {
  background: var(--coral);
  color: #230b08;
}

.inspector {
  position: sticky;
  top: 122px;
  display: grid;
  gap: 16px;
}

.alert-panel,
.mini-panel {
  padding: 18px;
}

.alerts {
  display: grid;
  gap: 10px;
}

.alert {
  display: grid;
  gap: 4px;
  padding: 12px;
  background: #fff2d9;
  border-left: 5px solid var(--gold);
}

.alert.danger {
  background: #ffe4df;
  border-left-color: var(--coral);
}

.alert.success {
  background: #dbf8eb;
  border-left-color: var(--mint);
}

.alert strong {
  font-size: 0.94rem;
}

.alert span {
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.preview-pane {
  min-height: 220px;
  display: grid;
  place-items: center;
  border: 1px dashed #b9ad9b;
  color: var(--muted);
  text-align: center;
  padding: 14px;
  overflow: hidden;
}

.preview-pane img,
.preview-pane object {
  width: 100%;
  max-height: 320px;
  object-fit: contain;
}

.statement-table {
  display: grid;
  gap: 8px;
  margin-top: 16px;
  max-height: 520px;
  overflow: auto;
  padding-right: 4px;
  scrollbar-width: thin;
}

.statement-row {
  display: grid;
  grid-template-columns: 104px minmax(220px, 1fr) 112px minmax(112px, auto);
  gap: 12px;
  align-items: start;
  padding: 13px 14px;
  background: var(--panel);
  border-left: 5px solid transparent;
  min-width: 680px;
}

.statement-row strong {
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.amount-cell {
  justify-self: end;
  font-weight: 900;
  white-space: nowrap;
}

.badge {
  justify-self: start;
  max-width: 100%;
  padding: 6px 9px;
  background: #e6e0d5;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.split-result {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}

.split-output {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  padding: 16px;
  background: var(--ink);
  color: var(--panel);
}

.split-output strong {
  font-size: 2.5rem;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-actions a,
.share-actions button {
  min-height: 38px;
  border: 1px solid rgba(255, 250, 241, 0.28);
  background: transparent;
  color: var(--panel);
  padding: 0 12px;
  text-decoration: none;
  font-weight: 850;
}

.message-preview {
  width: 100%;
  min-height: 260px;
  border-color: rgba(255, 250, 241, 0.28);
  background: rgba(255, 250, 241, 0.08);
  color: var(--panel);
}

.report-bars {
  display: grid;
  gap: 16px;
}

.report-row,
.report-legend {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: center;
}

.report-row strong {
  font-weight: 900;
}

.report-row.top-category > strong,
.report-row.top-category .report-amount > strong {
  color: var(--mint-dark);
}

.report-legend {
  padding-bottom: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.legend-items span {
  display: inline-flex;
  gap: 7px;
  align-items: center;
}

.legend-swatch {
  width: 24px;
  height: 10px;
  display: inline-block;
  border: 1px solid #cfc2b1;
}

.legend-swatch.current {
  background: var(--mint-dark);
}

.legend-swatch.previous {
  background: #908676;
}

.comparison-bar {
  position: relative;
  height: 24px;
  display: block;
  overflow: hidden;
  background: #e7decf;
  border: 1px solid #d2c5b3;
}

.comparison-bar .bar-fill {
  position: absolute;
  left: 0;
  top: 50%;
  display: block;
  transition: width 260ms ease;
  transform: translateY(-50%);
}

.comparison-bar .previous-fill {
  height: 100%;
  background: #908676;
  opacity: 0.7;
}

.comparison-bar .current-fill {
  height: 12px;
  min-width: 2px;
  background: var(--bar-color, var(--plum));
  box-shadow: 0 0 0 1px rgba(255, 250, 241, 0.4);
}

.top-category .comparison-bar {
  background: #dcece3;
  border-color: #b4d6c5;
}

.report-amount {
  display: grid;
  justify-items: end;
  gap: 3px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.report-amount small {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
  line-height: 1.25;
  white-space: nowrap;
}

.report-amount small:not(.compare-line) {
  display: none;
}

.report-amount small.up {
  color: #a24133;
}

.report-amount small.down {
  color: var(--mint-dark);
}

.empty-state {
  padding: 18px;
  border: 1px dashed #b9ad9b;
  color: var(--muted);
  text-align: center;
}

.profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 24px;
}

.import-panel,
.danger-zone {
  display: grid;
  gap: 12px;
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.62);
}

.import-panel h3,
.danger-zone h3 {
  margin: 4px 0;
}

.import-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.delete-account-button,
.remove-member-button {
  min-height: 36px;
  border: 0;
  background: #f1d8d3;
  color: #7c1f18;
  padding: 0 12px;
  font-weight: 900;
}

.profile-grid > * {
  min-width: 0;
}

.member-list,
.admin-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.member-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 250, 241, 0.62);
}

.admin-table-head,
.admin-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.85fr) minmax(220px, 1.1fr) minmax(190px, 0.9fr);
  gap: 14px;
  align-items: center;
}

.admin-table-head {
  margin-top: 18px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: #e8dfd1;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-row {
  padding: 14px;
  border: 1px solid var(--line);
  border-top: 0;
  background: rgba(255, 250, 241, 0.62);
}

.admin-row span,
.admin-row time,
.member-item small {
  color: var(--muted);
  font-weight: 750;
  overflow-wrap: anywhere;
}

.invite-share {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  min-width: 0;
  overflow: hidden;
}

.invite-url {
  display: block;
  max-width: 100%;
  color: var(--mint-dark);
  font-weight: 850;
  overflow-wrap: anywhere;
  word-break: break-all;
  line-height: 1.35;
}

.share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.share-row a,
.share-row button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 0 10px;
  font-weight: 850;
  text-decoration: none;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  border-block: 1px solid var(--line);
  margin-bottom: 16px;
}

.admin-stats div {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 14px;
  border-right: 1px solid var(--line);
}

.admin-stats .status-label::after {
  content: " -";
}

.admin-stats div:last-child {
  border-right: 0;
}

@media (max-width: 1320px) {
  .bill-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .bill-form .file-field {
    grid-column: span 3;
  }

  .split-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1360px) {
  .lanes {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1120px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .inspector {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bill-form,
  .split-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wide,
  .bill-form .file-field,
  .split-form .primary-action {
    grid-column: auto;
  }
}

@media (max-width: 760px) {
  html {
    scroll-padding-top: 86px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: sticky;
    top: 0;
    height: 62px;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: 1fr;
    padding: 0 12px;
  }

  .rail-nav {
    grid-auto-flow: column;
    justify-content: center;
  }

  .workspace {
    padding: 16px;
  }

  .topbar {
    position: static;
    display: grid;
  }

  .status-band {
    position: static;
  }

  .panel {
    scroll-margin-top: 86px;
  }

  .status-band,
  .lanes,
  .profile-grid,
  .admin-table-head,
  .admin-row,
  .inspector {
    grid-template-columns: 1fr;
  }

  .status-band > div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .section-heading {
    display: grid;
  }

  .bill-form,
  .split-form,
  .report-row,
  .report-legend {
    grid-template-columns: 1fr;
  }

  .report-legend > span:first-child,
  .report-legend > span:last-child {
    display: none;
  }

  .report-amount {
    justify-items: start;
    text-align: left;
  }

  .report-amount small {
    white-space: normal;
  }

  .statement-table {
    max-height: 460px;
  }

  .statement-row {
    min-width: 560px;
    grid-template-columns: 90px minmax(200px, 1fr) 98px 105px;
  }

  .bill-item {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .preview-thumb {
    width: 52px;
    height: 52px;
  }

  .bill-item .edit-amount {
    grid-column: 2 / 3;
    grid-row: auto;
  }

  .delete-button {
    grid-column: auto;
    grid-row: auto;
  }

  .bill-subline {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  :root {
    --topbar-height: 0px;
    --sticky-chrome-height: 128px;
  }

  html {
    scroll-padding-top: 12px;
  }

  body {
    font-size: 16px;
    background:
      linear-gradient(90deg, rgba(20, 17, 15, 0.025) 1px, transparent 1px) 0 0 / 34px 34px,
      var(--paper);
  }

  .auth-gate {
    align-items: stretch;
    padding: 14px;
    overflow: auto;
  }

  .auth-panel {
    align-self: center;
    width: 100%;
    max-height: calc(100svh - 28px);
    overflow: auto;
    padding: 20px;
    gap: 16px;
  }

  .auth-panel h1 {
    font-size: 2.15rem;
    line-height: 1;
  }

  .app-shell {
    display: block;
    min-height: 100svh;
  }

  .rail {
    position: fixed;
    inset: auto 0 0 0;
    height: calc(68px + env(safe-area-inset-bottom));
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: 1fr;
    align-items: center;
    justify-items: stretch;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 250, 241, 0.16);
    z-index: 20;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .rail-nav {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: space-around;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .rail-nav::-webkit-scrollbar {
    display: none;
  }

  .rail-nav a,
  .icon-button {
    width: 100%;
    max-width: 48px;
    height: 44px;
    aspect-ratio: auto;
    font-size: 0.86rem;
  }

  .workspace {
    padding: 12px 12px calc(90px + env(safe-area-inset-bottom));
  }

  .topbar {
    position: static;
    gap: 12px;
    padding: 8px 0 12px;
    border-bottom: 1px solid rgba(222, 213, 198, 0.75);
    background: rgba(246, 242, 234, 0.97);
  }

  .topbar h1 {
    max-width: 100%;
    margin-top: 0;
    font-size: 1.72rem;
    line-height: 1.04;
  }

  .signed-in-label {
    margin: 4px 0 0;
    font-size: 0.82rem;
    overflow-wrap: anywhere;
  }

  .period-picker {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "month year"
      "prev next"
      "current current";
    gap: 8px;
    align-items: end;
    margin-top: 10px;
  }

  .period-picker label {
    min-width: 0;
  }

  .period-picker label:nth-of-type(1) {
    grid-area: month;
  }

  .period-picker label:nth-of-type(2) {
    grid-area: year;
  }

  .period-picker .period-button {
    min-width: 0;
    padding: 0 8px;
  }

  #previousMonth {
    grid-area: prev;
  }

  #nextMonth {
    grid-area: next;
  }

  #currentMonth {
    grid-area: current;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: minmax(112px, 1.25fr) minmax(76px, 0.78fr) minmax(86px, 0.9fr);
    grid-template-areas:
      "scope export upload";
    gap: 8px;
    justify-content: stretch;
  }

  .quick-upload,
  .file-pill,
  .primary-action,
  .muted-action,
  .export-scope {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    padding: 0 8px;
    text-align: center;
    font-size: 0.86rem;
  }

  .quick-upload {
    grid-area: upload;
  }

  .export-scope {
    grid-area: scope;
  }

  #exportData {
    grid-area: export;
  }

  .status-band {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 12px 0 14px;
    border: 1px solid var(--line);
  }

  .status-band > div {
    min-height: 66px;
    padding: 10px 12px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .status-band > div:nth-child(2n) {
    border-right: 0;
  }

  .status-band > div:nth-last-child(-n + 2) {
    border-bottom: 0;
  }

  .status-band strong {
    font-size: 1.18rem;
  }

  .content-grid,
  .main-column {
    display: grid;
    gap: 14px;
  }

  .panel,
  .alert-panel,
  .mini-panel {
    padding: 16px;
    box-shadow: none;
  }

  .panel {
    scroll-margin-top: 12px;
  }

  .section-heading {
    gap: 12px;
    margin-bottom: 14px;
  }

  .section-heading h2 {
    font-size: 1.55rem;
    line-height: 1.08;
  }

  .segmented {
    width: 100%;
  }

  .segment {
    min-height: 44px;
  }

  .bill-form,
  .split-form {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }

  .bill-form .file-field,
  .split-form .file-field,
  .bill-form .primary-action,
  .split-form .primary-action {
    grid-column: auto;
  }

  .file-control {
    min-height: 48px;
  }

  input,
  select,
  textarea {
    min-height: 46px;
    font-size: 16px;
  }

  .checkbox-field,
  .row-check {
    min-height: 44px;
  }

  .import-panel,
  .danger-zone {
    padding: 14px;
  }

  .import-actions,
  .share-actions,
  .share-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .lanes {
    gap: 14px;
  }

  .bill-list {
    max-height: 430px;
    padding-right: 6px;
  }

  .bill-item {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
  }

  .preview-thumb {
    width: 48px;
    height: 48px;
    font-size: 0.72rem;
  }

  .bill-meta {
    grid-column: 2 / 3;
    grid-row: 1 / auto;
  }

  .bill-item .edit-amount {
    grid-column: 2 / 3;
    width: 100%;
  }

  .bill-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .bill-actions .edit-cycle,
  .bill-actions .row-check,
  .stop-future-button,
  .delete-button {
    width: 100%;
    min-width: 0;
    min-height: 42px;
  }

  .delete-button {
    font-size: 1rem;
  }

  .inspector {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .preview-pane {
    min-height: 160px;
  }

  .statement-table {
    max-height: 440px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0;
  }

  .statement-row {
    min-width: 0;
    grid-template-columns: 1fr auto;
    gap: 7px 10px;
    padding: 12px;
  }

  .statement-row span:first-child {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 800;
  }

  .statement-row strong {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .amount-cell {
    grid-column: 2 / 3;
    grid-row: 1;
    align-self: start;
  }

  .badge {
    grid-column: 1 / -1;
    grid-row: 3;
    white-space: normal;
    justify-self: start;
  }

  .split-output {
    padding: 14px;
  }

  .split-output strong {
    font-size: 2rem;
  }

  .message-preview {
    min-height: 220px;
  }

  .report-bars {
    gap: 14px;
  }

  .report-legend {
    display: block;
  }

  .legend-items {
    gap: 10px;
  }

  .report-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
  }

  .comparison-bar {
    height: 28px;
  }

  .report-amount {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
  }

  .report-amount small {
    font-size: 0.8rem;
    white-space: normal;
  }

  .profile-grid,
  .member-item,
  .admin-table-head,
  .admin-row,
  .admin-stats {
    grid-template-columns: 1fr;
  }

  .member-item {
    gap: 8px;
  }

  .remove-member-button {
    width: 100%;
  }

  .admin-table-head {
    display: none;
  }

  .admin-row {
    gap: 6px;
    border-top: 1px solid var(--line);
    margin-bottom: 8px;
  }

  .admin-row strong::before {
    content: "User: ";
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 900;
    text-transform: uppercase;
  }

  .admin-row span::before {
    content: "Email: ";
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 900;
    text-transform: uppercase;
  }

  .admin-row time::before {
    content: "Last login: ";
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 900;
    text-transform: uppercase;
  }
}

@media (max-width: 430px) {
  .workspace {
    padding-inline: 10px;
  }

  .topbar h1 {
    font-size: 1.45rem;
  }

  .period-picker {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "month year"
      "prev next"
      "current current";
  }

  .period-picker label:nth-of-type(1),
  .period-picker label:nth-of-type(2),
  #previousMonth,
  #nextMonth,
  #currentMonth {
    grid-column: auto;
  }

  #currentMonth {
    grid-area: current;
  }

  .status-band {
    grid-template-columns: 1fr;
  }

  .status-band > div,
  .status-band > div:nth-child(2n),
  .status-band > div:nth-last-child(-n + 2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .status-band > div:last-child {
    border-bottom: 0;
  }

  .rail {
    padding-inline: 8px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .rail-nav {
    gap: 4px;
  }

  .rail-nav a {
    max-width: 42px;
    height: 42px;
  }

  .panel,
  .alert-panel,
  .mini-panel {
    padding: 14px;
  }

  .section-heading h2 {
    font-size: 1.38rem;
  }
}
