/* Painel IE Madeira — identidade RGIS (paleta e tipografia da Apresentação Técnica) */
:root {
  --navy-950: #0A1D27;
  --navy-900: #12303E;
  --navy-800: #16394A;
  --navy-700: #1A4353;
  --steel: #3E86AD;
  --ice: #A8C8D6;
  --mist: #E9EFF2;
  --red: #C8102E;
  --red-dark: #8A0029;
  --paper: #F2F1EF;
  --paper-2: #F7F6F4;
  --surface: #FFFFFF;
  --line: #E2E0DC;
  --line-2: #C9CED2;
  --ink: #22303A;
  --ink-2: #5B6770;
  --ink-3: #8296A2;

  /* dados */
  --serie-real: #2B7BB0;
  --serie-plan: #8296A2;
  --cat-1: #2B7BB0; /* física */
  --cat-2: #D9952B; /* cadastral */
  --cat-3: #7A5BB5; /* sistêmica */
  --ok: #2E7D4F;
  --ok-bg: #E4F1E9;
  --warn: #9A6412;
  --warn-bg: #FBF0DC;
  --crit: #C8102E;
  --crit-bg: #FBE5E8;

  --r-sm: 4px;
  --r-md: 8px;
  --shadow: 0 1px 2px rgba(18, 48, 62, .06), 0 4px 16px rgba(18, 48, 62, .05);
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--steel); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; color: var(--navy-900); }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--steel); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }

.boot { padding: 48px; color: var(--ink-2); }

