/* =============================================================================
   Pufrelax · Dispecer — stiluri comune (ecranul de login + aplicația)
   Mobil întâi · paleta bej a casei · fără fonturi/imagini externe · CSP strict
   (niciun stil inline: vizibilitatea se comută DOAR prin clase, ex. .hidden)
   ============================================================================= */

/* ---------- Jetoane de design ---------- */
:root {
  color-scheme: light;
  --bg: #f6f1e7;
  --surface: #fffdf7;
  --surface-2: #fbf6ed;
  --ink: #3d3226;
  --ink-strong: #33281c;
  --muted: #8a7d6b;
  --muted-strong: #6b5f4d;
  --line: rgba(61, 50, 38, .10);
  --line-strong: rgba(61, 50, 38, .17);
  --clay: #b0663a;
  --clay-hi: #c67b47;
  --clay-lo: #a35a2c;
  --clay-deep: #96552f;
  --clay-text: #a5642a;
  --clay-tint: rgba(176, 102, 58, .08);
  --gold: #c8a24a;
  --ok: #5a7d55;
  --err: #b0433a;
  --warn: #b3801f;
  --rec: #c63d2b;
  --user-bg: #f5e6d6;
  --user-line: rgba(176, 102, 58, .22);
  --v-red: #b0433a;
  --v-yellow: #c8a24a;
  --v-green: #5a7d55;
  --v-unknown: #a59a88;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow-card: 0 14px 34px -26px rgba(61, 50, 38, .45), 0 1px 2px rgba(61, 50, 38, .05);
  --shadow-btn: 0 10px 22px -12px rgba(150, 85, 47, .7);
  --gl: max(16px, env(safe-area-inset-left));   /* margine laterală stânga (min 16 px + notch) */
  --gr: max(16px, env(safe-area-inset-right));  /* margine laterală dreapta */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --mic: 72px;
  --bar-h: 58px;
}

/* ---------- Bază ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: manipulation; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(900px 520px at 82% -12%, rgba(176, 102, 58, .13), transparent 60%),
    radial-gradient(720px 440px at -8% 8%, rgba(200, 162, 74, .14), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid rgba(176, 102, 58, .45); outline-offset: 2px; }
.hidden { display: none !important; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.ic { display: block; flex: none; width: 20px; height: 20px; fill: currentColor; }

/* Emblema „D” (aceeași ca pe poarta de login a casei) */
.emblem {
  display: grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(150deg, var(--clay-hi), var(--clay-deep));
  color: #fff8ef; font-family: var(--serif); font-weight: 700; font-size: 17px; letter-spacing: .02em;
  box-shadow: 0 8px 18px -10px rgba(150, 85, 47, .6), inset 0 1px 0 rgba(255, 255, 255, .25);
  user-select: none; -webkit-user-select: none;
}
.emblem-lg { width: 52px; height: 52px; border-radius: 15px; font-size: 20px; margin: 0 0 18px; }

/* =============================================================================
   ECRANUL DE LOGIN (copie a porții casei: auth_gate.login_html)
   ============================================================================= */
