/* Shared responsive rules for phones, tablets, rotation and the on-screen keyboard. */
:root {
  font-size: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --page-gutter: clamp(16px, 4vw, 36px);
}
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { min-inline-size: 0; }
.app-shell, .app-simple, .app-simple .page, .dashboard-grid,
.left-column, .right-column, .left-column > *, .right-column > *,
.panel, .hero, .day-group { min-inline-size: 0; max-inline-size: 100%; }
.left-column, .right-column { grid-template-columns: minmax(0, 1fr); }
.app-simple .simple-header {
  padding-inline-start: max(var(--page-gutter), var(--safe-left));
  padding-inline-end: max(var(--page-gutter), var(--safe-right));
  padding-block-start: var(--safe-top);
  height: auto;
  min-block-size: calc(77px + var(--safe-top));
  gap: 12px;
}
.app-simple .simple-header .brand { min-inline-size: 0; }
.app-simple .simple-header .brand > span:last-child { min-inline-size: 0; overflow-wrap: anywhere; }
.header-actions { flex-shrink: 0; }
.app-simple .page {
  padding-inline-start: max(var(--page-gutter), var(--safe-left));
  padding-inline-end: max(var(--page-gutter), var(--safe-right));
  padding-block-end: max(28px, var(--safe-bottom));
}
.page-heading, .section-heading { flex-wrap: wrap; }
.page-heading > *, .section-heading > *, .detail-heading-left,
.detail-heading-left > div { min-inline-size: 0; }
h1, h2, h3, .dialog-head p, .member-main > strong,
.member-email, .member-access, .check-label > span, .admin-project strong {
  overflow-wrap: anywhere;
}
.page-heading h1 { max-inline-size: 100%; }
.page-heading .period-button { max-inline-size: 100%; }
.period-button { min-block-size: 44px; font-size: 14px; white-space: normal; text-align: start; }
.period-button > span { min-inline-size: 0; overflow-wrap: anywhere; }
.period-button svg { flex-shrink: 0; }
.eyebrow { font-size: 12px; }
.app-simple .hero { padding: clamp(20px, 4vw, 28px); }
.app-simple .hero .hero-bottom { flex-wrap: wrap; gap: 12px; }
.app-simple .hero .capture-actions { min-inline-size: 0; max-inline-size: 100%; flex-wrap: wrap; gap: 8px 14px; }
.app-simple .hero .voice-primary, .app-simple .hero .manual-button { min-block-size: 44px; font-size: 14px; }
.app-simple .hero .voice-primary { white-space: normal; text-align: center; }
.app-simple .hero .manual-button { padding-inline: 4px; }
.app-simple .hero .export-compact { min-inline-size: 44px; min-block-size: 44px; }
.hero-label, .hero-period { font-size: 14px; line-height: 1.5; }
.amount { min-inline-size: 0; max-inline-size: 100%; }
.amount.long-amount { white-space: normal; overflow-wrap: anywhere; line-height: 1.15; }
.project-row { min-inline-size: 0; }
.project-text { min-inline-size: 0; }
.project-text strong { font-size: 15px; }
.project-meta { font-size: 12px; line-height: 1.6; flex-wrap: wrap; }
.project-total { min-inline-size: 0; max-inline-size: 48%; white-space: normal; overflow-wrap: anywhere; text-align: end; }
.row-arrow { flex-shrink: 0; }
.legend-row { min-inline-size: 0; font-size: 14px; align-items: start; }
.legend-row > span:nth-child(2) { min-inline-size: 0; overflow-wrap: anywhere; }
.legend-row strong { font-size: 13px; flex-shrink: 0; }
.legend-dot { margin-block-start: 5px; }
.card-title { font-size: 14px; }
.stat span, .last-update { font-size: 12px; }
.last-update strong { font-size: 12px; }
.list-footer { min-inline-size: 0; font-size: 13px; flex-wrap: wrap; }
.list-footer > * { min-inline-size: 0; }
.list-footer > strong { max-inline-size: 65%; overflow-wrap: anywhere; text-align: end; }
.toolbar { min-inline-size: 0; flex-wrap: wrap; }
.search-box { min-inline-size: 0; flex: 1 1 200px; block-size: 48px; }
.search-box input { min-inline-size: 0; font-size: 16px; }
.sort-wrap { min-inline-size: 0; max-inline-size: 100%; min-block-size: 48px; }
body .sort-wrap select { min-inline-size: 0; max-inline-size: 100%; min-block-size: 46px; font-size: 14px; }
.result-label { font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.operation { min-inline-size: 0; }
.operation-main, .operation-actions { min-inline-size: 0; }
.operation-title { font-size: 14px; }
.operation-sub { font-size: 12px; line-height: 1.6; }
.operation-actions { max-inline-size: 45%; }
.operation-amount { max-inline-size: 100%; white-space: normal; overflow-wrap: anywhere; text-align: end; }
.day-heading { font-size: 13px; line-height: 1.5; gap: 12px; }
.day-heading strong { min-inline-size: 0; max-inline-size: 55%; overflow-wrap: anywhere; text-align: end; }
.back-button, .delete-link, .all-link { min-block-size: 44px; font-size: 14px; }
.icon-button, .account-button { min-inline-size: 44px; min-block-size: 44px; }
.page-footer { font-size: 12px; line-height: 1.6; flex-wrap: wrap; }
.page-footer > span { min-inline-size: 0; }

/* Bound native dialogs to the visual viewport, including when only it shrinks. */
dialog[open], dialog[open].expense-dialog {
  position: fixed;
  inset-block-start: calc(var(--viewport-top, 0px) + var(--safe-top));
  inset-block-end: calc(100% - var(--viewport-top, 0px) - var(--viewport-height, 100dvh) + var(--safe-bottom));
  inset-inline-start: var(--safe-left);
  inset-inline-end: var(--safe-right);
  margin: auto;
  block-size: fit-content;
  min-block-size: 0;
  inline-size: min(510px, calc(100% - 24px));
  max-inline-size: calc(100% - var(--safe-left) - var(--safe-right) - 24px);
  max-block-size: calc(var(--viewport-height, 100dvh) - var(--safe-top) - var(--safe-bottom) - 24px);
  overscroll-behavior: contain;
  overflow: auto;
}
dialog .dialog-head { gap: 12px; }
.dialog-head > div { flex: 1; min-inline-size: 0; }
.dialog-head h2 { overflow-wrap: anywhere; }
.dialog-head .icon-button { margin: 0; flex-shrink: 0; }
.dialog-head p { font-size: 13px; line-height: 1.5; }
.dialog-body, .dialog-body form, .fields, .field, .field-grid { min-inline-size: 0; max-inline-size: 100%; }
body .field { font-size: 14px; line-height: 1.35; }
body .field > input, body .field > select, body .field > textarea {
  box-sizing: border-box;
  min-inline-size: 0;
  max-inline-size: 100%;
  font-size: 16px;
}
body .field > input, body .field > select { min-block-size: 44px; }
body select {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  inline-size: 100%;
  min-inline-size: 0;
  max-inline-size: 100%;
  min-block-size: 44px;
  padding-inline-end: 30px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='m3 4.5 3 3 3-3' fill='none' stroke='%236d7d60' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
}
.dialog-footer { min-inline-size: 0; gap: 10px; flex-wrap: wrap; }
.dialog-footer > button { min-inline-size: 0; min-block-size: 44px; padding-inline: 14px; font-size: 14px; }
.dialog-footer .primary { flex: 1 1 0; white-space: normal; overflow-wrap: anywhere; line-height: 1.3; }
.dialog-footer .secondary { flex: 0 0 auto; }
#expense-form .dialog-footer > button { font-size: 14px; }
.preset-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.preset-button { gap: 6px; min-inline-size: 0; min-block-size: 44px; font-size: 14px; line-height: 1.4; }
.preset-button svg { flex-shrink: 0; }
.custom-label, .import-help, .google-block p, .google-block details, .export-scope { font-size: 13px; line-height: 1.6; }
.google-block summary { min-block-size: 44px; padding-block: 10px; font-size: 14px; }
.google-title { font-size: 14px; line-height: 1.5; }
.google-title svg { flex-shrink: 0; }
.google-block .secondary { min-block-size: 44px; white-space: normal; font-size: 14px; }
.export-option { min-inline-size: 0; min-block-size: 72px; }
.export-option > span:nth-child(2) { min-inline-size: 0; overflow-wrap: anywhere; }
.export-option strong { font-size: 14px; line-height: 1.4; }
.export-option small { font-size: 12px; }
.export-result { font-size: 14px; }
.export-result a { display: inline-block; padding-block: 10px; }
.compact-menu > button, .compact-menu > a { min-block-size: 48px; font-size: 14px; }
.compact-menu > button { overflow-wrap: anywhere; }
.account-summary, .role-tag { font-size: 13px; }
.account-summary { gap: 12px; flex-wrap: wrap; }
.install-instructions { font-size: 14px; }
.install-visual span, .install-visual strong { font-size: 14px; }
.help-step { font-size: 14px; }
.help-step p { font-size: 13px; }
.field > .voice-transcript { max-inline-size: 100%; }
.voice-status { font-size: 14px; }
.voice-example { font-size: 13px; }
.voice-privacy { font-size: 12px; }
.voice-review { min-inline-size: 0; }
.voice-review > div { min-inline-size: 0; }
.voice-review p { font-size: 12px; }
.access-screen { padding-inline: max(20px, var(--safe-left)) max(20px, var(--safe-right)); }
.access-card { min-inline-size: 0; max-inline-size: 100%; }
.access-card > p { font-size: 14px; }
.access-actions { flex-wrap: wrap; }
.access-card > .text-link { min-block-size: 44px; font-size: 14px; }

/* Shared date display keeps iOS date metrics away from every form layout. */
.date-control, #expense-form .date-control {
  grid-column: 1 / -1;
  position: relative;
  display: flex;
  align-items: center;
  gap: 5px;
  box-sizing: border-box;
  inline-size: 100%;
  min-inline-size: 0;
  block-size: 44px;
  min-block-size: 44px;
  max-block-size: 44px;
  padding: 0 9px;
  border: 1px solid #dce2d2;
  border-radius: 10px;
  background: var(--paper);
  overflow: hidden;
  isolation: isolate;
}
.date-control-value, #expense-form .date-control-value {
  display: block;
  flex: 1;
  min-inline-size: 0;
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.date-control-value.is-empty, #expense-form .date-control-value.is-empty { font-size: 12px; color: var(--muted); }
.date-control > svg, #expense-form .date-control > svg { display: block; inline-size: 14px; block-size: 14px; flex-shrink: 0; pointer-events: none; color: #7a8a6c; }
.date-control > input[type="date"], #expense-form .date-control > input[type="date"], #period-form .date-control > input[type="date"] {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  inline-size: 100%;
  min-inline-size: 0;
  max-inline-size: 100%;
  block-size: 100%;
  min-block-size: 0;
  max-block-size: 100%;
  padding: 0;
  margin: 0;
  border: 0;
  opacity: 0;
  font-size: 16px;
  cursor: pointer;
}
.date-control:focus-within { border-color: #819b69; box-shadow: 0 0 0 2px #a4b58f22; }
.field-grid { align-items: start; grid-template-columns: repeat(2, minmax(0, 1fr)); }
#expense-form > .fields > .field-grid { grid-template-columns: minmax(0, .42fr) minmax(0, .58fr); gap: 10px; align-items: start; }
#expense-form > .fields > .field-grid > .field { align-items: start; }

/* Administration uses the same touch sizes and wraps long names/emails. */
.admin-intro { font-size: 14px; }
.admin-project-list { min-inline-size: 0; }
.admin-project { min-inline-size: 0; }
.admin-project strong { font-size: 14px; }
.admin-section .section-heading { align-items: center; gap: 12px; }
.admin-section .section-heading .primary, .admin-section .section-heading .secondary { min-block-size: 44px; font-size: 14px; padding: 10px 14px; }
.member-main { min-inline-size: 0; }
.member-main > strong { font-size: 14px; }
.member-email, .member-access { font-size: 13px; }
.access-fieldset { min-inline-size: 0; inline-size: 100%; }
.access-fieldset legend { max-inline-size: 100%; font-size: 14px; overflow-wrap: anywhere; }
.check-label, .project-choice { min-block-size: 44px; font-size: 14px; }
.check-label > span { min-inline-size: 0; }
.check-label small, .admin-footnote, .admin-access-note p { font-size: 13px; }
.admin-access-note { font-size: 14px; }
.notifications {
  inset-inline-start: 50%;
  inset-block-end: calc(100% - var(--viewport-top, 0px) - var(--viewport-height, 100dvh) + max(12px, var(--safe-bottom)));
  inline-size: min(520px, calc(100% - var(--safe-left) - var(--safe-right) - 24px));
  max-inline-size: calc(100% - var(--safe-left) - var(--safe-right) - 24px);
}
.toast { min-inline-size: 0; flex-wrap: wrap; gap: 6px 12px; font-size: 14px; }
.toast > span { flex: 1 1 180px; min-inline-size: 0; overflow-wrap: anywhere; }
.toast button, .toast .dismiss-toast { min-inline-size: 44px; min-block-size: 44px; font-size: 14px; }

@media (max-width: 980px) {
  .app-simple .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .app-simple .right-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .app-simple .right-column { grid-template-columns: minmax(0, 1fr); }
  .project-row { padding-inline: 14px; gap: 10px; }
  .project-icon { inline-size: 40px; block-size: 40px; }
  .page-footer span:last-child { max-inline-size: none; text-align: start; }
  .dialog-head { padding: 18px 18px 14px; }
  .dialog-body { padding: 0 18px 18px; }
  dialog.expense-dialog .dialog-head { padding: 14px 18px 10px; }
  dialog.expense-dialog .dialog-body { padding: 0 18px 14px; }
  dialog.expense-dialog .dialog-head p { font-size: 12px; line-height: 1.4; }
  #expense-form .dialog-footer > button { padding-inline: 12px; }
}
@media (max-width: 560px) {
  .toolbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .sort-wrap { inline-size: 100%; }
  body .sort-wrap select { inline-size: 100%; }
}
@media (max-width: 370px) {
  #expense-form > .fields > .field-grid { grid-template-columns: 112px minmax(0, 1fr); }
  .date-control > svg, #expense-form .date-control > svg { display: none; }
}
@media (max-width: 360px) {
  .project-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) 14px; gap: 5px 10px; }
  .project-row .project-icon { grid-column: 1; grid-row: 1 / 3; }
  .project-row .project-text { grid-column: 2; grid-row: 1; }
  .project-row .project-total { grid-column: 2; grid-row: 2; max-inline-size: 100%; text-align: start; }
  .project-row .row-arrow { grid-column: 3; grid-row: 1 / 3; }
  .project-text strong { font-size: 14px; }
}
@media (max-height: 560px) {
  dialog .dialog-footer { position: sticky; inset-block-end: -1px; z-index: 2; background: var(--paper); padding-block: 10px; }
  .dialog-head { padding-block: 12px; }
}
.keyboard-open dialog .dialog-footer { position: sticky; inset-block-end: -1px; z-index: 2; background: var(--paper); padding-block: 10px; }
/* Long operation details use the full card width on a phone. */
.operation-sub, .operation-sub > span { min-inline-size: 0; max-inline-size: 100%; overflow-wrap: anywhere; }
.category-tag { white-space: normal; }
.simple-header .brand { min-block-size: 44px; }
body .sort-wrap select, .field > textarea.voice-transcript { font-size: 16px; }
body .field > select { padding-inline-end: 30px; }
@media (max-width: 560px) {
  .operation { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; }
  .operation-icon { grid-column: 1; grid-row: 1; }
  .operation-main { grid-column: 2; grid-row: 1; }
  .operation-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    align-items: center;
    gap: 8px;
    inline-size: 100%;
    max-inline-size: 100%;
  }
  .operation-amount { text-align: start; font-size: 16px; line-height: 1.4; }
}
@media (max-width: 700px) and (max-height: 640px) {
  dialog.expense-dialog .dialog-head { padding-block: 10px 8px; }
  dialog.expense-dialog .dialog-body { padding-block-end: 10px; }
}
body .field > select { block-size: 44px; }

