/* ===========================================================
   Plataforma Onco SES-SP — tema CAF/GGAF (editorial bege/dourado).
   Alinhado com o Dashboard de Programações da Coordenadoria.
   =========================================================== */
:root {
  /* base — identidade SES-SP: marinho + dourado sobre azul-claro (ex-bege) */
  --bg: #f4f8fc;            /* fundo azul-claro */
  --bg-soft: #eaf1fa;       /* variação */
  --surface: #ffffff;       /* cards */
  --surface-2: #eaf1fa;     /* superfície secundária azul-clara */
  --border: #d7e3f0;        /* borda discreta */
  --border-strong: #b9cde3; /* borda azul mais forte */
  --divider: rgba(10, 37, 64, 0.10);

  /* tipografia / cores */
  --text: #17324d;          /* azul-escuro (corpo/títulos) */
  --text-soft: #3e556d;     /* corpo geral (escurecido p/ contraste no tema claro) */
  --muted: #4d6579;         /* labels, captions (escurecido — antes #7d93a8 lavava no claro) */
  --gold: #c6a15b;          /* dourado acento */
  --gold-dark: #a4813f;     /* dourado escuro */
  --brown: #1c4e8a;         /* AÇÃO principal = azul (ex-marrom) */
  --brown-dark: #123a63;    /* azul escuro hover */

  /* marinho — superfícies escuras (sidebar, faixas) */
  --ink: #0a2540; --ink-2: #123a63; --blue: #1c4e8a; --blue-soft: #2f6bb0;
  --sky: #eaf1fa; --sky-2: #f4f8fc;
  --on-dark: #eaf2fb; --on-dark-2: #cfe0f2; --gov: #a9c6e6;

  /* status */
  --ok: #2e7d55;
  --ok-bg: #e4f1ea;
  --warn: #9e7818;
  --warn-bg: #f6ecd3;
  --bad: #b23a2e;
  --bad-bg: #f8e7e3;

  /* helpers */
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(10, 37, 64, 0.06);
  --shadow-md: 0 8px 30px rgba(10, 37, 64, 0.10);
  --shadow-card: 0 1px 3px rgba(10, 37, 64, 0.08);
  --serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ───────── Cabeçalho institucional (topo das páginas internas) ───────── */
.topbar-sp {
  display: none; /* removido — padrão CAF não usa faixa SP cheia */
}

.header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header .brand {
  display: flex;
  align-items: baseline;
  gap: 16px;
}
.header .brand .ornament {
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0.04em;
}
.header .brand h1 {
  font-family: var(--serif);
  font-size: 22px;
  margin: 0;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.header .brand .ver {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  margin-left: 8px;
}
.header .crumbs {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ───────── Faixa de usuário (substitui faixa amarela) ───────── */
.user-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 13px;
  padding: 10px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.user-bar .who {
  font-weight: 600;
  color: var(--text);
}
.user-bar .who .role {
  color: var(--gold-dark);
  border: 1px solid var(--border-strong);
  background: #faf5ec;
  padding: 3px 10px;
  border-radius: 999px;
  margin-left: 10px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
}
.user-bar form { margin: 0; }
.user-bar .logout-btn {
  background: transparent;
  color: var(--brown);
  border: 1px solid var(--border-strong);
  padding: 5px 14px;
  font-size: 12px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: all 0.15s ease;
}
.user-bar .logout-btn:hover {
  background: var(--brown);
  color: var(--surface);
}

/* ───────── Nav da unidade (sub-barra fininha) ───────── */
.unidade-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  gap: 4px;
  align-items: stretch;
  overflow-x: auto;
}
.unidade-nav a {
  font-size: 13px;
  color: var(--text-soft);
  text-decoration: none;
  padding: 12px 16px;
  border-bottom: 2px solid transparent;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.unidade-nav a:hover {
  color: var(--brown);
  background: rgba(0,0,0,.02);
}
.unidade-nav a.active {
  color: var(--brown-dark);
  border-bottom-color: var(--gold);
  font-weight: 700;
}

/* ───────── Container ───────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px 32px 60px;
}
h2.page-title {
  font-family: var(--sans);
  font-size: 27px;
  margin: 0 0 4px;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: -0.01em;
}
.page-sub {
  color: var(--text-soft);
  margin: 0 0 24px;
  font-size: 13px;
}
.page-sub strong { color: var(--ink); font-weight: 700; }  /* prazo, nº de itens etc. em destaque */

/* ───────── Card ───────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 24px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.card h3 {
  font-family: var(--sans);
  margin: 0 0 14px;
  font-size: 18px;
  color: var(--ink);
  font-weight: 800;
}
.card.with-stripe {
  border-left: 3px solid var(--brown);
}

/* ───────── Form ───────── */
label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brown);
  box-shadow: 0 0 0 3px rgba(139, 94, 60, 0.12);
}
input::placeholder { color: #c0ad95; }
.form-row { margin-bottom: 16px; }

.btn {
  display: inline-block;
  padding: 12px 24px;
  font-size: 13px;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all 0.18s ease;
}
.btn-primary {
  background: linear-gradient(180deg, var(--gold-dark) 0%, var(--brown) 100%);
  color: var(--surface);
  box-shadow: 0 2px 4px rgba(139, 94, 60, 0.20);
}
.btn-primary:hover {
  filter: brightness(0.94);
  box-shadow: 0 4px 8px rgba(139, 94, 60, 0.30);
}
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--brown);
}

