/* ── Design tokens — light (default) ────────────────────────────────────────── */
:root {
  --bg:            #f2f2f0;
  --surface:       #ffffff;
  --surface2:      #f7f6f4;
  --stroke:        #e0ddd8;
  --stroke2:       #ccc9c3;
  --text:          #111110;
  --muted:         #6b6860;
  --muted2:        #9c9a95;
  --accent:        #d42b2b;
  --accent-bg:     rgba(212, 43, 43, 0.07);
  --accent-stroke: rgba(212, 43, 43, 0.30);
  --ok:            #1a9e6e;
  --ok-bg:         rgba(26, 158, 110, 0.09);
  --ok-stroke:     rgba(26, 158, 110, 0.30);
  --warn:          #b07800;
  --warn-bg:       rgba(176, 120, 0, 0.09);
  --warn-stroke:   rgba(176, 120, 0, 0.30);
  --danger:        #d42b2b;
  --shadow:        0 2px 12px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-lg:     0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.07);
  --radius:        4px;
  --radius2:       4px;
  color-scheme: light;
}

/* ── Design tokens — dark ────────────────────────────────────────────────────── */
/* Applied automatically via OS preference, or manually via [data-theme="dark"]. */
/* [data-theme="light"] hard-locks light mode when user explicitly chose it.     */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #111110;
    --surface:       #1c1c1b;
    --surface2:      #242423;
    --stroke:        #2e2e2c;
    --stroke2:       #3d3d3a;
    --text:          #f0efed;
    --muted:         #9c9a95;
    --muted2:        #6b6860;
    --accent:        #e84040;
    --accent-bg:     rgba(232, 64, 64, 0.12);
    --accent-stroke: rgba(232, 64, 64, 0.35);
    --ok:            #27c28a;
    --ok-bg:         rgba(39, 194, 138, 0.12);
    --ok-stroke:     rgba(39, 194, 138, 0.35);
    --warn:          #e0a020;
    --warn-bg:       rgba(224, 160, 32, 0.12);
    --warn-stroke:   rgba(224, 160, 32, 0.35);
    --danger:        #e84040;
    --shadow:        0 2px 12px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.25);
    --shadow-lg:     0 8px 32px rgba(0, 0, 0, 0.50), 0 2px 8px rgba(0, 0, 0, 0.30);
    color-scheme: dark;
  }
}

[data-theme="dark"] {
  --bg:            #111110;
  --surface:       #1c1c1b;
  --surface2:      #242423;
  --stroke:        #2e2e2c;
  --stroke2:       #3d3d3a;
  --text:          #f0efed;
  --muted:         #9c9a95;
  --muted2:        #6b6860;
  --accent:        #e84040;
  --accent-bg:     rgba(232, 64, 64, 0.12);
  --accent-stroke: rgba(232, 64, 64, 0.35);
  --ok:            #27c28a;
  --ok-bg:         rgba(39, 194, 138, 0.12);
  --ok-stroke:     rgba(39, 194, 138, 0.35);
  --warn:          #e0a020;
  --warn-bg:       rgba(224, 160, 32, 0.12);
  --warn-stroke:   rgba(224, 160, 32, 0.35);
  --danger:        #e84040;
  --shadow:        0 2px 12px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-lg:     0 8px 32px rgba(0, 0, 0, 0.50), 0 2px 8px rgba(0, 0, 0, 0.30);
  color-scheme: dark;
}

[data-theme="light"] {
  color-scheme: light;
}

/* ── Reset & base ────────────────────────────────────────────────────────────── */
html, body { height: 100%; }

* { box-sizing: border-box; }

a { color: inherit; }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: "Inter", "Helvetica Neue", "Arial", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── App shell ───────────────────────────────────────────────────────────────── */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

/* ── Top bar ─────────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 2px solid var(--text);
}

.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: stretch;
  gap: 0;
}

.brand {
  display: grid;
  gap: 1px;
  align-self: center;
  margin-right: 24px;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.brand .sub {
  font-size: 11px;
  color: var(--muted2);
  letter-spacing: 0.03em;
}

/* ── Tab bar ─────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  flex: 1;
}

.tab {
  padding: 0 20px;
  height: 100%;
  display: flex;
  align-items: center;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 100ms ease, border-color 100ms ease;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Tab panel controls ──────────────────────────────────────────────────────── */
.tab-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

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

/* ── Main content area ───────────────────────────────────────────────────────── */
.main {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 28px 24px;
}

/* ── Search input ────────────────────────────────────────────────────────────── */
.input {
  width: min(420px, 52vw);
  padding: 9px 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--stroke2);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 100ms ease;
}

.input:focus { border-color: var(--text); }

.input::placeholder { color: var(--muted2); }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1.5px solid var(--stroke2);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface2);
  border-color: var(--text);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover {
  background: #b82222;
  border-color: #b82222;
}

.btn.danger {
  background: transparent;
  border-color: var(--accent-stroke);
  color: var(--accent);
}

.btn.danger:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn.ghost:hover {
  background: var(--surface2);
  border-color: var(--stroke2);
  color: var(--text);
}

