/* Material Design 3 Expressive Tokens & Variables */
:root {
  --md-sys-color-primary: #6750a4;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #eaddff;
  --md-sys-color-on-primary-container: #21005d;
  --md-sys-color-surface: #fef7ff;
  --md-sys-color-on-surface: #1d1b20;
  --md-sys-color-surface-variant: #e7e0ec;
  --md-sys-color-on-surface-variant: #49454f;
  --md-sys-color-outline: #79747e;
  --md-sys-color-error: #b3261e;
  --md-sys-color-error-container: #f9dedc;
  --md-sys-color-success: #146c2e;
  --md-sys-color-success-container: #d7f8dd;
  --md-sys-color-on-success-container: #072711;
  --md-elevation-1: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);
  --md-elevation-3: 0px 4px 8px 3px rgba(0, 0, 0, 0.15);
  --md-radius-small: 8px;
  --md-radius-medium: 12px;
  --md-radius-large: 16px;
  --md-radius-full: 9999px;
  --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  -webkit-tap-highlight-color: transparent;
}

html.i18n-pending body {
  visibility: hidden;
}

body {
  background-color: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  padding:
    calc(16px + env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right))
    16px
    max(24px, env(safe-area-inset-left));
  background-color: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface-variant);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--md-elevation-1);
}

header h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

.app-brand {
  display: flex;
  flex-direction: column;
}

.app-brand span {
  margin-top: 1px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.7rem;
  font-weight: 500;
}

.sync-badge {
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: var(--md-radius-full);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-weight: bold;
}

.sync-badge.pending { background: #fff3cd; color: #856404; }
.sync-badge.syncing { background: #cce5ff; color: #004085; }
.sync-badge.synced { background: #d4edda; color: #155724; }
.sync-badge.error { background: #f8d7da; color: #721c24; }

main {
  flex: 1;
  padding: 16px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

.card {
  background: white;
  border-radius: var(--md-radius-medium);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--md-elevation-1);
  border: 1px solid var(--md-sys-color-surface-variant);
}

.card-header {
  font-size: 0.875rem;
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 8px;
  font-weight: 500;
}

.card-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--md-sys-color-primary);
}

.fab-container {
  position: fixed;
  bottom: calc(88px + env(safe-area-inset-bottom));
  right: max(24px, env(safe-area-inset-right));
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 10px;
}

.currency-total-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.currency-total-row + .currency-total-row {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--md-sys-color-surface-variant);
  font-size: 1.25rem;
}

.currency-total-row small {
  padding: 3px 7px;
  border-radius: var(--md-radius-full);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

.report-controls .form-group {
  margin-bottom: 0;
}

.report-controls {
  padding: 18px 16px;
  border-radius: 16px;
}

.report-filter-heading {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(112px, 1fr);
  align-items: start;
  gap: 12px;
}

.report-period-control > label,
.report-filter-heading label,
.report-currency-control label,
#report-currency-label {
  display: block;
  margin-bottom: 6px;
  color: var(--md-sys-color-outline);
  font-size: 0.75rem;
}

.report-period-control input,
.report-period-control select,
.report-filter-heading select,
.report-currency-control select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: #f4f2f8;
  color: var(--md-sys-color-on-surface);
  font: 500 0.875rem 'Inter', var(--font-family);
}

.report-period-control input:focus-visible,
.report-period-control select:focus-visible,
.report-filter-heading select:focus-visible {
  border-color: var(--md-sys-color-primary);
  outline: 2px solid var(--md-sys-color-primary-container);
  outline-offset: 1px;
}

.report-period-control input[type='date'],
.report-period-control input[type='month'] {
  cursor: pointer;
}

.report-currency-control {
  display: grid;
  grid-template-columns: auto minmax(150px, 1fr);
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.report-currency-control label {
  margin: 0;
}

.report-range-label {
  margin: 12px 0 0;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.report-card-title {
  margin: 0 0 16px;
  color: var(--md-sys-color-on-surface);
  font-size: 0.9375rem;
  font-weight: 600;
}

.report-chart-card,
.report-totals-card {
  padding: 20px 16px;
  border-radius: 16px;
}

.date-range-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.report-year-picker,
.week-picker-heading {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 4px;
}

.report-year-picker button,
.week-picker-heading button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-size: 1.5rem;
  cursor: pointer;
}

.week-picker {
  padding: 8px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-radius-small);
}

.week-picker-heading strong {
  text-align: center;
}

.week-picker-weekdays,
.week-picker-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.week-picker-weekdays {
  margin-top: 6px;
  color: var(--md-sys-color-outline);
  font-size: 0.65rem;
  font-weight: 700;
  text-align: center;
}

.week-picker-row {
  width: 100%;
  min-height: 36px;
  border: 0;
  border-radius: var(--md-radius-small);
  background: transparent;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
}

.week-picker-row:hover {
  background: var(--md-sys-color-surface-variant);
}

.week-picker-row.selected {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.week-picker-row span {
  display: grid;
  place-items: center;
  min-width: 0;
  font-size: 0.75rem;
}

.week-picker-row .outside-month {
  opacity: 0.45;
}

.category-chart-wrap {
  display: grid;
  place-items: center;
  position: relative;
  width: 100%;
  height: 340px;
  overflow: hidden;
}

#categoryChart {
  width: min(100%, 480px) !important;
  height: 100% !important;
  margin: 0 auto;
}

.category-total-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 6px 0;
  border-bottom: 1px solid var(--md-sys-color-surface-variant);
}

