@font-face {
  font-family: Vazirmatn;
  src: url("/static/fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url("/static/fonts/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Vazirmatn;
  src: url("/static/fonts/Vazirmatn-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --navy: #0f1f44;
  --navy-deep: #09162f;
  --navy-mid: #1a3268;
  --gold: #e8b23a;
  --gold-deep: #c4921d;
  --gold-soft: #f8edd0;
  --ink: #1a2233;
  --muted: #6e665b;
  --paper: #f4efe6;
  --panel: #fffdf9;
  --line: #e6dccb;
  --danger: #9d2c2c;
  --ok: #0d7a50;
  --warn: #8a5a00;
  --shadow: 0 16px 40px rgba(15, 31, 68, 0.08);
  --radius: 20px;
  --font: Vazirmatn, Tahoma, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-weight: 400;
  background:
    radial-gradient(900px 320px at 100% -8%, rgba(232, 178, 58, 0.2), transparent 60%),
    radial-gradient(700px 280px at 0% 0%, rgba(15, 31, 68, 0.06), transparent 55%),
    var(--paper);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font-family: inherit; touch-action: manipulation; }
::selection { background: #f3dd9a; color: var(--navy); }
code { font-family: Consolas, ui-monospace, monospace; direction: ltr; unicode-bidi: embed; font-size: 0.9em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 13.5px; }
.ok { color: var(--ok); font-size: 13.5px; }
.ltr { direction: ltr; unicode-bidi: embed; text-align: left; }
.num { direction: ltr; unicode-bidi: embed; font-variant-numeric: tabular-nums; }
.small-text { font-size: 12.5px; }
a { color: var(--navy-mid); }
a:hover { color: var(--gold-deep); }

header {
  flex: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 42%),
    linear-gradient(90deg, var(--navy-deep), var(--navy) 42%, #16305f);
  color: #f6f1e6;
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 8px 24px rgba(9, 22, 47, 0.18);
  padding-top: env(safe-area-inset-top);
}
.header-bar {
  width: min(1240px, 100%);
  margin-inline: auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "brand status actions";
  align-items: center;
  gap: 12px 18px;
  padding: 12px 22px;
}
header h1 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.01em;
  line-height: 1.2;
}
.brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}
.brand img {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: block;
  box-shadow: 0 0 0 2px rgba(232, 178, 58, 0.9);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-tag { font-size: 12px; color: #f0d48a; line-height: 1.3; }
.brand-logo {
  width: 76px;
  height: 76px;
  border-radius: 22px;
  align-self: center;
  box-shadow: 0 10px 24px rgba(15, 31, 68, 0.22), 0 0 0 3px #f3e2b0;
}
.status {
  grid-area: status;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  min-width: 0;
}
.status .pill {
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(232, 178, 58, 0.16);
  color: #f6e2ad;
  border: 1px solid rgba(232, 178, 58, 0.28);
  font-size: 12px;
  line-height: 1.7;
}
.status .pill.off {
  background: rgba(248, 113, 113, 0.14);
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.28);
}
.header-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.header-actions .muted { color: rgba(246, 241, 230, 0.78); }
#whoami {
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

main {
  flex: 1;
  min-height: 0;
  width: min(1240px, 100%);
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "chat tabs"
    "chat side";
  column-gap: 16px;
  row-gap: 0;
  padding: 16px 18px 18px;
}
#chat { grid-area: chat; }
.tabs { grid-area: tabs; }
#side { grid-area: side; }

#chat, #side {
  background: var(--panel);
  border: 1px solid rgba(15, 31, 68, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    linear-gradient(180deg, rgba(255, 253, 249, 0.2), rgba(244, 239, 230, 0.65));
  overscroll-behavior: contain;
}
#messages:empty::before {
  content: "سؤال بپرسید، یک درآمد یا دارایی را ثبت کنید، یا قاعده‌ای را به‌عنوان دانش ذخیره کنید.";
  margin: auto;
  max-width: 28rem;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  border: 1px dashed #e0d3b4;
  border-radius: 16px;
  padding: 18px 16px;
  line-height: 1.9;
}
.msg {
  max-width: min(78%, 38rem);
  padding: 10px 14px;
  border-radius: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.75;
}
.msg.user {
  align-self: flex-start;
  background: linear-gradient(180deg, #1b356a, var(--navy));
  color: #f7f3ea;
  border-radius: 16px 16px 6px 16px;
  box-shadow: 0 8px 18px rgba(15, 31, 68, 0.16);
}
.msg.assistant {
  align-self: flex-end;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 6px;
  box-shadow: 0 4px 14px rgba(15, 31, 68, 0.05);
}
.msg.system {
  align-self: center;
  max-width: 100%;
  background: var(--gold-soft);
  color: #6d5208;
  border: 1px solid #ead9a2;
  border-radius: 999px;
  font-size: 13px;
  padding: 6px 14px;
}
.msg .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.msg.user .meta { color: rgba(247, 243, 234, 0.72); }
.msg .badge {
  font-size: 11px;
  background: var(--gold-soft);
  color: var(--warn);
  padding: 1px 7px;
  border-radius: 999px;
  margin-inline-start: 6px;
}
.msg.user .badge { background: rgba(232, 178, 58, 0.22); color: #f6d48a; }
.msg .badge:empty { display: none; }

.composer {
  border-top: 1px solid var(--line);
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fffdf9;
}
.composer-top { display: none; }
.composer textarea {
  width: 100%;
  resize: vertical;
  font: inherit;
  font-size: 16px;
  line-height: 1.7;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 58px;
  background: #fff;
  color: var(--ink);
}
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.composer .busy {
  font-size: 12.5px;
  color: var(--navy);
  background: var(--gold-soft);
  border: 1px solid #ead9a2;
  padding: 3px 10px;
  border-radius: 999px;
}

button {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 16px;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid var(--navy-deep);
  background: linear-gradient(180deg, #1c366c, var(--navy));
  color: #fff;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
button:disabled { opacity: 0.55; cursor: default; }
button.secondary {
  background: #fff;
  color: var(--navy);
  border-color: #ddc98a;
  box-shadow: none;
}
button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
  box-shadow: none;
  min-height: 36px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
}
header button.ghost {
  color: #f6f1e6;
  border-color: rgba(246, 241, 230, 0.28);
  background: rgba(255, 255, 255, 0.04);
}
button.small { padding: 4px 12px; min-height: 34px; font-size: 12.5px; border-radius: 10px; }
button.danger {
  background: #fff;
  color: var(--danger);
  border-color: #e4b4b4;
  box-shadow: none;
}
.composer [data-mode="knowledge"] {
  background: linear-gradient(180deg, #f4c85a, #e0a82b);
  color: #2a210c;
  border-color: #c9962a;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}
@media (hover: hover) {
  button:hover { filter: brightness(1.06); }
  button.secondary:hover, button.danger:hover { background: #fbf6ea; filter: none; }
  header button.ghost:hover { background: rgba(255, 255, 255, 0.1); filter: none; }
  button.ghost:hover { background: #f7f1e4; filter: none; }
}
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
input, textarea, .edit-item textarea {
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, .edit-item textarea:focus {
  outline: none;
  border-color: var(--gold-deep);
  box-shadow: 0 0 0 3px rgba(232, 178, 58, 0.28);
}

.phone-tab { display: none; }
.tabs {
  display: flex;
  gap: 6px;
  padding: 10px;
  overflow-x: auto;
  border: 1px solid rgba(15, 31, 68, 0.08);
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--panel);
  scrollbar-width: none;
  flex: none;
}
#side {
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 0 0 auto;
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 999px;
  box-shadow: none;
  min-height: 38px;
  padding: 6px 14px;
  font-weight: 500;
}
.tabs button.active {
  background: var(--navy);
  color: #f6e2ad;
  border-color: var(--navy);
}
@media (min-width: 901px) {
  .tabs { flex-wrap: wrap; }
}
.tab { flex: 1; overflow: auto; padding: 14px; overscroll-behavior: contain; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
td.num, th.num { text-align: left; white-space: nowrap; }

.metric-group {
  margin-bottom: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px 4px;
  overflow-x: auto;
}
.metric-group h3 {
  font-size: 14px;
  margin: 0 0 6px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
.metric-group h3 small { color: var(--muted); font-weight: 400; font-size: 11px; }

.manage-section { margin-bottom: 20px; }
.manage-section h3 {
  font-size: 14.5px;
  margin: 0 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  color: var(--navy);
}
.manage-section h3 small { color: var(--muted); font-weight: 400; font-size: 11.5px; }
.knowledge-item, .edit-item, .user-row, .rule {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.knowledge-item { font-size: 13.5px; white-space: pre-wrap; }
.knowledge-item .head, .edit-item .head, .user-row .head, .alert .head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 11.5px;
  margin-bottom: 4px;
  white-space: normal;
}
.edit-item { font-size: 13px; }
.edit-item textarea {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  resize: vertical;
  min-height: 52px;
  background: #fff;
  color: var(--ink);
}
.edit-item .row, .user-row .row { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.edit-item.dirty { border-color: var(--gold-deep); box-shadow: 0 0 0 3px rgba(232, 178, 58, 0.2); }
.count {
  display: inline-block;
  min-width: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: #b42318;
  color: #fff;
  font-size: 11px;
  line-height: 1.6;
  margin-inline-start: 4px;
}
.two-col { display: flex; gap: 8px; }
.two-col input { flex: 1; min-width: 0; }
.user-row { font-size: 13px; }
.user-row .meta {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
  direction: ltr;
  text-align: right;
  unicode-bidi: plaintext;
  overflow-wrap: anywhere;
}
.status-chip {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #eeeae2;
  color: var(--muted);
}
.status-chip.pending { background: #f8edd0; color: var(--warn); }
.status-chip.approved { background: #d9f3e6; color: var(--ok); }
.status-chip.rejected, .status-chip.disabled { background: #fde8e8; color: var(--danger); }
.link-box {
  background: #fbf7ef;
  border: 1px dashed #e0d3b4;
  border-radius: 12px;
  padding: 10px 12px;
  margin-top: 8px;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.link-box a { direction: ltr; unicode-bidi: embed; }

.car-item .car-price { margin: 6px 0 2px; line-height: 1.7; }
.car-item .car-price strong { color: var(--gold-deep, #b8860b); }
#car-estimate-form { margin-top: 10px; max-width: 100%; }
#car-estimate-result { white-space: pre-line; line-height: 1.7; }
#car-estimate-result a { direction: ltr; unicode-bidi: embed; }

.rule h3 {
  margin: 0 0 4px;
  font-size: 14.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--navy);
}
.rule .state {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 8px;
  border-radius: 999px;
  background: #eeeae2;
  color: var(--muted);
}
.rule .state.active { background: #fde8e8; color: var(--danger); }
.rule .state.off { background: #f3f1ec; color: var(--muted); text-decoration: line-through; }
.rule dl { margin: 8px 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 10px; font-size: 12.5px; }
.rule dt { color: var(--muted); }
.rule dd { margin: 0; overflow-wrap: anywhere; }
.rule .result {
  margin-top: 8px;
  font-size: 12.5px;
  white-space: pre-wrap;
  background: #fbf7ef;
  padding: 8px 10px;
  border-radius: 10px;
}
.rule .err { color: var(--danger); font-size: 12px; }
.rule .actions { margin-top: 8px; }

.alert { border-bottom: 1px solid var(--line); padding: 10px 2px; font-size: 13px; white-space: pre-wrap; }
.alert.kind-error .head { color: var(--danger); }
.alert.kind-clear .head { color: var(--ok); }
.calendar-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.calendar-item a { color: var(--navy-mid); text-decoration: none; direction: ltr; unicode-bidi: embed; font-weight: 500; }
.calendar-item a:hover { color: var(--gold-deep); }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  background:
    radial-gradient(520px 320px at 15% 0%, rgba(232, 178, 58, 0.32), transparent 62%),
    radial-gradient(420px 280px at 100% 100%, rgba(232, 178, 58, 0.14), transparent 60%),
    linear-gradient(165deg, #12284f, var(--navy-deep) 55%, #071226);
}
.card {
  position: relative;
  z-index: 1;
  background: var(--panel);
  padding: 26px 24px 22px;
  border-radius: 22px;
  width: min(420px, 100%);
  margin-block: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}
#register-form.card { width: min(460px, 100%); }
.card::before {
  content: "";
  height: 4px;
  margin: -26px -24px 6px;
  background: linear-gradient(90deg, var(--navy), var(--gold), var(--navy));
}
.card h2 { margin: 0; text-align: center; font-size: 22px; color: var(--navy); }
.card .muted { text-align: center; margin: 0; }
.card .small-text { text-align: center; margin: 2px 0 0; }
.card input {
  font: inherit;
  font-size: 16px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
.card button { width: 100%; min-height: 46px; }
#recovery { z-index: 30; }
.recovery-key {
  direction: ltr;
  text-align: center;
  font-family: ui-monospace, Consolas, monospace;
  background: var(--gold-soft);
  border-radius: 12px;
  padding: 12px;
  user-select: all;
  word-break: break-all;
}

.password-form { display: flex; flex-direction: column; gap: 8px; max-width: 22rem; }
.password-form input {
  font: inherit;
  font-size: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
.usage-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
}
.usage-card .head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.usage-card .amount { font-weight: 600; color: var(--navy); }
.usage-card.total { background: var(--gold-soft); border-color: #ead9a2; }
.usage-note { font-size: 12.5px; line-height: 1.8; margin: 0 0 12px; }

.asset-intro { margin: 0 0 12px; }
.asset-actions { margin: 0 0 12px; }
.asset-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 12px 8px;
  margin-bottom: 16px;
}
.asset-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 2px;
}
.asset-panel h3 { margin: 0; font-size: 15px; color: var(--navy); }
.pie-wrap { display: flex; justify-content: center; padding: 6px 0 8px; }
.pie { width: min(220px, 72%); height: auto; display: block; }
.asset-sum, .asset-net {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--navy);
}
.asset-net .neg { color: var(--danger); }
.asset-cat {
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-bottom: 8px;
  background: #fff;
  overflow: hidden;
}
button.asset-cat-head {
  width: 100%;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  text-align: right;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  min-height: 48px;
  padding: 8px 12px;
  font-weight: 500;
}
button.asset-cat-head:hover { background: #faf6ee; }
.asset-swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.asset-name { flex: 1 1 auto; font-weight: 600; color: var(--navy); }
.asset-pct { color: var(--muted); font-size: 12.5px; }
.asset-amt { font-weight: 600; margin-inline-start: auto; }
.asset-chevron {
  width: 8px;
  height: 8px;
  border-left: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  margin-inline-start: 2px;
  flex: none;
}
.asset-cat.open .asset-chevron { transform: rotate(135deg); margin-top: 4px; }
.asset-children { display: none; padding: 2px 12px 12px; background: #fbf8f2; border-top: 1px solid var(--line); }
.asset-cat.open .asset-children { display: block; }
.holding-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.holding-title { flex: 1 1 8em; }
.holding-note { flex: 1 0 100%; margin: 0; }
.holding-form { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.holding-line > .holding-form { flex: 1 0 100%; }
.holding-form input, .holding-form select {
  flex: 1 1 120px;
  min-width: 0;
  min-height: 40px;
  font: inherit;
  font-size: 16px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}
.holding-form .form-error { flex: 1 0 100%; margin: 0; }

@media (max-width: 900px) {
  html, body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: pan-y;
  }
  body { min-height: 100dvh; }
  header { position: sticky; top: 0; z-index: 6; }
  body { font-size: 14.5px; }
  .header-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 14px 12px;
  }
  .brand { flex: 1 0 100%; }
  .header-actions { flex: 1 0 100%; justify-content: flex-start; }
  .status { flex: 1 0 100%; }
  #whoami { max-width: none; }
  header h1 { font-size: 17px; }
  main {
    display: flex;
    flex-direction: column;
    overflow: visible;
    flex: none;
    height: auto;
    padding: 12px 12px calc(16px + env(safe-area-inset-bottom));
  }
  .tabs { order: 0; width: 100%; }
  .phone-tab { display: inline-flex; }
  #chat, #side { order: 1; width: 100%; border-radius: 0 0 var(--radius) var(--radius); }
  #chat { display: none; }
  html.show-chat #chat { display: flex; }
  html.show-chat #side { display: none; }
  html.show-chat .tabs button[data-tab="metrics"].active {
    background: transparent;
    color: var(--muted);
    border-color: transparent;
  }
  html.show-chat .tabs button[data-tab="chat"] {
    background: var(--navy);
    color: #f6e2ad;
    border-color: var(--navy);
  }
  #chat, #side, #messages, .tab {
    overflow: visible;
    height: auto;
    min-height: 0;
    max-height: none;
    flex: none;
    overscroll-behavior: auto;
  }
  .composer-top {
    display: flex;
    border-top: 0;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
  }
  .msg.history-collapsed { display: none; }
  #composer { scroll-margin-bottom: 16px; }
  .msg { max-width: 92%; }
  .composer .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .composer .actions [data-mode="ask"],
  .composer .busy { grid-column: 1 / -1; }
  .composer .actions button { width: 100%; }
  .composer textarea { min-height: 92px; }
  .metric-group th { width: 42%; }
  .calendar-item { grid-template-columns: minmax(0, 1fr) auto; }
  .calendar-item a { grid-column: 1 / -1; }
}

@media (max-width: 420px) {
  .two-col { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  input, textarea, .edit-item textarea { transition: none; }
}