/* ── Meta bar ────────────────────────────────────────────────────────────────── */
.meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 6px 0 18px;
  color: var(--muted2);
  font-size: 12px;
  letter-spacing: 0.02em;
}

/* ── Card grid ───────────────────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
}

/* ── Client / Service cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1.5px solid var(--stroke);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color 100ms ease, box-shadow 100ms ease;
}

.card:hover {
  border-color: var(--text);
  box-shadow: var(--shadow);
  z-index: 1;
}

.card::before { display: none; }

.card-top {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}

.title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0;
  color: var(--text);
}

/* ── Pills / badges ──────────────────────────────────────────────────────────── */
.pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 2px;
  border: 1.5px solid var(--stroke2);
  background: var(--surface2);
  color: var(--muted);
}

.pill.ok {
  border-color: var(--ok-stroke);
  color: var(--ok);
  background: var(--ok-bg);
}

.pill.warn {
  border-color: var(--warn-stroke);
  color: var(--warn);
  background: var(--warn-bg);
}

.pill.muted {
  border-color: var(--stroke2);
  color: var(--muted);
  background: var(--surface2);
}

/* ── KV rows inside cards ────────────────────────────────────────────────────── */
.rows {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.kv { display: grid; gap: 2px; }

.k {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.v {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.v.mono {
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--muted);
}

/* ── Empty state ─────────────────────────────────────────────────────────────── */
.empty {
  border: 1.5px dashed var(--stroke2);
  border-radius: var(--radius);
  padding: 20px 18px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
}

/* ── Modal backdrop ──────────────────────────────────────────────────────────── */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 16, 0.45);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
}

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.modal {
  width: min(860px, 100%);
  max-height: min(88vh, 880px);
  overflow: auto;
  border-radius: var(--radius);
  border: 2px solid var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.modal-inner { padding: 20px; }

.modal-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  margin-bottom: 16px;
}

.modal-title {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Sections inside modals ──────────────────────────────────────────────────── */
.section {
  border-top: 1.5px solid var(--stroke);
  padding-top: 14px;
  margin-top: 14px;
}

.section h3 {
  margin: 0 0 12px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted2);
}

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field { display: grid; gap: 5px; }

.label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted2);
}

.control,
.select,
.textarea {
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1.5px solid var(--stroke2);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 100ms ease;
}

.control:focus,
.select:focus,
.textarea:focus { border-color: var(--text); }

.control:disabled,
.select:disabled,
.textarea:disabled {
  background: var(--surface2);
  color: var(--muted);
  border-color: var(--stroke);
}

.textarea {
  min-height: 88px;
  resize: vertical;
}

.span2 { grid-column: span 2; }

/* ── Preformatted / JSON dump ────────────────────────────────────────────────── */
.pre {
  margin: 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface2);
  border: 1.5px solid var(--stroke);
  color: var(--muted);
  overflow: auto;
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-size: 11px;
  line-height: 1.6;
}

/* ── Error banner ────────────────────────────────────────────────────────────── */
.error {
  color: var(--accent);
  background: var(--accent-bg);
  border: 1.5px solid var(--accent-stroke);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
}

/* ── Service calls ───────────────────────────────────────────────────────────── */

.sc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.sc-header h3 {
  margin: 0;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted2);
}

.sc-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sc-empty {
  font-size: 13px;
  color: var(--muted2);
  padding: 8px 0;
}

.sc-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--stroke);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 100ms ease, box-shadow 100ms ease;
}

.sc-card:hover {
  border-color: var(--text);
  box-shadow: var(--shadow);
}

