/* Fontes hospedadas no próprio servidor (sem enviar o IP dos usuários ao Google) */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('/static/fonts/inter-latin-wght.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('/static/fonts/jetbrains-mono-latin-400.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('/static/fonts/jetbrains-mono-latin-500.woff2') format('woff2'); }

/* ============================================================
   Sistema visual compartilhado (painel e inbox)
   ============================================================ */
:root {
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;

  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f4f8;
  --border: #e4e8ee;
  --border-strong: #cfd6df;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;

  --accent: #0d9467;
  --accent-hover: #0a7d57;
  --accent-soft: #e7f6f0;
  --accent-text: #ffffff;
  --accent-ink: #0a6b4b;

  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --info: #2563eb;
  --info-soft: #e8f0fe;

  --sidebar: #0c1a1f;
  --sidebar-2: #13252b;
  --sidebar-text: #c7d3d6;
  --sidebar-muted: #7f9399;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .14);
  --ring: 0 0 0 3px rgba(13, 148, 103, .18);

  --chat-bg: #efeae2;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;

  /* compatibilidade com nomes antigos usados no JS */
  --panel: var(--surface);
  --chip: var(--surface-3);
  --code: var(--surface-3);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0e13;
    --surface: #10161d;
    --surface-2: #131a22;
    --surface-3: #18212b;
    --border: #1f2934;
    --border-strong: #2d3a48;
    --text: #e7ecf2;
    --text-2: #c3ccd7;
    --muted: #8b98a8;
    --faint: #5f6c7b;

    --accent: #10b981;
    --accent-hover: #34d399;
    --accent-soft: rgba(16, 185, 129, .12);
    --accent-text: #04241a;
    --accent-ink: #4ade9e;

    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, .12);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, .12);
    --info: #60a5fa;
    --info-soft: rgba(96, 165, 250, .12);

    --sidebar: #070b0f;
    --sidebar-2: #101820;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 6px 20px rgba(0, 0, 0, .25);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);
    --ring: 0 0 0 3px rgba(16, 185, 129, .25);

    --chat-bg: #0b141a;
    --bubble-in: #1f2c33;
    --bubble-out: #005c4b;
    color-scheme: dark;
  }
}

/* Tema escolhido manualmente (botão de tema) */
:root[data-theme="dark"] {
  --bg: #0a0e13;
  --surface: #10161d;
  --surface-2: #131a22;
  --surface-3: #18212b;
  --border: #1f2934;
  --border-strong: #2d3a48;
  --text: #e7ecf2;
  --text-2: #c3ccd7;
  --muted: #8b98a8;
  --faint: #5f6c7b;

  --accent: #10b981;
  --accent-hover: #34d399;
  --accent-soft: rgba(16, 185, 129, .12);
  --accent-text: #04241a;
  --accent-ink: #4ade9e;

  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .12);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, .12);

  --sidebar: #070b0f;
  --sidebar-2: #101820;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 6px 20px rgba(0, 0, 0, .25);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);
  --ring: 0 0 0 3px rgba(16, 185, 129, .25);

  --chat-bg: #0b141a;
  --bubble-in: #1f2c33;
  --bubble-out: #005c4b;
  color-scheme: dark;
}


* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body { margin: 0; font: 14px/1.5 var(--font); background: var(--bg); color: var(--text); overflow-x: hidden; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent-soft); }

/* ---------- Tipografia ---------- */
h1, h2, h3 { color: var(--text); letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 700; margin: 0; }
h2 { font-size: 15px; font-weight: 650; margin: 0 0 14px; }
h3 { font-size: 13px; font-weight: 650; margin: 0; }
.muted { color: var(--muted); }
.help { font-size: 12.5px; color: var(--muted); margin: -4px 0 0; line-height: 1.45; }
.err { color: var(--danger); font-size: 13px; }
code, pre { font-family: var(--mono); font-size: 12px; background: var(--surface-3); border-radius: 6px; }
code { padding: 1px 6px; }
pre { padding: 12px; overflow: auto; max-height: 280px; margin: 0; border: 1px solid var(--border); }

/* ---------- Botões ---------- */
button {
  font: 500 13.5px/1 var(--font); cursor: pointer; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 14px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
  white-space: nowrap;
}
button:hover { background: var(--surface-2); border-color: var(--faint); color: var(--text); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
button.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
button.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
button.ghost { background: transparent; border-color: transparent; box-shadow: none; }
button.ghost:hover { background: var(--surface-3); }
button.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
button svg { width: 16px; height: 16px; flex: none; }
button.sm svg { width: 14px; height: 14px; }

/* ---------- Formulários ---------- */
input, textarea, select {
  font: 14px/1.4 var(--font); color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 9px 12px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, textarea:hover, select:hover { border-color: var(--faint); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input:disabled { background: var(--surface-3); color: var(--faint); }
textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
input[type=checkbox] {
  width: 18px; height: 18px; flex: none; margin: 0; padding: 0; accent-color: var(--accent); cursor: pointer; box-shadow: none;
}
input[type=file] { padding: 7px; background: var(--surface-2); border-style: dashed; cursor: pointer; }
input[type=file]::file-selector-button {
  font: 500 13px var(--font); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  border-radius: 6px; padding: 6px 12px; margin-right: 10px; cursor: pointer;
}
label { display: grid; gap: 6px; font-size: 13px; font-weight: 550; color: var(--text-2); }
label.inline { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--text); cursor: pointer; }

/* Interruptor (checkbox com classe .switch) */
.switchrow { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.switchrow .t { flex: 1; }
.switchrow .t b { display: block; font-weight: 600; font-size: 14px; }
.switchrow .t span { color: var(--muted); font-size: 12.5px; }
input.switch {
  appearance: none; width: 38px; height: 22px; border-radius: 22px; background: var(--border-strong); position: relative;
  transition: background .2s; border: 0; cursor: pointer; margin-top: 2px;
}
input.switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s;
}
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(16px); }
input.switch:focus-visible { box-shadow: var(--ring); }

details { border-radius: var(--radius-sm); }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 550; list-style: none; display: flex; align-items: center; gap: 6px; user-select: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: ''; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin: 0 4px 0 2px; }
details[open] summary::before { transform: rotate(45deg); }
details summary:hover { color: var(--text); }