.category-total-row:last-child {
  border-bottom: 0;
}

.category-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.category-total-row strong {
  overflow: hidden;
  font-size: 0.9375rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-total-row > span:not(.category-swatch) {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.8125rem;
}

.category-total-row .category-total-amount {
  color: var(--md-sys-color-on-surface);
  font-size: 0.9375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 420px) {
  .report-filter-heading {
    grid-template-columns: minmax(0, 1fr) 112px;
  }

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

  .category-chart-wrap {
    height: 250px;
  }

  #categoryChart {
    max-width: 250px;
  }

  .category-total-row {
    grid-template-columns: 12px minmax(0, 1fr) auto auto;
    gap: 8px;
  }

  .category-total-row > span:not(.category-swatch) {
    font-size: 0.75rem;
  }
}

.fab-toggle-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border: none;
  box-shadow: var(--md-elevation-3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, background-color 0.2s;
  touch-action: none;
  user-select: none;
}

[hidden] {
  display: none !important;
}

.fab-toggle-btn:active {
  transform: scale(0.95);
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.fab-toggle-btn svg {
  width: 32px;
  height: 32px;
  fill: currentColor;
}

.recorder-card {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 110;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: min(
    calc(100% - 32px - env(safe-area-inset-left) - env(safe-area-inset-right)),
    520px
  );
  min-height: 220px;
  padding: 24px;
  border: 1px solid var(--md-sys-color-surface-variant);
  border-radius: 32px;
  background: white;
  box-shadow: var(--md-elevation-3);
  transform: translate(-50%, -50%);
}

.recorder-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  left: 16px;
  display: flex;
  justify-content: space-between;
}

#recorder-help {
  order: 1;
}

#recorder-close {
  order: 2;
}

.recorder-icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

.recorder-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.big-mic-btn {
  position: relative;
  width: 108px;
  height: 108px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: #6750a4;
  color: #fff;
  box-shadow: var(--md-elevation-1);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  transition: transform 160ms ease, background-color 160ms ease;
}

.big-mic-btn svg {
  width: 48px;
  height: 48px;
  fill: currentColor;
}

.big-mic-btn.is-recording {
  background: #ff5b52;
}

.big-mic-btn.is-recording svg {
  visibility: hidden;
}

.big-mic-btn.is-recording::before {
  content: '';
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: #fff;
  transform: translateY(-12px);
}

.big-mic-btn.is-recording::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  animation: recording-pulse-ring 1.6s infinite ease-in-out;
}

@keyframes recording-pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.7);
  }
  70% {
    box-shadow: 0 0 0 18px rgba(255, 82, 82, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 82, 82, 0);
  }
}

.recording-timer {
  position: absolute;
  bottom: 14px;
  color: #fff;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.875rem;
  line-height: 1;
}

.speech-transcript {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 18px;
  padding: 10px 12px;
  border-radius: var(--md-radius-small);
  background: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.speech-transcript.is-error {
  border: 2px solid var(--md-sys-color-error);
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-error);
  font-weight: 600;
}

.onboarding-content {
  max-width: 480px;
}

.onboarding-eyebrow {
  margin: 0 0 6px;
  color: var(--md-sys-color-primary);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.onboarding-content h2 {
  margin: 0 0 12px;
}

.onboarding-steps {
  display: grid;
  gap: 12px;
  margin: 18px 0;
  padding-left: 24px;
}

.onboarding-note {
  padding: 12px;
  border-radius: var(--md-radius-small);
  background: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
  line-height: 1.5;
}

.onboarding-primary-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.onboarding-primary-actions .btn {
  min-height: 48px;
}

.onboarding-skip {
  display: block;
  min-height: 44px;
  margin: 10px auto 0;
  border: 0;
  background: transparent;
  color: var(--md-sys-color-primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.modal-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.help-content section + section {
  margin-top: 20px;
}

.help-content h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.help-content p,
.command-list {
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.5;
}

.command-list {
  padding-left: 20px;
}

.command-list li + li {
  margin-top: 6px;
}

.command-tip {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--md-radius-small);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.voice-toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  background: var(--md-sys-color-on-surface);
  color: var(--md-sys-color-surface);
  padding: 12px 20px;
  border-radius: var(--md-radius-full);
  font-size: 0.875rem;
  box-shadow: var(--md-elevation-3);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  transition: opacity 0.3s, transform 0.3s;
}

.voice-toast.toast-with-action {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.voice-toast.toast-with-action > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.toast-action {
  min-width: 44px;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}

.toast-progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  border: 0;
  appearance: none;
  background: transparent;
}

.toast-progress::-webkit-progress-bar {
  background: rgba(0, 0, 0, 0.12);
}

.toast-progress::-webkit-progress-value {
  background: currentColor;
}

.toast-progress::-moz-progress-bar {
  background: currentColor;
}

.voice-toast.toast-success {
  background: var(--md-sys-color-success-container);
  color: var(--md-sys-color-on-success-container);
}

.voice-toast.toast-error {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-error);
}

.voice-toast.toast-center {
  top: 50%;
  transform: translate(-50%, -50%) scale(0.96);
}

.voice-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(10px);
}

.voice-toast.toast-center.show {
  transform: translate(-50%, -50%) scale(1);
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background-color: var(--md-sys-color-surface-variant);
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 6px rgba(0,0,0,0.08);
  z-index: 90;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.75rem;
  font-weight: 500;
  min-width: 64px;
  min-height: 48px;
  justify-content: center;
}

