/* Voice-first, simplified, and mobile-friendly interface for v0.9.1. */
html {
  min-height: 100%;
  scroll-behavior: smooth;
}

.voice-entry-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .85rem 1rem;
  margin: 0 0 1.25rem;
  padding: 1rem;
  border: 1px solid #b9ddd5;
  border-radius: 18px;
  background: linear-gradient(135deg, #edf9f5, #f8fcfa);
}

.voice-entry-heading {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.voice-entry-heading strong,
.voice-entry-heading small {
  display: block;
}

.voice-entry-heading small {
  margin-top: .2rem;
  color: #52645f;
}

.voice-mic-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 14px;
  background: #d9f2eb;
  font-size: 1.25rem;
}

.voice-start-button {
  min-width: 164px;
  align-self: center;
}

.voice-entry-card.is-listening .voice-start-button {
  background: #c93636;
  box-shadow: 0 0 0 6px rgba(201, 54, 54, .14);
}

.voice-entry-card.is-starting .voice-start-button {
  background: #607a73;
  cursor: wait;
}

.voice-entry-card.is-listening .voice-mic-mark {
  animation: voice-pulse 1s ease-in-out infinite;
}

@keyframes voice-pulse {
  50% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(13, 126, 111, .12); }
}

.voice-transcript-label {
  grid-column: 1 / -1;
}

.voice-transcript-label textarea {
  min-height: 76px;
  resize: vertical;
}

.voice-apply-button {
  justify-self: start;
}

.voice-status {
  align-self: center;
  margin: 0;
  color: #52645f;
}

