/* Bandeja Vento — consola de atención por WhatsApp.
   Dirección: tablero de operaciones nocturno de la marca: tinta casi negra,
   lima Vento como señal, Archivo Black para rótulos, Archivo para leer. */

:root {
  --ink: #0a0a0a;
  --ink-2: #111211;
  --surface: #161716;
  --surface-2: #1d1f1c;
  --surface-3: #262924;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f2f2f2;
  --text-soft: #c9cbc6;
  --muted: #8f918c;
  --lime: #8db600;
  --lime-bright: #a6d400;
  --lime-wash: rgba(141, 182, 0, 0.12);
  --lime-line: rgba(141, 182, 0, 0.35);
  --alert: #ff5a36;
  --alert-wash: rgba(255, 90, 54, 0.12);
  --note: #ffb020;
  --note-wash: rgba(255, 176, 32, 0.08);
  --sky: #5fb4ff;

  --display: "Archivo Black", "Arial Black", system-ui, sans-serif;
  --body: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --text-xs: 0.72rem;
  --text-sm: 0.82rem;
  --text-base: 0.94rem;
  --text-lg: 1.15rem;
  --text-xl: 1.6rem;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 18px;
  --rail: 72px;
  --list: 360px;
  --info: 300px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --fast: 140ms;
  --normal: 260ms;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--body);
  font-size: var(--text-base);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--lime-bright); }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--lime-bright);
  outline-offset: 2px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---------- Rótulos y controles base ---------- */

.label {
  font-family: var(--display);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  font-weight: 600; font-size: var(--text-sm);
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:hover { background: var(--surface-3); border-color: var(--muted); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--lime); border-color: var(--lime); color: var(--ink); }
.btn-primary:hover { background: var(--lime-bright); border-color: var(--lime-bright); }
.btn-danger { border-color: rgba(255, 90, 54, 0.5); color: var(--alert); background: transparent; }
.btn-danger:hover { background: var(--alert-wash); border-color: var(--alert); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn-sm { min-height: 30px; padding: 0 12px; font-size: var(--text-xs); }

.field { display: grid; gap: 6px; }
.input, .select, .textarea {
  width: 100%;
  background: var(--ink-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--lime); background: #0d0e0c; }
.textarea { resize: vertical; line-height: 1.5; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  width: 38px; height: 22px; border-radius: 999px; background: var(--surface-3);
  border: 1px solid var(--line-strong); position: relative;
  transition: background var(--normal) var(--ease), border-color var(--normal) var(--ease);
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--muted);
  transition: transform var(--normal) var(--ease), background var(--normal) var(--ease);
}
.switch input:checked + .track { background: var(--lime-wash); border-color: var(--lime); }
.switch input:checked + .track::after { transform: translateX(16px); background: var(--lime-bright); }
.switch input:focus-visible + .track { outline: 2px solid var(--lime-bright); outline-offset: 2px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  font-size: var(--text-xs); font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--text-soft); white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--tag, var(--muted)); }