.nav-item.active {
  color: var(--md-sys-color-primary);
  font-weight: 700;
}

.nav-item svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
  margin-bottom: 2px;
}

/* Expense List */
.expense-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--md-sys-color-surface-variant);
}

.expense-item:last-child {
  border-bottom: none;
}

.expense-info h3 {
  font-size: 1rem;
  font-weight: 600;
}

.expense-info p {
  font-size: 0.75rem;
  color: var(--md-sys-color-outline);
}

.expense-info .expense-date {
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.expense-amount {
  font-size: 1rem;
  font-weight: 700;
}

/* Modal Form */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(28, 27, 31, 0.52);
  backdrop-filter: blur(3px);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.open { display: flex; }

.modal-content {
  background: white;
  border: 1px solid rgba(121, 116, 126, 0.18);
  border-radius: 20px;
  width: 100%;
  max-width: 450px;
  padding: 24px;
  max-height: calc(100vh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  box-shadow: 0 18px 48px rgba(28, 27, 31, 0.24);
}

.modal-content > h2,
.modal-heading h2,
.settings-card-heading h2 {
  color: var(--md-sys-color-on-surface);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.modal-content > h2 {
  margin-bottom: 18px;
}

.app-dialog-content {
  max-width: 420px;
}

.app-dialog-content h2 {
  margin: 0 0 12px;
}

.app-dialog-content p {
  margin: 0;
  color: var(--md-sys-color-on-surface-variant);
  line-height: 1.5;
}

.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.app-dialog-actions .btn {
  min-width: 96px;
  min-height: 44px;
}

.settings-card-heading,
.settings-category-row,
.category-modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-card-heading {
  justify-content: space-between;
  margin-bottom: 20px;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section-label {
  margin: 0 0 8px 8px;
  color: var(--md-sys-color-outline);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-list-card {
  overflow: hidden;
  padding: 0;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(28, 27, 31, 0.06);
}

.configuration-menu {
  overflow: hidden;
}

.configuration-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: 64px;
  padding: 14px 16px;
  border: 0;
  background: transparent;
  color: var(--md-sys-color-on-surface);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.configuration-menu-item + .configuration-menu-item {
  border-top: 1px solid var(--md-sys-color-surface-variant);
}

.configuration-menu-item strong,
.configuration-menu-item small,
.settings-item-copy strong,
.settings-item-copy small {
  display: block;
}

.configuration-menu-item small,
.settings-item-copy small {
  margin-top: 3px;
  color: var(--md-sys-color-outline);
  font-size: 0.8125rem;
  font-weight: 400;
}

.settings-item-copy {
  flex: 1;
  min-width: 0;
}

.settings-item-icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #f4f2f8;
  font-size: 1.125rem;
}

.settings-chevron {
  color: var(--md-sys-color-outline);
  font-size: 1.75rem;
  line-height: 1;
}

.configuration-menu-item:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: -2px;
}

.configuration-modal-content {
  max-width: 520px;
}

.configuration-modal-content.category-sheet-content {
  height: min(720px, calc(100vh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)));
}

.category-sheet-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.category-sheet-content .settings-card-heading,
.category-sheet-content .modal-heading {
  flex: 0 0 auto;
  margin: 0;
  padding: 12px 24px 16px;
  border-bottom: 1px solid var(--md-sys-color-surface-variant);
}

.category-sheet-handle {
  display: none;
  flex: 0 0 auto;
  width: 36px;
  height: 4px;
  margin: 10px auto 2px;
  border-radius: var(--md-radius-full);
  background: var(--md-sys-color-outline);
  opacity: 0.5;
}

.category-sheet-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 20px 24px calc(24px + env(safe-area-inset-bottom));
}

.category-editor-content form {
  overflow-y: auto;
  padding: 20px 24px calc(24px + env(safe-area-inset-bottom));
}

.category-add-button {
  width: 100%;
  min-height: 48px;
  justify-content: center;
}

.configuration-modal-hint {
  flex: 0 0 auto;
  margin-top: 14px;
}

.voice-diagnostic-content {
  max-height: min(86vh, 720px);
  overflow-y: auto;
}

.voice-diagnostic-tests {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}

.voice-diagnostic-test {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 16px;
}

.voice-diagnostic-test div {
  display: grid;
  gap: 3px;
}

.voice-diagnostic-test small {
  color: var(--md-sys-color-on-surface-variant);
}

.voice-diagnostic-result {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--md-sys-color-on-surface-variant);
}

.voice-diagnostic-result.is-success {
  color: var(--md-sys-color-primary);
}

.voice-diagnostic-result.is-error {
  color: var(--md-sys-color-error);
}

.voice-diagnostic-report {
  display: grid;
  gap: 8px;
}

.voice-diagnostic-report pre {
  min-height: 120px;
  max-height: 220px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 12px;
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  font: 0.75rem/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.category-list-panel {
  flex: 1 1 auto;
  min-height: 120px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--md-sys-color-surface-variant);
  border-radius: 16px;
  background: #f4f2f8;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.category-list-panel::-webkit-scrollbar {
  width: 6px;
}

.category-list-panel::-webkit-scrollbar-thumb {
  border-radius: var(--md-radius-full);
  background: var(--md-sys-color-outline);
}

.settings-preference-row,
.settings-restore-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 68px;
  padding: 14px 16px;
}

.settings-preference-row {
  cursor: pointer;
}

