* { box-sizing: border-box; }
:root { color-scheme: light; font-family: Inter, "Segoe UI", sans-serif; color: #172a23; background: #f3f7f4; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
header { border-bottom: 1px solid #d7e2da; background: #fff; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 16px clamp(16px, 5vw, 64px); }
header img { object-fit: contain; }
.brand { display: flex; align-items: center; gap: 9px; border-left: 1px solid #d7e2da; padding-left: 16px; font-weight: 650; }
.brand svg { width: 22px; height: 22px; color: #166b47; }
.status { margin: 0 0 0 auto; color: #345348; font-size: .875rem; }
main { width: min(100% - 32px, 850px); margin: 40px auto auto; }
h1 { margin: 0; font-size: clamp(1.55rem, 4vw, 2.25rem); letter-spacing: -.03em; }
.subtitle, footer { color: #465e53; }
#messages { margin: 24px 0; display: grid; gap: 12px; }
#messages p { margin: 0; padding: 14px 16px; background: white; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
#messages [data-role="user"] { background: #dcefe4; justify-self: end; max-width: 90%; }
form { background: white; padding: 18px; border: 1px solid #d7e2da; border-radius: 14px; }
label { display: block; font-weight: 650; margin-bottom: 8px; }
.composer { display: flex; align-items: end; gap: 12px; }
textarea { width: 100%; min-width: 0; font: inherit; border: 1px solid #82988b; padding: 10px; border-radius: 8px; resize: vertical; }
button { border: 0; background: #176044; color: white; padding: 12px 18px; font: inherit; font-weight: 650; min-height: 44px; border-radius: 8px; cursor: pointer; }
button:disabled { opacity: .65; cursor: wait; }
:focus-visible { outline: 3px solid #0c6446; outline-offset: 3px; }
footer { width: min(100% - 32px, 850px); margin: 32px auto 20px; font-size: .875rem; }
@media (max-width: 480px) {
  header { gap: 10px; }
  .status { width: 100%; }
  main { margin-top: 28px; }
  .composer { align-items: stretch; flex-direction: column; }
}
[hidden] { display: none !important; }
:root { background: #dceee1; }
header { background: #103f2d; color: #fff; border-color: #0b3022; }
header .status, header .brand svg { color: #dceee1; }
header .brand { border-color: #6a9a79; }
#login-panel { max-width: 440px; }
#login-panel form { margin-top: 18px; }
input { font: inherit; border: 1px solid #82988b; border-radius: 8px; padding: 9px; max-width: 100%; margin-bottom: 14px; }
#login input { display: block; width: 100%; }
#login-status:empty { display: none; }
header .quickbooks-mark { object-fit: contain; flex: none; height: 34px; width: 72px; padding: 3px 5px; background: #fff; border-radius: 5px; }
.pending-table { overflow-x: auto; background: #fff; border: 1px solid #b9d4c2; border-radius: 12px; }
.pending-table table { width: 100%; border-collapse: collapse; text-align: left; font-size: .9rem; }
.pending-table caption { padding: 12px; text-align: left; font-weight: 650; }
.pending-table th { background: #dceee1; color: #173e2e; }
.pending-table th, .pending-table td { padding: 10px 12px; vertical-align: top; border-top: 1px solid #d7e2da; }
.pending-table td:first-child { font-family: ui-monospace, monospace; min-width: 17em; }
.pending-table td:last-child { min-width: 12em; }
#root { display: flex; flex-direction: column; min-height: 100vh; }
.chat-entry { display: grid; gap: 12px; min-width: 0; }
.intuit-card { display: grid; gap: 12px; padding: 16px; background: #fff; border: 1px solid #bdd7c6; border-radius: 12px; overflow-wrap: anywhere; }
.intuit-card-heading { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px 16px; }
.intuit-card h3 { margin: 3px 0 0; font-size: 1.05rem; }
.intuit-action, .intuit-meta { color: #465e53; font-size: .875rem; }
.intuit-action { font-weight: 650; }
.intuit-meta { display: flex; gap: 6px 18px; flex-wrap: wrap; }
.intuit-status { padding: 4px 9px; border-radius: 6px; background: #e9efeb; color: #283d33; font-size: .8rem; font-weight: 700; }
.intuit-status[data-tone="success"] { background: #dcefe4; color: #154c33; }
.intuit-status[data-tone="waiting"] { background: #fff0d3; color: #644509; }
.intuit-card > button { justify-self: start; }
.intuit-help { margin: 0 0 16px; padding: 12px; border-radius: 8px; background: #f3f7f4; }
.intuit-help summary, .intuit-audit summary { cursor: pointer; font-weight: 650; }
.intuit-help p { margin: 8px 0 0; }
.intuit-audit { margin-top: 18px; }
.intuit-audit > button, .intuit-audit > .intuit-card { margin-top: 12px; }
.intuit-audit-detail { font-size: .875rem; }
.intuit-audit-detail dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; margin-bottom: 0; }
.intuit-audit-detail dd { margin: 0; }
.assistant-context { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; font-size: .9rem; }
.assistant-context strong { margin-inline-start: 4px; overflow-wrap: anywhere; }
.intuit-meta { align-items: center; }
.intuit-identifier { padding: 4px 8px; border-radius: 6px; background: #edf5ef; color: #173e2e; }
.intuit-identifier strong { margin-inline-start: 3px; font-variant-numeric: tabular-nums; }
#chat .composer { display: grid; align-items: stretch; }
.composer-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.composer-picker { position: relative; }
.composer-picker label, .composer-file button { margin: 0; padding: 10px 12px; min-height: 44px; border: 1px solid #82988b; border-radius: 8px; background: #fff; color: #173e2e; }
.composer-picker input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.composer-picker:focus-within { outline: 3px solid #0c6446; outline-offset: 3px; border-radius: 8px; }
.composer-picker input:disabled { cursor: wait; }
.composer-file { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; background: #f3f7f4; border-radius: 8px; overflow-wrap: anywhere; }
.composer-file span { min-width: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

#root:has(> #chat-panel) {
  height: 100vh;
  height: 100dvh;
  min-height: 0;
}

#chat-panel {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  margin: 0 auto;
}

.chat-history {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior-y: contain;
  padding: clamp(12px, 3vh, 28px) 4px 4px;
  scrollbar-gutter: stable;
}

.chat-history:focus-visible { outline-offset: -3px; }
.chat-latest { align-self: center; }
#chat-panel #chat {
  position: relative;
  flex: none;
  margin-bottom: max(8px, env(safe-area-inset-bottom));
  padding: 12px;
}

#chat-panel #chat textarea { max-height: max(60px, 22dvh); }
#chat-panel #chat > label { margin-bottom: 6px; }
#chat-panel #chat > label input { margin-bottom: 0; }
#chat-panel .intuit-help { margin-bottom: 8px; padding: 8px 12px; }
#chat-panel .intuit-help-content {
  position: absolute;
  z-index: 1;
  inset-inline: 0;
  bottom: calc(100% + 4px);
  max-height: 24dvh;
  overflow-y: auto;
  overflow-wrap: anywhere;
  padding: 12px;
  background: #fff;
  border: 1px solid #bdd7c6;
  border-radius: 8px;
  box-shadow: 0 8px 20px #103f2d20;
}

@media (max-width: 480px) {
  #chat-panel { width: calc(100% - 20px); }
}

@media (max-height: 520px) {
  #root:has(> #chat-panel) > header { padding: 6px 12px; gap: 8px; }
  #chat-panel { gap: 4px; }
  .chat-history { padding-block: 4px; }
  .chat-latest { padding-block: 6px; }
  #root:has(> #chat-panel) header .status {
    min-width: 0;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #chat-panel #chat { padding: 8px; }
  #chat-panel #chat .composer {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
  }
  #chat-panel .composer-file { grid-column: 1 / -1; grid-row: 2; }
  #chat-panel .composer-actions { align-items: start; }
  #chat-panel .intuit-help-content { max-height: 12dvh; }
}
@media (max-height: 520px) and (max-width: 540px) {
  #chat-panel #chat .composer { grid-template-columns: minmax(0, 1fr); }
  #chat-panel .composer-file { grid-column: auto; grid-row: auto; }
}

.assistant-login {
  background: #fff;
  border: 1px solid #bdd7c6;
  border-radius: 20px;
  margin-block: clamp(20px, 6vh, 64px) auto;
  box-shadow: 0 16px 48px #103f2d12;
  padding: clamp(20px, 5vw, 32px);
}

.assistant-login-brand {
  background: #103f2d;
  border-radius: 12px;
  padding: 12px 16px;
  display: inline-flex;
}

.assistant-login-heading { margin-top: 20px; }
.assistant-login-heading p { margin: 8px 0 0; color: #465e53; line-height: 1.5; }
.assistant-login form { border: 0; padding: 0; margin-top: 20px; }
.assistant-login label, .assistant-logout { display: flex; align-items: center; gap: 8px; }
.assistant-login input, .assistant-login select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #82988b;
  border-radius: 8px;
  padding: 9px 12px;
  margin-bottom: 16px;
  background: #fff;
  color: #172a23;
  font: inherit;
}

.assistant-login button[type="submit"] {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.login-feedback { margin: 12px 0 0; }
.login-feedback:empty { display: none; }