.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--lime); color: var(--ink);
  font-size: 0.68rem; font-weight: 800;
}
.badge-alert { background: var(--alert); color: #fff; }

/* ---------- Esqueleto de la app ---------- */

.app {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  height: 100dvh;
  overflow: hidden;
}

.rail {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 16px 0;
  background: #070707;
  border-right: 1px solid var(--line);
}
.rail-logo { width: 38px; height: 38px; margin-bottom: 18px; }
.rail-nav { display: flex; flex-direction: column; gap: 6px; }
.rail-btn {
  position: relative;
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.rail-btn svg { width: 22px; height: 22px; }
.rail-btn:hover { color: var(--text); background: var(--surface); }
.rail-btn[aria-current="page"] { color: var(--lime-bright); background: var(--lime-wash); border-color: var(--lime-line); }
.rail-btn .badge { position: absolute; top: 2px; right: 0; transform: translateX(30%); }
.rail-btn .tip {
  position: absolute; left: calc(100% + 12px); top: 50%; transform: translate(-4px, -50%);
  background: var(--surface-3); color: var(--text); border: 1px solid var(--line-strong);
  padding: 5px 10px; border-radius: var(--radius-sm); font-size: var(--text-xs); font-weight: 600;
  white-space: nowrap; pointer-events: none; opacity: 0;
  transition: opacity var(--fast) var(--ease), transform var(--fast) var(--ease); z-index: 20;
}
.rail-btn:hover .tip, .rail-btn:focus-visible .tip { opacity: 1; transform: translate(0, -50%); }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; }

.bot-power {
  width: 48px; padding: 8px 0 6px; border-radius: 14px;
  display: grid; justify-items: center; gap: 4px;
  border: 1px solid var(--line-strong); background: var(--surface);
  font-family: var(--display); font-size: 0.56rem; letter-spacing: 0.1em; color: var(--muted);
}
.bot-power .led { width: 9px; height: 9px; border-radius: 50%; background: var(--alert); box-shadow: 0 0 0 3px var(--alert-wash); }
.bot-power.on { border-color: var(--lime-line); color: var(--lime-bright); }
.bot-power.on .led { background: var(--lime-bright); box-shadow: 0 0 0 3px var(--lime-wash), 0 0 12px var(--lime); }
.bot-power:disabled { cursor: default; }

.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-3); border: 1px solid var(--line-strong);
  font-family: var(--display); font-size: 0.8rem; color: var(--text);
}
button.avatar:hover { border-color: var(--lime); }

.view { min-width: 0; min-height: 0; }

/* ---------- Bandeja: tres columnas ---------- */

.inbox {
  display: grid;
  grid-template-columns: var(--list) minmax(0, 1fr) var(--info);
  height: 100%;
}
.inbox.no-info { grid-template-columns: var(--list) minmax(0, 1fr); }

.list-pane {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--line);
  background: var(--ink-2);
}
.list-head { padding: 20px 18px 12px; display: grid; gap: 14px; border-bottom: 1px solid var(--line); }
.list-title { display: flex; align-items: baseline; justify-content: space-between; }
.list-title h1 { margin: 0; font-family: var(--display); font-size: var(--text-xl); letter-spacing: -0.01em; text-transform: uppercase; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 34px; border-radius: 999px; }

.filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.filter {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  padding: 6px 11px; border-radius: 999px;
  background: transparent; border: 1px solid var(--line-strong);
  color: var(--text-soft); font-size: var(--text-xs); font-weight: 700;
  transition: all var(--fast) var(--ease);
}
.filter:hover { border-color: var(--muted); color: var(--text); }
.filter[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--ink); }
.filter.urgent .n { color: var(--alert); }
.filter[aria-pressed="true"].urgent { background: var(--alert); border-color: var(--alert); color: #fff; }
.filter[aria-pressed="true"].urgent .n { color: #fff; }
.filter-row { display: flex; gap: 8px; }
.list-head > .select { padding: 6px 10px; font-size: var(--text-xs); border-radius: 999px; }
.chip.line-chip { color: var(--sky); border-color: rgba(95, 180, 255, 0.35); }
.filter-row .select { padding: 6px 10px; font-size: var(--text-xs); border-radius: 999px; }

.conv-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.conv {
  position: relative;
  display: grid; grid-template-columns: 1fr auto; gap: 3px 10px;
  width: 100%; text-align: left;
  padding: 12px 12px 12px 16px; border-radius: var(--radius);
  background: transparent; border: 1px solid transparent;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.conv:hover { background: var(--surface); }
.conv[aria-current="true"] { background: var(--surface-2); border-color: var(--line-strong); }
.conv::before {
  content: ""; position: absolute; left: 5px; top: 14px; bottom: 14px; width: 3px; border-radius: 3px;
  background: transparent;
}
.conv.is-urgent::before { background: var(--alert); }
.conv.is-unread .conv-name { color: var(--text); }
.conv.is-unread .conv-preview { color: var(--text-soft); }
.conv-name { font-weight: 700; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: var(--text-xs); color: var(--muted); }
.conv.is-unread .conv-time { color: var(--lime-bright); font-weight: 700; }
.conv > .badge { justify-self: end; align-self: center; }
.conv-preview {
  grid-column: 1; font-size: var(--text-sm); color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-meta { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; margin-top: 5px; flex-wrap: wrap; }
.conv-meta .who { font-size: var(--text-xs); color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.conv-meta .who svg { width: 13px; height: 13px; }
.tag-dots { display: inline-flex; gap: 3px; }
.tag-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--tag); }

.list-empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.list-empty strong { display: block; font-family: var(--display); text-transform: uppercase; color: var(--text-soft); margin-bottom: 6px; letter-spacing: 0.04em; }
.list-more { margin: 8px auto 16px; display: flex; }

/* ---------- Chat ---------- */

.chat-pane {
  display: grid; grid-template-rows: auto 1fr auto; min-height: 0;
  background:
    radial-gradient(1200px 500px at 70% -10%, rgba(141, 182, 0, 0.06), transparent 60%),
    var(--ink);
}
.chat-empty { display: grid; place-items: center; text-align: center; color: var(--muted); padding: 40px; grid-row: 1 / -1; }
.chat-empty .big { font-family: var(--display); font-size: clamp(2rem, 1rem + 3vw, 3.6rem); line-height: 0.95; color: var(--surface-3); text-transform: uppercase; letter-spacing: -0.02em; }

.chat-head {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  background: rgba(10, 10, 10, 0.85); backdrop-filter: blur(10px);
}
.chat-back { display: none; }
.chat-who { min-width: 0; flex: 1; }
.chat-who h2 { margin: 0; font-size: var(--text-lg); font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-who .sub { font-size: var(--text-xs); color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.state-pill {
  font-family: var(--display); font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--text-soft);
}
.state-pill.requiere_humano { border-color: var(--alert); color: var(--alert); background: var(--alert-wash); }
.state-pill.abierta { border-color: var(--lime-line); color: var(--lime-bright); }
.state-pill.prueba { border-color: var(--sky); color: var(--sky); }
.chat-actions { display: flex; gap: 8px; align-items: center; }

.messages { overflow-y: auto; padding: 24px clamp(16px, 4vw, 48px) 12px; display: flex; flex-direction: column; gap: 4px; }
.day-sep { align-self: center; margin: 16px 0 8px; }

.msg { max-width: min(560px, 82%); display: grid; gap: 4px; animation: rise var(--normal) var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg + .msg.other-side { margin-top: 10px; }
.bubble {
  padding: 10px 14px; border-radius: var(--radius-lg);
  white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: var(--text-base);
}
.msg-meta { font-size: 0.7rem; color: var(--muted); display: flex; gap: 6px; align-items: center; padding: 0 6px; }
.msg-meta .who { font-family: var(--display); letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.6rem; }

.msg.in { align-self: flex-start; }
.msg.in .bubble { background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 6px; }

.msg.out { align-self: flex-end; justify-items: end; }
.msg.bot .bubble { background: var(--ink-2); border: 1px solid var(--lime-line); border-bottom-right-radius: 6px; color: var(--text); }
.msg.bot .who { color: var(--lime); }
.msg.op .bubble { background: var(--lime); color: var(--ink); border-bottom-right-radius: 6px; font-weight: 500; }
.msg.op .bubble a { color: var(--ink); }
.msg.op .who { color: var(--text-soft); }
.msg.failed .bubble { border: 1px dashed var(--alert); background: var(--alert-wash); color: var(--text); }
.ticks { display: inline-flex; color: var(--muted); }
.ticks svg { width: 15px; height: 15px; }
.ticks.read { color: var(--sky); }
.ticks.fail { color: var(--alert); }

.msg.note { align-self: center; max-width: min(620px, 92%); justify-items: center; }
.msg.note .bubble {
  background: var(--note-wash); border: 1px dashed rgba(255, 176, 32, 0.45);
  color: #ffd27a; font-size: var(--text-sm); border-radius: var(--radius);
}
.msg.note .who { color: var(--note); }
.msg.system { align-self: center; max-width: 92%; }
.msg.system .bubble { background: transparent; color: var(--muted); font-size: var(--text-xs); padding: 4px 10px; text-align: center; }

.media img { display: block; max-width: 280px; max-height: 320px; border-radius: var(--radius); margin-bottom: 6px; background: var(--surface-3); }
.media audio { display: block; width: 260px; margin-bottom: 6px; }

.typing { align-self: flex-end; display: flex; align-items: center; gap: 8px; color: var(--lime); font-size: var(--text-xs); padding: 8px 6px; }
.typing span { display: inline-flex; gap: 3px; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--lime); animation: blink 1.2s infinite var(--ease); }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.composer { border-top: 1px solid var(--line); padding: 12px clamp(12px, 3vw, 28px) 16px; background: var(--ink-2); display: grid; gap: 10px; }
.composer-banner {
  font-size: var(--text-sm); color: var(--text-soft);
  padding: 10px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line);
}
.composer-banner.warn { border-color: rgba(255, 176, 32, 0.4); background: var(--note-wash); color: #ffd27a; }
.composer-banner.bot { border-color: var(--lime-line); background: var(--lime-wash); color: var(--text); display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.composer-row { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea {
  flex: 1; min-height: 46px; max-height: 180px; resize: none; overflow-y: hidden;
  border-radius: 22px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line-strong);
}
.composer textarea:focus { outline: none; border-color: var(--lime); }
.composer.is-note textarea { border-color: rgba(255, 176, 32, 0.55); background: var(--note-wash); }
.composer.as-runner textarea { border-color: var(--sky); }
.send {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--lime); color: var(--ink); border: 0;
  transition: transform var(--fast) var(--ease), background var(--fast) var(--ease);
}
.send svg { width: 20px; height: 20px; }
.send:hover { background: var(--lime-bright); }
.send:active { transform: scale(0.92); }
.send:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
.composer.is-note .send { background: var(--note); }
.composer-tools { display: flex; gap: 16px; align-items: center; font-size: var(--text-xs); color: var(--muted); flex-wrap: wrap; }
.composer-tools .switch { font-weight: 600; color: var(--text-soft); }
.composer-tools .hint { margin-left: auto; }

/* ---------- Panel de detalle ---------- */

.info-pane { border-left: 1px solid var(--line); background: var(--ink-2); overflow-y: auto; padding: 20px 18px; display: grid; align-content: start; gap: 22px; }
.info-block { display: grid; gap: 10px; }
.info-phone { font-family: var(--mono); font-size: var(--text-sm); color: var(--text-soft); }
.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  background: transparent; border: 1px dashed var(--line-strong); color: var(--muted);
  font-size: var(--text-xs); font-weight: 600;
  transition: all var(--fast) var(--ease);
}
.tag-toggle .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--tag); opacity: 0.5; }
.tag-toggle:hover { border-color: var(--tag); color: var(--text-soft); }
.tag-toggle[aria-pressed="true"] { border-style: solid; border-color: var(--tag); color: var(--text); background: color-mix(in srgb, var(--tag) 14%, transparent); }
.tag-toggle[aria-pressed="true"] .dot { opacity: 1; }
.info-actions { display: grid; gap: 8px; }

/* ---------- Pantallas de gestión ---------- */

.page { height: 100%; overflow-y: auto; padding: clamp(20px, 4vw, 48px); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-family: var(--display); font-size: clamp(2rem, 1.2rem + 2.4vw, 3.2rem); line-height: 0.95; text-transform: uppercase; letter-spacing: -0.02em; }
.page-head p { margin: 8px 0 0; color: var(--muted); max-width: 60ch; }

.split { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 28px; align-items: start; }
.side-list { display: grid; gap: 6px; }
.side-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius); text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.side-item:hover { border-color: var(--line-strong); }
.side-item[aria-current="true"] { border-color: var(--lime); background: var(--lime-wash); }
.side-item small { color: var(--muted); font-size: var(--text-xs); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: clamp(18px, 2.5vw, 28px); display: grid; gap: 18px; }
.panel-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: end; }
.panel-row > .field { flex: 1; min-width: 200px; }
.kb-editor { font-family: var(--mono); font-size: 0.86rem; min-height: 52vh; tab-size: 2; }
.kb-help { font-size: var(--text-sm); color: var(--text-soft); background: var(--ink-2); border-left: 3px solid var(--lime); padding: 12px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.kb-help code { font-family: var(--mono); color: var(--note); }
.kb-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.kb-foot .count { color: var(--muted); font-size: var(--text-xs); margin-right: auto; }
.kb-foot .pending { color: var(--note); font-size: var(--text-xs); font-weight: 700; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-strong); }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr.inactive td { opacity: 0.45; }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.color-input { width: 44px; height: 38px; padding: 2px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--ink-2); }

