:root {
  --bg: #f3f6f8;
  --bg-soft: #f8fafb;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --text: #1c2b36;
  --muted: #70808e;
  --line: #e3eaf0;
  --shadow: 0 8px 22px rgba(18, 36, 51, 0.08);
  --accent: #11a58f;
  --accent-soft: #e8f8f5;
  --accent-2: #59c6b5;
  --danger: #de6458;
  --danger-soft: #fff2f0;
  --glow-a: transparent;
  --glow-b: transparent;
  --hero-a: transparent;
  --hero-b: transparent;
  --hero-orb: transparent;
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --font: "Manrope", sans-serif;
}

body[data-theme="ocean-mint"] {
  --bg: #e9f6f6;
  --bg-soft: rgba(244, 255, 253, 0.84);
  --surface: rgba(255, 255, 255, 0.68);
  --surface-strong: #f5fffd;
  --text: #17323a;
  --muted: #66828a;
  --line: rgba(23, 50, 58, 0.08);
  --shadow: 0 22px 70px rgba(61, 115, 117, 0.16);
  --accent: #1b9aaa;
  --accent-soft: #dff6fb;
  --accent-2: #58c7b2;
  --danger: #de6a77;
  --danger-soft: #fff2f4;
  --glow-a: rgba(27, 154, 170, 0.18);
  --glow-b: rgba(88, 199, 178, 0.22);
  --hero-a: rgba(27, 154, 170, 0.13);
  --hero-b: rgba(88, 199, 178, 0.14);
  --hero-orb: rgba(27, 154, 170, 0.18);
}

body[data-theme="sand-gold"] {
  --bg: #f6ecdb;
  --bg-soft: rgba(255, 249, 240, 0.84);
  --surface: rgba(255, 252, 246, 0.72);
  --surface-strong: #fffaf0;
  --text: #2f2418;
  --muted: #8a725b;
  --line: rgba(47, 36, 24, 0.08);
  --shadow: 0 24px 78px rgba(166, 128, 64, 0.18);
  --accent: #c78a2d;
  --accent-soft: #fff1d8;
  --accent-2: #e2b84b;
  --danger: #c96f52;
  --danger-soft: #fff3ed;
  --glow-a: rgba(199, 138, 45, 0.18);
  --glow-b: rgba(226, 184, 75, 0.22);
  --hero-a: rgba(199, 138, 45, 0.13);
  --hero-b: rgba(226, 184, 75, 0.14);
  --hero-orb: rgba(199, 138, 45, 0.18);
}

body[data-theme="graphite-luxe"] {
  --bg: #dce0e7;
  --bg-soft: rgba(247, 248, 251, 0.82);
  --surface: rgba(255, 255, 255, 0.62);
  --surface-strong: #f8fafc;
  --text: #1c2430;
  --muted: #697586;
  --line: rgba(28, 36, 48, 0.09);
  --shadow: 0 24px 80px rgba(58, 67, 82, 0.18);
  --accent: #4a637d;
  --accent-soft: #e4ecf5;
  --accent-2: #9aa8ba;
  --danger: #c66a74;
  --danger-soft: #fff1f3;
  --glow-a: rgba(74, 99, 125, 0.18);
  --glow-b: rgba(154, 168, 186, 0.22);
  --hero-a: rgba(74, 99, 125, 0.13);
  --hero-b: rgba(154, 168, 186, 0.14);
  --hero-orb: rgba(74, 99, 125, 0.18);
}

body[data-theme="rose-cream"] {
  --bg: #fbebea;
  --bg-soft: rgba(255, 248, 248, 0.86);
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: #fffafa;
  --text: #35212a;
  --muted: #8e7380;
  --line: rgba(53, 33, 42, 0.08);
  --shadow: 0 22px 78px rgba(161, 102, 123, 0.16);
  --accent: #cf6f91;
  --accent-soft: #ffe5ef;
  --accent-2: #f0a2b9;
  --danger: #d56c72;
  --danger-soft: #fff0f1;
  --glow-a: rgba(207, 111, 145, 0.18);
  --glow-b: rgba(240, 162, 185, 0.22);
  --hero-a: rgba(207, 111, 145, 0.13);
  --hero-b: rgba(240, 162, 185, 0.14);
  --hero-orb: rgba(207, 111, 145, 0.18);
}

