:root {
  --bg: #f4f7f5;
  --panel: #fff;
  --ink: #17201b;
  --muted: #65746d;
  --line: #d9e1dc;
  --brand: #0e7a4f;
  --brand-strong: #075f3c;
  --accent: #f3b43f;
  --danger: #b43b3b;
  --user: #dff3e8;
  --shadow: 0 10px 30px rgba(22, 38, 29, .08);
  font-family: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
}

button, input, select, textarea {
  font: inherit;
}

button, .link-button {
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 9px 11px;
  cursor: pointer;
  text-decoration: none;
}

button:disabled {
  opacity: .65;
  cursor: wait;
}

.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 700;
}

.warning {
  background: #fff8e7;
  border-color: #f0d79b;
  color: #684700;
}

.login-screen {
  min-height: 100svh;
  max-width: 480px;
  margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 18px;
  box-shadow: var(--shadow);
}

.login-brand, .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand { margin-bottom: 22px; }
.login-brand img, .brand img { width: 44px; height: 44px; border-radius: 10px; }
.brand img { width: 38px; height: 38px; border-radius: 8px; }
.login-brand strong, .brand strong { display: block; font-size: 21px; line-height: 1.1; }
.brand strong { font-size: 18px; }
.login-brand span, .brand span { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; }

label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin: 12px 0 5px;
}

input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 44px;
  max-height: 120px;
  resize: none;
  border-radius: 999px;
  line-height: 1.3;
  overflow-y: hidden;
}

.login-card button { width: 100%; margin-top: 16px; }

.phone {
  min-height: 100svh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(244, 247, 245, .96);
  border-bottom: 1px solid var(--line);
  padding: max(14px, env(safe-area-inset-top)) 16px 12px;
  backdrop-filter: blur(10px);
}

.topbar, .expense-head, .period-head, .period-item-top, .photo-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.user-menu { position: relative; font-size: 12px; white-space: nowrap; }
.user-menu summary {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 6px 9px;
  cursor: pointer;
  list-style: none;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-name {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--brand-strong);
  font-weight: 700;
}
.user-name-icon {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 190px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
  align-items: stretch;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 20;
}
.user-dropdown > button,
.user-dropdown > a {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 9px 11px;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
}
.sheet-summary-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: #188038;
  fill: rgba(24, 128, 56, .1);
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.user-dropdown > button[hidden] {
  display: none !important;
}
.install-app {
  color: var(--brand-strong);
  font-weight: 700;
}
.user-dropdown > button:hover,
.user-dropdown > button:focus,
.user-dropdown > a:hover,
.user-dropdown > a:focus {
  background: #f4f7f5;
  outline: none;
}

