:root {
  --brand-navy: #0b1d33;
  --brand-navy-soft: #132c47;
  --brand-green: #28a745;
  --brand-green-dark: #1f7a36;
  --brand-teal: #0d6e6e;
  --brand-mint: #a6e3a1;
  --bg: #f2f4f7;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d9e1ea;
  --accent: var(--brand-teal);
  --accent-dark: #095757;
  --accent-soft: #e8f7ec;
  --sidebar: var(--brand-navy);
  --focus-ring: rgba(40, 167, 69, .24);
  --shadow-sm: 0 2px 8px rgba(11, 29, 51, .06);
  --shadow-md: 0 12px 32px rgba(11, 29, 51, .11);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-sans: "Poppins", "Segoe UI", Arial, sans-serif;
}

html { color-scheme: light; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.45;
}

a, button, input, select, textarea, summary { transition: color .16s ease, background-color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s ease; }

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.sidebar {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: linear-gradient(180deg, var(--brand-navy) 0%, #071523 100%);
  padding: 18px 16px;
  box-shadow: 5px 0 24px rgba(11, 29, 51, .08);
}

.sidebar::after {
  content: "";
  position: absolute;
  z-index: -2;
  inset: 0;
  background:
    radial-gradient(circle at 72% 22%, rgba(13, 110, 110, .2), transparent 30%),
    radial-gradient(circle at 20% 72%, rgba(40, 167, 69, .08), transparent 32%);
  pointer-events: none;
}

.sidebar > :not(.sidebar-map-watermark) { position: relative; z-index: 1; }

.sidebar-map-watermark {
  position: absolute;
  z-index: -1;
  top: 150px;
  right: -72px;
  width: 260px;
  height: auto;
  color: #23a6ba;
  opacity: .19;
  filter: drop-shadow(0 0 12px rgba(31, 203, 221, .24));
  pointer-events: none;
}

.sidebar-map-outline,
.sidebar-map-network path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sidebar-map-outline { stroke-width: 2; }
.sidebar-map-network path { stroke-width: 1; }
.sidebar-map-network circle { fill: #2bd38a; stroke: #0b1d33; stroke-width: 1; }

.brand {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  margin: 0 -2px 20px;
  padding: 10px;
  border: 1px solid rgba(166, 227, 161, .18);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 255, 255, .09), rgba(13, 110, 110, .08));
  box-shadow: inset 0 1px rgba(255, 255, 255, .06), 0 10px 26px rgba(0, 0, 0, .12);
}

.brand-logo {
  width: 58px;
  height: 58px;
  padding: 4px;
  object-fit: contain;
  border-radius: 13px;
  background: #fff;
  box-shadow: 0 7px 18px rgba(0, 0, 0, .2);
}