.page-login {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) var(--gr) max(20px, env(safe-area-inset-bottom)) var(--gl);
}
.login-card {
  background: var(--surface); padding: 34px 32px; border-radius: 18px; width: 352px; max-width: 100%;
  border: 1px solid rgba(61, 50, 38, .1);
  box-shadow: 0 26px 64px -30px rgba(61, 50, 38, .42), 0 2px 6px rgba(61, 50, 38, .05);
}
.eyebrow {
  font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase; color: var(--clay-text);
  font-weight: 700; margin: 0 0 7px;
}
.login-title {
  font-family: var(--serif); font-weight: 600; font-size: 21px; line-height: 1.25;
  margin: 0 0 3px; color: var(--ink-strong);
}
.login-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 22px; line-height: 1.45; }
.login-card label { display: block; font-size: 11.5px; font-weight: 600; color: var(--muted-strong); margin: 0 0 6px; }
.login-card input {
  display: block; width: 100%; padding: 12px; border-radius: var(--radius-sm);
  border: 1px solid rgba(61, 50, 38, .16); background: #fff; color: var(--ink);
  font-size: 16px; /* 16 px: iPhone nu mai face zoom la focus */
  transition: border-color .15s, box-shadow .15s;
}
.login-card input::placeholder { color: #b4a892; }
.login-card input:focus { outline: none; border-color: var(--clay); box-shadow: 0 0 0 3px rgba(176, 102, 58, .14); }
.login-card .code-input {
  letter-spacing: .4em; font-variant-numeric: tabular-nums; text-align: center;
  font-size: 20px; padding-left: calc(12px + .4em);
}
.btn-primary {
  display: block; width: 100%; min-height: 46px; margin-top: 14px; padding: 12px;
  border: none; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--clay-hi), var(--clay-lo)); color: #fff;
  font-size: 15px; font-weight: 600; box-shadow: var(--shadow-btn);
  transition: filter .15s, transform .05s;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: .6; filter: none; transform: none; }