body[data-theme="forest-soft"] {
  --bg: #e8f0e6;
  --bg-soft: rgba(249, 255, 248, 0.84);
  --surface: rgba(255, 255, 255, 0.7);
  --surface-strong: #f8fff8;
  --text: #203027;
  --muted: #6f8378;
  --line: rgba(32, 48, 39, 0.08);
  --shadow: 0 22px 76px rgba(82, 121, 98, 0.16);
  --accent: #4d8b63;
  --accent-soft: #e1f3e7;
  --accent-2: #88b378;
  --danger: #c56f58;
  --danger-soft: #fff2ed;
  --glow-a: rgba(77, 139, 99, 0.18);
  --glow-b: rgba(136, 179, 120, 0.22);
  --hero-a: rgba(77, 139, 99, 0.13);
  --hero-b: rgba(136, 179, 120, 0.14);
  --hero-orb: rgba(77, 139, 99, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  overflow-x: hidden;
  background: var(--bg);
}

body::before {
  content: none;
}

.app-shell {
  width: min(100%, 430px);
  margin: 0 auto;
  padding: 12px 12px calc(88px + env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
}

.hero-card,
.panel,
.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero-card {
  position: relative;
  overflow: hidden;
  padding: 24px;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.78), rgba(255, 248, 239, 0.7)),
    linear-gradient(120deg, var(--hero-a), var(--hero-b));
}

.hero-card::after {
  content: "";
  position: absolute;
  right: -24px;
  top: -32px;
  width: 160px;
  height: 160px;
  border-radius: 999px;
  background: radial-gradient(circle, var(--hero-orb), transparent 70%);
}

.hero-copy h1,
.panel h2,
.metric-card h3 {
  margin: 0;
}