.brand-copy { display: grid; min-width: 0; line-height: 1.05; }
.brand-copy strong { color: #36c26a; font-size: 18px; font-style: italic; font-weight: 850; letter-spacing: -.025em; text-transform: uppercase; }
.brand-copy strong span { color: #fff; }
.brand-copy small { margin-top: 4px; color: #c7d3df; font-size: 8px; font-weight: 600; letter-spacing: .035em; text-transform: uppercase; }
.brand-integration { margin-top: 7px; color: #72d8c2; font-size: 8px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }

.sidebar-search { padding: 0 4px 12px; }
.sidebar-search input {
  min-height: 40px;
  border-color: rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .075);
  border-radius: var(--radius-sm);
}
.sidebar-search input:focus { border-color: var(--brand-mint); box-shadow: 0 0 0 3px rgba(166, 227, 161, .14); }

nav { gap: 4px; }
nav a, .nav-group summary { border-radius: var(--radius-sm); }
nav a.active, nav a:hover, .nav-group summary:hover, .nav-group summary.active {
  background: rgba(255, 255, 255, .10);
  color: #fff;
}
nav a.active, .nav-group summary.active { box-shadow: inset 3px 0 var(--brand-green); }
.nav-submenu a.active { box-shadow: inset 3px 0 var(--brand-green); }
.nav-section-label { color: #8da4ba; }
.sidebar-footer span { color: var(--brand-mint); }

.mobile-menu-toggle, .sidebar-backdrop { display: none; }
.inline-update-form .sync-scope-field { width: 180px; }
.inline-update-form .sync-scope-field select { width: 100%; }

/* Gestão comercial — paleta Giro Escolar */
.commercial-page-header { align-items: end; }
.commercial-filter-bar { display:grid; grid-template-columns:minmax(260px,2fr) repeat(2,minmax(150px,1fr)) auto auto; gap:12px; align-items:end; margin-bottom:18px; padding:16px; border:1px solid var(--line); border-radius:var(--radius-md); background:var(--panel); box-shadow:var(--shadow-sm); }
.commercial-filter-bar label { display:grid; gap:6px; color:var(--muted); font-size:12px; font-weight:600; }
.commercial-filter-bar input,.commercial-filter-bar select { width:100%; min-height:40px; }
.commercial-kpis { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:12px; margin-bottom:18px; }
.commercial-kpi { position:relative; display:grid; gap:5px; min-height:126px; padding:18px; overflow:hidden; border:1px solid var(--line); border-radius:var(--radius-md); background:var(--panel); box-shadow:var(--shadow-sm); }
.commercial-kpi::before { content:""; position:absolute; inset:0 auto 0 0; width:4px; background:var(--brand-teal); }
.commercial-kpi span,.commercial-kpi small { color:var(--muted); }
.commercial-kpi strong { color:var(--brand-navy); font-size:clamp(22px,2vw,32px); line-height:1.1; }
.commercial-kpi-primary { color:#fff; border-color:transparent; background:linear-gradient(135deg,var(--brand-navy),var(--brand-teal)); }
.commercial-kpi-primary::before { background:var(--brand-green); }
.commercial-kpi-primary span,.commercial-kpi-primary small,.commercial-kpi-primary strong { color:#fff; }
.commercial-kpi-alert::before { background:#e0a526; }
.commercial-panel { margin-bottom:18px; padding:20px; border:1px solid var(--line); border-radius:var(--radius-lg); background:var(--panel); box-shadow:var(--shadow-sm); }
.commercial-section-heading { display:flex; justify-content:space-between; gap:16px; align-items:end; margin-bottom:16px; }
.commercial-section-heading h2 { margin:2px 0 0; }
.commercial-section-heading > small,.commercial-result-count { color:var(--muted); }
.commercial-funnel { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:10px; }
.commercial-stage { position:relative; display:grid; gap:4px; min-height:106px; padding:15px 16px; border:1px solid var(--line); border-top:4px solid var(--brand-teal); border-radius:var(--radius-md); color:var(--text); background:#f8fafc; text-decoration:none; }
.commercial-stage:hover,.commercial-stage.active { border-color:var(--brand-green); background:var(--accent-soft); transform:translateY(-2px); box-shadow:var(--shadow-sm); }
.commercial-stage strong { color:var(--brand-navy); font-size:28px; }
.commercial-stage small { color:var(--muted); }
.commercial-stage-2 { border-top-color:#1677c8; }.commercial-stage-3 { border-top-color:var(--brand-green); }.commercial-stage-4 { border-top-color:#d15b50; }.commercial-stage-5 { border-top-color:#94a3b8; }
.commercial-card-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; }
.commercial-opportunity-card { display:grid; gap:13px; padding:17px; border:1px solid var(--line); border-left:4px solid var(--brand-teal); border-radius:var(--radius-md); background:#fff; box-shadow:0 4px 16px rgba(11,29,51,.055); }
.commercial-opportunity-card.is-overdue { border-left-color:#c62f25; }.commercial-opportunity-card.needs-follow-up { border-left-color:#e0a526; }
.commercial-card-topline,.commercial-card-footer { display:flex; justify-content:space-between; gap:10px; align-items:center; }
.commercial-status { padding:4px 8px; border-radius:999px; color:var(--brand-teal); background:#e7f6f3; font-size:11px; font-weight:700; text-transform:uppercase; }
.commercial-warning { color:#b42318; font-size:11px; font-weight:700; }.commercial-warning.is-neutral { color:#9a6700; }
.commercial-card-title { display:grid; gap:3px; color:var(--text); text-decoration:none; }.commercial-card-title strong { color:var(--brand-teal); font-size:13px; }.commercial-card-title span { color:var(--brand-navy); font-size:16px; font-weight:700; line-height:1.25; }
.commercial-card-meta { display:grid; gap:3px; min-height:42px; color:var(--muted); font-size:12px; }
.commercial-card-value { display:flex; justify-content:space-between; gap:10px; align-items:end; padding:10px 12px; border-radius:var(--radius-sm); background:#f3f7fa; }.commercial-card-value span { color:var(--muted); font-size:11px; }.commercial-card-value strong { color:var(--brand-navy); }
.commercial-next-action { display:grid; gap:3px; padding-top:11px; border-top:1px solid var(--line); }.commercial-next-action > span { color:var(--brand-teal); font-size:10px; font-weight:800; letter-spacing:.08em; text-transform:uppercase; }.commercial-next-action strong { font-size:13px; }.commercial-next-action small { color:var(--muted); }
.commercial-card-footer { color:var(--muted); font-size:11px; }.commercial-card-footer a { color:var(--brand-teal); font-weight:700; text-decoration:none; }

@media (max-width:1200px) { .commercial-kpis { grid-template-columns:repeat(3,1fr); }.commercial-card-grid { grid-template-columns:repeat(2,1fr); } }
@media (max-width:760px) { .commercial-filter-bar { grid-template-columns:1fr 1fr; }.commercial-search { grid-column:1/-1; }.commercial-kpis,.commercial-funnel,.commercial-card-grid { grid-template-columns:1fr; }.commercial-kpi { min-height:auto; }.commercial-section-heading { align-items:start; flex-direction:column; } }

.content { padding: 28px clamp(18px, 2.4vw, 38px); }
.page-header { margin-bottom: 22px; }
.page-header h1, h1 { color: var(--brand-navy); letter-spacing: -.025em; }
h2 { color: #21334a; }
.eyebrow { color: var(--brand-teal); letter-spacing: .12em; }

.button, button {
  min-height: 40px;
  border-radius: var(--radius-sm);
  background: var(--brand-teal);
  box-shadow: 0 1px 2px rgba(11, 29, 51, .08);
}
.button:hover, button:hover { background: var(--accent-dark); transform: translateY(-1px); }
.button-secondary { background: var(--brand-navy); }
.button-secondary:hover { background: var(--brand-navy-soft); }
.button-danger { background: #b42318; }
.button-danger:hover { background: #8f1d14; }

input, select, textarea {
  border-radius: var(--radius-sm) !important;
  border-color: #cfd8e3 !important;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand-teal) !important;
  box-shadow: 0 0 0 3px rgba(13, 110, 110, .12);
  outline: none;
}

.metric, .panel, .triage-summary, .metric-card, .summary-card {
  border-color: var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.metric-link:hover { border-color: var(--brand-green); box-shadow: 0 10px 24px rgba(11, 29, 51, .09); }
.metric strong, .metric-card strong { color: var(--brand-navy); }
.panel { overflow: clip; }

.flash { border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }
.flash-success { color: #176b31; background: #edf9f0; border-color: #a6dbb2; }

.status-pill, .status-badge, .score-badge, .count-badge { border-radius: 999px; }
.table-wrap { border-radius: var(--radius-md); }
table thead th { color: #53647a; background: #f7f9fb; }
table tbody tr:hover { background: #f5faf7; }

.modal-card, .processing-box {
  border-radius: var(--radius-lg);
  border-color: var(--line);
  box-shadow: var(--shadow-md);
}

.app-footer { border-color: var(--line); }

.auth-shell {
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 20%, rgba(40, 167, 69, .16), transparent 34%),
    radial-gradient(circle at 88% 78%, rgba(13, 110, 110, .13), transparent 32%),
    linear-gradient(145deg, #f8fafc, #e9eef4);
}
.auth-card {
  width: min(480px, 100%);
  gap: 12px;
  padding: clamp(24px, 5vw, 40px);
  border: 0;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(11, 29, 51, .16);
}
.auth-logo {
  width: min(320px, 100%);
  height: 130px;
  margin: 0 auto 4px;
  object-fit: contain;
  border-radius: 0;
}
.auth-card h1 { text-align: center; color: var(--brand-navy); }
.auth-card > p { text-align: center; }
.auth-tagline { margin-top: -8px !important; color: var(--brand-teal) !important; font-size: 13px; font-weight: 700; letter-spacing: .04em; }
.auth-form button { margin-top: 4px; background: var(--brand-green-dark); }
.auth-form button:hover { background: #17632b; }
.auth-help-link { color: var(--brand-teal); }

/* Dashboard executivo */
.dashboard-context-bar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, .82);
  box-shadow: var(--shadow-sm);
}
.dashboard-context-bar form { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.dashboard-context-bar label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
.dashboard-context-bar select { min-width: 150px; max-width: 250px; min-height: 40px; }
.dashboard-context-bar > span { color: var(--muted); font-size: 11px; text-align: right; }
.dashboard-context-bar > span strong { display: block; color: var(--brand-navy); }

.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.dashboard-kpi {
  --kpi-color: var(--brand-green);
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 13px;
  align-items: center;
  min-height: 116px;
  padding: 17px;
  color: var(--text);
  border: 1px solid var(--line);
  border-top: 3px solid var(--kpi-color);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
.dashboard-kpi:hover { color: var(--text); border-color: color-mix(in srgb, var(--kpi-color) 46%, var(--line)); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.dashboard-kpi-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; color: #fff; background: var(--kpi-color); font-size: 18px; font-weight: 800; }
.dashboard-kpi small, .dashboard-kpi em { display: block; color: var(--muted); font-style: normal; }
.dashboard-kpi small { font-size: 12px; font-weight: 600; }
.dashboard-kpi strong { display: block; margin: 2px 0; color: var(--brand-navy); font-size: clamp(22px, 2.3vw, 30px); line-height: 1.1; }
.dashboard-kpi em { font-size: 10px; }
.dashboard-kpi.tone-blue { --kpi-color:#2563eb; }.dashboard-kpi.tone-teal { --kpi-color:var(--brand-teal); }.dashboard-kpi.tone-navy { --kpi-color:var(--brand-navy); }.dashboard-kpi.tone-mint { --kpi-color:#169b62; }.dashboard-kpi.tone-amber { --kpi-color:#d18b0e; }

.dashboard-charts { display: grid; grid-template-columns: 1.25fr .9fr 1fr; gap: 12px; margin-bottom: 16px; }
.dashboard-chart { min-height: 292px; padding: 18px; }
.dashboard-chart .panel-title { margin-bottom: 12px; }
.dashboard-chart svg { display: block; width: 100%; height: 200px; overflow: visible; }
.dashboard-chart svg text { fill: #758397; font-family: var(--font-sans); font-size: 9px; }
.dashboard-chart svg .chart-value { fill: var(--brand-navy); font-size: 8px; font-weight: 700; }
.chart-axis { stroke: #dce3eb; stroke-width: 1; }
.chart-line { fill: none; stroke: var(--brand-green); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 3px 4px rgba(40, 167, 69, .2)); }
.chart-point { fill: #fff; stroke: var(--brand-teal); stroke-width: 3; }

.dashboard-donut-layout { display: grid; grid-template-columns: 136px minmax(0, 1fr); gap: 18px; align-items: center; min-height: 190px; }
.dashboard-donut { position: relative; width: 136px; aspect-ratio: 1; border-radius: 50%; }
.dashboard-donut::after { content:""; position:absolute; inset:25px; border-radius:50%; background:#fff; box-shadow:inset 0 0 0 1px var(--line); }
.dashboard-donut > span { position:absolute; z-index:1; inset:0; display:grid; place-content:center; text-align:center; }
.dashboard-donut strong { display:block; color:var(--brand-navy); font-size:27px; line-height:1; }.dashboard-donut small { color:var(--muted); font-size:10px; }
.dashboard-donut-layout ul { display:grid; gap:9px; margin:0; padding:0; list-style:none; }
.dashboard-donut-layout li { display:grid; grid-template-columns:9px 1fr auto; gap:7px; align-items:center; color:var(--muted); font-size:10px; }
.dashboard-donut-layout li i { width:9px; height:9px; border-radius:3px; }.dashboard-donut-layout li strong { color:var(--brand-navy); }

.dashboard-status-bars { display:grid; gap:14px; padding-top:8px; }
.dashboard-status-bars a { display:grid; grid-template-columns:86px 1fr 28px; gap:9px; align-items:center; color:var(--muted); font-size:10px; }
.dashboard-status-bars a:hover { color:var(--brand-teal); }
.dashboard-status-bars a div { height:9px; overflow:hidden; border-radius:99px; background:#e8edf2; }
.dashboard-status-bars a i { display:block; min-width:3px; height:100%; border-radius:inherit; background:linear-gradient(90deg,var(--brand-teal),var(--brand-green)); }
.dashboard-status-bars a strong { color:var(--brand-navy); text-align:right; }

.dashboard-tools { margin-bottom:16px; border:1px solid var(--line); border-radius:var(--radius-md); background:#fff; box-shadow:var(--shadow-sm); }
.dashboard-tools > summary { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:14px 16px; cursor:pointer; list-style:none; }
.dashboard-tools > summary::-webkit-details-marker { display:none; }.dashboard-tools > summary span { display:grid; }.dashboard-tools > summary small { color:var(--muted); }.dashboard-tools > summary b { color:var(--brand-teal); font-size:11px; }
.dashboard-tools-content { padding:0 14px 14px; }.dashboard-tools-content .portal-search { margin-top:0; }

@media (max-width: 1180px) {
  .dashboard-kpis { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .dashboard-charts { grid-template-columns:1fr 1fr; }.dashboard-trend-chart { grid-column:1/-1; }
}

@media (max-width: 980px) {
  body:not(.standalone-monitor) { display: block; padding-top: 62px; }
  .mobile-menu-toggle {
    position: fixed;
    z-index: 42;
    top: 10px;
    left: 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 8px 13px;
    background: var(--brand-navy);
    box-shadow: var(--shadow-md);
    transition: left .22s ease, background-color .16s ease, transform .16s ease;
  }
  .mobile-menu-toggle span { font-size: 20px; line-height: 1; }
  .sidebar {
    position: fixed;
    z-index: 41;
    inset: 0 auto 0 0;
    width: min(310px, 86vw);
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform .22s ease;
  }
  .menu-open .sidebar { transform: translateX(0); }
  .menu-open .mobile-menu-toggle { left: calc(min(310px, 86vw) + 8px); }
  .sidebar-backdrop {
    position: fixed;
    z-index: 40;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: rgba(5, 17, 29, .58);
  }
  .sidebar-backdrop:hover { background: rgba(5, 17, 29, .58); transform: none; }
  .menu-open .sidebar-backdrop { display: block; }
  .brand-logo { height: 58px; }
  .content { padding: 20px 16px; }
  .dashboard-context-bar { align-items:stretch; flex-direction:column; }.dashboard-context-bar > span { text-align:left; }
}

@media (max-width: 520px) {
  .auth-shell { padding: 14px; }
  .auth-card { padding: 24px 20px; }
  .auth-logo { height: 100px; }
  .page-header { align-items: flex-start; }
  .dashboard-page-header { flex-direction:column; }
  .dashboard-page-header .header-actions, .dashboard-page-header .inline-update-form { width:100%; }
  .dashboard-page-header .inline-update-form label { flex:1; width:auto; }
  .dashboard-page-header .inline-update-form input,
  .dashboard-page-header .inline-update-form select { width:100%; }
  .dashboard-context-bar form, .dashboard-context-bar label, .dashboard-context-bar select, .dashboard-context-bar button, .dashboard-context-bar .button { width:100%; max-width:none; }
  .dashboard-kpis, .dashboard-charts { grid-template-columns:1fr; }
  .dashboard-trend-chart { grid-column:auto; }
  .dashboard-kpi { min-height:98px; }
  .dashboard-donut-layout { grid-template-columns:1fr; justify-items:center; }.dashboard-donut-layout ul { width:100%; }
}
