:root {
  --primary: #0f5fa8;
  --primary-dark: #0b4a82;
  --bg: #f2f4f7;
  --panel: #ffffff;
  --border: #dde2e8;
  --text: #1f2937;
  --muted: #6b7280;
  --danger: #c0392b;
  --danger-bg: #fdecea;
  --warn: #b8860b;
  --warn-bg: #fff6e0;
  --ok: #1e8e3e;
  --ok-bg: #e7f6ec;
  --crit: #8e1e1e;
  --crit-bg: #fbe4e4;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; }

/* ---------- Login ---------- */
/* coluna: area central (logo + card) que ocupa o espaco disponivel + rodape no fluxo normal
   logo abaixo dela - evita que o card fique sobreposto ao logo da MA Consultoria em telas
   mais baixas (o rodape nunca fica "por baixo" do conteudo, so empurra/faz rolar se precisar) */
.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #0f5fa8 0%, #123a63 100%);
}
.login-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
}
/* logo fica fora do card de login (nao mais dentro do espaco com padding), livre para
   ser exibido maior, sem espremer os campos do formulario abaixo */
.login-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.login-logo { display: block; width: min(70vw, 340px); height: auto; }
.login-back { align-self: flex-start; color: rgba(255,255,255,0.85); font-size: 12.5px; text-decoration: none; margin-bottom: -6px; }
.login-back:hover { color: #fff; text-decoration: underline; }
.login-box {
  background: var(--panel);
  padding: 36px 40px;
  border-radius: 12px;
  width: 360px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.login-box h1 { font-size: 19px; margin: 0 0 4px; text-align: center; }
.login-box .subtitle { color: var(--muted); margin: 0 0 20px; font-size: 13px; text-align: center; }
.login-box label { display: block; font-size: 12px; font-weight: 600; margin: 12px 0 4px; color: var(--muted); }
.login-box input {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
}
.login-box button {
  margin-top: 20px; width: 100%; padding: 10px; background: var(--primary); color: #fff;
  border: none; border-radius: 6px; font-size: 14px; font-weight: 600;
}
.login-box button:hover { background: var(--primary-dark); }
.password-field { position: relative; }
.password-field input { padding-right: 38px; }
.login-box .password-toggle-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  margin-top: 0; width: auto; background: none; border: none; cursor: pointer;
  font-size: 16px; line-height: 1; padding: 6px; color: var(--muted); border-radius: 4px;
}
.login-box .password-toggle-btn:hover { color: var(--text); background: rgba(0,0,0,0.06); }
.login-forgot-row { text-align: right; margin-top: 6px; }
.login-box .login-forgot-row .btn-link {
  margin-top: 0; width: auto; background: none; padding: 0;
  font-size: 12.5px; font-weight: 500; color: var(--primary); cursor: pointer;
}
.login-box .login-forgot-row .btn-link:hover { text-decoration: underline; background: none; }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 16px; }
.field-error { color: var(--danger); font-size: 11.5px; min-height: 14px; display: block; }
.form-field input.invalid { border-color: var(--danger); background: var(--danger-bg, #fdeceb); }

/* ---------- App shell ---------- */
.app { height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: var(--primary); color: #fff; display: flex; align-items: center;
  justify-content: space-between; padding: 0 16px; height: 76px; gap: 16px; flex-shrink: 0; flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.brand { font-weight: 700; font-size: 15px; white-space: nowrap; }
.ctx-select {
  padding: 5px 8px; border-radius: 5px; border: none; font-size: 12.5px; max-width: 220px;
}
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 12.5px; white-space: nowrap; }
.topbar-logo { height: 51px; width: auto; display: block; }
.btn-link { background: none; border: none; color: #fff; text-decoration: underline; font-size: 12.5px; }

/* corpo: conteudo a esquerda + menu lateral recolhivel a direita */
.body-shell { flex: 1; display: flex; overflow: hidden; }
.content { flex: 1; overflow: auto; padding: 20px; }

/* ---------- Rodape (marca MA Consultoria em TI) ---------- */
.app-footer {
  flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 34px; padding: 0 16px; background: #fff; border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--muted);
}
.app-footer .footer-logo { height: 18px; width: auto; display: block; }
.app-footer a { color: var(--primary); text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }
.app-footer-login { flex-shrink: 0; height: auto; padding: 10px 16px 18px; background: transparent; border-top: none; color: rgba(255,255,255,0.75); }
.app-footer-login a { color: #fff; }

/* ---------- Menu lateral (sidebar) ---------- */
.sidebar {
  width: 190px; flex-shrink: 0; background: #fff; border-left: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden;
  transition: width .18s ease;
}
.sidebar.collapsed { width: 56px; }
.sidebar-toggle {
  background: none; border: none; border-bottom: 1px solid var(--border); color: var(--muted);
  padding: 10px; font-size: 15px; align-self: flex-end; width: 100%; text-align: center;
}
.sidebar-toggle:hover { background: #f2f4f7; color: var(--primary); }
.sidebar.collapsed .sidebar-toggle-icon { display: inline-block; transform: rotate(180deg); }
.tabs { display: flex; flex-direction: column; gap: 2px; padding: 8px; flex: 1; }
.tab-btn {
  background: transparent; border: none; color: var(--text); padding: 9px 10px; font-size: 13px;
  border-radius: 6px; white-space: nowrap; display: flex; align-items: center; gap: 10px; text-align: left; width: 100%;
}
.tab-btn:hover { background: #eaf3fb; color: var(--primary-dark); }
.tab-btn.active { background: var(--primary); color: #fff; font-weight: 600; }
.tab-icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }
.tab-label { overflow: hidden; text-overflow: ellipsis; }
.sidebar.collapsed .tab-btn { justify-content: center; padding: 9px 0; }
.sidebar.collapsed .tab-label { display: none; }

/* ---------- Generic UI ---------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 12px; font-size: 16px; }
.panel h3 { margin: 18px 0 8px; font-size: 13.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.row { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.row > .panel { flex: 1; min-width: 280px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.toolbar h1 { font-size: 19px; margin: 0; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }
tr:hover td { background: #f8fafc; }

.btn {
  background: var(--primary); color: #fff; border: none; padding: 8px 14px; border-radius: 6px; font-size: 13px; font-weight: 600;
}
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn.secondary:hover { background: #eaf3fb; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #a5311f; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.crit { background: var(--crit-bg); color: var(--crit); }
.badge.muted { background: #eef0f3; color: var(--muted); }
.badge.info { background: #e6f0fb; color: var(--primary); }
.impersonation-banner {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  background: #fff3cd; color: #7a5c00; padding: 8px 16px; font-size: 13px; font-weight: 600;
  border-bottom: 1px solid #f0d98c;
}
.impersonation-banner.hidden { display: none; }
.impersonation-banner .btn.small { font-weight: 600; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; }
.form-grid.full { grid-template-columns: 1fr; }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-field.span2 { grid-column: span 2; }
.form-field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.form-field input, .form-field select, .form-field textarea {
  padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 13.5px; font-family: inherit;
}
.form-field textarea { resize: vertical; min-height: 50px; }
.form-field.checkbox-field { justify-content: center; }
.form-field.checkbox-field label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text); }
.form-field.checkbox-field input[type="checkbox"] { width: auto; }
.form-actions { display: flex; gap: 8px; margin-top: 14px; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.empty-state { color: var(--muted); font-style: italic; padding: 20px 0; text-align: center; }

/* ---------- Sub-list builders (areas envolvidas / prerequisitos) ---------- */
.sub-list { border: 1px dashed var(--border); border-radius: 6px; padding: 10px; margin-top: 6px; }
.sub-row { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 8px; flex-wrap: wrap; }
.sub-row .form-field { flex: 1; min-width: 140px; }
.sub-row .remove-btn { background: var(--danger-bg); color: var(--danger); border: none; border-radius: 6px; padding: 7px 10px; font-size: 12px; height: fit-content; }

/* ---------- Kanban ---------- */
/* estrutura em coluna que preenche 100% da altura disponivel em #content: o cabecalho
   (kanban-toolbar) fica com sua altura natural e o quadro (kanban-board-holder) ocupa todo o
   resto - assim a barra de rolagem horizontal do quadro sempre fica "colada" no fim da area
   util, sem sobrar espaco em branco entre ela e o rodape */
.kanban-page { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.kanban-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; flex-shrink: 0; }
.kanban-filter-group { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.kanban-filter-check { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.kanban-filter-check input { width: auto; }
.kanban-board-holder { flex: 1; min-height: 0; }
.kanban-board { box-sizing: border-box; display: flex; gap: 12px; overflow-x: auto; overflow-y: hidden; padding-bottom: 10px; align-items: stretch; height: 100%; }
/* colunas crescem para ocupar a largura disponivel (poucas areas = colunas mais largas) e
   preenchem toda a altura disponivel (em vez de encolher para o tamanho do conteudo), evitando
   o quadro "flutuar" pequeno no meio de uma tela grande */
.kanban-col { background: #eef1f5; border-radius: 8px; flex: 1 1 260px; min-width: 230px; max-width: 340px; display: flex; flex-direction: column; height: 100%; }
.kanban-col-header { padding: 10px 12px; font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); display: flex; justify-content: space-between; border-bottom: 1px solid #dde2e8; }
.kanban-col-body { padding: 8px; overflow-y: auto; flex: 1; min-height: 60px; }
.kanban-col-body.dragover { background: #dceafc; }
.kcard {
  background: #fff; border: 1px solid var(--border); border-radius: 7px; padding: 10px; margin-bottom: 8px;
  cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.kcard:hover { border-color: var(--primary); }
.kcard.has-occ { border-left: 4px solid var(--danger); }
.kcard .kcard-code { font-weight: 700; font-size: 12.5px; }
.kcard .kcard-name { font-size: 12.5px; margin: 4px 0; color: var(--text); }
.kcard .kcard-keyuser { font-size: 11.5px; color: var(--primary-dark); font-weight: 600; margin-bottom: 4px; }
.kcard .kcard-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5); display: flex; align-items: flex-start;
  justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50;
}
.modal-box { background: #fff; border-radius: 10px; width: 100%; max-width: 640px; padding: 22px 26px; margin-bottom: 40px; }
.modal-box.wide { max-width: 800px; }
.modal-box.xwide { max-width: 1180px; }
.modal-box.xwide table { table-layout: fixed; }
.modal-box.xwide table td, .modal-box.xwide table th { word-wrap: break-word; overflow-wrap: break-word; }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--muted); line-height: 1; }
.modal-section { margin-top: 16px; }
.modal-section h4 { margin: 0 0 8px; font-size: 12.5px; text-transform: uppercase; color: var(--muted); letter-spacing: .02em; }

.history-item { border-left: 2px solid var(--border); padding: 4px 0 4px 12px; margin-bottom: 4px; font-size: 12.5px; }
.history-item .h-meta { color: var(--muted); font-size: 11px; }

/* ---------- Dashboard ---------- */
.kpi-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.kpi-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px;
  min-width: 170px; flex: 1; display: flex; align-items: center; gap: 12px;
}
.kpi-card .kpi-icon { font-size: 22px; line-height: 1; }
.kpi-card .kpi-value { font-size: 24px; font-weight: 700; color: var(--primary); }
.kpi-card .kpi-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi-card.kpi-primary { background: #eaf3fb; border-color: #cfe3f5; }
.kpi-card.kpi-danger { background: var(--danger-bg); border-color: #f5c9c2; }
.kpi-card.kpi-danger .kpi-value { color: var(--danger); }
.kpi-card.kpi-ok { background: var(--ok-bg); border-color: #c6ead2; }
.kpi-card.kpi-ok .kpi-value { color: var(--ok); }

.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 40px; gap: 8px; align-items: center; font-size: 12.5px; }
.bar-track { background: #eef1f5; border-radius: 4px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 4px; }
.bar-fill.danger { background: var(--danger); }
.bar-fill.warn { background: var(--warn); }
.bar-fill.crit { background: var(--crit); }
.bar-fill.ok { background: var(--ok); }

/* segmented control: alterna entre os estilos "Visual leve" e "Gráficos" no dashboard */
.seg-control { display: flex; background: #eef1f5; border-radius: 8px; padding: 3px; gap: 2px; }
.seg-control button { background: transparent; border: none; padding: 6px 12px; font-size: 12.5px; border-radius: 6px; color: var(--muted); font-weight: 600; }
.seg-control button.active { background: #fff; color: var(--primary-dark); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg-control button:hover:not(.active) { color: var(--text); }

/* donut de status (estilo "Visual leve") */
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut-legend { font-size: 11.5px; line-height: 2; color: var(--text); }
.donut-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }

/* lista de saude das areas */
.health-list { display: flex; flex-direction: column; gap: 9px; }
.health-row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.health-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.health-dot.ok { background: var(--ok); }
.health-dot.warn { background: var(--warn); }
.health-dot.danger { background: var(--danger); }
.health-name { min-width: 120px; }
.health-count { white-space: nowrap; color: var(--text); font-size: 11.5px; margin-left: auto; }

/* container dos graficos Chart.js (estilo "Gráficos") */
.chart-box { position: relative; height: 220px; }

/* ---------- Pagina institucional (landing, publica) ---------- */
.landing-nav { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.landing-nav-inner {
  max-width: 1100px; margin: 0 auto; padding: 8px 24px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
}
.landing-nav-spacer { min-width: 0; }
.landing-nav-logo { height: 216px; width: auto; display: block; justify-self: center; }
.landing-nav-right { display: flex; align-items: center; gap: 22px; justify-self: end; }
.landing-nav-links { display: flex; gap: 22px; }
.landing-nav-links a { color: var(--text); text-decoration: none; font-size: 13.5px; font-weight: 600; }
.landing-nav-links a:hover { color: var(--primary); }

@media (max-width: 700px) {
  .landing-nav-inner { grid-template-columns: 1fr; justify-items: center; gap: 8px; padding: 10px 16px; }
  .landing-nav-spacer { display: none; }
  .landing-nav-logo { height: 96px; }
  .landing-nav-right { justify-self: center; flex-wrap: wrap; justify-content: center; }
}

.landing-hero {
  background: linear-gradient(135deg, #0f5fa8 0%, #123a63 100%); color: #fff; text-align: center;
  padding: 64px 24px;
}
.landing-hero-inner { max-width: 720px; margin: 0 auto; }
.landing-hero h1 { font-size: 32px; margin: 0 0 14px; }
.landing-hero-sub { font-size: 15px; line-height: 1.6; color: rgba(255,255,255,0.88); margin: 0 0 28px; }
.landing-hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.landing-hero-cta .btn { padding: 11px 22px; font-size: 14px; }
.landing-hero-cta .btn.secondary { background: transparent; color: #fff; border-color: rgba(255,255,255,0.6); }
.landing-hero-cta .btn.secondary:hover { background: rgba(255,255,255,0.12); }

.landing-features { max-width: 1100px; margin: 0 auto; padding: 56px 24px; text-align: center; }
.landing-features h2 { font-size: 24px; margin: 0 0 32px; }
.landing-feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; text-align: left; }
.landing-feature-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.landing-feature-icon { font-size: 26px; margin-bottom: 10px; }
.landing-feature-card h3 { font-size: 14.5px; margin: 0 0 8px; }
.landing-feature-card p { font-size: 12.5px; color: var(--muted); line-height: 1.55; margin: 0; }

.landing-plans { background: #eef1f5; padding: 56px 24px; text-align: center; }
.landing-plans h2 { font-size: 24px; margin: 0 0 8px; }
.landing-plans-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 32px; }
.landing-plans-grid { max-width: 1100px; margin: 0 auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; text-align: left; }
.landing-plan-card {
  position: relative;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 24px;
  display: flex; flex-direction: column; box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.landing-plan-card.highlighted {
  border-color: var(--primary); box-shadow: 0 6px 18px rgba(15,95,168,0.16); transform: translateY(-4px);
}
.landing-plan-badge {
  position: absolute; top: -12px; right: 20px; background: var(--primary); color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px; padding: 4px 12px; border-radius: 999px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.landing-plan-card h3 { font-size: 17px; margin: 0 0 6px; }
.landing-plan-price { color: var(--primary); font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.landing-plan-users { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.landing-plan-desc { font-size: 12.5px; color: var(--text); line-height: 1.5; margin: 0 0 14px; }
.landing-plan-features-intro { font-size: 12px; font-weight: 700; color: var(--text); margin: 0 0 8px; }
.landing-plan-features { list-style: none; margin: 0 0 20px; padding: 0; flex: 1; }
.landing-plan-features li {
  font-size: 12.5px; color: var(--text); line-height: 1.5; padding: 3px 0 3px 22px; position: relative;
}
.landing-plan-features li::before {
  content: "✓"; position: absolute; left: 0; top: 3px; color: var(--primary); font-weight: 700;
}
.landing-plan-btn { width: 100%; margin-top: auto; }

@media (max-width: 900px) {
  .landing-feature-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .landing-feature-grid { grid-template-columns: 1fr; }
  .landing-hero h1 { font-size: 26px; }
}

@media (max-width: 760px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-field.span2 { grid-column: span 1; }
}