.settings-preference-row + .settings-preference-row {
  border-top: 1px solid var(--md-sys-color-surface-variant);
}

.settings-select-control {
  position: relative;
  flex: 0 0 auto;
  width: 156px;
  min-height: 44px;
  border-radius: var(--md-radius-medium);
  background: var(--md-sys-color-surface-variant);
}

.settings-compact-select {
  width: 100%;
  min-height: 44px;
  appearance: none;
  border: 0;
  border-radius: inherit;
  padding: 0 36px 0 14px;
  background: transparent;
  color: var(--md-sys-color-on-surface);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.settings-compact-select:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.settings-select-chevron {
  position: absolute;
  top: 50%;
  right: 13px;
  color: var(--md-sys-color-primary);
  font-size: 1.1rem;
  pointer-events: none;
  transform: translateY(-58%);
}

.settings-compact-select:disabled {
  opacity: 0.6;
}

@media (max-width: 420px) {
  .language-setting-row {
    flex-wrap: wrap;
  }

  .language-setting-row .settings-select-control {
    width: calc(100% - 54px);
    margin-left: 54px;
  }
}

.voice-mode-control {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.voice-mode-label {
  color: var(--md-sys-color-outline);
  font-size: 0.75rem;
  font-weight: 600;
}

.voice-mode-label.active {
  color: var(--md-sys-color-primary);
}

.settings-switch {
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 26px;
}

.settings-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.settings-switch-track {
  position: absolute;
  inset: 0;
  border-radius: var(--md-radius-full);
  background: var(--md-sys-color-surface-variant);
  transition: background-color 160ms ease;
}

.settings-switch-track::before {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  content: '';
  transition: transform 160ms ease;
}

.settings-switch input:checked + .settings-switch-track {
  background: var(--md-sys-color-primary);
}

.settings-switch input:checked + .settings-switch-track::before {
  transform: translateX(18px);
}

.settings-switch input:focus-visible + .settings-switch-track {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 3px;
}

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

.settings-export-grid .btn {
  justify-content: center;
}

.settings-restore-row {
  flex-wrap: wrap;
  border-top: 1px solid var(--md-sys-color-surface-variant);
}

.settings-file-button {
  margin-left: 50px;
  cursor: pointer;
}

.settings-hint {
  margin-bottom: 14px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
  line-height: 1.5;
}

.currency-settings-fieldset {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.currency-settings-fieldset legend {
  margin-bottom: 6px;
  color: var(--md-sys-color-outline);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.currency-sheet-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow: hidden;
  padding: 20px 24px calc(24px + env(safe-area-inset-bottom));
}

.default-currency-box {
  flex: 0 0 auto;
  padding: 14px 16px;
  border: 1px solid var(--md-sys-color-primary);
  border-radius: 14px;
  background: var(--md-sys-color-primary-container);
}

.default-currency-box label {
  display: block;
  margin-bottom: 7px;
  color: var(--md-sys-color-primary);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.default-currency-box select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--md-sys-color-surface-variant);
  border-radius: 10px;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font: 600 0.9375rem 'Inter', var(--font-family);
}

.currency-search-wrapper {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
}

.currency-search-icon {
  position: absolute;
  left: 15px;
  z-index: 1;
  color: var(--md-sys-color-outline);
  font-size: 1.25rem;
  pointer-events: none;
}

.currency-search-wrapper input {
  width: 100%;
  min-height: 44px;
  padding: 11px 16px 11px 42px;
  border: 1px solid transparent;
  border-radius: var(--md-radius-full);
  outline: 0;
  background: #f4f2f8;
  color: var(--md-sys-color-on-surface);
  font: 400 0.875rem 'Inter', var(--font-family);
}

.currency-search-wrapper input:focus-visible {
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-surface);
  box-shadow: 0 0 0 2px var(--md-sys-color-primary-container);
}

.currency-list-panel {
  flex: 1 1 auto;
  min-height: 120px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid var(--md-sys-color-surface-variant);
  border-radius: 16px;
  background: #f4f2f8;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.currency-list-panel::-webkit-scrollbar {
  width: 6px;
}

.currency-list-panel::-webkit-scrollbar-thumb {
  border-radius: var(--md-radius-full);
  background: var(--md-sys-color-outline);
}

.settings-currency-list {
  display: grid;
  gap: 8px;
}

.settings-currency-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 12px;
  border: 1px solid var(--md-sys-color-surface-variant);
  border-radius: 14px;
  background: var(--md-sys-color-surface);
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease;
}

.settings-currency-row:hover {
  border-color: var(--md-sys-color-primary);
}

.settings-currency-symbol {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-primary);
  font-size: 0.875rem;
  font-weight: 700;
}

.settings-currency-row input {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-left: auto;
  accent-color: var(--md-sys-color-primary);
}

.settings-currency-row input:disabled {
  opacity: 0.7;
}

.settings-currency-details {
  flex: 1;
  min-width: 0;
}

.settings-currency-code-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-currency-details strong,
.settings-currency-details small {
  display: block;
}

.settings-currency-details small {
  margin-top: 2px;
  color: var(--md-sys-color-outline);
  font-size: 0.75rem;
}

.settings-currency-default-badge {
  padding: 2px 8px;
  border-radius: var(--md-radius-full);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-primary);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.settings-category-list {
  display: grid;
  gap: 8px;
}