.summary-title {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 8px;
  min-width: 0;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.metric:hover,
.metric:focus {
  border-color: #aac9ba;
  box-shadow: 0 0 0 3px rgba(14, 122, 79, .08);
  outline: none;
}
.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.metric strong { display: block; margin-top: 3px; font-size: 15px; color: var(--brand-strong); }

main {
  flex: 1;
  padding: 14px 12px 188px;
}

.date {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 6px 0 14px;
}

.message { display: flex; margin: 10px 0; }
.message.user { justify-content: flex-end; }
.bubble {
  width: fit-content;
  max-width: min(90%, 390px);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 11px 12px;
  box-shadow: 0 4px 18px rgba(25, 39, 32, .04);
  line-height: 1.35;
  font-size: 15px;
  background: #fff;
}
.message.user .bubble {
  background: var(--user);
  border-color: #bfdecf;
  border-top-right-radius: 6px;
}
.message.bot .bubble { border-top-left-radius: 6px; }
.bubble small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; }
.message-attachment {
  display: block;
  margin-top: 7px;
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 700;
}
.typing-message .bubble {
  min-width: 108px;
}
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 18px;
}
.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  opacity: .4;
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .35; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.expense, .period-item {
  margin-top: 10px;
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.expense-head {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: #f7faf8;
}
.expense-head strong { font-size: 14px; }
.pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 8px;
  background: #edf8f2;
  color: var(--brand-strong);
  font-size: 11px;
  white-space: nowrap;
}
.rows { padding: 6px 10px 10px; }
.row {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px;
  padding-top: 8px;
  font-size: 13px;
}
.row span { color: var(--muted); }
.amount {
  margin-top: 6px;
  color: var(--brand-strong);
  font-size: 24px;
  font-weight: 700;
}
.amount.cost, .period-amount.cost { color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.composer {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(480px, 100%);
  padding: 10px 12px max(14px, env(safe-area-inset-bottom));
  background: rgba(244, 247, 245, .98);
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 28px rgba(22, 38, 29, .08);
}
.inputbar {
  display: grid;
  grid-template-columns: 44px 1fr 88px;
  gap: 9px;
  align-items: center;
}
.icon-button, .mic {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--panel);
  font-weight: 700;
}
#messageInput {
  min-width: 0;
  min-height: 44px;
  padding: 11px 14px;
  font-size: 14px;
}
.mic {
  width: 88px;
  height: 88px;
  border: 0;
  background: var(--brand);
  color: #fff;
  transform: translateY(-24px);
  box-shadow: 0 16px 30px rgba(14, 122, 79, .32);
}
.mic svg {
  width: 38px;
  height: 38px;
  fill: currentColor;
  stroke: none;
}
.mic.recording {
  background: var(--danger);
  animation: pulse 1.1s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(180, 59, 59, .35); }
  100% { box-shadow: 0 0 0 18px rgba(180, 59, 59, 0); }
}

.recorder-overlay {
  --voice-level: 0;
  --voice-mic-scale: 1;
  --voice-ring-1: .86;
  --voice-ring-2: .95;
  --voice-ring-3: 1.04;
  --voice-ring-opacity-1: 0;
  --voice-ring-opacity-2: 0;
  --voice-ring-opacity-3: 0;
  --voice-bar-opacity: .18;
  --voice-bar-1: .14;
  --voice-bar-2: .2;
  --voice-bar-3: .24;
  --voice-bar-4: .28;
  --voice-bar-5: .24;
  --voice-bar-6: .18;
  --voice-bar-7: .14;
  position: fixed;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 16px max(22px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 50% 40%, rgba(14, 122, 79, .16), transparent 34%),
    rgba(244, 247, 245, .92);
  backdrop-filter: blur(12px);
}