.voice-status[data-tone="success"] { color: #08764c; }
.voice-status[data-tone="warning"] { color: #986000; }
.voice-status[data-tone="error"] { color: #b32424; }
.voice-status[data-tone="listening"] { color: #0d6f63; font-weight: 700; }

.voice-examples {
  grid-column: 1 / -1;
  color: #52645f;
}

.voice-examples summary {
  cursor: pointer;
  color: #0d6f63;
  font-weight: 700;
}

.voice-examples ul {
  margin: .55rem 0 0;
  padding-left: 1.25rem;
}

.voice-examples li + li { margin-top: .35rem; }

@media (max-width: 720px) {
  .voice-entry-card {
    grid-template-columns: 1fr;
  }

  .voice-start-button,
  .voice-apply-button {
    width: 100%;
  }

  .voice-status,
  .voice-examples,
  .voice-transcript-label {
    grid-column: 1;
  }
}

body {
  min-height: 100%;
  overflow-x: hidden;
}

button:disabled {
  opacity: .65;
  cursor: wait;
}

.danger-notice {
  background: #fff0f0;
  border-color: #fecaca;
  color: #991b1b;
}

.ocr-retry {
  margin: .7rem 0;
}

.local-ocr {
  display: grid;
  gap: .65rem;
  padding: .9rem 0;
}

.ocr-actions {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-wrap: wrap;
}

.privacy-chip {
  border-radius: 999px;
  padding: .35rem .65rem;
  background: #e7f6ef;
  color: #166534;
  font-size: .78rem;
  font-weight: 700;
}

.ocr-progress {
  display: grid;
  gap: .4rem;
}

.ocr-progress[hidden],
.ocr-result[hidden],
.ocr-raw[hidden] {
  display: none;
}

.ocr-progress progress {
  width: 100%;
  height: .75rem;
  accent-color: #147d70;
}

.ocr-raw {
  font-size: .82rem;
}

.ocr-raw pre {
  max-height: 190px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: .7rem;
  border-radius: 10px;
  background: #f5f8f6;
}

.shared-expense-card {
  display: grid;
  gap: .9rem;
  padding: 1rem;
  border: 1px solid #b9d8cf;
  border-radius: 16px;
  background: #f1faf7;
}

.shared-expense-card[hidden],
.shared-detail-grid[hidden],
.shared-calculation[hidden],
[data-mixed-amount-wrap][hidden] {
  display: none;
}

.shared-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .9rem;
}

.shared-calculation {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .55rem;
}

.shared-calculation span,
.member-payment-grid article {
  display: grid;
  gap: .2rem;
  padding: .7rem;
  border-radius: 11px;
  background: #fff;
  color: var(--muted);
  font-size: .78rem;
}

.shared-calculation strong,
.member-payment-grid strong {
  color: var(--ink);
  font-size: .95rem;
}

.shared-label {
  color: var(--brand);
  font-weight: 700;
}

.shared-month-head,
.shared-month-head .month-filter,
.settlement-result,
.member-payment-grid {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.month-filter label {
  min-width: 175px;
}

.settlement-result {
  align-items: center;
  padding: 1.1rem;
  border-radius: 16px;
  background: #fff4d6;
  color: #714d08;
  font-size: 1.05rem;
}

.settlement-result > strong {
  font-size: 1.5rem;
}

.settlement-result.settled {
  background: #dcfce7;
  color: #166534;
}

.member-payment-grid {
  align-items: stretch;
  justify-content: stretch;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 1rem;
}

.member-payment-grid article {
  border: 1px solid var(--line);
}

.mobile-row-actions {
  display: none;
}

.compact-button {
  padding: .48rem .7rem;
  border-radius: 9px;
  font-size: .78rem;
}

.delete-transaction-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.2rem;
  padding: 1rem;
  border: 1px solid #fecaca;
  border-radius: 14px;
  background: #fff7f7;
}

.delete-transaction-zone small {
  margin-top: .25rem;
}

.sub-editor {
  margin: .7rem 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .2rem .8rem .8rem;
  background: #fbfdfc;
}

.sub-editor > summary {
  display: flex;
  justify-content: space-between;
  gap: .8rem;
  cursor: pointer;
  padding: .75rem 0;
}

.record-history {
  margin: 1rem 0;
}

.record-history h2,
.record-history h3,
.debt-card h3 {
  margin: 1rem 0 .4rem;
}

.finance-controls {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
}

.finance-controls .month-filter {
  display: flex;
  align-items: end;
  gap: .6rem;
}

.finance-controls p {
  margin: 0;
}

.finance-equation {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .7rem;
  margin: 1rem 0;
}

.finance-equation span {
  display: grid;
  gap: .25rem;
  padding: .9rem;
  border-radius: 12px;
  background: #edf5f1;
  color: var(--muted);
  font-size: .82rem;
}

.finance-equation strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.debt-plan-list {
  display: grid;
}

.debt-plan-list article {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: .8rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}

.debt-plan-list article > div {
  min-width: 0;
}

.priority-number {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.finance-disclaimer {
  margin-top: 1.2rem;
  font-size: .8rem;
}

.period-filter {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.period-filter > div {
  display: grid;
  gap: .28rem;
}

.date-range-form {
  display: flex;
  align-items: end;
  gap: .6rem;
  flex-wrap: wrap;
}

.date-range-form label {
  min-width: 155px;
}

.entry-switch {
  display: flex;
  align-items: center;
  gap: .55rem;
  flex-wrap: wrap;
  margin: 0 0 1rem;
}

.entry-switch a {
  padding: .72rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.entry-switch a.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.narrow-panel {
  max-width: 820px;
}

.workspace-switcher label {
  display: flex;
  align-items: center;
  gap: .55rem;
}

.workspace-switcher label > span {
  color: var(--muted);
  font-size: .75rem;
  white-space: nowrap;
}

.sidebar-more {
  margin-top: .2rem;
}

.sidebar-more > summary {
  list-style: none;
  cursor: pointer;
  color: #d2e6e0;
  padding: .68rem .8rem;
  border-radius: 10px;
  font-weight: 650;
}

.sidebar-more > summary::-webkit-details-marker { display: none; }
.sidebar-more > summary::after { content: '⌄'; float: right; }
.sidebar-more[open] > summary { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-more > div { display: grid; gap: .15rem; padding: .25rem 0 0 .5rem; }
.sidebar-more > div a { font-size: .88rem; }
.sidebar-add { border: 1px solid rgba(255,255,255,.18); }

.mobile-bottom-nav { display: none; }

.page-actions,
.entry-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.page-actions .compact-period-filter { flex: 1; }
.primary-add { white-space: nowrap; }

.compact-period-filter {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .85rem 1rem;
}

.compact-period-filter > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: .7rem;
  cursor: pointer;
}

.compact-period-filter > summary::-webkit-details-marker { display: none; }
.compact-period-filter > summary span:first-child { color: var(--muted); font-size: .78rem; }
.compact-period-filter .filter-hint { margin-left: auto; color: var(--brand); font-size: .78rem; font-weight: 700; }
.compact-period-filter .date-range-form { padding-top: 1rem; }

.compact-stats { grid-template-columns: repeat(3,minmax(0,1fr)); }
.compact-empty { padding: 1.5rem .75rem; }
.transaction-table { min-width: 640px; }

.entry-page-head h2 { margin-bottom: .3rem; }
.entry-page-head p { margin-bottom: 0; }
.voice-first-panel { max-width: 860px; margin-inline: auto; }

.stat-link {
  color: var(--ink);
  cursor: pointer;
  position: relative;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.stat-link:hover,
.stat-link:focus-visible {
  color: var(--ink);
  border-color: #8bc7b8;
  box-shadow: 0 14px 32px rgba(15, 118, 110, .12);
  transform: translateY(-2px);
}

.stat-link:focus-visible {
  outline: 3px solid rgba(15, 118, 110, .2);
  outline-offset: 2px;
}

.stat-link .stat-action {
  color: var(--brand);
  font-weight: 750;
  margin-top: .15rem;
}

.transaction-group {
  scroll-margin-top: 1rem;
}

.debt-payment-overview {
  scroll-margin-top: 1rem;
}

.payment-total {
  display: grid;
  justify-items: end;
  gap: .15rem;
}

.payment-total span {
  color: var(--muted);
  font-size: .78rem;
}

.payment-total strong {
  color: var(--brand);
  font-size: 1.35rem;
}

.payment-history-list {
  display: grid;
}

.payment-history-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) auto auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem 0;
  border-top: 1px solid var(--line);
}

.payment-history-main {
  display: grid;
  gap: .2rem;
  min-width: 0;
}

.payment-history-main small {
  color: var(--muted);
}

.payment-history-main .payment-note {
  color: var(--ink);
}

.payment-history-amount {
  color: var(--brand);
  white-space: nowrap;
}

.payment-history-edit {
  min-width: 95px;
}

.payment-history-edit > summary {
  color: var(--brand);
  cursor: pointer;
  font-weight: 750;
  list-style: none;
}

.payment-history-edit > summary::-webkit-details-marker { display: none; }

.payment-history-edit[open] {
  grid-column: 1 / -1;
  padding: .8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdfc;
}

.settings-security-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 1rem;
}

.settings-security-grid .panel {
  margin-block: 0 1rem;
}

.recovery-code-box {
  display: grid;
  gap: .55rem;
  margin: 1rem 0;
  padding: 1.15rem;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(135deg,#123a33,#0f766e);
}

.recovery-code-box span {
  color: #b9e4d9;
  font-size: .8rem;
}

.recovery-code-box strong {
  overflow-wrap: anywhere;
  font-size: 1.35rem;
  letter-spacing: .08em;
}

.recovery-code-box p {
  margin: 0;
  color: #d9f1eb;
  font-size: .84rem;
}

.auth-help {
  margin-top: 1rem;
  text-align: center;
  font-size: .8rem;
}

.member-management-list {
  display: grid;
  gap: .75rem;
  margin-top: 1rem;
}

.member-management-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdfc;
  overflow: hidden;
}

.member-management-card > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  cursor: pointer;
  list-style: none;
}

.member-management-card > summary::-webkit-details-marker { display: none; }
.member-management-card > summary strong,
.member-management-card > summary small { display: block; }
.member-management-card > form { padding: 0 1rem 1rem; }

@media (max-width: 760px) {
  .settings-security-grid {
    grid-template-columns: 1fr;
  }

  .payment-history-row {
    grid-template-columns: minmax(0,1fr) auto;
    gap: .65rem;
  }

  .payment-history-edit {
    grid-column: 1 / -1;
  }

  .payment-history-edit[open] {
    padding: .7rem;
  }
}
.unified-entry-form { margin-top: .4rem; }

.income-entry-fields {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 1rem;
  padding: 1rem;
  border: 1px solid #b9d8cf;
  border-radius: 16px;
  background: #f1faf7;
}

.income-entry-fields[hidden] { display: none; }

.advanced-fields {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .85rem 1rem;
  background: #fbfdfc;
}

.advanced-fields > summary { cursor: pointer; color: var(--brand); font-weight: 750; }

.more-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: .8rem;
  max-width: 900px;
}

.more-card {
  display: flex;
  align-items: center;
  gap: .9rem;
  margin: 0;
  color: var(--ink);
}

.more-card > span { font-size: 1.45rem; }
.more-card strong,.more-card small { display: block; }
.more-card small { margin-top: .2rem; }
.system-note { margin-top: 1.2rem; }

@media (max-width: 760px) {
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .app-shell {
    min-height: 100dvh;
  }

  .main {
    min-height: 100dvh;
    padding-bottom: calc(6.5rem + env(safe-area-inset-bottom));
  }

  .auth-shell {
    min-height: 100dvh;
    place-items: start center;
    padding-bottom: calc(38vh + env(safe-area-inset-bottom));
  }

  .main label,
  .main input,
  .main select,
  .main textarea {
    scroll-margin-top: 18vh;
    scroll-margin-bottom: 45vh;
  }

  .form-actions {
    position: sticky;
    bottom: calc(4.8rem + env(safe-area-inset-bottom));
    background: rgba(245, 248, 246, .96);
    padding: .7rem 0;
    z-index: 4;
  }

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

  .shared-detail-grid,
  .shared-calculation {
    grid-template-columns: 1fr;
  }

  .shared-month-head,
  .shared-month-head .month-filter,
  .settlement-result {
    align-items: stretch;
    flex-direction: column;
  }

  .month-filter label {
    min-width: 0;
  }

  .mobile-row-actions {
    display: flex;
    align-items: center;
    gap: .55rem;
    margin-top: .7rem;
  }

  .mobile-row-actions form {
    margin: 0;
  }

  .row-actions {
    display: none;
  }

  .delete-transaction-zone {
    align-items: stretch;
    flex-direction: column;
  }

  .delete-transaction-zone button {
    width: 100%;
  }

  .finance-controls,
  .finance-controls .month-filter {
    align-items: stretch;
    flex-direction: column;
  }

  .finance-equation {
    grid-template-columns: 1fr;
  }

  .period-filter,
  .date-range-form {
    align-items: stretch;
    flex-direction: column;
  }

  .date-range-form label {
    min-width: 0;
  }

  .entry-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .entry-switch a {
    text-align: center;
  }

  .entry-switch a:last-child {
    grid-column: 1 / -1;
  }

  .sidebar {
    padding: .8rem 1rem;
  }

  .sidebar .brand {
    margin: 0;
  }

  .sidebar nav,
  .sidebar .logout-form {
    display: none;
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5,1fr);
    align-items: end;
    padding: .45rem .35rem calc(.4rem + env(safe-area-inset-bottom));
    background: rgba(255,255,255,.97);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 25px rgba(20,48,39,.09);
  }

  .mobile-bottom-nav a {
    display: grid;
    place-items: center;
    gap: .15rem;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 700;
  }

  .mobile-bottom-nav a > span { font-size: 1.1rem; line-height: 1; }
  .mobile-bottom-nav a.active { color: var(--brand); }
  .mobile-bottom-nav .mobile-add > span {
    width: 46px;
    height: 46px;
    margin-top: -1.25rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-size: 1.8rem;
    box-shadow: 0 8px 20px rgba(15,118,110,.3);
  }

  .page-actions { display: block; }
  .page-actions .primary-add { display: none; }
  .compact-period-filter > summary { flex-wrap: wrap; }
  .compact-period-filter .filter-hint { margin-left: 0; width: 100%; }
  .compact-stats { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .compact-stats .stat { padding: .75rem .6rem; }
  .compact-stats .stat strong { font-size: .95rem; }
  .entry-page-head { align-items: flex-start; }
  .entry-page-head .button { display: none; }
  .voice-first-panel { margin: .5rem -.25rem; padding: .9rem; }
  .income-entry-fields,.more-grid { grid-template-columns: 1fr; }
  .more-grid { gap: .65rem; }
  .more-card { padding: 1rem; }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 1rem 0;
  }

  .top-actions {
    display: flex;
    align-items: stretch;
    width: 100%;
  }

  .workspace-switcher {
    flex: 1;
  }

  .workspace-switcher label {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace-switcher select {
    width: 100%;
  }

  .debt-plan-list article {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .debt-plan-list article > strong {
    grid-column: 2;
  }
}