.hero-copy h1 {
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.hero-subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.hero-badges {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.glass-badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.82);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.dashboard,
.view-block {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.account-sections {
  display: grid;
  gap: 16px;
  margin-top: 12px;
}

.dashboard {
  margin-top: 16px;
}

.view-block {
  display: none;
}

.view-block.active {
  display: grid;
}

.panel {
  padding: 16px;
  border-radius: var(--radius-lg);
  min-width: 0;
  overflow: hidden;
}

.panel-title {
  padding: 12px 14px;
}

.panel-title h2 {
  margin: 0;
  font-size: 20px;
}

.inner-panel {
  box-shadow: none;
  border-color: var(--line);
  background: #fbfdff;
}

.panel-header,
.settings-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.section-label,
.metric-label,
.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.fold {
  padding: 0;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.fold[hidden] {
  display: none;
}

.fold > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  margin: 0;
  padding: 2px 0;
  font-weight: 800;
  font-size: 15px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.fold > summary::-webkit-details-marker {
  display: none;
}

.fold > summary::after {
  content: "▾";
  color: var(--muted);
  font-size: 14px;
  transition: transform 160ms ease;
}

.fold:not([open]) > summary::after {
  transform: rotate(-90deg);
}

.fold > :not(summary) {
  padding: 8px 0 0;
}

.fold > summary:focus {
  outline: none;
}

.fab-btn {
  position: fixed;
  right: max(calc((100vw - min(100vw, 430px)) / 2 + 16px), 16px);
  bottom: max(calc(env(safe-area-inset-bottom) + 84px), 92px);
  z-index: 35;
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 12px 22px rgba(17, 165, 143, 0.28);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.fab-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(17, 165, 143, 0.32);
}

body.form-focus .fab-btn {
  opacity: 0;
  pointer-events: none;
}

[data-view-panel]:not(.active) .fab-btn {
  display: none;
}

.top-switcher,
.period-switcher {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.top-switcher {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.period-switcher {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.period-dropdown {
  position: relative;
  margin-top: 14px;
  z-index: 5;
}

.period-dropdown-trigger {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  text-align: left;
  padding: 0 14px;
  cursor: pointer;
}

.period-dropdown-trigger::after {
  content: "▾";
  float: right;
  color: var(--muted);
}

.period-menu {
  position: relative;
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 12px 22px rgba(18, 36, 51, 0.12);
}

.period-menu[hidden] {
  display: none;
}

.period-menu .period-btn {
  width: 100%;
}

.period-btn,
.primary-btn,
.ghost-btn,
.chip-btn,
.top-tab,
select,
input,
textarea {
  font: inherit;
}

.period-btn,
.primary-btn,
.ghost-btn,
.chip-btn,
.top-tab {
  border: 0;
  border-radius: 18px;
  min-height: 48px;
  padding: 0 16px;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.top-tab {
  font-size: 13px;
  padding: 0 10px;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.period-btn,
.top-tab,
.ghost-btn,
.chip-btn {
  background: #fff;
  color: var(--text);
  font-weight: 700;
  border: 1px solid var(--line);
}

.period-btn.active,
.top-tab.active {
  background: var(--accent);
  color: white;
  box-shadow: 0 10px 20px rgba(17, 165, 143, 0.24);
}

.primary-btn {
  background: var(--accent);
  color: white;
  font-weight: 700;
}

#apply-range-btn {
  grid-column: 1 / -1;
  width: 100%;
}

.ghost-btn {
  background: #fff;
}

.ghost-btn.danger {
  color: var(--danger);
}

.chip-btn {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
}

.chip-btn.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.chip-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.primary-btn:hover,
.period-btn:hover,
.top-tab:hover,
.ghost-btn:hover,
.chip-btn:hover {
  transform: translateY(-1px);
}

.bottom-tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  transform: none;
  z-index: 40;
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  background: #ffffff;
  border: none;
  border-top: 1px solid var(--line);
  border-radius: 0;
  box-shadow: 0 -6px 20px rgba(15, 32, 48, 0.08);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.bottom-tabs .top-tab {
  min-height: 44px;
  font-size: 10px;
  padding: 0 6px;
  border-radius: 14px;
  background: #f7fafc;
  color: #1d2f3c;
  border: 1px solid rgba(23, 34, 45, 0.08);
}

.bottom-tabs .top-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 16px rgba(17, 165, 143, 0.22);
}

#group-details-panel { order: 1; }
#group-expense-panel { order: 2; }
#group-settlement-panel { order: 3; }
#group-history-panel { order: 4; }
#group-categories-panel { order: 5; }

.custom-range {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 14px;
}

.custom-range[hidden] {
  display: none !important;
}

.field-full {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

input,
select,
textarea {
  min-height: 48px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 0 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.76);
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  overflow: hidden;
  text-overflow: ellipsis;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(17, 165, 143, 0.75);
  box-shadow: 0 0 0 1px rgba(17, 165, 143, 0.35);
}

input[readonly][data-picker-target] {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

input[type="date"],
input[type="datetime-local"],
input[type="time"] {
  display: block;
  font-size: 16px;
  width: 100%;
  max-width: 100%;
  line-height: 1.2;
  padding-right: 14px;
  text-align: center;
  padding-top: 11px;
  padding-bottom: 0;
}

input[type="date"]::-webkit-date-and-time-value,
input[type="datetime-local"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value {
  text-align: center;
  width: 100%;
}

input[type="date"]::-webkit-datetime-edit,
input[type="datetime-local"]::-webkit-datetime-edit,
input[type="time"]::-webkit-datetime-edit {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  padding: 10px 0 0;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  margin: 0;
  opacity: 0.9;
}

input[type="date"]::-webkit-datetime-edit-fields-wrapper,
input[type="datetime-local"]::-webkit-datetime-edit-fields-wrapper,
input[type="time"]::-webkit-datetime-edit-fields-wrapper {
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
}

input[type="checkbox"] {
  appearance: auto;
  -webkit-appearance: checkbox;
}

textarea {
  min-height: 108px;
  padding-top: 12px;
  resize: vertical;
}

.field.compact {
  min-width: 118px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border-radius: var(--radius-lg);
}

.metric-card.accent {
  background:
    linear-gradient(140deg, rgba(15, 157, 143, 0.16), rgba(255, 255, 255, 0.78)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 248, 241, 0.84));
}

.metric-card h3 {
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.metric-footnote {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.chart-layout {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

.donut-wrap {
  display: grid;
  justify-items: center;
  gap: 12px;
}

.donut-card {
  width: 140px;
  height: 140px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-chart {
  width: 140px;
  height: 140px;
  transform: rotate(-90deg);
}

.donut-summary {
  display: grid;
  gap: 6px;
  justify-items: center;
  text-align: center;
}

.donut-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.donut-summary strong {
  max-width: 140px;
  font-size: 22px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}

.legend-list {
  display: grid;
  gap: 10px;
}

.legend-item {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 10px;
  align-items: center;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.legend-meta strong,
.expense-line strong {
  display: block;
  font-size: 14px;
}

.legend-meta span,
.expense-line span {
  color: var(--muted);
  font-size: 12px;
}

.bars-chart,
.stacked-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 18px;
  min-height: 200px;
  overflow-x: auto;
  padding-bottom: 8px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.stacked-column {
  min-width: 38px;
  display: grid;
  gap: 8px;
  justify-items: center;
  flex: 0 0 38px;
}

.stacked-track {
  width: 100%;
  height: 150px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(15, 157, 143, 0.05), rgba(23, 34, 45, 0.06));
  padding: 8px;
}

.stacked-fill {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column-reverse;
}

.stack-segment {
  width: 100%;
}

.bar-label,
.bar-value {
  text-align: center;
}

.bar-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.bar-value {
  font-size: 11px;
  font-weight: 800;
}

.stacked-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 16px;
}

.stacked-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 34, 45, 0.06);
  font-size: 13px;
  font-weight: 700;
}

.comment-cards {
  display: flex;
  align-items: start;
  gap: 12px;
  margin-top: 16px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x proximity;
}

.comment-card {
  width: min(300px, 78vw);
  min-width: min(300px, 78vw);
  flex: 0 0 min(300px, 78vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(23, 34, 45, 0.06);
  scroll-snap-align: start;
  min-height: 220px;
  height: max-content;
  align-self: flex-start;
}

.comment-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.comment-card-date {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.comment-card-total {
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.comment-card-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.comment-entry-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comment-entry {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(245, 239, 231, 0.75);
  align-content: start;
  min-height: 72px;
}

.comment-entry-top,
.comment-entry-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.comment-entry-top strong {
  font-size: 14px;
}

.comment-entry-top span,
.comment-entry-meta {
  font-size: 12px;
}

.comment-entry-meta {
  color: var(--muted);
}

.comment-note {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}

.comment-note.empty {
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid .field:nth-child(3),
.form-grid .field:nth-child(4) {
  grid-column: 1 / -1;
}

.settings-grid {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.expense-form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.inline-form {
  display: flex;
  gap: 12px;
  align-items: end;
  margin-top: 16px;
  min-width: 0;
}

.grow {
  flex: 1;
  min-width: 0;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.friend-tools {
  margin-top: 8px;
}

.friend-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.friend-pager span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.currency-selected-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.currency-add-row {
  margin-top: 8px;
}

.settings-save-btn {
  width: 100%;
}

.time-input {
  max-width: 180px;
}

.status-line {
  display: block;
  min-height: 24px;
  margin-top: 14px;
  padding-left: 2px;
  overflow: visible;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.status-line.error {
  color: var(--danger);
}

.expenses-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.expense-item,
.empty-state {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 34, 45, 0.06);
}

.expense-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  flex-wrap: wrap;
}

.expense-amount {
  font-size: 15px;
  font-weight: 800;
}

.expense-comment {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.expense-payer {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  font-weight: 600;
}

.expense-payer-info {
  margin: 0 0 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15, 157, 143, 0.08);
  border: 1px solid rgba(15, 157, 143, 0.15);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.expense-payer-info[hidden] {
  display: none !important;
}

.expense-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.toggle-card {
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 0 18px;
  border-radius: 16px;
  border: 1px solid rgba(23, 34, 45, 0.06);
  background: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  font-weight: 700;
  justify-items: start;
  position: relative;
}

.toggle-card input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.toggle-mark {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1.5px solid rgba(23, 34, 45, 0.16);
  background: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 160ms ease, background 160ms ease;
}

.toggle-mark::after {
  content: "";
  width: 7px;
  height: 12px;
  border-right: 2px solid white;
  border-bottom: 2px solid white;
  transform: rotate(45deg) translate(-1px, -1px);
  opacity: 0;
  transition: opacity 160ms ease;
}

.toggle-label {
  justify-self: start;
  text-align: left;
  padding-left: 6px;
}

.toggle-card input:checked + .toggle-mark {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-card input:checked + .toggle-mark::after {
  opacity: 1;
}

.toggle-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 0 16px;
  border-radius: 16px;
  border: 1px solid rgba(23, 34, 45, 0.06);
  background: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  font-weight: 700;
}

.toggle-switch input {
  width: 20px;
  min-height: 20px;
  margin: 0;
  accent-color: var(--accent);
}

#date-from,
#date-to,
#expense-created-at {
  text-align: center;
  padding-left: 14px;
}

#settings-reminder-day,
#settings-reminder-time {
  width: 100%;
  max-width: 100%;
  text-align: center;
}

#payment-screenshot-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

#payment-screenshot-form .ghost-btn {
  width: 100%;
}

#payment-screenshot-file {
  min-height: 44px;
  padding: 8px 12px;
}

.time-input {
  width: 100%;
  max-width: 100%;
}

.picker-modal[hidden] {
  display: none;
}

.picker-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  align-items: end;
}

.picker-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 25, 32, 0.38);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.picker-sheet {
  position: relative;
  display: grid;
  gap: 16px;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  border-radius: 26px 26px 0 0;
  background: rgba(255, 251, 246, 0.96);
  border-top: 1px solid rgba(23, 34, 45, 0.08);
  box-shadow: 0 -20px 60px rgba(23, 34, 45, 0.18);
}

.picker-sheet-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.picker-sheet-head h3 {
  margin: 0;
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.picker-close-btn {
  min-height: 42px;
  padding: 0 14px;
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.picker-grid.picker-grid-time {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.picker-field {
  display: grid;
  gap: 6px;
}

.picker-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.picker-field select {
  min-height: 52px;
  text-align: center;
  text-align-last: center;
  padding-inline: 12px 34px;
}

.picker-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.category-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.category-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(23, 34, 45, 0.06);
}

.category-item > strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.category-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.empty-state {
  place-items: center;
  text-align: center;
  min-height: 120px;
}

.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: 380px) {
  .hero-copy h1 {
    font-size: 26px;
  }

  .top-switcher,
  .cards-grid,
  .chart-layout,
  .form-grid,
  .toggle-grid {
    grid-template-columns: 1fr;
  }

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .donut-card {
    margin-bottom: 10px;
  }
}

@media (max-width: 560px) {
  .top-switcher,
  .form-grid,
  .toggle-grid,
  .cards-grid,
  .chart-layout {
    grid-template-columns: 1fr;
  }

  .top-tab {
    font-size: 10px;
    min-height: 46px;
    padding: 0 4px;
  }

  .bottom-tabs .top-tab {
    min-height: 44px;
    font-size: 10px;
  }

  .custom-range {
    grid-template-columns: 1fr;
  }

  .comment-card {
    width: min(286px, 82vw);
    min-width: min(286px, 82vw);
    flex-basis: min(286px, 82vw);
    min-height: 180px;
  }

  .toggle-grid {
    grid-template-columns: 1fr;
  }

  .toggle-card {
    grid-template-columns: 26px 1fr;
    padding: 0 18px;
  }

  .toggle-label {
    padding-left: 8px;
  }

  #settings-reminder-day,
  #settings-reminder-time,
  .time-input {
    width: 100%;
    max-width: 100%;
  }

  .picker-grid {
    grid-template-columns: 1fr;
  }

  .picker-grid.picker-grid-time {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-form .primary-btn,
  .inline-form .ghost-btn,
  .inline-form .chip-btn {
    width: 100%;
  }

  .fab-btn {
    right: 14px;
    bottom: max(calc(env(safe-area-inset-bottom) + 78px), 86px);
    min-height: 44px;
    font-size: 13px;
  }
}

@media (max-width: 768px) {
  .custom-range {
    display: flex;
    flex-direction: column;
  }

  .custom-range .field,
  .custom-range .field-full,
  #apply-range-btn {
    width: 100%;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .field:nth-child(3),
  .form-grid .field:nth-child(4) {
    grid-column: auto;
  }

  input[type="date"],
  input[type="datetime-local"] {
    font-size: 16px;
  }

  .custom-range .field {
    display: flex;
    flex-direction: column;
  }

  .custom-range input[type="date"] {
    width: 100%;
    max-width: 100%;
  }

  .top-switcher {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.payment-screenshot-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(4px);
}

.payment-screenshot-lightbox-inner {
  max-width: min(100%, 420px);
  max-height: min(88vh, 720px);
  overflow: auto;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  background: #fff;
}

.payment-screenshot-lightbox-inner img {
  display: block;
  width: 100%;
  height: auto;
}

.payment-screenshot-lightbox-close {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 2001;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.95);
  color: #111827;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}
