:root {
  color-scheme: light;
  --bg: #f5f8f8;
  --surface: #ffffff;
  --surface-soft: #eef4f4;
  --text: #202520;
  --muted: #64706f;
  --line: #d9e4e2;
  --green: #4f8f73;
  --blue: #4f7fa8;
  --violet: #7468a8;
  --red: #a65d55;
  --amber: #a78336;
  --accent-blue-soft: #eaf3fa;
  --accent-green-soft: #eaf6ef;
  --accent-violet-soft: #f0edf8;
  --accent-amber-soft: #f7f0dd;
  --accent-red-soft: #f7e9e6;
  --shadow: 0 16px 45px rgba(26, 44, 50, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
  -webkit-text-size-adjust: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 12px;
  cursor: pointer;
}

button:hover {
  border-color: #b6c9ca;
  background: #fbfdfd;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}

.auth-box {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.auth-brand {
  margin-bottom: 22px;
}

.auth-box h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

.auth-box p {
  color: var(--muted);
  line-height: 1.45;
}

.auth-form {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.auth-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 46px;
  padding: 0 13px;
  font-size: 16px;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 22px 18px;
  background: rgba(251, 253, 253, 0.78);
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
}

.mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #31445b;
  color: white;
  font-weight: 700;
  font-size: 14px;
}

.brand strong {
  display: block;
  font-size: 16px;
}

.brand span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 7px;
}

.nav button {
  text-align: left;
  width: 100%;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.nav button.active {
  background: var(--accent-blue-soft);
  color: var(--text);
  border-color: #c7dce8;
  box-shadow: 0 5px 18px rgba(49, 95, 143, 0.08);
}

main {
  padding: 24px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

h1 {
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.05;
  margin: 0;
  font-weight: 720;
}

.date {
  color: var(--muted);
  margin-top: 6px;
  font-size: 14px;
}

.status {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-green-soft);
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
}

.agent {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.answer {
  min-height: 142px;
  padding: 22px;
  display: grid;
  align-content: start;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--accent-blue-soft);
}

.answer-title {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.answer-body {
  font-size: 19px;
  line-height: 1.45;
  max-width: 980px;
}

.undo-action {
  justify-self: start;
  background: var(--accent-amber-soft);
  border-color: #d9bf7a;
  color: #694a10;
  min-height: 36px;
}

.undo-action:hover {
  background: #fff6df;
  border-color: #c7a95a;
}

.focus-pulse {
  animation: focusPulse 1.35s ease-out;
}

@keyframes focusPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(79, 127, 168, 0.34), var(--shadow);
    border-color: #8bb4d1;
  }
  100% {
    box-shadow: var(--shadow);
    border-color: var(--line);
  }
}

.chief-output {
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfd;
  padding: 16px;
  white-space: pre-wrap;
  line-height: 1.5;
  overflow: auto;
}

.compact-form {
  align-items: end;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  padding: 14px;
  background: #fbfdfd;
}

.composer input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 44px;
  padding: 0 14px;
  background: white;
  outline: none;
  font-size: 16px;
}

.composer input:focus {
  border-color: #9eb9c8;
  box-shadow: 0 0 0 4px rgba(79, 127, 168, 0.13);
}

.voice-button.listening {
  background: var(--accent-red-soft);
  border-color: #d8a39c;
  color: #7b3934;
  animation: voicePulse 1s ease-in-out infinite;
}

@keyframes voicePulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(166, 93, 85, 0.22);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(166, 93, 85, 0.1);
  }
}

.primary {
  background: #31445b;
  color: white;
  border-color: #31445b;
}

.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.quick-actions button:not(.primary):nth-child(4n + 1) {
  background: var(--accent-blue-soft);
}

.quick-actions button:not(.primary):nth-child(4n + 2) {
  background: var(--accent-green-soft);
}

.quick-actions button:not(.primary):nth-child(4n + 3) {
  background: var(--accent-violet-soft);
}

.quick-actions button:not(.primary):nth-child(4n + 4) {
  background: var(--accent-amber-soft);
}

.section-label {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-height: 34px;
}

