/* View-specific layout. One section per file in js/views/. */

/* ---- add-view ---- */

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius-control);
  padding: 3px;
}
.segmented button {
  border: 0;
  background: none;
  padding: 6px;
  border-radius: 10px;
  font: 600 14px var(--font-display);
  color: var(--text-2);
}
.segmented button.active {
  background: var(--selected);
  color: var(--on-selected);
  font-weight: 700;
}

.amount {
  text-align: center;
}
.amount-value {
  font: 500 34px/1.2 var(--font-mono);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.amount-value small {
  font: 700 20px var(--font-display);
  color: var(--coral-500);
  margin-left: 4px;
  letter-spacing: 0;
}
.amount-sub {
  min-height: 18px;
  color: var(--muted);
  font: 500 13px var(--font-mono);
}

.more-toggle {
  border: 0;
  background: none;
  color: var(--text-2);
  font: 600 13px var(--font-display);
  text-align: left;
  padding: 2px 0;
}
.more {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius-card);
  padding: 12px;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: auto;
}
.keypad button {
  background: var(--surface);
  border: var(--stroke) solid var(--border);
  border-radius: 12px;
  padding: 6px 0;
  font: 600 22px var(--font-display);
  box-shadow: 2px 2px 0 var(--shadow-color);
  touch-action: manipulation;
  transition:
    transform 120ms,
    box-shadow 120ms;
}
.keypad button:active {
  transform: translate(2px, 2px);
  box-shadow: none;
  background: var(--surface-sunk);
}
.keypad button[data-value='back'] {
  background: var(--surface-sunk);
}

/* Pinned above the tab bar so Save stays reachable when the details panel is open. */
.actions {
  display: flex;
  gap: 10px;
  position: sticky;
  bottom: calc(env(safe-area-inset-bottom) + var(--tabbar-height));
  z-index: 1;
  margin: 0 -16px;
  padding: 6px 16px 8px;
  background: var(--bg);
}
.actions .btn {
  flex: 1;
}
.actions .btn-secondary,
.actions .btn-danger {
  flex: 0 0 auto;
}

/* ---- list-view ---- */

.day h2 {
  display: flex;
  justify-content: space-between;
  font: 700 11px var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 12px 4px 6px;
}
.day h2 span:last-child {
  font: 500 12px var(--font-mono);
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-2);
}
/* Whole row is a button: tap to edit (delete lives in the edit screen, with undo). */
.entry {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius-button);
  padding: 10px 14px;
  margin-bottom: 10px;
  touch-action: manipulation;
}
.entry:active {
  background: var(--surface-sunk);
}
.entry-transfer {
  background: var(--pos-soft);
}
.entry-main {
  flex: 1;
  min-width: 0;
}
.entry-title {
  font: 600 15px var(--font-display);
}
.entry-sub {
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entry-amount {
  text-align: right;
  font: 500 14px var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.entry-amount small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
}

/* Category / transfer icon tile, shared by list rows and the summary category breakdown. */
.entry-icon {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--surface-sunk);
  border: var(--stroke-inner) solid var(--border);
  color: var(--text);
}
.entry-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linejoin: miter;
}
.entry-icon svg .accent {
  fill: var(--sun-500);
  stroke: none;
}
.entry-transfer .entry-icon {
  background: var(--surface);
}

.list-filter {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.list-filter select {
  min-width: 0;
  padding-top: 8px;
  padding-bottom: 8px;
  font: 600 14px var(--font-display);
}
.filter-summary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin: 0 4px;
  font-size: 13px;
  color: var(--text-2);
}
.filter-summary .btn-link {
  flex: none;
}

/* ---- list-overview: fund card + daily chart ---- */

