/* AgentOS — Centro de controle.
   Paleta derivada do Organograma Gerencial 2.0: marinho do cabeçalho e as cinco cores de divisão. */
:root {
  --ink: #101e34;
  --ink-2: #1b2d4a;
  --canvas: #f1f4f9;
  --panel: #ffffff;
  --panel-2: #f6f8fc;
  --line: #d8e0ec;
  --text: #1d2a3d;
  --muted: #5c6b80;
  --focus: #2868d6;
  --nutef: #2868d6;
  --apostileiros: #ad6a20;
  --advocacia: #7143ae;
  --corporativo: #15806b;
  --agentos: #b83b5b;
  --st-queued: #6b7a90;
  --st-running: #2868d6;
  --st-waiting: #7d5bb8;
  --st-needs_approval: #b7791f;
  --st-completed: #1f8a5b;
  --st-failed: #c0362c;
  --st-cancelled: #8b93a1;
  --danger: #c0362c;
  --display: "Bahnschrift", "DIN Alternate", "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  --mono: "Cascadia Mono", "Cascadia Code", ui-monospace, Consolas, "SF Mono", monospace;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #0b1526;
    --ink-2: #16243b;
    --canvas: #0f1a2b;
    --panel: #15233a;
    --panel-2: #1a2a44;
    --line: #2a3b57;
    --text: #e5ebf5;
    --muted: #98a6bd;
    --focus: #7aa7ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--body); color: var(--text); background: var(--canvas); }
[hidden] { display: none !important; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
a { color: var(--focus); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--display); font-stretch: condensed; font-weight: 600; letter-spacing: 0.01em; margin: 0; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
.eyebrow { font-family: var(--display); text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.78rem; color: var(--muted); margin: 0 0 4px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.85rem; }
.form-error { color: var(--danger); min-height: 1.2em; margin: 4px 0; }

/* ------------------------------------------------ login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--ink); }
.login-card { width: min(440px, 100%); background: var(--panel); border-radius: 14px; padding: 28px; display: grid; gap: 8px; }
.login-card .eyebrow { color: var(--agentos); }

/* ------------------------------------------------ casca */
.shell { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: 56px 1fr; min-height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-stretch: condensed; font-weight: 700; font-size: 1.3rem; letter-spacing: 0.04em; }
.brand-mark { width: 22px; height: 22px; border-radius: 4px; background: linear-gradient(90deg, var(--nutef) 0 20%, var(--apostileiros) 20% 40%, var(--advocacia) 40% 60%, var(--corporativo) 60% 80%, var(--agentos) 80%); }
.live { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: #c9d6ea; min-width: 0; flex: 1; }
.live #live-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live .dot { width: 9px; height: 9px; border-radius: 50%; background: #6b7a90; flex: none; }
.live.on .dot { background: #4cc38a; box-shadow: 0 0 0 0 rgba(76, 195, 138, 0.6); animation: pulse 2.4s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(76, 195, 138, 0); } 100% { box-shadow: 0 0 0 0 rgba(76, 195, 138, 0); } }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.whoami { font-size: 0.85rem; color: #c9d6ea; }
.nav { background: var(--panel); border-right: 1px solid var(--line); padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 56px; height: calc(100vh - 56px); overflow: auto; }
.nav button { all: unset; cursor: pointer; padding: 8px 12px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; color: var(--text); font-size: 0.95rem; }
.nav button:hover { background: var(--panel-2); }
.nav button[aria-current="page"] { background: var(--ink); color: #fff; }
.nav button:focus-visible { outline: 3px solid var(--focus); }
.nav .count { font-family: var(--mono); font-size: 0.75rem; background: var(--st-needs_approval); color: #fff; border-radius: 10px; padding: 0 7px; }
.main { padding: 20px 24px 60px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }

/* ------------------------------------------------ peças */
.btn { font: inherit; font-size: 0.9rem; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 6px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.ok { color: var(--st-completed); border-color: var(--st-completed); }
.btn.ghost { background: transparent; color: inherit; border-color: transparent; }
.topbar .btn.ghost { color: #c9d6ea; }
.btn.kill { background: transparent; color: #ffb4ac; border: 1.5px solid #ffb4ac; font-family: var(--display); font-stretch: condensed; letter-spacing: 0.06em; text-transform: uppercase; }
.btn.kill.on { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; min-width: 0; }
.card h3 { margin-bottom: 8px; }
.stat { font-family: var(--display); font-stretch: condensed; font-size: 2rem; font-weight: 600; line-height: 1.1; }
.stat small { font-family: var(--body); font-size: 0.85rem; font-weight: 400; color: var(--muted); display: block; }
.badge { display: inline-block; font-family: var(--display); font-stretch: condensed; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.72rem; padding: 1px 7px; border-radius: 4px; border: 1px solid currentColor; white-space: nowrap; }
.badge.demo { color: #b7791f; }
.badge.na { color: var(--muted); }
.badge.ok { color: var(--st-completed); }
.badge.bad { color: var(--danger); }
.state { display: inline-flex; align-items: center; gap: 6px; font-family: var(--display); font-stretch: condensed; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.78rem; white-space: nowrap; }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: currentColor; }
.state.queued { color: var(--st-queued); } .state.running { color: var(--st-running); } .state.waiting { color: var(--st-waiting); }
.state.needs_approval { color: var(--st-needs_approval); } .state.completed { color: var(--st-completed); } .state.failed { color: var(--st-failed); } .state.cancelled { color: var(--st-cancelled); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; font-family: var(--display); font-stretch: condensed; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.75rem; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 6px 8px; }
td { border-bottom: 1px solid var(--line); padding: 7px 8px; vertical-align: top; }
.table-wrap { overflow-x: auto; }
pre { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto; max-height: 360px; font: 0.82rem/1.45 var(--mono); white-space: pre-wrap; word-break: break-word; margin: 6px 0; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%; }
textarea { font-family: var(--mono); font-size: 0.85rem; min-height: 120px; }
label { font-size: 0.85rem; color: var(--muted); display: block; margin-top: 8px; }
form.inline { display: grid; gap: 6px; }
.empty { padding: 22px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r); }
.section { margin-top: 22px; }
.section > h2 { margin-bottom: 10px; }
.toast { position: fixed; bottom: 16px; right: 16px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 50; max-width: min(480px, calc(100vw - 32px)); }
.toast.err { background: var(--danger); }

/* ------------------------------------------------ fita de comando (assinatura) */
.chain { display: flex; height: 22px; border-radius: 4px; overflow: hidden; font-family: var(--mono); font-size: 0.68rem; max-width: 100%; }
.chain span { display: flex; align-items: center; padding: 0 7px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.chain span + span { box-shadow: inset 2px 0 0 rgba(255, 255, 255, 0.55); }
.chain span.last { flex: 1 0 auto; font-weight: 700; }
.div-NUTEF { background: var(--nutef); } .div-APOSTILEIROS { background: var(--apostileiros); } .div-ADVOCACIA { background: var(--advocacia); }
.div-CORPORATIVO { background: var(--corporativo); } .div-AGENTOS { background: var(--agentos); } .div-none { background: #4a5a74; }
.fg-NUTEF { color: var(--nutef); } .fg-APOSTILEIROS { color: var(--apostileiros); } .fg-ADVOCACIA { color: var(--advocacia); } .fg-CORPORATIVO { color: var(--corporativo); } .fg-AGENTOS { color: var(--agentos); }

/* ------------------------------------------------ tarefas */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; align-items: flex-start; }
.lane { flex: 1 0 260px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; min-height: 120px; }
.lane.vazia { flex: 0 0 132px; min-height: 0; opacity: 0.75; }
.lane.vazia h3 { flex-direction: column; gap: 2px; }
.lane h3 { margin-bottom: 8px; display: flex; justify-content: space-between; }
.strip { all: unset; display: grid; gap: 6px; width: 100%; box-sizing: border-box; background: var(--panel); border: 1px solid var(--line); border-left-width: 4px; border-radius: 8px; padding: 9px 10px; margin-bottom: 8px; cursor: pointer; }
.strip:hover { border-color: var(--muted); }
.strip:focus-visible { outline: 3px solid var(--focus); }
.strip .obj { font-size: 0.88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.strip .meta { display: flex; justify-content: space-between; gap: 6px; font-size: 0.75rem; color: var(--muted); }

/* ------------------------------------------------ organograma */
.org-top { display: grid; justify-items: center; gap: 6px; margin-bottom: 14px; }
.org-node { border-radius: 10px; padding: 8px 18px; text-align: center; }
.org-node.direcao { border: 1px solid var(--line); background: var(--panel); font-family: var(--display); font-stretch: condensed; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.85rem; }
.org-node.atlas { background: var(--ink); color: #fff; cursor: pointer; border: 0; font: inherit; }
.org-node.atlas strong { font-family: var(--display); font-stretch: condensed; font-size: 1.2rem; letter-spacing: 0.06em; display: block; }
.org-link { width: 2px; height: 14px; background: var(--line); }
.org-cols { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.org-col { min-width: 0; }
.org-div { all: unset; box-sizing: border-box; display: block; width: 100%; background: var(--panel); border: 1px solid var(--line); border-top: 5px solid currentColor; border-radius: 10px; padding: 10px 12px; cursor: pointer; margin-bottom: 10px; }
.org-div .name { font-family: var(--display); font-stretch: condensed; font-weight: 700; font-size: 1.15rem; letter-spacing: 0.03em; }
.org-sector { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px; }
.org-sector .sname { font-weight: 600; font-size: 0.88rem; margin-bottom: 6px; }
.chip { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 6px; width: 100%; padding: 4px 6px; border-radius: 6px; cursor: pointer; font-family: var(--mono); font-size: 0.72rem; }
.chip:hover { background: var(--panel-2); }
.chip:focus-visible { outline: 3px solid var(--focus); }
.chip.chief { font-weight: 700; margin-bottom: 2px; }
.chip .m { font-family: var(--display); font-size: 0.7rem; border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; color: var(--muted); }
.chip.dim { opacity: 0.55; }
.sdot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: none; }
.sdot.ocioso { background: var(--st-completed); } .sdot.executando { background: var(--st-running); } .sdot.pausado { background: var(--st-needs_approval); } .sdot.bloqueado { background: var(--danger); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted); margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }

/* ------------------------------------------------ gaveta */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: var(--panel); border-left: 1px solid var(--line); z-index: 30; display: flex; flex-direction: column; box-shadow: -12px 0 30px rgba(16, 30, 52, 0.18); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); gap: 8px; }
.drawer-head h2 { font-family: var(--mono); font-stretch: normal; font-size: 1.05rem; word-break: break-all; }
.drawer-body { padding: 16px 18px 40px; overflow: auto; }
.scrim { position: fixed; inset: 0; background: rgba(16, 30, 52, 0.35); z-index: 25; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 4px 12px; font-size: 0.9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; word-break: break-word; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 0.85rem; }
.timeline li { padding: 4px 0 4px 14px; border-left: 2px solid var(--line); }
.timeline time { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); margin-right: 6px; }
.warn-box { border: 1px solid var(--st-needs_approval); background: color-mix(in srgb, var(--st-needs_approval) 9%, var(--panel)); border-radius: 8px; padding: 8px 12px; font-size: 0.88rem; margin: 8px 0; }
.bar { display: flex; height: 12px; border-radius: 3px; overflow: hidden; background: var(--panel-2); border: 1px solid var(--line); }
.bar span { height: 100%; }

/* .org-div usa all:unset; a cor da divisão precisa de especificidade maior */
.org-div.fg-NUTEF { color: var(--nutef); } .org-div.fg-APOSTILEIROS { color: var(--apostileiros); } .org-div.fg-ADVOCACIA { color: var(--advocacia); }
.org-div.fg-CORPORATIVO { color: var(--corporativo); } .org-div.fg-AGENTOS { color: var(--agentos); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 56px auto 1fr; }
  .nav { flex-direction: row; position: static; height: auto; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 6px 8px; }
  .nav button { flex: none; }
  .main { padding: 16px; }
  .whoami { display: none; }
  .kv { grid-template-columns: 1fr; }
  .org-cols { grid-template-columns: repeat(5, 240px); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
