:root {
  --bg: #0e1619;
  --bg-2: #152025;
  --surface: #1a262c;
  --surface-2: #213038;
  --ink: #e8eef1;
  --muted: #8aa0ab;
  --line: rgba(232, 238, 241, 0.1);
  --accent: #3d9bb0;
  --accent-2: #2a7a8c;
  --accent-soft: rgba(61, 155, 176, 0.16);
  --danger: #d07060;
  --ok: #6bb89a;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --radius: 20px;
  --radius-sm: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Instrument Serif", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 70% 50% at 50% -10%, rgba(61, 155, 176, 0.22), transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 80%, rgba(42, 122, 140, 0.12), transparent 50%),
    linear-gradient(180deg, #101a1e 0%, var(--bg) 40%, #0b1215 100%);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

#app { min-height: 100dvh; }

.shell {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 18px 56px;
}

/* Login */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.login-card {
  width: min(100%, 380px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow);
  animation: rise 0.45s ease both;
}
.login-card h1 {
  font-family: var(--display);
  font-size: 2.4rem;
  font-weight: 400;
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}
.login-card h1 em {
  font-style: italic;
  color: var(--accent);
}
.login-card > p {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 0.95rem;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.input, select.input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease;
}
.input:focus {
  border-color: rgba(61, 155, 176, 0.55);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 12px 18px;
  transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: #061216;
  width: 100%;
}
.btn-primary:hover { background: #4aadbf; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.btn-ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn-danger {
  background: rgba(208, 112, 96, 0.18);
  color: var(--danger);
}
.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.btn-row .btn { flex: 1; }

/* Top */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.brand {
  font-family: var(--display);
  font-size: clamp(2rem, 7vw, 2.6rem);
  font-weight: 400;
  letter-spacing: -0.03em;
  margin: 0;
  line-height: 1.05;
}
.brand em {
  font-style: italic;
  color: var(--accent);
}
.top-meta {
  text-align: right;
  font-size: 0.82rem;
  color: var(--muted);
  padding-top: 8px;
}
.top-meta button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-top: 2px;
}

.tagline {
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 0.98rem;
}

/* Mic hero */
.mic-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 12px 0 28px;
  animation: rise 0.5s ease both;
}
.mic-btn {
  position: relative;
  width: 148px;
  height: 148px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  background: linear-gradient(160deg, #2a7a8c 0%, #1a4f5c 100%);
  color: #e8f6f9;
  box-shadow:
    0 0 0 0 rgba(61, 155, 176, 0.35),
    0 18px 40px rgba(0, 0, 0, 0.4);
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.mic-btn svg {
  width: 52px;
  height: 52px;
}
.mic-btn:hover { transform: scale(1.03); }
.mic-btn.listening {
  background: linear-gradient(160deg, #c4785a 0%, #8b4a38 100%);
  animation: pulse-ring 1.4s ease infinite;
}
.mic-btn.processing {
  opacity: 0.85;
  pointer-events: none;
  animation: spin-glow 1.2s linear infinite;
}
.mic-status {
  font-size: 0.95rem;
  color: var(--muted);
  min-height: 1.4em;
  text-align: center;
}
.mic-status strong { color: var(--ink); font-weight: 600; }

.shortcut {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  justify-content: center;
}
.shortcut button {
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.hist-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 0 16px;
}
.hist-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.8rem;
  font-weight: 400;
}
.hist-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.hist-filters .field:nth-child(3),
.hist-filters .btn {
  grid-column: 1 / -1;
}
.hist-total {
  margin-bottom: 14px;
}

/* Confirm / forms */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  animation: rise 0.35s ease both;
}
.panel h2 {
  margin: 0 0 4px;
  font-family: var(--display);
  font-size: 1.65rem;
  font-weight: 400;
}
.panel .hint {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.88rem;
}
.transcript {
  background: var(--bg-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 14px;
  font-style: italic;
}
.conf-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 12px;
}

/* Month section */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 28px 0 14px;
}
.month-nav h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}
.month-nav .nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.1rem;
}

.total-block {
  text-align: center;
  margin-bottom: 18px;
  animation: rise 0.4s ease 0.05s both;
}
.total-block .label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
.total-block .value {
  font-family: var(--display);
  font-size: clamp(2.2rem, 8vw, 2.8rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  margin-top: 2px;
}

.cat-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 22px;
}
.cat-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  align-items: center;
}
.cat-row .name {
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cat-row .amt {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}
.cat-bar {
  grid-column: 1 / -1;
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
}
.cat-bar > i {
  display: block;
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.gasto-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gasto-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  animation: rise 0.35s ease both;
}
.gasto-item .desc {
  font-weight: 600;
  font-size: 0.95rem;
}
.gasto-item .meta {
  font-size: 0.78rem;
  color: var(--muted);
  grid-column: 1;
}
.gasto-item .valor {
  font-weight: 700;
  font-size: 0.95rem;
  align-self: center;
}
.gasto-item .actions {
  grid-column: 2;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
  justify-content: center;
}
.gasto-item .actions button {
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 0;
}
.gasto-item .actions button:hover { color: var(--accent); }
.gasto-item .actions button.del:hover { color: var(--danger); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 24px 12px;
  font-size: 0.92rem;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 12, 14, 0.72);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: end center;
  z-index: 40;
  padding: 16px;
  animation: fade 0.2s ease;
}
.overlay .panel {
  width: min(100%, 440px);
  margin-bottom: env(safe-area-inset-bottom, 0);
  max-height: 90dvh;
  overflow-y: auto;
}

#toast-root {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  pointer-events: none;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: rise 0.25s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(196, 120, 90, 0.5), 0 18px 40px rgba(0,0,0,0.4); }
  70% { box-shadow: 0 0 0 22px rgba(196, 120, 90, 0), 0 18px 40px rgba(0,0,0,0.4); }
  100% { box-shadow: 0 0 0 0 rgba(196, 120, 90, 0), 0 18px 40px rgba(0,0,0,0.4); }
}
@keyframes spin-glow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.25); }
}

@media (min-width: 640px) {
  .overlay { place-items: center; }
}