/* ───────── Login — 1 coluna centralizada (mesmo padrão do Dashboard CAF) ───────── */
.login-wrap {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 60px 24px 40px;
}
.login-institucional {
  text-align: center;
  margin-bottom: 26px;
  width: 100%;
  max-width: 720px;
}
.login-institucional .crest {
  font-size: 12px;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--brown);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-bottom: 8px;
  text-transform: none;
}
.login-institucional .crest::before,
.login-institucional .crest::after {
  content: '';
  height: 1px;
  flex: 0 0 56px;
  background: var(--border-strong);
}
.login-institucional .crest-sub {
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 28px;
}
.login-institucional .titulo {
  font-family: var(--serif);
  font-size: 56px;
  color: var(--text);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 22px 0;
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}
.login-institucional .titulo .login-ver {
  font-family: var(--mono, monospace);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0;
  background: var(--surface-2);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  cursor: help;
  align-self: center;
}
.login-institucional .ano {
  display: inline-block;
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.2em;
  color: var(--text);
  border: 1.5px solid var(--border-strong);
  padding: 6px 22px;
  border-radius: 999px;
  margin-bottom: 18px;
}
.login-institucional .escopo {
  font-size: 14px;
  color: var(--text-soft);
  font-weight: 500;
}
.login-institucional .escopo b {
  color: var(--brown);
  font-weight: 700;
}
.login-institucional .divider {
  width: 60px;
  height: 1px;
  background: var(--gold);
  margin: 22px auto 0;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
.login-card .btn-primary { width: 100%; padding: 14px; }

.login-actions {
  width: 100%;
  max-width: 620px;
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.login-actions .btn {
  width: 100%;
  text-align: center;
  padding: 10px;
  font-size: 11px;
}
.login-footer {
  margin-top: 32px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-align: center;
}
.login-help {
  font-size: 11px;
  color: var(--muted);
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  line-height: 1.7;
  letter-spacing: 0.02em;
}
.login-help code {
  background: var(--surface-2);
  color: var(--brown-dark);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 10px;
}

@media (max-width: 680px) {
  .login-institucional .titulo { font-size: 40px; }
  .login-actions { grid-template-columns: 1fr; }
}

/* ───────── Alertas ───────── */
.alert {
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  border-left: 3px solid;
}
.alert-ok { background: var(--ok-bg); color: var(--ok); border-left-color: var(--ok); }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-left-color: var(--warn); }
.alert-bad { background: var(--bad-bg); color: var(--bad); border-left-color: var(--bad); }

/* ───────── Tabela ───────── */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
  padding: 12px 14px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  border-bottom: 1px solid var(--border-strong);
}
table.tbl td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-soft);
}
table.tbl tr:hover td { background: var(--surface-2); }
table.tbl .num { font-family: var(--mono); text-align: right; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: var(--surface-2); color: var(--brown-dark); border: 1px solid var(--border); }
.badge-soft { background: #f1ebe0; color: var(--muted); }

/* código inline */
code {
  background: var(--surface-2);
  color: var(--brown-dark);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.9em;
}

a { color: var(--brown); text-decoration: underline; text-decoration-color: var(--gold); }
a:hover { color: var(--brown-dark); }

/* ═══════════════════════════════════════════════════════════════════
   Admin shell (sidebar + content) — padrão CEAF
   ═══════════════════════════════════════════════════════════════════ */
body.has-sidebar { background: var(--bg); }
.admin-shell { min-height: 100vh; }

/* ───────── sidebar: colapsada (64px) → expande no hover (248px) ───────── */
.admin-sidebar {
  position: fixed; top: 0; left: 0; height: 100vh; width: 64px; z-index: 50;
  background: linear-gradient(180deg, var(--ink), #0b2a4c);
  color: var(--on-dark);
  border-right: 3px solid var(--gold);
  padding: 0 0 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  white-space: nowrap;
  transition: width .18s ease, box-shadow .18s ease;
}
.admin-sidebar:hover { width: 248px; box-shadow: 6px 0 34px rgba(10, 37, 64, .38); }
.sb-brand {
  display: flex; align-items: center; gap: 9px;
  padding: 0 0 0 10px; min-height: 58px; flex: none;
  border-bottom: 1px solid rgba(255, 255, 255, .10); margin: 0;
}
.sb-brand::before {                        /* selo dourado ONCO — sempre visível (colapsado) */
  content: 'ONCO'; flex: none;
  padding: 0 7px; height: 23px; border-radius: 6px;
  background: linear-gradient(140deg, var(--gold), var(--gold-dark));
  color: var(--ink); font-family: var(--sans); font-weight: 800; font-size: 10.5px; letter-spacing: .05em;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.sb-brand-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.sb-brand-ver {
  font-family: var(--mono, monospace);
  font-size: 10px;
  font-weight: 700;
  color: var(--gov);
  letter-spacing: 0;
  background: rgba(255, 255, 255, .08);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(198, 161, 91, .4);
  cursor: help;
}
.sb-brand-sub { display: none; }           /* enxuga o topo colapsado */

.sb-section-label {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  color: var(--gov);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 14px 20px 6px;
}
.sb-nav { display: flex; flex-direction: column; gap: 1px; padding: 8px; }

.sb-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--on-dark-2);
  text-decoration: none;
  font-weight: 600;
  border-left: 3px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.sb-item:hover {
  background: rgba(255, 255, 255, .06);
  color: #fff;
}
.sb-item.active {
  background: rgba(198, 161, 91, .15);
  color: #fff;
  border-left-color: var(--gold);
  font-weight: 700;
}
.sb-item.disabled {
  color: var(--gov);
  cursor: not-allowed;
  opacity: 0.6;
}
.sb-item.disabled:hover { background: transparent; }

.sb-icon {
  width: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  opacity: .95;
  flex-shrink: 0;
}
.sb-icon svg { width: 18px; height: 18px; display: block; }
.sb-item.active .sb-icon { color: var(--gold); }

.sb-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.2;
  flex-shrink: 0;
}
.sb-badge-warn { background: rgba(158, 120, 24, .28); color: #e7c56a; }
.sb-badge-pend { background: rgba(178, 58, 46, .26); color: #f0a99f; }
.sb-badge-bad { background: rgba(178, 58, 46, .26); color: #f0a99f; }
.sb-badge-ok { background: rgba(46, 125, 85, .26); color: #86d3a9; }
.sb-badge-info { background: rgba(198, 161, 91, .22); color: var(--gold); }
.sb-badge-soft { background: rgba(255, 255, 255, .08); color: var(--gov); }
.sb-badge-num {
  background: rgba(255, 255, 255, .08);
  color: #cfe0f2;
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .12);
}

.sb-footer {
  margin-top: auto;
  padding: 12px 20px 0;
  border-top: 1px solid rgba(255, 255, 255, .10);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--gov);
  letter-spacing: 0.04em;
}

/* ───────── main (área de conteúdo) ───────── */
.admin-main {
  margin-left: 64px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  background: var(--bg);
}
/* ────────────────────────────────────────────────────────────────
   Topbar — padrão "Nível 3 + selo" (ver BRIEFING_AGENTES_PADRAO_VISUAL_E_COR.md)
   Cor da plataforma ONCO: #c9a227 (amarelo dourado), selo "ONCO".
   ──────────────────────────────────────────────────────────────── */
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  height: 56px;
  flex: none;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.adm-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.adm-selo {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  color: var(--ink) !important;
  background: linear-gradient(140deg, var(--gold), var(--gold-dark)) !important;
  border-radius: 6px;
  padding: 4px 10px;
  flex: none;
}
.adm-crumbs {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
}
.adm-crumbs b { color: var(--ink); }
.adm-ver {
  font-family: var(--mono, monospace);
  font-size: 10px;
  font-weight: 700;
  color: var(--blue);
  background: var(--sky);
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  cursor: help;
  letter-spacing: 0;
}
.adm-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.adm-user-email {
  color: var(--text);
  font-weight: 600;
}
.adm-user-role {
  color: var(--blue);
  border: 1px solid var(--border-strong);
  background: var(--sky);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}
.adm-logout {
  background: transparent;
  color: var(--blue);
  border: 1px solid var(--border-strong);
  padding: 5px 14px;
  font-size: 11px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: all 0.15s ease;
  font-family: inherit;
}
.adm-logout:hover {
  background: var(--blue);
  color: #fff;
}
.admin-content {
  padding: 26px 30px 56px;
  flex: 1;
  max-width: 1520px;   /* aproveita a tela, mas não estica ao infinito em monitores grandes */
  width: 100%;
}

/* ───────── responsive (hover não existe em touch → sidebar vira barra no topo) ───────── */
@media (max-width: 860px) {
  .admin-sidebar {
    position: static; width: 100%; height: auto;
    flex-direction: row; flex-wrap: wrap; align-items: center;
    border-right: 0; border-bottom: 3px solid var(--gold); overflow: visible;
  }
  .admin-sidebar:hover { width: 100%; box-shadow: none; }
  .sb-brand { border-bottom: 0; }
  .sb-section-label { display: none; }
  .sb-nav { flex-direction: row; overflow-x: auto; flex-basis: 100%; padding: 4px 8px; }
  .sb-item { border-left: 0; border-bottom: 3px solid transparent; white-space: nowrap; }
  .sb-item.active { border-left: 0; border-bottom-color: var(--gold); }
  .sb-label { overflow: visible; }
  .sb-footer { display: none; }
  .admin-main { margin-left: 0; }
  .admin-topbar, .admin-content { padding-left: 16px; padding-right: 16px; }
}