.sent {
  font-size: 12.5px; color: #5f5647; line-height: 1.5; margin: 0 0 16px; padding: 12px 13px;
  border-radius: var(--radius-sm); background: rgba(176, 102, 58, .07); border: 1px solid rgba(176, 102, 58, .16);
  overflow-wrap: anywhere;
}
.sent b { color: var(--ink); }
.links { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.link-btn {
  min-height: 44px; padding: 0 2px; border: 0; background: none;
  color: var(--clay-deep); font-size: 12.5px; font-weight: 600; text-align: left;
}
.link-btn:hover { text-decoration: underline; }
.link-btn:disabled { opacity: .5; text-decoration: none; }
.login-msg { font-size: 12.5px; margin: 10px 0 0; min-height: 18px; color: var(--clay-text); line-height: 1.4; }
.login-msg.ok { color: var(--ok); }
.login-msg.err { color: var(--err); }
.login-note {
  margin: 14px 0 0; padding-top: 12px; border-top: 1px dashed rgba(61, 50, 38, .14);
  font-size: 11.5px; color: var(--muted); line-height: 1.4;
}
@media (max-width: 400px) { .login-card { padding: 26px 22px; } }

/* =============================================================================
   APLICAȚIA — carcasă pe toată înălțimea ecranului; fiecare panou are scroll propriu
   Mobil: [antet] / [conținut] / [taburi jos]
   ============================================================================= */
.page-app { height: 100vh; height: 100dvh; overflow: hidden; overscroll-behavior: none; }
.app {
  display: grid;
  height: 100vh; height: 100dvh;
  max-width: 900px; margin: 0 auto;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "brand user" "main main" "nav nav";
}

/* ---------- Antet: titlu + starea dispecerului | utilizator + ieșire ---------- */
.brand, .user {
  min-height: var(--bar-h); padding-top: env(safe-area-inset-top);
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand {
  grid-area: brand; display: flex; align-items: center; gap: 10px; min-width: 0;
  padding-left: var(--gl); padding-right: 6px;
}
.brand .emblem { display: none; }
.brand-text { min-width: 0; padding: 6px 0; }
.title {
  margin: 0; font-family: var(--serif); font-weight: 600; font-size: 18px; line-height: 1.2;
  color: var(--ink-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.title-pre { display: none; }
.disp-status {
  display: flex; align-items: center; gap: 6px; margin: 2px 0 0;
  font-size: 12px; line-height: 1.3; color: var(--muted-strong);
}
.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #c3b8a6; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(90, 125, 85, .18); }
.dot.off { background: var(--warn); box-shadow: 0 0 0 3px rgba(179, 128, 31, .16); }

.user {
  grid-area: user; display: flex; align-items: center; justify-content: flex-end; gap: 4px;
  padding-right: var(--gr); padding-left: 4px;
}
.chip { display: flex; align-items: center; gap: 7px; min-width: 0; border-radius: 999px; }
.avatar {
  display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(150deg, #ecd6bd, #d8ae86); color: #5b3418;
  font-size: 12.5px; font-weight: 700; letter-spacing: .02em;
}
.chip-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.chip-name {
  display: none; max-width: 150px; font-size: 13px; font-weight: 600; color: var(--ink-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip-role { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.icon-btn {
  display: grid; place-items: center; flex: none; width: 44px; height: 44px;
  border: 0; border-radius: 12px; background: transparent; color: var(--muted-strong);
}
.icon-btn:hover { background: var(--clay-tint); color: var(--clay-lo); }

/* ---------- Taburi (jos pe mobil) ---------- */
.tabs {
  grid-area: nav; display: flex; align-items: stretch;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  user-select: none; -webkit-user-select: none;
}
.tab {
  position: relative; flex: 1 1 0; min-width: 0; min-height: 56px; padding: 6px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: transparent; color: var(--muted);
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
}
.tab .ic { width: 22px; height: 22px; }
.tab:hover { color: var(--clay-lo); }
.tab[aria-selected="true"] { color: var(--clay-lo); }
.tab[aria-selected="true"]::after {
  content: ""; position: absolute; left: 24%; right: 24%; top: 0; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--clay);
}
.tab-dot {
  position: absolute; top: 7px; left: calc(50% + 7px); width: 10px; height: 10px; border-radius: 50%;
  background: var(--err); border: 2px solid var(--surface);
}

/* ---------- Zona de conținut + panouri ---------- */
.main { grid-area: main; position: relative; min-height: 0; display: flex; flex-direction: column; }
.panel {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px var(--gr) 28px var(--gl);
}
.panel:focus-visible { outline-offset: -3px; }
.panel-chat { display: flex; flex-direction: column; overflow: hidden; padding: 0; }

/* Banda „dispecer oprit” */
.banner {
  flex: none; display: flex; align-items: flex-start; gap: 8px;
  margin: 10px var(--gr) 0 var(--gl); padding: 10px 12px; border-radius: 12px;
  font-size: 13px; line-height: 1.4; color: #6d4a12;
  background: #f8ecd0; border: 1px solid rgba(179, 128, 31, .28);
}
.banner .ic { width: 18px; height: 18px; margin-top: 1px; color: var(--warn); }

/* =============================================================================
   DISCUȚIE
   ============================================================================= */
.thread-wrap { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.messages {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column;
  padding: 14px var(--gr) 14px var(--gl);
}
.messages:focus-visible { outline-offset: -3px; }
.thread { margin-top: auto; display: flex; flex-direction: column; gap: 12px; } /* lipită de jos */
.thread-note { margin: 0; align-self: center; font-size: 13px; color: var(--muted); text-align: center; }

.msg { display: flex; flex-direction: column; gap: 2px; min-width: 0; max-width: min(86%, 640px); }
.msg-user { align-self: flex-end; align-items: flex-end; }
.msg-assistant { align-self: flex-start; align-items: flex-start; }
.msg-system { align-self: center; align-items: center; max-width: 94%; }
.bubble { min-width: 0; max-width: 100%; padding: 10px 13px; border-radius: 16px; font-size: 15.5px; line-height: 1.45; }
.msg-user .bubble {
  background: var(--user-bg); border: 1px solid var(--user-line); border-bottom-right-radius: 6px;
  color: var(--ink-strong);
}
.msg-assistant .bubble {
  background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-card);
}
.msg-system .bubble { background: transparent; padding: 4px 8px; font-size: 13px; color: var(--muted); text-align: center; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-text .ic { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }

.msg-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; line-height: 1.5; white-space: nowrap;
  background: var(--clay-tint); color: var(--clay-deep);
}
.tag .ic { width: 13px; height: 13px; }
.tag-queue { background: #f3ead4; color: #7a5a12; }
.tag-answer { background: #e5eedd; color: #3f6a3a; }
.tag-voice { background: rgba(255, 255, 255, .6); }
.tag-stale { background: #efe9df; color: #7a6e5d; }

.sources {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 9px; padding-top: 8px; border-top: 1px dashed var(--line-strong);
}
.src-chip {
  display: inline-block; max-width: 100%; padding: 3px 9px; border-radius: 8px;
  font-size: 11.5px; line-height: 1.4; color: var(--muted-strong);
  background: var(--surface-2); border: 1px solid var(--line); overflow-wrap: anywhere;
}
.src-more {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--clay-deep); font-size: 12px; font-weight: 700;
}
.src-more:hover { background: var(--clay-tint); }

.msg-meta {
  display: flex; align-items: center; gap: 4px; min-height: 20px; padding: 0 4px;
  font-size: 11.5px; color: var(--muted);
}
.msg-meta time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.play-btn {
  display: inline-flex; align-items: center; gap: 5px; min-height: 44px; min-width: 44px;
  padding: 0 12px 0 8px; border: 0; border-radius: 999px; background: transparent;
  color: var(--clay-deep); font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.play-btn .ic { width: 18px; height: 18px; }
.play-btn:hover { background: var(--clay-tint); }
.play-btn.playing { color: var(--err); }
.play-btn.loading .ic { animation: fade 1s ease-in-out infinite; }

/* Bule „în curs” (se trimite / transcriu) și bule eșuate */
.msg.pending .bubble { opacity: .82; }
.pending-note {
  display: flex; align-items: center; gap: 7px; margin-top: 6px;
  font-size: 12.5px; color: var(--muted-strong); font-style: italic;
}
.msg.failed .bubble { background: #fbeeec; border-color: rgba(176, 67, 58, .35); opacity: 1; }
.msg.failed .pending-note { color: #8e2f25; font-style: normal; font-weight: 600; }
.msg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.btn-small {
  min-height: 44px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 13.5px; font-weight: 600; color: var(--ink);
}
.btn-small.primary { border: 0; background: linear-gradient(135deg, var(--clay-hi), var(--clay-lo)); color: #fff; }
.spinner {
  display: inline-block; flex: none; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(163, 90, 44, .25); border-top-color: var(--clay-lo);
  animation: spin .9s linear infinite;
}

/* Starea goală + sugestii */
.empty { margin: auto 0; align-self: center; max-width: 440px; padding: 18px 4px 22px; text-align: center; color: var(--muted-strong); }
.empty .emblem-lg { margin: 0 auto 12px; }
.empty-title { margin: 0 0 6px; font-family: var(--serif); font-weight: 600; font-size: 20px; color: var(--ink-strong); }
.empty p { margin: 0 0 16px; font-size: 14px; line-height: 1.5; }
.suggestions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.suggestion {
  min-height: 44px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--user-line); background: var(--surface);
  color: var(--clay-deep); font-size: 14px; font-weight: 600; text-align: left;
}
.suggestion:hover { background: var(--user-bg); }

/* Butonul „Mesaje noi” când ești mai sus în istoric */
.new-pill {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 2;
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border: 0; border-radius: 999px; background: var(--ink-strong); color: #fff8ef;
  font-size: 13px; font-weight: 600; box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .55);
}
.new-pill .ic { width: 16px; height: 16px; }

/* ---------- Compozitorul: comutator voce + text + trimite + microfon ---------- */
.composer {
  flex: none; background: var(--surface); border-top: 1px solid var(--line);
  padding: 2px var(--gr) 10px var(--gl);
}
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; }
.switch {
  display: inline-flex; align-items: center; gap: 8px; flex: none; min-height: 44px; padding: 0 4px 0 0;
  border: 0; background: transparent; color: var(--muted-strong); font-size: 13px; font-weight: 600;
}
.switch-track {
  position: relative; flex: none; width: 38px; height: 22px; border-radius: 999px;
  background: #d9d0c2; transition: background .15s;
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s;
}
.switch[aria-checked="true"] { color: var(--ink-strong); }
.switch[aria-checked="true"] .switch-track { background: var(--ok); }
.switch[aria-checked="true"] .switch-thumb { transform: translateX(16px); }
.composer-hint { min-width: 0; font-size: 12px; line-height: 1.3; color: var(--muted); text-align: right; }
.composer-hint.busy { color: var(--clay-deep); font-weight: 600; }
.composer-hint.err { color: var(--err); }

.composer-row { display: flex; align-items: center; gap: 8px; }
.field { position: relative; flex: 1 1 auto; min-width: 0; }
.field textarea {
  display: block; width: 100%; min-height: 48px; max-height: 140px; margin: 0; padding: 12px 14px;
  border: 1px solid var(--line-strong); border-radius: 16px; background: #fff; color: var(--ink);
  font-size: 16px; line-height: 1.35; resize: none; overflow-y: auto;
  field-sizing: content; /* crește cu textul unde browserul știe; altfel JS pune .multi */
}
.field textarea.multi { height: 112px; }
.field textarea::placeholder { color: #ab9f8b; }
.field textarea:focus { outline: none; border-color: var(--clay); box-shadow: 0 0 0 3px rgba(176, 102, 58, .14); }

.send-btn {
  display: grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 50%;
  border: 0; background: var(--clay-tint); color: var(--clay-lo);
}
.send-btn:not(:disabled):hover { background: rgba(176, 102, 58, .16); }
.send-btn:disabled { background: transparent; color: #c4b8a5; }
.send-btn.busy .ic { animation: fade 1s ease-in-out infinite; }

.mic-btn {
  display: grid; place-items: center; flex: none; width: var(--mic); height: var(--mic); border-radius: 50%;
  border: 0; color: #fff8ef;
  background: linear-gradient(150deg, var(--clay-hi), var(--clay-deep));
  box-shadow: 0 14px 26px -14px rgba(150, 85, 47, .85), inset 0 1px 0 rgba(255, 255, 255, .25);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .08s, background .15s;
}
.mic-btn .ic { width: 30px; height: 30px; }
.mic-btn:active { transform: scale(.96); }
.mic-btn.recording { background: linear-gradient(150deg, #e0583f, #a92c1c); animation: rec-pulse 1.3s ease-out infinite; }
.mic-btn.busy { opacity: .65; }
.mic-btn.unavailable { background: linear-gradient(150deg, #cfc4b3, #b3a690); box-shadow: none; }

/* Panoul de înregistrare (ia locul câmpului de text cât înregistrezi) */
.rec-panel {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 4px 4px 4px 14px;
  border-radius: 16px; background: #fdf0ec; border: 1px solid rgba(198, 61, 43, .28); color: #8e2a1c;
}
.rec-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--rec); animation: blink 1s steps(2, start) infinite; }
.rec-time { flex: none; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rec-time.warn { color: var(--rec); }
.rec-hint { flex: 1 1 auto; min-width: 0; font-size: 12.5px; line-height: 1.3; }
.rec-cancel {
  display: grid; place-items: center; flex: none; width: 44px; height: 44px;
  border: 0; border-radius: 12px; background: transparent; color: #8e2a1c;
}
.rec-cancel:hover { background: rgba(198, 61, 43, .1); }

/* =============================================================================
   PANOU / CERERI / JURNAL
   ============================================================================= */
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head > div { min-width: 0; }
.panel-title { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 21px; line-height: 1.2; color: var(--ink-strong); }
.panel-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface);
  color: var(--clay-deep); font-size: 13.5px; font-weight: 600; white-space: nowrap;
}
.btn-ghost .ic { width: 18px; height: 18px; }
.btn-ghost:hover { background: var(--clay-tint); }
.btn-ghost.loading .ic { animation: spin .9s linear infinite; }

.counts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.count {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 13px; font-weight: 700; color: var(--ink); white-space: nowrap;
}

.flows { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.flow {
  min-width: 0; padding: 13px 14px 12px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--v-unknown);
  box-shadow: var(--shadow-card);
}
.flow.v-red { border-left-color: var(--v-red); }
.flow.v-yellow { border-left-color: var(--v-yellow); }
.flow.v-green { border-left-color: var(--v-green); }
.flow-head { display: flex; align-items: center; gap: 9px; }
.flow-verdict { flex: none; font-size: 19px; line-height: 1; }
/* „❔” e un semn alb: pe card alb abia se vede → îi dau un disc gri, ca să fie citit dintr-o privire */
.flow.v-unknown .flow-verdict, .count-unknown .count-emoji {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--v-unknown); font-size: 13px;
}
.count-unknown .count-emoji { width: 18px; height: 18px; font-size: 11px; }
.flow-name {
  min-width: 0; margin: 0; font-family: var(--serif); font-weight: 600; font-size: 16.5px; line-height: 1.25;
  color: var(--ink-strong); overflow-wrap: anywhere;
}
.flow-headline { margin: 7px 0 0; font-size: 14px; line-height: 1.45; color: var(--ink); overflow-wrap: anywhere; }
.flow-headline.muted { color: var(--muted); font-style: italic; }
.flow-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 9px; font-size: 12px; color: var(--muted); }
.needs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 9px; font-size: 12px; color: var(--muted-strong); }
.need { padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.need-owner { background: #f6e0cf; color: #8a4a1f; }
.need-dan { background: #e6ecf4; color: #34506e; }
.need-prod { background: #e5eedd; color: #3f6a3a; }
.prod { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 5px 12px; margin: 10px 0 0; font-size: 14px; }
.prod dt { color: var(--muted-strong); }
.prod dd { margin: 0; font-weight: 600; color: var(--ink-strong); overflow-wrap: anywhere; }

.list { display: flex; flex-direction: column; gap: 10px; }
.list-empty {
  grid-column: 1 / -1; margin: 0; padding: 28px 14px; border-radius: 14px; text-align: center;
  font-size: 14px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong);
}
.req {
  min-width: 0; padding: 12px 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-card);
}
.req-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.req-id { font-family: var(--mono); font-size: 12.5px; font-weight: 700; color: var(--muted-strong); }
.req-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill { margin-left: auto; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.st-pending { background: #f5e9c8; color: #7a5a12; }
.st-routed { background: #e6ecf4; color: #34506e; }
.st-answered { background: #e3eedf; color: #3f6a3a; }
.st-clarify { background: #f6e0cf; color: #8a4a1f; }
.st-superseded { background: #ece8e1; color: #6b6257; }
.st-rejected { background: #f3dcd8; color: #8e3329; }
.st-unknown { background: #ece8e1; color: #6b6257; }
.req-text { margin: 8px 0 0; font-size: 14.5px; line-height: 1.45; color: var(--ink-strong); white-space: pre-wrap; overflow-wrap: anywhere; }
.req-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12px; color: var(--muted-strong); overflow-wrap: anywhere; }
.risk { padding: 1px 8px; border-radius: 999px; background: #f6e0cf; color: #8a4a1f; font-weight: 700; white-space: nowrap; }

.audit { padding: 2px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-card); }
.audit-row { min-width: 0; padding: 10px 0; border-bottom: 1px solid var(--line); }
.audit-row:last-child { border-bottom: 0; }
.audit-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.audit-time { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.audit-action { font-size: 14px; font-weight: 700; color: var(--ink-strong); }
.audit-who, .audit-detail { margin-top: 2px; font-size: 12.5px; color: var(--muted-strong); overflow-wrap: anywhere; }
.audit-detail { color: var(--muted); }

/* ---------- Notificări scurte (toast) ---------- */
.toasts {
  position: fixed; z-index: 50; left: 50%; top: calc(env(safe-area-inset-top) + var(--bar-h) + 8px);
  transform: translateX(-50%); width: min(92vw, 440px);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  max-width: 100%; padding: 10px 14px; border-radius: 12px; pointer-events: auto;
  background: var(--ink-strong); color: #fff8ef; font-size: 13.5px; line-height: 1.4; text-align: center;
  box-shadow: 0 16px 34px -16px rgba(0, 0, 0, .55); overflow-wrap: anywhere;
  animation: toast-in .18s ease-out;
}
.toast.err { background: #8e2f25; }
.toast.ok { background: #44613f; }
.toast.warn { background: #6d5212; }
.toast.leaving { opacity: 0; transform: translateY(-6px); transition: opacity .25s, transform .25s; }

/* ---------- Animații ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { 50% { opacity: .35; } }
@keyframes blink { to { visibility: hidden; } }
@keyframes rec-pulse {
  0% { box-shadow: 0 0 0 0 rgba(198, 61, 43, .5); }
  70% { box-shadow: 0 0 0 18px rgba(198, 61, 43, 0); }
  100% { box-shadow: 0 0 0 0 rgba(198, 61, 43, 0); }
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* =============================================================================
   ADAPTĂRI PE LĂȚIME / ÎNĂLȚIME
   ============================================================================= */
@media (min-width: 400px) {
  .brand .emblem { display: grid; }
}
/* Telefon vertical mai lat: încape și numele în chip */
@media (min-width: 520px) and (max-width: 767px) and (min-height: 561px) {
  .chip { padding: 3px 12px 3px 3px; background: var(--surface-2); border: 1px solid var(--line); }
  .chip-name { display: block; }
}
@media (min-width: 640px) {
  .flows { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Ecran lat (laptop/tabletă) SAU telefon culcat: taburile urcă în bara de sus → un singur rând */
@media (min-width: 768px), (min-width: 560px) and (max-height: 560px) {
  .app {
    grid-template-columns: minmax(0, 1fr) auto 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "brand nav user" "main main main";
  }
  .tabs {
    justify-content: center; gap: 2px; padding: env(safe-area-inset-top) 4px 0;
    border-top: 0; border-bottom: 1px solid var(--line);
  }
  .tab { flex: 0 0 auto; flex-direction: row; gap: 7px; min-height: var(--bar-h); padding: 0 11px; font-size: 14px; }
  .tab .ic { width: 19px; height: 19px; }
  .tab[aria-selected="true"]::after { top: auto; bottom: -1px; left: 9px; right: 9px; border-radius: 3px 3px 0 0; }
  .tab-dot { top: 11px; left: auto; right: 2px; }
  .brand .emblem { display: grid; }
  .chip-text { display: none; }
  /* fără taburi jos: zona sigură de jos o iau compozitorul și panourile */
  .composer { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .panel { padding-bottom: max(28px, calc(env(safe-area-inset-bottom) + 16px)); }
  .panel-chat { padding-bottom: 0; } /* discuția: compozitorul stă lipit de marginea de jos */
}
/* Bara de sus îngustă (sub 900 px) sau telefon culcat: taburile doar cu text, ca să încapă */
@media (min-width: 768px) and (max-width: 899px), (min-width: 560px) and (max-height: 560px) {
  .tab .ic { display: none; }
}
@media (min-width: 900px) {
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
/* Laptop/desktop (lat ȘI înalt): titlul întreg + chip cu nume și rol */
@media (min-width: 900px) and (min-height: 561px) {
  .title-pre { display: inline; }
  .chip { padding: 3px 12px 3px 3px; background: var(--surface-2); border: 1px solid var(--line); }
  .chip-text { display: flex; }
  .chip-name { display: block; }
}

/* Ecran scund (telefon culcat): compactez barele și microfonul */
@media (max-height: 560px) {
  :root { --mic: 58px; --bar-h: 50px; }
  .brand-text { padding: 3px 0; }
  .disp-status { font-size: 11.5px; margin-top: 1px; }
  .tab { min-height: 50px; }
  .messages { padding-top: 10px; padding-bottom: 10px; }
  .thread { gap: 10px; }
  .banner { margin-top: 6px; padding: 7px 10px; font-size: 12.5px; }
  .mic-btn .ic { width: 26px; height: 26px; }
  .empty { padding: 8px 4px 10px; }
  .empty .emblem-lg { display: none; }
}

/* Fără animații pentru cine le-a dezactivat din sistem */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
  .mic-btn.recording { animation: none; box-shadow: 0 0 0 5px rgba(198, 61, 43, .35); }
  .rec-dot, .spinner, .play-btn.loading .ic, .send-btn.busy .ic, .btn-ghost.loading .ic { animation: none; }
}