.settings-category-row {
  position: relative;
  min-height: 56px;
  padding: 8px 6px;
  border: 1px solid var(--md-sys-color-surface-variant);
  border-radius: 14px;
  background: var(--md-sys-color-surface);
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.settings-category-row:hover {
  border-color: var(--md-sys-color-primary);
}

.settings-category-row.is-dragging {
  visibility: hidden;
}

.category-drag-layer {
  position: fixed;
  z-index: 2147483647;
  inset: 0;
  overflow: visible;
  pointer-events: none;
  isolation: isolate;
}

.category-drag-preview {
  position: fixed;
  margin: 0;
  pointer-events: none;
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 12px 28px rgba(28, 27, 31, 0.28);
  opacity: 0.98;
  transform: translateZ(0);
  will-change: left, top;
}

.settings-category-label {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  font-weight: 600;
}

.settings-category-icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #f4f2f8;
  font-size: 1.25rem;
}

.settings-category-details {
  min-width: 0;
}

.settings-category-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-category-label small {
  display: block;
  margin-top: 2px;
  color: var(--md-sys-color-outline);
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.category-action {
  width: 44px;
  height: 44px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-radius-full);
  background: transparent;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
}

.category-delete {
  color: var(--md-sys-color-error);
}

.category-drag-handle {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--md-radius-full);
  background: transparent;
  color: var(--md-sys-color-outline);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  cursor: grab;
  touch-action: none;
}

.category-drag-handle:active {
  cursor: grabbing;
  background: var(--md-sys-color-surface-variant);
}

.category-action:focus-visible,
.category-drag-handle:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.category-icon-fieldset {
  min-width: 0;
  padding: 0;
  border: 0;
}

.category-icon-fieldset legend {
  margin-bottom: 8px;
  color: var(--md-sys-color-outline);
  font-size: 0.75rem;
}

.category-icon-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(44px, 1fr));
  gap: 8px;
}

.category-icon-option {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--md-sys-color-surface-variant);
  border-radius: 10px;
  background: #f4f2f8;
  font-size: 1.25rem;
  cursor: pointer;
}

.category-icon-option.selected {
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-primary-container);
  box-shadow: inset 0 0 0 1px var(--md-sys-color-primary);
}

.category-icon-option:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.category-modal-actions {
  justify-content: flex-end;
  margin-top: 20px;
}

@media (max-width: 599px) {
  .category-sheet-modal {
    align-items: flex-end;
    padding: 0;
  }

  .category-sheet-content {
    max-width: none;
    max-height: min(88vh, calc(100vh - env(safe-area-inset-top)));
    border-radius: 28px 28px 0 0;
    border-bottom: 0;
  }

  .configuration-modal-content.category-sheet-content {
    height: min(88vh, calc(100vh - env(safe-area-inset-top)));
  }

  .category-sheet-handle {
    display: block;
  }

  .category-icon-grid {
    grid-template-columns: repeat(5, minmax(44px, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .settings-category-row,
  .category-icon-option {
    transition: none;
  }
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  margin-bottom: 4px;
  color: var(--md-sys-color-outline);
}

.form-group input, .form-group select {
  width: 100%;
  padding: 12px 16px;
  border: 0;
  border-radius: 12px;
  background: #f4f2f8;
  color: var(--md-sys-color-on-surface);
  font-size: 1rem;
}

#form-edit {
  margin-top: 20px;
}

#form-edit label,
#form-edit input,
#form-edit select,
#form-edit button {
  font-family: 'Inter', var(--font-family);
}

#form-edit .form-group {
  margin-bottom: 16px;
}

#form-edit .form-group label,
#form-edit .field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.8125rem;
  font-weight: 600;
}

#form-edit input,
#form-edit select,
.amount-input-shell {
  min-height: 48px;
}

#form-edit input:focus,
#form-edit select:focus,
.amount-input-shell:focus-within {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 1px;
}

.amount-input-shell {
  display: flex;
  align-items: center;
  overflow: hidden;
  border-radius: 12px;
  background: #f4f2f8;
}

.amount-currency-prefix {
  flex: 0 0 auto;
  padding-left: 16px;
  color: var(--md-sys-color-primary);
  font-family: 'Inter', var(--font-family);
  font-size: 0.9375rem;
  font-weight: 700;
  white-space: nowrap;
}

#form-edit .amount-input-shell input {
  min-width: 0;
  padding-left: 10px;
  background: transparent;
  outline: none;
}

.quick-adjust-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  overflow-x: auto;
}

.quick-adjust-chips button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 6px 12px;
  border: 0;
  border-radius: 16px;
  background: #f4f2f8;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.quick-adjust-chips button:active:not(:disabled) {
  background: var(--md-sys-color-secondary-container);
}

.quick-adjust-chips button:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.quick-adjust-chips button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.currency-scroll-container {
  display: flex;
  gap: 8px;
  width: 100%;
  overflow-x: auto;
  padding: 2px 1px 6px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
  touch-action: pan-y;
}

.currency-scroll-container::-webkit-scrollbar {
  display: none;
}

.currency-scroll-container.is-dragging {
  scroll-snap-type: none;
  cursor: grabbing;
  user-select: none;
}

.report-currency-control .currency-scroll-container {
  width: 100%;
}

.currency-scroll-container .currency-pill {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 8px 16px;
  border: 0;
  border-radius: var(--md-radius-full);
  background: #f4f2f8;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  scroll-snap-align: center;
}

.currency-scroll-container .currency-pill span {
  margin-left: 4px;
  color: var(--md-sys-color-outline);
  font-size: 0.75rem;
}