/* Continuous expense list; existing project screens keep their own layout. */
.operations-feed-description { margin: 5px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.operations-feed time { min-inline-size: 0; max-inline-size: 100%; overflow-wrap: anywhere; }
/* Account registration and sign-in use the same compact mobile controls. */
.auth-screen { padding-block-start: max(24px, var(--safe-top)); padding-block-end: max(24px, var(--safe-bottom)); }
.auth-card { inline-size: min(430px, 100%); }
.auth-card h1 { font-size: clamp(24px, 6vw, 30px); line-height: 1.2; }
.auth-form { inline-size: 100%; text-align: start; margin-block-start: 24px; }
.auth-form .fields { gap: 14px; }
.auth-form .field > input { block-size: 46px; }
.auth-actions { margin-block-start: 18px; padding-block-start: 16px; }
.auth-actions .primary { inline-size: 100%; min-block-size: 46px; }
.auth-error { min-block-size: 0; overflow-wrap: anywhere; }
.auth-footnote { font-size: 13px; line-height: 1.6; color: var(--muted); }
.data-clear-option strong, .data-clear-option .file-icon { color: var(--red); }
.clear-preview { margin-block-start: 18px; }
@media (max-height: 640px) {
 .auth-screen { gap: 16px; padding-block: 16px; }
 .auth-screen > .brand-symbol { inline-size: 44px; block-size: 44px; font-size: 28px; }
 .auth-form { margin-block-start: 16px; }
 .auth-form .fields { gap: 10px; }
}