.section-label span {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.section-label strong {
  font-size: 22px;
}

.form-drawer {
  display: grid;
  gap: 14px;
}

.form-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.data-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.data-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.data-form input,
.data-form select,
.data-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 11px;
  background: white;
  color: var(--text);
  outline: none;
  font-size: 16px;
}

.data-form textarea {
  padding: 10px 11px;
  resize: vertical;
}

.data-form input:focus,
.data-form select:focus,
.data-form textarea:focus {
  border-color: #9eb9c8;
  box-shadow: 0 0 0 4px rgba(79, 127, 168, 0.13);
}

.data-form .wide {
  grid-column: 1 / -1;
}

.form-fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin: 0;
}

.form-fieldset legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
}

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

.data-form .checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}

.data-form .checkbox input {
  width: 18px;
  min-height: 18px;
}

.view {
  display: none;
}

.active-view {
  display: grid;
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid #d7e6ee;
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
}

.panel:nth-child(4n + 1) {
  border-top-color: #cfe8dc;
}

.panel:nth-child(4n + 2) {
  border-top-color: #d7e6ee;
}

.panel:nth-child(4n + 3) {
  border-top-color: #e5dff2;
}

.panel:nth-child(4n + 4) {
  border-top-color: #efe3be;
}

.span-3 {
  grid-column: span 3;
}

.span-4 {
  grid-column: span 4;
}

.span-5 {
  grid-column: span 5;
}