.currency-scroll-container .currency-pill[aria-pressed="true"] {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.currency-scroll-container .currency-pill[aria-pressed="true"] span {
  color: inherit;
}

.currency-scroll-container .currency-pill:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

.recorder-currencies {
  position: absolute;
  top: 70px;
  left: 16px;
  width: auto;
  margin: 0;
}

.recorder-currencies .currency-scroll-container {
  justify-content: flex-start;
}

.recorder-language-indicator {
  margin-top: 4px;
}

.recorder-currencies .currency-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 52px;
  min-height: 20px;
  padding: 2px 6px;
  border-radius: var(--md-radius-full);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  text-align: center;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: default;
}

.recorder-currencies .currency-pill span {
  font-size: inherit;
  color: inherit;
}

body.dark-mode .recorder-currencies .currency-pill {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.expense-form-actions,
.expense-form-primary-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.expense-form-actions {
  justify-content: space-between;
  margin-top: 24px;
}

.expense-form-primary-actions {
  justify-content: flex-end;
}

.expense-form-actions .btn {
  min-width: 88px;
  padding: 12px 18px;
}

.expense-delete {
  width: 44px;
  min-width: 44px !important;
  padding: 0 !important;
  background: transparent;
  color: var(--md-sys-color-error);
}

.expense-delete svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  vertical-align: middle;
}

body.dark-mode .amount-input-shell,
body.dark-mode .quick-adjust-chips button,
body.dark-mode .settings-currency-row {
  background: var(--md-sys-color-surface);
}

body.dark-mode .currency-scroll-container .currency-pill:not([aria-pressed="true"]) {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

body.dark-mode .currency-scroll-container .currency-pill:not([aria-pressed="true"]) span {
  color: inherit;
}

.btn {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--md-radius-full);
  border: none;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.btn-secondary {
  background: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface-variant);
}

.btn-danger {
  background: var(--md-sys-color-error);
  color: white;
}

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

.category-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: var(--md-radius-small);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.expense-info {
  min-width: 0;
  padding-right: 12px;
}

.expense-info p {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.expense-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 2px;
}

.btn-edit {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--md-sys-color-primary);
  cursor: pointer;
}

.btn-delete-expense {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--md-sys-color-error);
  cursor: pointer;
}

.btn-edit svg,
.btn-delete-expense svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  vertical-align: middle;
}

.empty-state {
  padding: 24px 8px;
  text-align: center;
  color: var(--md-sys-color-outline);
}

.empty-state.compact {
  padding: 16px;
}

.transaction-search {
  margin: 4px 0 8px;
}

.transaction-tabs {
  position: sticky;
  top: 8px;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  border-radius: var(--md-radius-full);
  background: var(--md-sys-color-surface-variant);
  box-shadow: var(--md-elevation-1);
}

.transaction-tabs button {
  min-width: 0;
  min-height: 44px;
  padding: 8px 4px;
  border: 0;
  border-radius: var(--md-radius-full);
  background: transparent;
  color: var(--md-sys-color-on-surface-variant);
  font-weight: 600;
  cursor: pointer;
}

.transaction-tabs button.active {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.period-heading,
.calendar-heading,
.annual-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.period-heading h2,
.calendar-heading h2,
.annual-controls h2 {
  font-size: 1.1rem;
}

.period-heading p,
.annual-controls p {
  margin-top: 3px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.8rem;
}

.period-totals {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  color: var(--md-sys-color-primary);
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.period-totals.compact {
  font-size: 0.8rem;
}

.calendar-heading {
  margin-bottom: 14px;
}

.calendar-nav-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-size: 1.75rem;
  cursor: pointer;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.calendar-weekdays {
  margin-bottom: 4px;
  color: var(--md-sys-color-outline);
  font-size: 0.65rem;
  font-weight: 700;
  text-align: center;
}

.calendar-day {
  position: relative;
  min-width: 0;
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: var(--md-radius-small);
  background: transparent;
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
}

.calendar-day small {
  position: absolute;
  right: 3px;
  bottom: 3px;
  display: grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: var(--md-radius-full);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-size: 0.6rem;
}

.calendar-day.today {
  border-color: var(--md-sys-color-primary);
}

.calendar-day.selected {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.calendar-day.selected small {
  background: var(--md-sys-color-on-primary);
  color: var(--md-sys-color-primary);
}

.period-group {
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid var(--md-sys-color-surface-variant);
  border-radius: var(--md-radius-medium);
  background: white;
  box-shadow: var(--md-elevation-1);
}

.period-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  padding: 12px 16px;
  cursor: pointer;
}

.week-list {
  padding: 0 16px 8px;
}

.week-row,
.annual-month-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 8px 0;
  border-top: 1px solid var(--md-sys-color-surface-variant);
}

.week-row > span {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.85rem;
}

.annual-controls label {
  margin-left: auto;
  color: var(--md-sys-color-outline);
  font-size: 0.75rem;
}

.annual-controls select {
  min-width: 92px;
  min-height: 44px;
  padding: 8px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--md-radius-small);
  background: white;
  color: var(--md-sys-color-on-surface);
  font-size: 1rem;
}

.annual-controls + #annual-totals {
  margin-top: 16px;
}

.recording-status {
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.75rem;
  text-align: center;
}

.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;
}