.sc-card-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.sc-card-name {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sc-card-date {
  font-size: 11px;
  color: var(--muted2);
  letter-spacing: 0.02em;
}

.sc-card-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sc-card-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ── Nested modal (service call detail inside client modal) ──────────────────── */
.nested-modal {
  margin-top: 6px;
  border-radius: var(--radius);
  border: 1.5px solid var(--stroke);
  background: var(--surface2);
  padding: 16px;
}

.nested-modal .modal-head { margin-bottom: 10px; }

/* ── Documents section ───────────────────────────────────────────────────────── */

.doc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.doc-header h3 { margin: 0; }

.doc-empty {
  font-size: 13px;
  color: var(--muted2);
  padding: 6px 0 10px;
}

.doc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.doc-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1.5px solid var(--stroke);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.doc-thumb {
  width: 72px;
  height: 96px;
  object-fit: cover;
  border-radius: 2px;
  border: 1.5px solid var(--stroke);
  background: var(--surface2);
  flex-shrink: 0;
}

.doc-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.doc-name {
  font-weight: 700;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.doc-uploaded {
  font-size: 11px;
  color: var(--muted2);
}

.doc-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.doc-actions a.btn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.upload-zone { margin-top: 10px; }

.upload-label {
  display: inline-block;
  cursor: pointer;
}

/* ── Transactions section ────────────────────────────────────────────────────── */

.tx-empty {
  font-size: 13px;
  color: var(--muted2);
  padding: 6px 0 10px;
}

.tx-form {
  background: var(--surface);
  border: 1.5px solid var(--stroke);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.tx-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.tx-form-fields {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
}

.tx-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 2px;
}

.tx-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1.5px solid var(--stroke);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.tx-amount {
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  min-width: 110px;
  flex-shrink: 0;
}

.tx-positive { color: var(--ok); }

.tx-negative { color: var(--accent); }

.tx-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tx-description {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-date {
  font-size: 11px;
  color: var(--muted2);
}

.tx-delete {
  flex-shrink: 0;
  font-size: 10px;
  padding: 5px 10px;
}

/* ── Theme toggle button ─────────────────────────────────────────────────────── */
.theme-toggle {
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1.5px solid var(--stroke2);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
  flex-shrink: 0;
  align-self: center;
  margin-left: 12px;
}

.theme-toggle:hover {
  background: var(--surface2);
  border-color: var(--stroke2);
  color: var(--text);
}

/* ── Assistant / chat panel ──────────────────────────────────────────────────── */

.chat-root {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 80px);
  width: 100%;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 0 12px;
}

.chat-empty {
  color: var(--muted2);
  font-size: 14px;
  text-align: center;
  margin-top: 40px;
}

.chat-message {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.chat-message.user {
  align-self: flex-end;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--text);
  border: 1.5px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}

.chat-message.assistant {
  align-self: flex-start;
  max-width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--stroke);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

/* Compact markdown inside assistant bubbles */
.chat-md p { margin: 0 0 6px; }
.chat-md p:last-child { margin-bottom: 0; }
.chat-md ul,
.chat-md ol { margin: 4px 0 6px; padding-left: 20px; }
.chat-md li { margin: 2px 0; }
.chat-md li > ul,
.chat-md li > ol { margin: 2px 0; }
.chat-md h1,
.chat-md h2,
.chat-md h3 { margin: 8px 0 4px; font-size: 1em; font-weight: 600; }
.chat-md code { font-size: 12px; background: var(--surface2); padding: 1px 4px; border-radius: 3px; }
.chat-md pre { margin: 6px 0; background: var(--surface2); border-radius: var(--radius); padding: 10px 12px; overflow-x: auto; }
.chat-md pre code { background: none; padding: 0; }
.chat-md blockquote { margin: 4px 0; padding-left: 10px; border-left: 3px solid var(--stroke2); color: var(--muted); }

/* Timestamp shown beneath each message */
.chat-message-wrap {
  display: flex;
  flex-direction: column;
}
.chat-message-wrap.user { align-self: flex-end; max-width: 88%; }
.chat-message-wrap.assistant { align-self: flex-start; width: 100%; }
.chat-ts {
  font-size: 11px;
  color: var(--muted2);
  margin-top: 3px;
}
.chat-message-wrap.user .chat-ts { text-align: right; }
.chat-message-wrap.assistant .chat-ts { text-align: left; }

/* Blinking cursor at end of streaming assistant message */
.chat-cursor {
  display: inline-block;
  width: 7px;
  height: 13px;
  background: var(--accent);
  border-radius: 1px;
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 0.75s step-end infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Clear / new conversation button */
.chat-clear {
  flex-shrink: 0;
  align-self: flex-end;
  padding: 9px 14px;
  font-size: 12px;
  background: transparent;
  border: 1.5px solid var(--stroke);
  color: var(--muted);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 120ms, color 120ms;
}
.chat-clear:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chat-message.tool-status {
  align-self: flex-start;
  background: transparent;
  border: 1.5px dashed var(--stroke2);
  color: var(--muted);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-style: italic;
}

.tool-status-text { display: inline; }

.chat-error {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1.5px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 8px;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 0 16px;
  border-top: 1.5px solid var(--stroke);
}

.chat-textarea {
  flex: 1;
  resize: none;
  overflow-y: hidden;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.45;
  padding: 9px 12px;
  border: 1.5px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 120ms ease;
  min-height: 38px;
  max-height: 160px;
  overflow-y: auto;
}

.chat-textarea:focus {
  border-color: var(--accent);
}

.chat-textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-send {
  flex-shrink: 0;
  align-self: flex-end;
  padding: 9px 20px;
}

/* Navigation action button rendered inside the chat by the AI */
.chat-message-wrap.action-button {
  align-self: flex-start;
  display: flex;
  flex-direction: column;
}

.chat-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--accent-bg);
  border: 1.5px solid var(--accent-stroke);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  white-space: nowrap;
}

.chat-action-btn::before {
  content: "→";
  font-size: 14px;
  line-height: 1;
}

.chat-action-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 4px; }
  .brand { margin-right: 12px; }
  .tabs { order: 3; width: 100%; flex-basis: 100%; }
  .theme-toggle { margin-left: auto; }
  .main { padding: 20px 16px; }
  .input { width: 100%; }
  .controls { width: 100%; }
  .rows { grid-template-columns: 1fr; }
  .form { grid-template-columns: 1fr; }
  .span2 { grid-column: span 1; }
  .tx-form-fields { grid-template-columns: 1fr; }
}