.span-6 {
  grid-column: span 6;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: span 12;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

h2 {
  font-size: 15px;
  margin: 0;
}

.metric {
  display: grid;
  gap: 5px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.panel:nth-child(4n + 1) .metric {
  background: var(--accent-green-soft);
}

.panel:nth-child(4n + 2) .metric {
  background: var(--accent-blue-soft);
}

.panel:nth-child(4n + 3) .metric {
  background: var(--accent-violet-soft);
}

.panel:nth-child(4n + 4) .metric {
  background: var(--accent-amber-soft);
}

.metric strong {
  font-size: 25px;
  line-height: 1.1;
}

.metric span,
.small {
  color: var(--muted);
  font-size: 13px;
}

.list {
  display: grid;
  gap: 10px;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  min-height: 42px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.row:first-child {
  border-top: 0;
  padding-top: 0;
}

.row strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}

.tag {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  background: var(--accent-blue-soft);
  color: var(--blue);
  white-space: nowrap;
}

.tag.green {
  background: var(--accent-green-soft);
  color: var(--green);
}

.tag.red {
  background: var(--accent-red-soft);
  color: var(--red);
}

.tag.amber {
  background: var(--accent-amber-soft);
  color: var(--amber);
}

.money {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.money.positive {
  color: var(--green);
}

.money.negative {
  color: var(--red);
}

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

.event {
  padding: 12px;
  background: var(--accent-violet-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.event strong {
  display: block;
  margin-bottom: 4px;
}

.event p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
  font-size: 14px;
}

.client-button {
  text-align: left;
  min-height: 54px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  background: #fcfefd;
}

.client-button:hover {
  background: var(--accent-green-soft);
}

.client-button strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-empty {
  color: var(--muted);
  min-height: 220px;
  display: grid;
  place-items: center;
  text-align: center;
  background: var(--accent-blue-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.detail-metric {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 4px;
}

.detail-metric:nth-child(4n + 1) {
  background: var(--accent-green-soft);
}

.detail-metric:nth-child(4n + 2) {
  background: var(--accent-blue-soft);
}

.detail-metric:nth-child(4n + 3) {
  background: var(--accent-violet-soft);
}

.detail-metric:nth-child(4n + 4) {
  background: var(--accent-amber-soft);
}

.detail-metric span {
  color: var(--muted);
  font-size: 12px;
}

.detail-metric strong {
  font-size: 17px;
}

.detail-section {
  margin-top: 14px;
}

.detail-section h3 {
  font-size: 14px;
  margin: 0 0 8px;
}

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

.annual-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.annual-card-empty {
  background: var(--surface-soft);
  border-style: dashed;
}

.annual-head,
.annual-foot,
.annual-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.annual-numbers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.annual-numbers div {
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 8px;
  display: grid;
  gap: 2px;
}

.annual-numbers span,
.annual-card p {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.annual-numbers strong {
  font-size: 14px;
}

.annual-card strong.green {
  color: var(--green);
}

.annual-card strong.red {
  color: var(--red);
}

.client-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 4px;
}

.client-actions button {
  min-height: 38px;
  padding: 0 12px;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.filter-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.filter-row select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  background: white;
  color: var(--text);
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin: 14px 0;
}

.inline-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.inline-form input {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  background: white;
  color: var(--text);
  font-size: 16px;
}

.profit-row {
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.profit-row[open] {
  background: #fbfdfd;
  border-radius: 8px;
  padding: 10px;
}

.profit-row:first-child {
  border-top: 0;
}

.profit-row summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  list-style: none;
}

.profit-row summary::-webkit-details-marker {
  display: none;
}

.profit-row summary strong,
.profit-row summary .small {
  display: block;
}

.profit-detail {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

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

.profit-columns h3 {
  font-size: 14px;
  margin: 0 0 8px;
}

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

.reconcile-grid section {
  display: grid;
  align-content: start;
  gap: 10px;
}

.mini-head {
  margin-bottom: 0;
}

.mini-head h3 {
  margin: 0;
  font-size: 15px;
}

.row.compact {
  min-height: 34px;
  padding-top: 7px;
}

.statement-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
}

.bank-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.bank-row-side,
.bank-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.bank-row-side .money {
  min-width: 104px;
  text-align: right;
}

.import-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}

.import-actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.file-picker {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.file-picker input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: white;
  color: var(--text);
}

.import-preview {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

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

.import-metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--accent-blue-soft);
  display: grid;
  gap: 4px;
}

.import-metrics div:nth-child(4n + 1) {
  background: var(--accent-blue-soft);
}

.import-metrics div:nth-child(4n + 2) {
  background: var(--accent-green-soft);
}

.import-metrics div:nth-child(4n + 3) {
  background: var(--accent-violet-soft);
}

.import-metrics div:nth-child(4n + 4) {
  background: var(--accent-amber-soft);
}

.import-metrics span {
  color: var(--muted);
  font-size: 12px;
}

.import-metrics strong {
  font-size: 18px;
}

.import-clients {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.import-warnings {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.45;
}

.import-samples {
  display: grid;
  gap: 8px;
}

.import-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  font-size: 14px;
}

.import-row span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .nav button {
    text-align: center;
    padding: 0 8px;
  }

  main {
    padding: 18px;
  }

  .span-3,
  .span-4,
  .span-5,
  .span-6,
  .span-8 {
    grid-column: span 6;
  }

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

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

  .import-actions-row {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body {
    background: var(--bg);
  }

  .app {
    padding-bottom: 78px;
  }

  .sidebar {
    padding: 14px 14px 10px;
    background: var(--surface);
  }

  .brand {
    margin-bottom: 12px;
  }

  .brand span {
    display: none;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  h1 {
    font-size: 28px;
  }

  main {
    padding: 14px;
    gap: 14px;
  }

  .status {
    width: 100%;
    justify-content: center;
  }

  .nav {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 20;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(251, 253, 253, 0.96);
    box-shadow: 0 16px 40px rgba(26, 32, 28, 0.14);
    backdrop-filter: blur(16px);
  }

  .nav button {
    min-height: 42px;
    font-size: 13px;
    border-radius: 8px;
  }

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

  .answer {
    min-height: 120px;
    padding: 16px;
  }

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

  .quick-actions button {
    min-height: 44px;
  }

  .panel,
  .form-panel {
    padding: 14px;
  }

  .metric strong {
    font-size: 22px;
  }

  .span-3,
  .span-4,
  .span-5,
  .span-6,
  .span-8 {
    grid-column: span 12;
  }

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

  .data-form {
    grid-template-columns: 1fr;
  }

  .filter-row,
  .inline-form,
  .profit-columns,
  .reconcile-grid,
  .service-grid {
    grid-template-columns: 1fr;
  }

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

  .import-row {
    grid-template-columns: 1fr;
  }

  .data-form button[type="submit"] {
    min-height: 46px;
  }

  .answer-body {
    font-size: 17px;
  }
}