:focus-visible {
  outline: 3px solid var(--md-sys-color-primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .big-mic-btn.is-recording {
    box-shadow:
      0 0 0 10px rgba(255, 82, 82, 0.28),
      var(--md-elevation-1);
  }

  .big-mic-btn.is-recording::after {
    display: none;
  }
}

@media (max-width: 420px) {
  main {
    padding-inline:
      max(12px, env(safe-area-inset-left))
      max(12px, env(safe-area-inset-right));
  }

  .nav-item {
    min-width: 0;
    flex: 1 1 25%;
    font-size: 0.68rem;
  }

  .transaction-tabs {
    overflow-x: auto;
    border-radius: var(--md-radius-large);
  }

  .transaction-tabs button {
    font-size: 0.72rem;
  }

  .period-heading {
    align-items: flex-start;
  }

  .onboarding-primary-actions {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 768px) {
  main {
    max-width: 960px;
    padding: 24px;
  }

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

  .dashboard-main .card {
    margin-bottom: 0;
  }

  .dashboard-category-card,
  .dashboard-recent-card {
    grid-column: 1 / -1;
  }

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

  .report-main {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
    gap: 16px;
    align-items: start;
  }

  .report-main .card {
    margin-bottom: 0;
  }

  .report-controls {
    grid-column: 1 / -1;
  }

  .settings-main {
    display: block;
    max-width: 600px;
  }

  .settings-main .card {
    margin-bottom: 0;
  }

  .transactions-main {
    max-width: 900px;
  }

  [data-transaction-panel='daily']:not([hidden]) {
    display: grid;
    grid-template-columns: minmax(240px, 0.7fr) minmax(0, 1.3fr);
    gap: 16px;
    align-items: start;
  }

  [data-transaction-panel='daily'] .card,
  [data-transaction-panel='calendar'] .card {
    margin-bottom: 0;
  }

  [data-transaction-panel='calendar']:not([hidden]) {
    display: grid;
    grid-template-columns: minmax(360px, 1fr) minmax(300px, 1fr);
    gap: 16px;
    align-items: start;
  }
}

@media (orientation: landscape) and (max-height: 600px) {
  header {
    padding-top: max(10px, env(safe-area-inset-top));
    padding-bottom: 10px;
  }

  .recorder-card {
    width: min(
      calc(100% - 32px - env(safe-area-inset-left) - env(safe-area-inset-right)),
      680px
    );
    min-height: 156px;
    padding: 16px 20px;
  }

  .big-mic-btn {
    width: 84px;
    height: 84px;
  }

  .big-mic-btn svg {
    width: 38px;
    height: 38px;
  }

  .speech-transcript {
    min-height: 36px;
    margin-top: 10px;
    padding-block: 7px;
  }

  .modal-content {
    max-height: calc(100vh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
}

.field-help {
  display: block;
  margin-top: 6px;
  color: var(--md-sys-color-on-surface-variant);
}

#edit-amount[readonly] {
  cursor: pointer;
}

.calculator-modal {
  align-items: flex-end;
}

.calculator-sheet {
  width: min(100%, 440px);
  max-height: calc(100vh - env(safe-area-inset-top) - 12px);
  margin: 0 auto;
  padding: 18px max(16px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  border-radius: 24px 24px 0 0;
}

.calculator-screen {
  min-height: 112px;
  padding: 12px 4px;
  text-align: right;
  overflow-wrap: anywhere;
}

.calculator-expression,
.calculator-display {
  display: block;
}

.calculator-expression {
  min-height: 22px;
  color: var(--md-sys-color-on-surface-variant);
}

.calculator-display {
  font-size: clamp(2rem, 10vw, 3.25rem);
  line-height: 1.15;
}

.calculator-breakdown {
  display: flex;
  align-items: baseline;
  justify-content: end;
  gap: 12px;
  min-height: 22px;
  overflow-x: auto;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.82rem;
  white-space: nowrap;
}

.calculator-breakdown-line {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}

.calculator-charge-actions {
  display: flex;
  gap: 8px;
  min-height: 44px;
  margin-bottom: 10px;
}

.calculator-charge-actions button {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: 999px;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font-weight: 700;
}

.calculator-charge-actions button[aria-pressed='true'] {
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.calculator-keys {
  display: grid;
  grid-template-columns: repeat(4, minmax(56px, 1fr));
  gap: 8px;
}

.calculator-keys button {
  min-width: 56px;
  min-height: 54px;
  border: 0;
  border-radius: 16px;
  background: var(--md-sys-color-surface-variant);
  color: var(--md-sys-color-on-surface);
  font: inherit;
  font-size: 1.2rem;
  font-weight: 700;
}

.calculator-keys .calculator-key-operation {
  background: var(--md-sys-color-secondary-container, #e8def8);
}

.calculator-keys .calculator-key-muted {
  color: var(--md-sys-color-primary);
}

.calculator-keys .calculator-key-zero {
  grid-column: span 2;
}

.calculator-keys .calculator-key-apply {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.calculator-cancel {
  width: 100%;
  margin-top: 10px;
}

.calculator-config-form {
  display: grid;
  gap: 14px;
  overflow-y: auto;
  padding: 2px 2px 18px;
}

.calculator-config-section {
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--md-sys-color-outline);
  border-radius: 16px;
}

.calculator-config-section legend {
  margin-left: 12px;
  padding: 0 6px;
  font-weight: 700;
}

.calculator-config-section .settings-preference-row {
  border-bottom: 1px solid var(--md-sys-color-outline);
}

.calculator-config-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, 0.55fr);
  gap: 12px;
  padding: 14px;
}

.calculator-config-grid label {
  display: grid;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
}

.calculator-config-grid input {
  width: 100%;
}

.calculator-compound-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px 14px;
}

.calculator-config-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  background: var(--md-sys-color-surface-variant);
}

.calculator-config-save {
  width: 100%;
}

.calculator-config-content {
  width: min(100%, 440px);
  height: min(92vh, 820px);
  padding: 12px 0 0;
  overflow: hidden;
  background: #f4f3ef;
}

.calculator-config-content .modal-heading {
  padding: 0 16px 12px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant, #e4e2dc);
}

.charges-tax-screen {
  height: 100%;
  overflow-y: auto;
  padding: 18px 16px max(28px, env(safe-area-inset-bottom));
}

.charges-profile-row {
  display: grid;
  gap: 7px;
  margin-bottom: 22px;
}

.charges-profile-row label,
.charges-settings-section > h3 {
  margin: 0 0 8px 4px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.charges-profile-row select {
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--md-sys-color-outline-variant, #d3d1c9);
  border-radius: 12px;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  font: inherit;
}

.charges-settings-section {
  margin-bottom: 22px;
}

.charges-settings-card,
.charges-preview-card {
  overflow: hidden;
  border: 1px solid var(--md-sys-color-outline-variant, #e4e2dc);
  border-radius: 15px;
  background: var(--md-sys-color-surface);
}

.charges-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 12px 15px;
}

.charges-setting-row + .charges-setting-row,
.calculator-tax-row,
.calculator-add-tax {
  border-top: 1px solid var(--md-sys-color-outline-variant, #e4e2dc);
}

.charges-setting-row > span:first-child,
.charges-setting-row strong {
  min-width: 0;
  font-size: 0.94rem;
  font-weight: 600;
}

.charges-setting-row small {
  display: block;
  margin-top: 3px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.78rem;
  font-weight: 400;
}

.charges-rate-field {
  display: flex;
  flex: none;
  align-items: center;
  gap: 7px;
  color: var(--md-sys-color-on-surface-variant);
}

.charges-rate-field input {
  width: 76px;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--md-sys-color-outline-variant, #d3d1c9);
  border-radius: 10px;
  background: #fafaf8;
  color: var(--md-sys-color-on-surface);
  font: inherit;
  text-align: right;
}

.calculator-tax-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  padding: 10px 15px;
}

.calculator-tax-row > input {
  min-width: 0;
  flex: 1;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--md-sys-color-outline-variant, #d3d1c9);
  border-radius: 10px;
  background: #fafaf8;
  color: var(--md-sys-color-on-surface);
  font: inherit;
}

.calculator-remove-tax {
  width: 38px;
  height: 38px;
  flex: none;
  border: 1px solid var(--md-sys-color-outline-variant, #d3d1c9);
  border-radius: 9px;
  background: transparent;
  color: var(--md-sys-color-error);
  font-size: 1.2rem;
}

.calculator-add-tax {
  width: 100%;
  min-height: 48px;
  border-right: 0;
  border-bottom: 0;
  border-left: 0;
  background: transparent;
  color: var(--md-sys-color-primary);
  font: inherit;
  font-weight: 700;
}

.charges-preview-card {
  padding: 12px 15px;
}

.charges-preview-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 5px 0;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.9rem;
}

.charges-preview-row span:last-child {
  color: var(--md-sys-color-on-surface);
  font-variant-numeric: tabular-nums;
}

.charges-preview-row.total {
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--md-sys-color-outline-variant, #d3d1c9);
  color: var(--md-sys-color-on-surface);
  font-size: 1.05rem;
  font-weight: 800;
}

.charges-tax-caption {
  margin: 9px 4px 0;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.74rem;
  line-height: 1.45;
}

.settings-version-row {
  width: 100%;
}

.debug-entitlements-heading {
  display: grid;
  gap: 3px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant, #e4e2dc);
}

.debug-entitlements-heading small {
  color: var(--md-sys-color-on-surface-variant);
}

.debug-page-main .settings-preference-row
  + .settings-preference-row {
  border-top: 1px solid var(--md-sys-color-outline-variant, #e4e2dc);
}

.debug-page-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.debug-page-header h1 {
  font-size: 1.15rem;
}

.debug-back-link {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: inherit;
  font-size: 2rem;
  text-decoration: none;
}

.debug-page-main {
  padding-top: 20px;
}

.debug-entitlement-status {
  margin: 10px 4px;
}

.recorder-test-link-card,
.recorder-test-card {
  display: grid;
  gap: 16px;
}

.recorder-test-link-card {
  align-items: center;
  grid-template-columns: 1fr auto;
}

.recorder-test-link-card small {
  display: block;
  margin-top: 4px;
  color: var(--md-sys-color-outline);
}

.recorder-test-status {
  min-height: 24px;
  color: var(--md-sys-color-primary);
  font-weight: 600;
}

.recorder-test-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 1fr);
}

.recorder-test-audio {
  width: 100%;
}

.recorder-test-download {
  justify-self: start;
}

.recorder-test-result {
  display: grid;
  gap: 8px;
}

.recorder-test-result[hidden] {
  display: none;
}

.recorder-test-result div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.recorder-test-result dt {
  color: var(--md-sys-color-outline);
}

.recorder-test-result dd {
  overflow-wrap: anywhere;
  text-align: right;
}

@media (max-width: 480px) {
  .recorder-test-link-card,
  .recorder-test-actions {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 600px) {
  .calculator-modal {
    align-items: center;
  }

  .calculator-sheet {
    border-radius: 24px;
  }
}