.recorder-panel {
  width: min(480px, 100%);
  min-height: min(620px, calc(100svh - 42px));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.recorder-stage {
  position: relative;
  width: min(78vw, 360px);
  height: min(50svh, 360px);
  max-height: 360px;
  display: grid;
  place-items: center;
}

.voice-ring {
  position: absolute;
  inset: 9%;
  border: 2px solid rgba(14, 122, 79, .2);
  border-radius: 50%;
  opacity: 0;
  transform: scale(.86);
  transition: opacity .14s ease-out, transform .14s ease-out;
}

.voice-ring:nth-child(1) { transform: scale(var(--voice-ring-1)); }
.voice-ring:nth-child(2) { transform: scale(var(--voice-ring-2)); }
.voice-ring:nth-child(3) { transform: scale(var(--voice-ring-3)); }

.recorder-overlay.is-recording.is-speaking .voice-ring {
  opacity: var(--voice-ring-opacity-1);
}

.recorder-overlay.is-recording.is-speaking .voice-ring:nth-child(2) {
  opacity: var(--voice-ring-opacity-2);
}

.recorder-overlay.is-recording.is-speaking .voice-ring:nth-child(3) {
  opacity: var(--voice-ring-opacity-3);
}

.recorder-mic {
  position: relative;
  z-index: 1;
  width: min(64vw, 40svh, 300px);
  height: min(64vw, 40svh, 300px);
  min-width: 190px;
  min-height: 190px;
  max-width: 300px;
  max-height: 300px;
  border: 0;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  display: grid;
  place-items: center;
  padding: 0;
  box-shadow:
    0 26px 54px rgba(180, 59, 59, .3),
    inset 0 -18px 32px rgba(98, 18, 18, .18);
  transform: scale(1);
  transition: background-color .18s ease, box-shadow .18s ease, transform .14s ease-out;
}

.recorder-overlay.is-starting .recorder-mic,
.recorder-overlay.is-transcribing .recorder-mic {
  background: #8a958f;
  box-shadow:
    0 18px 40px rgba(75, 86, 81, .22),
    inset 0 -16px 28px rgba(34, 43, 38, .14);
}

.recorder-overlay.is-recording.is-speaking .recorder-mic {
  transform: scale(var(--voice-mic-scale));
}

.recorder-mic svg {
  width: 46%;
  height: 46%;
  fill: currentColor;
}

.voice-bars {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.voice-bars span {
  width: 7px;
  height: 64px;
  border-radius: 999px;
  background: var(--brand);
  opacity: .18;
  transform: scaleY(.14);
  transform-origin: center;
  transition: opacity .14s ease-out, transform .14s ease-out;
}

.recorder-overlay.is-recording .voice-bars span:nth-child(1) { transform: scaleY(var(--voice-bar-1)); }
.recorder-overlay.is-recording .voice-bars span:nth-child(2) { transform: scaleY(var(--voice-bar-2)); }
.recorder-overlay.is-recording .voice-bars span:nth-child(3) { transform: scaleY(var(--voice-bar-3)); }
.recorder-overlay.is-recording .voice-bars span:nth-child(4) { transform: scaleY(var(--voice-bar-4)); }
.recorder-overlay.is-recording .voice-bars span:nth-child(5) { transform: scaleY(var(--voice-bar-5)); }
.recorder-overlay.is-recording .voice-bars span:nth-child(6) { transform: scaleY(var(--voice-bar-6)); }
.recorder-overlay.is-recording .voice-bars span:nth-child(7) { transform: scaleY(var(--voice-bar-7)); }

.recorder-overlay.is-recording.is-speaking .voice-bars span {
  opacity: var(--voice-bar-opacity);
}

.photo-preview {
  margin-bottom: 8px;
  align-items: flex-start;
  justify-content: space-between;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
  color: var(--muted);
}
.photo-preview-info {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px 10px;
  align-items: center;
  min-width: 0;
}
.photo-preview img {
  grid-row: span 2;
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
}
.photo-preview span {
  color: var(--ink);
  font-weight: 700;
  overflow-wrap: anywhere;
}
.photo-preview small {
  display: block;
  line-height: 1.3;
}
.photo-preview-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
  margin-left: 8px;
}
.photo-preview button { min-height: 32px; padding: 5px 8px; }

dialog {
  width: min(440px, calc(100% - 24px));
  border: 0;
  border-radius: 12px;
  padding: 0;
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(15, 25, 19, .38); }
.modal { padding: 16px; }
.modal h2 { margin: 0 0 12px; font-size: 18px; }
.modal-entry-id {
  color: var(--muted);
  font-weight: 600;
}
.amount-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 56px;
  gap: 8px;
  align-items: stretch;
}
.amount-input-row button {
  min-height: 44px;
  padding: 0;
  font-weight: 700;
}
.sheet-dialog {
  position: fixed;
  inset: auto 0 0 0;
  width: min(480px, 100%);
  max-width: none;
  margin: 0 auto;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -18px 42px rgba(15, 25, 19, .22);
}
.sheet { padding: 10px 14px max(16px, env(safe-area-inset-bottom)); }
.sheet-handle { width: 42px; height: 4px; border-radius: 999px; background: #cbd5cf; margin: 0 auto 14px; }
.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.sheet h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}
.sheet-option {
  width: 100%;
  min-height: 64px;
  margin-top: 10px;
  text-align: left;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
}
.sheet-option svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  flex: 0 0 auto;
}
.sheet-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #edf8f2;
  color: var(--brand-strong);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.sheet-copy strong {
  font-size: 15px;
}

.install-modal {
  background: #fff;
}

.install-steps {
  padding: 14px 16px 16px;
}