/* ---------- Diálogos y avisos ---------- */

dialog {
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text); padding: 0;
  width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(3px); }
.dialog-body { padding: 24px; display: grid; gap: 16px; }
.dialog-body h2 { margin: 0; font-family: var(--display); text-transform: uppercase; font-size: var(--text-lg); letter-spacing: 0.02em; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; pointer-events: none; }
.toast {
  padding: 11px 18px; border-radius: 999px; background: var(--text); color: var(--ink);
  font-weight: 600; font-size: var(--text-sm); box-shadow: var(--shadow);
  animation: rise var(--normal) var(--ease);
}
.toast.error { background: var(--alert); color: #fff; }

.form-error { color: var(--alert); font-size: var(--text-sm); min-height: 1.2em; margin: 0; }

/* ---------- Login ---------- */

.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 16px;
  background:
    radial-gradient(800px 420px at 15% 0%, rgba(141, 182, 0, 0.16), transparent 60%),
    radial-gradient(600px 400px at 100% 100%, rgba(141, 182, 0, 0.08), transparent 60%),
    var(--ink);
}
.login-card { width: min(400px, 100%); display: grid; gap: 28px; }
.login-brand img { width: 150px; height: auto; }
.login-brand h1 { margin: 18px 0 0; font-family: var(--display); font-size: clamp(2.2rem, 1.6rem + 2vw, 3rem); line-height: 0.92; text-transform: uppercase; letter-spacing: -0.02em; }
.login-brand h1 span { color: var(--lime); }
.login-brand p { margin: 10px 0 0; color: var(--muted); }
.login form { display: grid; gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; }
.login .btn-primary { min-height: 46px; font-size: var(--text-base); }

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .inbox { grid-template-columns: var(--list) minmax(0, 1fr); }
  .info-pane { display: none; }
  .inbox.show-info .info-pane {
    display: grid; position: fixed; right: 0; top: 0; bottom: 0; width: min(340px, 100vw);
    z-index: 30; box-shadow: var(--shadow);
  }
}

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .rail { flex-direction: row; justify-content: space-around; padding: 6px 8px; border-right: 0; border-top: 1px solid var(--line); order: 2; }
  .rail-logo { display: none; }
  .rail-nav { flex-direction: row; }
  .rail-foot { margin: 0; flex-direction: row; }
  .rail-btn .tip { display: none; }
  .bot-power { width: auto; padding: 6px 10px; grid-auto-flow: column; }
  .inbox { grid-template-columns: 1fr; }
  .inbox .chat-pane { display: none; }
  .inbox.chat-open .list-pane { display: none; }
  .inbox.chat-open .chat-pane { display: grid; }
  .chat-back { display: inline-flex; }
  .chat-head { padding: 10px 12px; gap: 8px; }
  .chat-actions .hide-sm { display: none; }
  .composer-tools .hint { display: none; }
  .msg { max-width: 90%; }
  .split { grid-template-columns: 1fr; }
  .table thead { display: none; }
  .table tr { display: grid; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .table td { border: 0; padding: 4px 0; }
  .table .actions { justify-content: flex-start; }
  .page { padding: 20px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
