:root {
  --ink:#20313b;
  --muted:#778791;
  --line:#e1e8ec;
  --soft:#f4f7f9;
  --surface:#ffffff;
  --primary:#3d6276;
  --primary-soft:#eaf1f5;
  --positive:#18875a;
  --positive-soft:#eaf7f1;
  --negative:#c34842;
  --negative-soft:#fbefee;
  --shadow:0 1px 2px rgba(15,23,42,.035),0 16px 42px rgba(15,23,42,.055);
  --radius:20px;
}

* { box-sizing:border-box; }

html {
  min-height:100%;
  background:#f7f9fa;
}

body {
  min-height:100vh;
  margin:0;
  background:
    radial-gradient(circle at 12% 0%,rgba(61,98,118,.055),transparent 25rem),
    #f7f9fa;
  color:var(--ink);
  font-family:Inter,ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
  -webkit-font-smoothing:antialiased;
}

button,textarea { font:inherit; }

button { -webkit-tap-highlight-color:transparent; }

.app-shell {
  width:min(100%,980px);
  min-height:100vh;
  margin:0 auto;
  padding:
    max(18px,env(safe-area-inset-top))
    max(18px,env(safe-area-inset-right))
    max(24px,env(safe-area-inset-bottom))
    max(18px,env(safe-area-inset-left));
}

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

.brand {
  display:flex;
  align-items:center;
  gap:11px;
  min-width:0;
}

.brand-mark {
  width:42px;
  height:42px;
  flex:0 0 42px;
  display:grid;
  place-items:center;
  border:1px solid #d6e0e6;
  border-radius:13px;
  background:#fff;
  color:var(--primary);
  box-shadow:0 5px 14px rgba(15,23,42,.04);
}

.brand-mark svg {
  width:27px;
  height:27px;
}

.brand-name {
  color:#263a45;
  font-size:15px;
  font-weight:820;
  letter-spacing:-.015em;
}

.brand-sub {
  margin-top:2px;
  color:#8b979f;
  font-size:9.5px;
}

.top-actions {
  display:flex;
  align-items:center;
  gap:8px;
}

.icon-button {
  width:36px;
  height:36px;
  display:grid;
  place-items:center;
  padding:0;
  border:1px solid var(--line);
  border-radius:11px;
  background:#fff;
  color:#62757f;
  cursor:pointer;
}

.icon-button svg { width:17px;height:17px; }

.status-pill {
  display:inline-flex;
  align-items:center;
  gap:7px;
  min-height:36px;
  padding:0 11px;
  border:1px solid var(--line);
  border-radius:999px;
  background:#fff;
  color:#6b7c86;
  font-size:9.5px;
  font-weight:760;
  white-space:nowrap;
}

.status-dot {
  width:7px;
  height:7px;
  border-radius:50%;
  background:#a4b0b7;
}

.status-pill.ready .status-dot {
  background:var(--positive);
  box-shadow:0 0 0 3px rgba(24,135,90,.10);
}

.status-pill.error .status-dot {
  background:var(--negative);
}

.hero {
  display:grid;
  grid-template-columns:minmax(0,1.25fr) minmax(300px,.75fr);
  gap:28px;
  align-items:end;
  margin-bottom:20px;
}

.eyebrow {
  margin:0 0 8px;
  color:#80909a;
  font-size:9px;
  font-weight:820;
  letter-spacing:.12em;
}

.hero h1 {
  max-width:650px;
  margin:0;
  color:#20313b;
  font-size:clamp(28px,4vw,43px);
  line-height:1.05;
  font-weight:840;
  letter-spacing:-.04em;
}

.hero-copy {
  max-width:620px;
  margin:11px 0 0;
  color:#788993;
  font-size:12px;
  line-height:1.55;
}

.quick-grid {
  display:grid;
  gap:9px;
}

.quick-card {
  width:100%;
  display:flex;
  align-items:center;
  gap:11px;
  padding:12px;
  border:1px solid var(--line);
  border-radius:14px;
  background:rgba(255,255,255,.86);
  color:#334650;
  text-align:left;
  cursor:pointer;
  box-shadow:0 3px 12px rgba(15,23,42,.025);
  transition:.15s ease;
}

.quick-card:hover {
  transform:translateY(-1px);
  border-color:#ccd8df;
  background:#fff;
}

.quick-card strong {
  display:block;
  font-size:10.5px;
  font-weight:800;
}

.quick-card small {
  display:block;
  margin-top:3px;
  color:#93a0a8;
  font-size:8.7px;
}

.quick-icon {
  width:31px;
  height:31px;
  flex:0 0 31px;
  display:grid;
  place-items:center;
  border-radius:10px;
  font-size:18px;
  font-weight:600;
}