.install-steps p {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

#periodDialog {
  width: min(860px, calc(100% - 24px));
  max-height: min(680px, calc(100svh - 24px));
  max-height: min(680px, calc(100dvh - 24px));
  overflow-x: hidden;
  overflow-y: auto;
}
.period-modal {
  min-height: 0;
  background: #fff;
}
.period-head {
  align-items: flex-start;
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
#periodDialog .period-head {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px 36px;
  gap: 8px;
}
.period-title-block {
  min-width: 0;
  text-align: center;
}
.period-head h2 { margin: 0; font-size: 18px; line-height: 1.2; }
.period-head span { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; }
.period-head .period-summary {
  justify-content: center;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.period-summary .profit {
  color: var(--brand-strong);
}
.period-summary .cost {
  color: var(--danger);
}
.period-nav,
.period-close { width: 36px; height: 36px; min-height: 36px; padding: 0; border-radius: 50%; }
.period-nav {
  display: grid;
  place-items: center;
  font-size: 18px;
  line-height: 1;
}
.period-nav.is-hidden {
  visibility: hidden;
  pointer-events: none;
}
.period-charts {
  padding: 12px 16px 0;
}
.period-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.period-chart-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
}
.period-chart-card h3 {
  margin: 0 0 10px;
  font-size: 16px;
  line-height: 1.2;
}
.period-chart-body {
  display: grid;
  justify-items: center;
  gap: 12px;
}
.pie-chart {
  width: 144px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--chart-background, #d9e1dc);
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(23, 32, 27, .08);
}
.pie-chart-total {
  width: 106px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--panel);
  display: grid;
  place-items: center;
  padding: 8px;
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 0 0 1px var(--line);
}
.pie-chart-total.cost {
  color: var(--danger);
}
.chart-legend {
  width: 100%;
  border-collapse: collapse;
}
.chart-legend td {
  padding: 5px 0;
  border-top: 1px solid #edf1ee;
  font-size: 12px;
  line-height: 1.25;
  vertical-align: middle;
}
.chart-legend tr.is-selected td {
  position: relative;
  background: #edf8f2;
  box-shadow: inset 0 1px 0 #c9e7d7, inset 0 -1px 0 #c9e7d7;
}
.chart-legend tr.is-selected td:first-child {
  box-shadow: inset 0 1px 0 #c9e7d7, inset 0 -1px 0 #c9e7d7;
}
.chart-legend tr.is-selected td:first-child::before {
  content: "";
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: -8px;
  width: 8px;
  background: #edf8f2;
  box-shadow: inset 4px 0 0 var(--brand), inset 0 1px 0 #c9e7d7, inset 0 -1px 0 #c9e7d7;
}
.chart-legend tr.is-selected .chart-name {
  color: var(--brand-strong);
}
.chart-legend tr.is-selected .chart-dot {
  box-shadow: 0 0 0 3px rgba(14, 122, 79, .14);
}
.chart-legend .chart-breakdown-row td {
  padding-top: 4px;
  padding-bottom: 4px;
  background: #f7faf8;
  border-top-color: #e3ece7;
}
.chart-legend .chart-breakdown-row td:first-child {
  padding-left: 17px;
}
.chart-legend .chart-breakdown-row.is-selected td {
  background: #e8f4ee;
}
.chart-breakdown-button {
  min-height: 26px;
  padding-top: 2px;
  padding-bottom: 2px;
}
.chart-breakdown-button .chart-name {
  font-weight: 600;
}
.chart-filter-button {
  width: 100%;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 3px 5px 3px 0;
  text-align: left;
  font: inherit;
}
.chart-filter-button:hover,
.chart-filter-button:focus {
  background: #f4f7f5;
  outline: none;
}
.chart-filter-button:focus-visible {
  box-shadow: 0 0 0 3px rgba(14, 122, 79, .18);
}
.chart-filter-button .chart-dot {
  flex: 0 0 auto;
  margin-right: 0;
}
.chart-filter-button .chart-name {
  min-width: 0;
  overflow-wrap: anywhere;
}
.chart-legend td:nth-child(2),
.chart-legend td:nth-child(3) {
  text-align: right;
  white-space: nowrap;
}
.chart-legend td:nth-child(2) {
  width: 48px;
  color: var(--muted);
}
.chart-legend td:nth-child(3) {
  width: 90px;
  font-weight: 700;
}
.chart-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--dot-color);
  vertical-align: -1px;
}
.chart-name {
  font-weight: 700;
}
.period-chart-empty {
  width: 100%;
  margin: 0;
  padding: 10px 0 2px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.period-list {
  padding: 12px 16px 16px;
  display: block;
}
.period-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: start;
  gap: 10px;
  margin: 0 0 10px;
  padding: 12px;
  overflow: visible;
}
.period-item:last-child { margin-bottom: 0; }
.period-item-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: start;
  justify-content: stretch;
  gap: 10px;
}
.period-main { min-width: 0; flex: 1 1 auto; }
.period-side {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.period-category {
  display: block;
  font-size: 14px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.period-amount {
  flex: 0 0 auto;
  max-width: 160px;
  line-height: 1.3;
  text-align: right;
  white-space: nowrap;
  overflow-wrap: anywhere;
  color: var(--brand-strong);
}
.period-meta, .period-desc { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.period-desc {
  color: var(--ink);
}
.period-actions {
  justify-content: flex-end;
  margin-top: 0;
}
.period-actions button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
}
.period-user {
  display: inline;
}
.period-meta-icon {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 4px;
  vertical-align: -2px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.period-desc-row {
  margin-top: 5px;
}
.period-desc-row .period-desc { margin-top: 0; }
.period-note {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
  margin-left: 6px;
}
.period-note-button {
  width: 30px;
  height: 30px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 999px;
  color: var(--brand-strong);
  background: #f7faf8;
}
.period-note-button:hover,
.period-note-button:focus {
  border-color: #aac9ba;
  box-shadow: 0 0 0 3px rgba(14, 122, 79, .08);
  outline: none;
}
.period-note-icon,
.period-tooltip-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.period-tooltip {
  display: none;
  position: fixed;
  top: var(--tooltip-top, 80px);
  left: var(--tooltip-left, 16px);
  z-index: 80;
  width: var(--tooltip-width, min(360px, calc(100vw - 32px)));
  max-height: min(320px, calc(100dvh - 160px));
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(22, 38, 29, .18);
  color: var(--ink);
  text-align: left;
}
.period-note.is-open .period-tooltip {
  display: block;
}
.period-tooltip-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  margin-bottom: 5px;
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 700;
}
.period-tooltip-title .period-tooltip-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}
.period-tooltip p {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.period-tooltip p + .period-tooltip-title {
  margin-top: 10px;
}

@media (max-width: 719px) {
  .period-chart-grid {
    grid-template-columns: 1fr;
  }

  .pie-chart {
    width: 132px;
  }

  .period-tooltip {
    left: 16px;
    right: 16px;
    bottom: auto;
    width: auto;
    max-height: min(60dvh, calc(100dvh - var(--tooltip-top, 80px) - 16px));
    z-index: 60;
  }
}

@media (max-width: 390px) and (max-height: 670px) {
  .summary-title,
  .summary-grid {
    display: none;
  }

  header {
    padding-bottom: 10px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .period-note:not(.is-suppressed):hover .period-tooltip {
    display: block;
  }
}

.toast {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 154px;
  transform: translateX(-50%);
  width: min(440px, calc(100% - 24px));
  background: #17201b;
  color: #fff;
  border-radius: 8px;
  padding: 11px 13px;
  font-size: 14px;
  z-index: 30;
  box-shadow: var(--shadow);
}
.toast.show { display: block; }

@media (min-width: 720px) {
  body { padding: 24px 0; }
  .phone {
    width: min(760px, calc(100% - 32px));
    max-width: 760px;
    min-height: calc(100svh - 48px);
    border: 1px solid var(--line);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: var(--shadow);
  }
  .composer {
    width: min(760px, calc(100% - 32px));
    border: 1px solid var(--line);
    border-radius: 16px;
    bottom: 24px;
  }
  .recorder-panel {
    width: min(760px, calc(100% - 32px));
  }
  .bubble { max-width: min(680px, 92%); }
}
