:root {
  --bg: #f2efe7;
  --paper: #fbfaf6;
  --ink: #18231c;
  --muted: #6c746e;
  --line: #d9d4c8;
  --green: #173f2b;
  --green-2: #2b6245;
  --green-soft: #e4eee7;
  --gold: #a98442;
  --red: #973e36;
  --red-soft: #f3e6e3;
  --shadow: 0 14px 36px rgba(31, 40, 34, .07);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  background:
    radial-gradient(circle at 12% -10%, rgba(169, 132, 66, .09), transparent 34rem),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.shell { max-width: 1420px; margin: 0 auto; padding: 30px; }
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  border-bottom: 1px solid var(--line); padding-bottom: 20px; margin-bottom: 18px;
}
.eyebrow, .section-kicker, .voice-kicker, .agent-label {
  color: var(--gold); font-size: 11px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase;
}
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; }
h1 { margin: 5px 0 2px; font-size: clamp(30px, 4vw, 42px); letter-spacing: -.035em; }
h2 { margin: 3px 0 0; font-size: 22px; }
h3 { margin: 4px 0 0; font-size: 27px; }
.subtitle { color: var(--muted); margin: 6px 0 0; font-size: 13px; }
.controls { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
input, select, button.ghost, button.primary, .command-send {
  border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); padding: 10px 12px;
}
button.primary, .command-send { background: var(--green); color: white; border-color: var(--green); font-weight: 750; }
button.primary:hover, .command-send:hover { background: #0f3523; }
button.ghost:hover { background: #efebe2; }

.card {
  background: rgba(251, 250, 246, .96); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow);
}

.voice-card {
  margin: 0 0 18px; padding: 16px 18px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px 20px;
  border-color: #cfc5ad;
}
.voice-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.mic-button {
  width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--green); color: white;
  display: grid; place-items: center; box-shadow: 0 7px 18px rgba(23, 63, 43, .22); flex: 0 0 auto;
}
.mic-button:hover { transform: translateY(-1px); }
.mic-button.recording { background: var(--red); animation: pulse 1.4s infinite; }
.mic-icon { width: 14px; height: 20px; border: 2px solid currentColor; border-radius: 10px; background: transparent; position: relative; color: white; font-size: 0; }
.mic-icon::after { content: ""; position: absolute; width: 22px; height: 12px; border: 2px solid white; border-top: 0; border-radius: 0 0 14px 14px; left: 50%; top: 11px; transform: translateX(-50%); }
.mic-icon::before { content: ""; position: absolute; width: 2px; height: 7px; background: white; left: 50%; top: 22px; transform: translateX(-50%); }
@keyframes pulse { 0%,100%{box-shadow:0 0 0 0 rgba(151,62,54,.15)} 50%{box-shadow:0 0 0 10px rgba(151,62,54,0)} }
.voice-title { font-family: Georgia, serif; font-size: 20px; margin-top: 2px; }
.voice-hint { color: var(--muted); font-size: 12px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 900px; }
.voice-status-wrap { display: flex; gap: 7px; align-items: center; font-size: 12px; color: var(--muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #718078; }
.status-dot.busy { background: var(--gold); }
.status-dot.live { background: var(--red); }
.status-dot.ok { background: var(--green-2); }
.status-dot.error { background: var(--red); }
.command-row { grid-column: 1/-1; display: flex; gap: 8px; }
.command-row input { flex: 1; min-width: 0; background: #fff; }
.command-send { min-width: 105px; }
.agent-result {
  grid-column: 1/-1; display: flex; justify-content: space-between; align-items: flex-start; gap: 18px;
  padding-top: 12px; border-top: 1px solid var(--line);
}
.agent-transcript { font-size: 14px; margin-top: 3px; }
.agent-right { color: var(--green-2); font-size: 13px; text-align: right; }
.link-button { border: 0; background: transparent; color: var(--red); font-weight: 700; padding: 4px 0 0 8px; }
.hidden { display: none !important; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.metric-card { padding: 18px; }
.metric-label { font-size: 11px; text-transform: uppercase; letter-spacing: .11em; color: var(--muted); font-weight: 800; }
.metric-value { font-family: Georgia, serif; font-size: 30px; margin-top: 7px; font-variant-numeric: tabular-nums; }
.metric-note { font-size: 12px; color: var(--muted); margin-top: 5px; }
.positive { color: var(--green-2); }
.negative { color: var(--red); }

.section-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .55fr); gap: 18px; margin-top: 18px; align-items: start; }
.ledger-card { padding: 18px; }
.side-column { display: grid; gap: 18px; }
.side-column > .card { padding: 18px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 8px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .09em; border-bottom: 1px solid var(--line); }
td { padding: 12px 8px; border-bottom: 1px solid #ebe7dd; font-size: 13px; vertical-align: middle; }
.right, td.amount { text-align: right; }
td.amount { font-weight: 800; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; padding: 4px 8px; border-radius: 999px; background: #ece8de; color: #4f574f; font-size: 11px; white-space: nowrap; }
.pill-income { background: var(--green-soft); color: var(--green-2); }
.pill-expense { background: var(--red-soft); color: var(--red); }
.delete { border: 0; background: transparent; color: var(--red); font-size: 11px; padding: 4px; }
.empty { text-align: center; color: var(--muted); padding: 32px 10px; }

.bar-row { margin: 14px 0; }
.bar-head { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; margin-bottom: 6px; }
.bar { height: 8px; background: #e7e2d7; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--green); border-radius: inherit; }
.aside-line, .config-row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid #ebe7dd; font-size: 13px; }
.aside-line:last-child, .config-row:last-child { border-bottom: 0; }
.aside-key, .config-row span { color: var(--muted); }
.compact-card strong { font-size: 12px; }
footer { margin: 19px 0 4px; color: var(--muted); text-align: center; font-size: 11px; }

/* Dialog */
dialog { border: 0; border-radius: 15px; padding: 0; width: min(520px, calc(100% - 28px)); box-shadow: 0 28px 80px rgba(10, 18, 13, .28); }
dialog::backdrop { background: rgba(16, 24, 19, .46); backdrop-filter: blur(2px); }
.modal { padding: 22px; background: var(--paper); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.icon-button { border: 0; background: transparent; font-size: 28px; color: var(--muted); line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 750; }
.form-grid .wide { grid-column: 1/-1; }
.form-grid input, .form-grid select { background: white; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

@media (max-width: 940px) {
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .section-grid { grid-template-columns: 1fr; }
  .voice-hint { white-space: normal; }
}
@media (max-width: 670px) {
  .shell { padding: 16px; }
  .topbar { flex-direction: column; align-items: stretch; }
  .controls { justify-content: stretch; }
  .controls > * { flex: 1; }
  .voice-card { grid-template-columns: 1fr; }
  .voice-status-wrap { justify-self: start; }
  .command-row { grid-column: 1; }
  .agent-result { grid-column: 1; flex-direction: column; }
  .agent-right { text-align: left; }
  .metrics-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  th:nth-child(4), td:nth-child(4) { display: none; }
}