.quick-icon.expense {
  background:var(--negative-soft);
  color:var(--negative);
}

.quick-icon.income {
  background:var(--positive-soft);
  color:var(--positive);
}

.chat-card {
  overflow:hidden;
  border:1px solid var(--line);
  border-radius:var(--radius);
  background:#fff;
  box-shadow:var(--shadow);
}

.chat-head {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding:15px 17px;
  border-bottom:1px solid #edf1f3;
  background:linear-gradient(180deg,#fff,#fbfcfd);
}

.chat-title {
  color:#334650;
  font-size:12px;
  font-weight:810;
}

.chat-note {
  margin-top:2px;
  color:#909ca4;
  font-size:8.8px;
}

.text-button {
  min-height:31px;
  padding:0 9px;
  border:1px solid #dce5ea;
  border-radius:9px;
  background:#fff;
  color:#687983;
  font-size:9px;
  font-weight:760;
  cursor:pointer;
}

.chat {
  min-height:410px;
  max-height:56vh;
  overflow-y:auto;
  overscroll-behavior:contain;
  padding:20px;
  background:
    radial-gradient(circle at 12% 5%,rgba(61,98,118,.032),transparent 22rem),
    #fff;
  scroll-behavior:smooth;
}

.welcome-card {
  display:flex;
  gap:11px;
  width:min(100%,620px);
  margin:3px 0 18px;
  padding:15px;
  border:1px solid #e5ebef;
  border-radius:15px;
  background:#f8fafb;
}

.welcome-badge {
  width:30px;
  height:30px;
  flex:0 0 30px;
  display:grid;
  place-items:center;
  border-radius:9px;
  background:var(--primary-soft);
  color:var(--primary);
  font-size:8px;
  font-weight:850;
  letter-spacing:.05em;
}

.welcome-card strong {
  color:#344852;
  font-size:11.5px;
  font-weight:800;
}

.welcome-card p {
  margin:4px 0 0;
  color:#84929a;
  font-size:9.7px;
  line-height:1.5;
}

.message-row {
  display:flex;
  width:100%;
  margin:0 0 14px;
}

.message-row.user { justify-content:flex-end; }

.message {
  width:fit-content;
  max-width:min(80%,690px);
  padding:10px 12px;
  border:1px solid #e5ebef;
  border-radius:14px 14px 14px 5px;
  background:#f8fafb;
  color:#344650;
  font-size:11.5px;
  line-height:1.5;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
}

.message-row.user .message {
  border-color:#d7e2e8;
  border-radius:14px 14px 5px 14px;
  background:#edf3f6;
  color:#304753;
}

.message-row.system .message {
  max-width:100%;
  border-style:dashed;
  color:#71818b;
  font-size:10px;
}

.typing {
  display:inline-flex;
  align-items:center;
  gap:4px;
  min-height:14px;
}

.typing i {
  width:5px;
  height:5px;
  border-radius:50%;
  background:#91a0a8;
  animation:typing 1s ease-in-out infinite;
}

.typing i:nth-child(2){ animation-delay:.14s; }
.typing i:nth-child(3){ animation-delay:.28s; }

@keyframes typing {
  0%,60%,100% { transform:translateY(0);opacity:.45; }
  30% { transform:translateY(-3px);opacity:1; }
}

.proposal {
  width:min(100%,620px);
  margin:3px 0 16px;
  overflow:hidden;
  border:1px solid #dfe7eb;
  border-radius:16px;
  background:#fff;
  box-shadow:0 8px 25px rgba(15,23,42,.045);
}

.proposal-head {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding:13px 14px;
  border-bottom:1px solid #edf1f3;
  background:#fbfcfd;
}

.proposal-kicker {
  color:#8a979f;
  font-size:7.8px;
  font-weight:800;
  letter-spacing:.08em;
  text-transform:uppercase;
}

.proposal-desc {
  margin-top:3px;
  color:#314650;
  font-size:12px;
  font-weight:810;
}

.proposal-value {
  font-size:16px;
  font-weight:830;
  white-space:nowrap;
}

.proposal-value.expense { color:var(--negative); }
.proposal-value.income { color:var(--positive); }

.proposal-grid {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:1px;
  background:#edf1f3;
  border-bottom:1px solid #edf1f3;
}

.proposal-field {
  min-width:0;
  padding:10px 11px;
  background:#fff;
}

.proposal-label {
  color:#98a3aa;
  font-size:7.4px;
  font-weight:770;
  letter-spacing:.035em;
  text-transform:uppercase;
}

.proposal-data {
  margin-top:3px;
  overflow:hidden;
  color:#445761;
  font-size:9.8px;
  font-weight:730;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.proposal-actions {
  display:flex;
  justify-content:flex-end;
  gap:8px;
  padding:11px 12px;
}

.action-button {
  min-height:34px;
  padding:0 11px;
  border:1px solid #dce5ea;
  border-radius:10px;
  background:#fff;
  color:#687983;
  font-size:9.5px;
  font-weight:780;
  cursor:pointer;
}

.action-button.primary {
  border-color:#3d6276;
  background:#3d6276;
  color:#fff;
}

.action-button:disabled {
  opacity:.58;
  cursor:default;
}

.confirmed {
  width:100%;
  color:#287c5e;
  font-size:10px;
  font-weight:790;
  text-align:right;
}

.composer-wrap {
  padding:
    12px 14px
    max(13px,env(safe-area-inset-bottom));
  border-top:1px solid #edf1f3;
  background:#fbfcfd;
}

.composer {
  display:grid;
  grid-template-columns:40px minmax(0,1fr) 40px;
  gap:8px;
  align-items:end;
  padding:7px;
  border:1px solid #dbe4e9;
  border-radius:16px;
  background:#fff;
  box-shadow:0 2px 8px rgba(15,23,42,.025);
}

.composer:focus-within {
  border-color:#b9cbd5;
  box-shadow:0 0 0 3px rgba(61,98,118,.06);
}

.composer-action,
.send-button {
  width:40px;
  height:40px;
  display:grid;
  place-items:center;
  padding:0;
  border:0;
  border-radius:12px;
  cursor:pointer;
}

.composer-action {
  background:#f1f5f7;
  color:#687c87;
}

.composer-action.listening {
  background:var(--negative-soft);
  color:var(--negative);
  animation:pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% { box-shadow:0 0 0 5px rgba(195,72,66,.08); }
}

.send-button {
  background:var(--primary);
  color:#fff;
}

.composer-action svg,
.send-button svg {
  width:19px;
  height:19px;
}

.composer-action:disabled,
.send-button:disabled {
  opacity:.45;
  cursor:default;
}

textarea {
  width:100%;
  min-height:40px;
  max-height:116px;
  resize:none;
  overflow-y:auto;
  padding:10px 4px 7px;
  border:0;
  outline:0;
  background:transparent;
  color:#30434d;
  font-size:11.5px;
  line-height:1.45;
}

textarea::placeholder { color:#a0abb2; }

.composer-foot {
  display:flex;
  justify-content:space-between;
  gap:12px;
  padding:6px 3px 0;
  color:#a0aab1;
  font-size:7.8px;
}

.toast-stack {
  position:fixed;
  right:max(16px,env(safe-area-inset-right));
  bottom:max(16px,env(safe-area-inset-bottom));
  z-index:100;
  display:grid;
  gap:8px;
  pointer-events:none;
}

.toast {
  max-width:min(330px,calc(100vw - 32px));
  padding:10px 12px;
  border:1px solid #dfe7eb;
  border-radius:11px;
  background:#fff;
  color:#4b5d67;
  font-size:9.5px;
  font-weight:700;
  box-shadow:0 10px 30px rgba(15,23,42,.10);
  animation:toastIn .2s ease;
}

.toast.success { border-color:#d2eadf;color:#287c5e; }
.toast.error { border-color:#f0d8d6;color:#b34a45; }

@keyframes toastIn {
  from { opacity:0;transform:translateY(6px); }
}

@media(max-width:760px) {
  .app-shell {
    padding:
      max(14px,env(safe-area-inset-top))
      max(12px,env(safe-area-inset-right))
      max(16px,env(safe-area-inset-bottom))
      max(12px,env(safe-area-inset-left));
  }

  .brand-sub { display:none; }

  .status-pill {
    max-width:140px;
    overflow:hidden;
    text-overflow:ellipsis;
  }

  .hero {
    grid-template-columns:1fr;
    gap:15px;
    margin-bottom:15px;
  }

  .hero h1 {
    font-size:30px;
  }

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

  .quick-card {
    align-items:flex-start;
    padding:10px;
  }

  .quick-card small { display:none; }

  .chat {
    min-height:48vh;
    max-height:none;
    padding:14px 12px;
  }

  .chat-card {
    border-radius:17px;
  }

  .message {
    max-width:88%;
    font-size:11.5px;
  }

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

  .composer-foot span:last-child { display:none; }
}

@media(max-width:420px) {
  .topbar { margin-bottom:22px; }

  .brand-mark {
    width:38px;
    height:38px;
    flex-basis:38px;
  }

  .status-pill {
    min-height:32px;
    padding:0 9px;
    font-size:8.5px;
  }

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

  .quick-card strong { font-size:9.4px; }

  .chat-head { padding:13px 12px; }

  .chat-note { display:none; }

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

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