/* ---------- Cartões ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.card-h { display: flex; align-items: center; gap: 10px; margin: -4px 0 16px; }
.card-h h2 { margin: 0; flex: 1; }
.card-h .ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); flex: none; }
.card-h .ico svg { width: 17px; height: 17px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; border: 0; }

/* ---------- Utilitários ---------- */
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 20px; align-items: start; }
.tablewrap { overflow-x: auto; margin: 0 -20px; }
.url { font-family: var(--mono); font-size: 11.5px; color: var(--muted); display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }

/* ---------- Tabelas ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 20px; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
td { text-align: left; padding: 12px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-2); }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td b { color: var(--text); font-weight: 600; }

/* ---------- Selos ---------- */
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; line-height: 1; padding: 5px 9px; border-radius: 999px; background: var(--surface-3); color: var(--muted); white-space: nowrap; flex: none; }
.tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.tag.ok, .tag.t-end, .tag.t-handoff, .tag.t-ai { background: var(--accent-soft); color: var(--accent-ink); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.info, .tag.t-action, .tag.t-condition { background: var(--info-soft); color: var(--info); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Mensagem vazia ---------- */
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }

/* ---------- Rolagem discreta ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- Tela de login (compartilhada) ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-brand {
  position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; color: #e6f4ef;
  background: radial-gradient(1200px 600px at -10% -20%, #12a477 0%, transparent 55%), radial-gradient(900px 500px at 120% 120%, #0b6e8a 0%, transparent 55%), #0b1d22;
}
.auth-brand::after {
  content: ''; position: absolute; inset: 0; opacity: .08; pointer-events: none;
  background-image: linear-gradient(#fff 1px, transparent 1px), linear-gradient(90deg, #fff 1px, transparent 1px); background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}
.auth-brand > * { position: relative; z-index: 1; }
.auth-brand h1 { color: #fff; font-size: 34px; line-height: 1.15; max-width: 460px; letter-spacing: -0.02em; }
.auth-brand p { color: #b6d3ca; font-size: 15px; max-width: 440px; margin: 14px 0 0; }
.auth-feats { display: grid; gap: 14px; margin-top: 36px; }
.auth-feats div { display: flex; gap: 12px; align-items: flex-start; color: #d5ebe3; font-size: 14px; }
.auth-feats svg { width: 20px; height: 20px; flex: none; color: #4ade9e; margin-top: 1px; }
.auth-form { display: grid; place-items: center; padding: 32px 20px; background: var(--surface); }
.auth-form form { width: 100%; max-width: 380px; display: grid; gap: 16px; }
.auth-form h2 { font-size: 24px; font-weight: 700; margin: 0; }
.auth-form .sub { color: var(--muted); margin: -8px 0 8px; }
.auth-form button.primary { padding: 12px; font-size: 14.5px; }
.auth-foot { font-size: 12px; color: #8fb3a8; display: flex; gap: 8px; align-items: center; }
.brandmark { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: #fff; letter-spacing: -0.01em; }
.brandmark .logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, #22c58f, #0d9467); color: #fff; box-shadow: 0 6px 18px rgba(13,148,103,.4); }
.brandmark .logo svg { width: 19px; height: 19px; }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 28px 24px; }
  .auth-brand h1 { font-size: 24px; }
  .auth-feats, .auth-foot { display: none; }
}

/* ---------- Seletor de tema ---------- */
.themebtn svg { width: 18px; height: 18px; }
.themebtn .t-auto, .themebtn .t-light, .themebtn .t-dark { display: none; }
:root:not([data-theme]) .themebtn .t-auto, :root[data-theme="auto"] .themebtn .t-auto { display: block; }
:root[data-theme="light"] .themebtn .t-light { display: block; }
:root[data-theme="dark"] .themebtn .t-dark { display: block; }
html.theme-anim, html.theme-anim * { transition: background-color .25s, border-color .25s, color .2s !important; }
.auth-form { position: relative; }
.auththeme { position: absolute; top: 18px; right: 18px; }

/* ============================================================
   Responsividade: nada de texto cortado em botões
   ============================================================ */
/* Botões nunca encolhem abaixo do próprio texto; quem quebra linha é o contêiner */
button { flex-shrink: 0; max-width: 100%; }
.row, .card-h, .pagehead .actions { flex-wrap: wrap; }
.card-h h2 { min-width: 120px; }
/* Campos dentro de linhas flexíveis podem encolher (os botões não) */
.row > input, .row > select, .row > textarea { min-width: 0; flex: 1 1 160px; }
select { text-overflow: ellipsis; }
/* Rótulo de botão que pode ser escondido em telas estreitas, mantendo o ícone */
.lbl { display: inline; }