/* ---------- login ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 1fr);
  background: var(--surface);
}
.auth-hero {
  position: relative;
  background: var(--navy-950) url('img/capa.jpg') center / cover no-repeat;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px 48px;
  overflow: hidden;
}
.auth-hero::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10, 29, 39, .55) 0%, rgba(10, 29, 39, .2) 45%, rgba(10, 29, 39, .92) 100%);
}
.auth-hero > * { position: relative; z-index: 1; }
.auth-hero .logos { display: flex; align-items: center; gap: 24px; }
.auth-hero .logos img:first-child { height: 34px; width: auto; }
.auth-hero .logos img:last-child { height: 30px; width: auto; opacity: .9; }
.auth-hero .logos span { width: 1px; height: 28px; background: rgba(255,255,255,.35); }
.auth-hero h1 { color: #fff; font-size: clamp(30px, 3.6vw, 46px); font-weight: 700; letter-spacing: -.01em; max-width: 14ch; }
.auth-hero .lead { margin-top: 14px; max-width: 46ch; color: rgba(255,255,255,.82); font-size: 15px; }
.auth-facts { display: flex; gap: 32px; margin-top: 28px; flex-wrap: wrap; }
.auth-facts div { font-size: 13px; color: rgba(255,255,255,.75); }
.auth-facts strong { display: block; font-size: 26px; font-weight: 600; color: #fff; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 22px; }
.auth-card .sub { margin: 6px 0 24px; color: var(--ink-2); }
.auth-switch { margin-top: 18px; display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--steel); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.notice { padding: 12px 14px; border-radius: var(--r-md); background: var(--mist); color: var(--navy-900); font-size: 13px; margin-bottom: 16px; }
.notice.err { background: var(--crit-bg); color: var(--red-dark); }

/* ---------- formulários ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 500; color: var(--ink); }
.field .hint { font-size: 12px; color: var(--ink-2); }
.input, .field input[type=text], .field input[type=email], .field input[type=password], .field input[type=number], .field input[type=date], .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  padding: 9px 11px;
  min-height: 40px;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--steel); outline: 2px solid rgba(62,134,173,.25); outline-offset: 0; }
.field.check { flex-direction: row; align-items: center; gap: 10px; }
.field.check input { width: 18px; height: 18px; accent-color: var(--navy-900); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--r-sm);
  padding: 9px 16px; min-height: 40px;
  font-weight: 600; font-size: 13px; cursor: pointer;
  background: var(--navy-900); color: #fff;
  transition: background-color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--navy-700); }
.btn.primary { background: var(--red); }
.btn.primary:hover { background: #A90D27; }
.btn.ghost { background: transparent; color: var(--navy-900); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--paper-2); }
.btn.quiet { background: transparent; color: var(--ink-2); padding: 6px 10px; min-height: 32px; }
.btn.quiet:hover { background: var(--paper); color: var(--navy-900); }
.btn.danger { background: transparent; color: var(--red); border-color: #E8B4BD; }
.btn.danger:hover { background: var(--crit-bg); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: progress; }
.btn svg { width: 16px; height: 16px; }

/* ---------- estrutura ---------- */
.topbar {
  background: var(--navy-950);
  color: #fff;
  display: flex; align-items: center; gap: 24px;
  padding: 0 28px; min-height: 64px;
}
.topbar .brand { display: flex; align-items: center; gap: 16px; }
.topbar .brand img { height: 22px; width: auto; }
.topbar .brand .sep { width: 1px; height: 26px; background: rgba(255,255,255,.25); }
.topbar .title { font-weight: 600; font-size: 15px; line-height: 1.2; }
.topbar .title span { display: block; font-weight: 400; font-size: 12px; color: var(--ice); }
.topbar .spacer { flex: 1; }
.clock { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--ice); }
.clock strong { color: #fff; font-size: 15px; font-weight: 600; }
.clock .bar { width: 120px; height: 6px; border-radius: 3px; background: rgba(168,200,214,.25); overflow: hidden; }
.clock .bar i { display: block; height: 100%; background: var(--red); border-radius: 3px; }
.user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ice); }
.user .btn.quiet { color: var(--ice); }
.user .btn.quiet:hover { background: rgba(255,255,255,.08); color: #fff; }

.tabs {
  background: var(--navy-900);
  display: flex; gap: 4px; padding: 0 20px;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  color: var(--ice); text-decoration: none; font-weight: 500; font-size: 13px;
  padding: 13px 14px 11px; border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs a:hover { color: #fff; }
.tabs a[aria-current=page] { color: #fff; border-bottom-color: var(--red); }

main { max-width: 1440px; margin: 0 auto; padding: 24px 28px 64px; }
.toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.toolbar h1 { font-size: 22px; }
.toolbar .desc { color: var(--ink-2); margin-top: 4px; max-width: 70ch; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters select, .filters input { border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface); padding: 7px 10px; min-height: 36px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.mt { margin-top: 16px; }

.panel { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 20px 22px; min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h2 { font-size: 15px; }
.panel-head p { color: var(--ink-2); font-size: 12px; }

/* Régua do prazo: elemento-assinatura */
.regua { background: var(--navy-900); color: #fff; border-radius: var(--r-md); padding: 22px 24px 18px; box-shadow: var(--shadow); }
.regua .panel-head h2 { color: #fff; font-size: 16px; }
.regua .panel-head p { color: var(--ice); }
.regua .legend span { color: var(--ice); }
.regua .chart { overflow-x: auto; }

/* indicadores */
.kpi { display: flex; flex-direction: column; gap: 12px; }
.kpi h3 { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.kpi .hero { font-size: 40px; font-weight: 600; color: var(--navy-900); line-height: 1; letter-spacing: -.01em; }
.kpi .hero small { font-size: 15px; font-weight: 500; color: var(--ink-2); margin-left: 4px; letter-spacing: 0; }
.kpi dl { margin: 0; display: grid; grid-template-columns: 1fr auto; row-gap: 6px; column-gap: 12px; font-size: 13px; border-top: 1px solid var(--line); padding-top: 12px; }
.kpi dt { color: var(--ink-2); }
.kpi dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.meter { height: 8px; border-radius: 4px; background: var(--mist); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 4px; background: var(--navy-900); }
.meter.ok i { background: var(--ok); }

.delta-up { color: var(--ok); }
.delta-down { color: var(--red); }

/* chips de status */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 2px 9px 2px 7px; border-radius: 999px; background: var(--paper); color: var(--ink); white-space: nowrap; }
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.chip.s-planejada::before, .chip.s-pendente::before, .chip.s-aberto::before { background: var(--ink-3); }
.chip.s-mobilizacao::before, .chip.s-em_andamento::before, .chip.s-em_tratamento::before { background: var(--cat-2); }
.chip.s-em_execucao::before, .chip.s-organizacao::before { background: var(--serie-real); }
.chip.s-concluida::before, .chip.s-concluido::before, .chip.s-resolvida::before { background: var(--ok); }
.chip.s-validada::before, .chip.s-validado_isa::before { background: var(--navy-900); }
.chip.s-aberta::before { background: var(--red); }
.chip.s-cancelada::before { background: var(--line-2); }
.chip.i-alto { background: var(--crit-bg); color: var(--red-dark); }
.chip.i-alto::before { background: var(--red); }
.chip.i-medio { background: var(--warn-bg); color: var(--warn); }
.chip.i-medio::before { background: var(--cat-2); }

/* tabelas */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
table.data td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data td.n, table.data th.n { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: var(--paper-2); }
table.data td .sub { display: block; font-size: 12px; color: var(--ink-2); }
table.data .row-actions { white-space: nowrap; text-align: right; }
.progress-cell { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.progress-cell .meter { flex: 1; }
.empty { padding: 28px; text-align: center; color: var(--ink-2); border: 1px dashed var(--line-2); border-radius: var(--r-md); background: var(--paper-2); }
.empty strong { display: block; color: var(--navy-900); margin-bottom: 4px; }

/* legendas e gráficos */
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 2px; border-radius: 1px; width: 16px; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font); font-size: 11px; fill: var(--ink-2); }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-line { stroke: var(--line-2); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .bar:hover, .chart .bar:focus { filter: brightness(1.15); outline: none; }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--navy-950); color: #fff; border-radius: var(--r-sm);
  padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  max-width: 260px;
}
.tooltip .t-title { color: var(--ice); margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 8px; }
.tooltip .t-row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tooltip .t-row i { width: 12px; height: 2px; display: inline-block; }

.toast { position: fixed; z-index: 60; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--navy-950); color: #fff; padding: 10px 16px; border-radius: var(--r-sm); font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.err { background: var(--red-dark); }

/* lista de eventos */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: start; }
.feed li:last-child { border-bottom: 0; }
.feed .when { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.feed .when strong { display: block; font-size: 15px; color: var(--navy-900); }
.feed h4 { font-size: 14px; }
.feed .meta { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.feed .body { margin-top: 6px; color: var(--ink); white-space: pre-line; }
.feed .decisoes { margin-top: 6px; font-size: 13px; padding-left: 10px; border-left: 2px solid var(--ice); color: var(--ink-2); white-space: pre-line; }
.thumbs { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.thumbs a, .thumbs .ph { width: 64px; height: 64px; border-radius: var(--r-sm); overflow: hidden; background: var(--mist); display: block; }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }

/* diálogo */
dialog.modal { border: 0; border-radius: var(--r-md); padding: 0; width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 20px 60px rgba(10,29,39,.35); color: var(--ink); }
dialog.modal::backdrop { background: rgba(10, 29, 39, .55); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 20px 22px 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 18px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }
.modal-foot .left { margin-right: auto; }

.import-preview { max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); margin-top: 10px; }
.import-preview table.data td, .import-preview table.data th { padding: 6px 8px; }
.err-text { color: var(--red-dark); }
code.inline { background: var(--paper); padding: 1px 6px; border-radius: 3px; font-size: 12px; }

.pending { max-width: 520px; margin: 80px auto; text-align: left; }
.pending h1 { font-size: 22px; margin-bottom: 10px; }

/* ---------- responsivo ---------- */
@media (max-width: 1100px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-21 { grid-template-columns: minmax(0, 1fr); }
  .clock .bar { display: none; }
}
@media (max-width: 760px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { min-height: 340px; padding: 28px 20px; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; gap: 10px 16px; }
  .topbar .title span { display: none; }
  .user .email { display: none; }
  .tabs { padding: 0 8px; }
  main { padding: 18px 16px 48px; }
  .g-4, .g-3, .g-2 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .panel { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .kpi .hero { font-size: 34px; }
  .feed li { grid-template-columns: 60px minmax(0, 1fr); }
  .feed li > :last-child { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
@media print {
  .tabs, .actions, .filters, .row-actions, .user { display: none !important; }
  body { background: #fff; }
  .panel, .regua { box-shadow: none; break-inside: avoid; }
}