.overline {
  font: 700 11px var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.fund,
.chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fund-head,
.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 12.5px;
}
.fund-hero {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font: 600 14px var(--font-display);
}
.fund-hero strong {
  font: 500 24px/1.2 var(--font-mono);
  letter-spacing: -0.03em;
}
/* Meter: share of the fund already used; the track is a lighter step of the fill. */
.meter {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-sunk);
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--text);
}
.meter-over i {
  background: var(--neg);
}
.fund-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 12px;
  margin: 0;
  font-size: 12px;
}
.fund-stats dt {
  color: var(--muted);
}
.fund-stats dd {
  margin: 0;
  font: 500 13px var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.fund-people {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 8px;
  border-top: var(--stroke-inner) solid var(--divider);
}
.fund-person {
  display: grid;
  grid-template-columns: minmax(0, 6.5em) 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}
.fund-person-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fund-person-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-sunk);
  overflow: hidden;
}
.fund-person-bar i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--sun-500);
}
.fund-person-amount {
  font: 500 13px var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.fund-person-amount.muted {
  font: 500 12.5px var(--font-body);
}
.fund .hint {
  margin: 0;
}

.chart-caption {
  color: var(--text-2);
  font-size: 12.5px;
  text-align: right;
}
.chart-caption b {
  font: 500 13px var(--font-mono);
  color: var(--text);
}
/* Columns: <=24px wide, 4px rounded data-end, square at the shared baseline. */
.chart-plot {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 2px;
  height: 104px;
  padding-top: 18px; /* room for the peak label */
  border-bottom: 1px solid var(--divider);
}
.chart-col {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border: 0;
  padding: 0;
  background: none;
  touch-action: manipulation;
}
.chart-col i {
  display: block;
  width: 100%;
  max-width: 24px;
  border-radius: 4px 4px 0 0;
  background: var(--text);
}
.chart-col.active i {
  background: var(--link);
}
.chart-peak {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 2px;
  font: 500 11px var(--font-mono);
  color: var(--text-2);
  white-space: nowrap;
}
.chart-axis {
  display: flex;
  justify-content: space-between;
  font: 500 11px var(--font-mono);
  color: var(--muted);
}

/* ---- summary-view ---- */

.category-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.category-main {
  flex: 1;
  min-width: 0;
}
.category-main .line {
  padding: 0 0 4px;
}
.category-bar {
  height: 8px;
  border-radius: 4px;
  border: var(--stroke-inner) solid var(--border);
  background: var(--surface-sunk);
  overflow: hidden;
}
.category-bar i {
  display: block;
  height: 100%;
  background: var(--sun-500);
}

.card.total {
  text-align: center;
  padding: 16px;
  box-shadow: var(--shadow-lg);
}
.card.total > div:first-child {
  font: 700 11px var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.card.total strong {
  display: block;
  font: 500 32px/1.2 var(--font-mono);
  letter-spacing: -0.03em;
  margin: 4px 0 2px;
}
.card.total small {
  color: var(--muted);
  font-size: 12.5px;
}
.line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 7px 0;
}
.line strong,
.line > span:last-child {
  font-family: var(--font-mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.person {
  padding: 6px 0;
  border-bottom: var(--stroke-inner) solid var(--divider);
}
.person:last-child {
  border-bottom: 0;
}
.person b {
  font-family: var(--font-display);
}
.person .badge {
  vertical-align: 2px;
  margin-left: 4px;
}
.person-parts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 12px;
  margin: 0 0 4px;
  font-size: 12px;
}
.person-parts dt {
  color: var(--muted);
}
.person-parts dd {
  margin: 0;
  font: 500 12.5px var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.total-me {
  margin-top: 10px;
  padding-top: 10px;
  border-top: var(--stroke-inner) dashed var(--divider);
  font: 600 15px var(--font-display);
}
.total-me b {
  font: 500 16px var(--font-mono);
}

.settle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: var(--stroke-inner) solid var(--divider);
}
.settle-row:last-child {
  border-bottom: 0;
}
.settle-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.settle-main strong {
  font-size: 15px;
}
.settle-row .btn {
  flex: none;
  box-shadow: 2px 2px 0 var(--shadow-color);
}

/* ---- settings-view ---- */

.view-settings {
  gap: 6px;
}

.trip-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius-card);
  background: var(--ink);
  color: var(--paper);
  border: var(--stroke) solid var(--ink);
  box-shadow: 4px 4px 0 var(--sun-500);
  margin-top: 4px;
}
.trip-card-body {
  flex: 1;
  min-width: 0;
}
.trip-card-title {
  font: 700 21px/1.3 var(--font-display);
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.trip-card-meta {
  font-size: 13px;
  color: #c5d2d6;
}

.rate-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rate-code {
  flex: 0 0 64px;
  font: 500 14px var(--font-mono);
}
.rate-eq,
.rate-unit {
  color: var(--muted);
}
.rate-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.status-dot {
  flex: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: var(--stroke-inner) solid var(--ink);
  background: var(--faint);
}
.status-dot.pos {
  background: var(--teal-700);
}
.status-dot.warn {
  background: var(--sun-500);
}
.status-dot.neg {
  background: var(--danger);
}
.status-title {
  font: 700 15px var(--font-display);
}
.status-detail {
  font-size: 12.5px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.danger-zone {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---- onboarding-view ---- */

.onboarding {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: calc(env(safe-area-inset-top) + 12px) 20px calc(env(safe-area-inset-bottom) + 16px);
  gap: 14px;
}
.onboarding-top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 32px;
}
.progress {
  flex: 1;
  display: flex;
  gap: 6px;
}
.progress i {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  border: var(--stroke-inner) solid var(--border);
  background: var(--surface);
}
.progress i.on {
  background: var(--sun-500);
}
.onboarding-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.onboarding-brand .brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  border-width: var(--stroke);
}
.onboarding-brand .brand-mark svg {
  width: 28px;
  height: 28px;
}
.onboarding-brand b {
  font: 700 22px var(--font-display);
  letter-spacing: -0.02em;
}
.onboarding-brand small {
  display: block;
  font: 700 10px var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--coral-700);
}
.onboarding-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.onboarding-title {
  margin: 4px 0 0;
  font-size: 28px;
  line-height: 1.15;
}
.onboarding-sub {
  margin: 0;
  color: var(--text-2);
}
.onboarding-footer {
  display: flex;
  gap: 10px;
  position: sticky;
  bottom: 0;
  margin: 0 -20px calc(-1 * (env(safe-area-inset-bottom) + 16px));
  padding: 12px 20px calc(env(safe-area-inset-bottom) + 16px);
  background: var(--bg);
  border-top: var(--stroke-inner) solid var(--divider);
}
.onboarding-footer .btn {
  padding: 13px 18px;
}
.onboarding-footer .btn-primary {
  flex: 1;
  font-size: 17px;
}
.install-hint {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.install-hint .btn-link {
  font-size: 14px;
}
