/* Fonte da marca (Inter 400/500/600/700), servida pelo próprio painel. */
@font-face { font-family: "Inter"; font-weight: 400; font-style: normal; font-display: swap; src: url("fonts/Inter-Regular.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-weight: 500; font-style: normal; font-display: swap; src: url("fonts/Inter-Medium.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-weight: 600; font-style: normal; font-display: swap; src: url("fonts/Inter-SemiBold.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-weight: 700; font-style: normal; font-display: swap; src: url("fonts/Inter-Bold.ttf") format("truetype"); }

:root {
  --navy: #071B4B; --navy-2: #0A2A72; --blue: #1C6BFF; --blue-2: #0647A8; --muted: #5E6B82; --line: #E3E8F0;
  --bg: #F4F6FA; --card: #FFFFFF; --text: #0F1D3D; --ok: #17785B; --ok-bg: #E6F4EE;
  --warn: #9A5B00; --warn-bg: #FFF4E0; --bad: #B3261E; --bad-bg: #FDECEA; --info-bg: #EDF3FF;
  --radius: 16px; --shadow: 0 1px 3px rgba(7,27,75,.05), 0 8px 24px rgba(7,27,75,.06);
  --shadow-hover: 0 2px 4px rgba(7,27,75,.06), 0 14px 32px rgba(7,27,75,.10);
  --ring: 0 0 0 3px rgba(28,107,255,.28);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A1020; --card: #111A2E; --text: #EAF0FB; --muted: #9AA8C2; --line: #22304D;
    --info-bg: #16233F; --ok-bg: #12352A; --warn-bg: #3A2A0E; --bad-bg: #3B1717; --navy: #8FB3FF; --blue: #5B8CFF;
    --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-hover: 0 6px 20px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
:focus-visible { outline: none; box-shadow: var(--ring); }
.boot { padding: 40px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: linear-gradient(180deg, #0A2A72 0%, #071B4B 55%, #040F2E 100%); color: #DCE6FA; padding: 18px 12px;
  position: sticky; top: 0; height: 100vh; overflow: auto; }
.side .brand { font-weight: 700; font-size: 20px; color: #fff; padding: 6px 10px 18px; letter-spacing: -.5px; }
.side .brand small { display: block; font-weight: 500; font-size: 11.5px; color: #9DB2DC; letter-spacing: 0; margin-top: 2px; }
.side nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px;
  border-radius: 12px; color: #DCE6FA; text-decoration: none; margin-bottom: 2px; font-weight: 500;
  transition: background .15s, color .15s; }
.side nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.side nav a.active { background: linear-gradient(135deg, #1C6BFF, #0647A8); color: #fff; font-weight: 600;
  box-shadow: 0 6px 16px rgba(28,107,255,.35); }
.side .badge { background: #F2A900; color: #241600; border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.side .who { margin-top: 20px; padding: 10px; font-size: 12px; color: #9DB2DC; border-top: 1px solid rgba(255,255,255,.1); }
.main { padding: 28px 32px 60px; min-width: 0; max-width: 1480px; }
.topbar { display: none; }
h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.6px; }
h2 { font-size: 16px; font-weight: 600; margin: 24px 0 10px; letter-spacing: -.2px; }
.sub { color: var(--muted); margin: 0 0 20px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 50; transform: translateX(-102%); transition: transform .2s; height: 100%; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: #071B4B; color: #fff; position: sticky; top: 0; z-index: 40; }
  .topbar button { background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; min-width: 44px; min-height: 44px; }
  .main { padding: 16px 16px 60px; }
}

/* componentes */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
a.card, .card.click { transition: box-shadow .15s, transform .15s; }
a.card:hover, .card.click:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.kpi { position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: linear-gradient(180deg, #1C6BFF, #0647A8); opacity: .85; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -.8px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }

.btn { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 8px 15px; cursor: pointer; min-height: 40px; font-weight: 600;
  transition: border-color .15s, box-shadow .15s, transform .1s, filter .15s; }
.btn:hover { border-color: var(--blue); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn.primary { background: linear-gradient(135deg, #1C6BFF, #0647A8); border-color: transparent; color: #fff; box-shadow: 0 4px 12px rgba(28,107,255,.28); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: 12px; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input:not([type]), input[type=search], select, textarea {
  border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 8px 12px; min-height: 40px; width: 100%;
  transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: var(--ring); }
textarea { min-height: 80px; resize: vertical; }
input:disabled, select:disabled, textarea:disabled { opacity: .5; cursor: not-allowed; }
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 12px; }
.check { display: inline-flex; gap: 6px; align-items: center; margin-right: 14px; min-height: 32px; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; min-width: 640px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
  background: color-mix(in srgb, var(--card) 94%, var(--navy)); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--info-bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--info-bg); color: var(--blue); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.grey { background: color-mix(in srgb, var(--muted) 15%, transparent); color: var(--muted); }

.notice { padding: 10px 12px; border-radius: 10px; background: var(--info-bg); margin: 8px 0; }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* documentos */
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.doc { display: flex; flex-direction: column; gap: 8px; }
.doc .thumb { height: 160px; border-radius: 10px; background: var(--bg); display: flex; align-items: center; justify-content: center;
  overflow: hidden; cursor: zoom-in; border: 1px solid var(--line); }
.doc .thumb img { max-width: 100%; max-height: 100%; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(5,12,30,.55); z-index: 100; display: flex; align-items: flex-start; justify-content: center; overflow: auto; padding: 32px 12px; }
.modal { background: var(--card); color: var(--text); border-radius: 18px; width: min(1100px, 100%); padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal.narrow { width: min(520px, 100%); }
.modal header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.modal header h1 { flex: 1; }
.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 200; display: flex; flex-direction: column; }
.viewer .bar { display: flex; gap: 8px; padding: 10px; justify-content: center; flex-wrap: wrap; }
.viewer .stage { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; }
.viewer img { transition: transform .15s; max-width: none; }
.viewer iframe { width: 92vw; height: 82vh; border: 0; background: #fff; }

.map { height: 360px; border-radius: 12px; border: 1px solid var(--line); }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 2px solid var(--line); }
.timeline li { padding: 4px 0 10px 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 9px; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #13213F; color: #fff; padding: 10px 16px;
  border-radius: 12px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 300; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.bad { background: var(--bad); }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 30%, rgba(47,107,255,.35), transparent 60%), linear-gradient(160deg, #0A2A72, #040F2E); }
.login .card { width: min(420px, 100%); padding: 32px; border-radius: 22px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.login h1 { color: var(--navy); }
/* Mapas (Leaflet) usam z-index internos altos: isolar evita que fiquem por cima de janelas e do menu. */
.map { position: relative; z-index: 0; isolation: isolate; }

/* Central de avisos (sino) */
.bell { position: fixed; top: 10px; right: 16px; z-index: 60; }
.bell-btn { position: relative; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--card, #fff);
  font-size: 18px; cursor: pointer; box-shadow: 0 2px 10px rgba(7, 27, 75, .12); }
.bell-count { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: var(--bad, #B3261E); color: #fff; font-size: 11px; font-weight: 800; line-height: 20px; text-align: center; }
.bell-panel { position: absolute; top: 50px; right: 0; width: min(380px, calc(100vw - 32px)); max-height: min(560px, 75vh); overflow: auto;
  background: var(--card, #fff); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 40px rgba(7, 27, 75, .2); }
.bell-head { position: sticky; top: 0; display: flex; gap: 6px; align-items: center; padding: 12px 14px; background: inherit;
  border-bottom: 1px solid var(--line); }
.bell-item { display: flex; gap: 10px; width: 100%; text-align: left; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; cursor: pointer; font: inherit; color: inherit; }
.bell-item:hover { background: color-mix(in srgb, var(--muted) 8%, transparent); }
.bell-item.unread { background: color-mix(in srgb, #1C6BFF 7%, transparent); }
.bell-item.unread strong::after { content: ''; display: inline-block; width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; background: #1C6BFF; }
.bell-icon { font-size: 18px; line-height: 1.3; }
.bell-text { display: flex; flex-direction: column; gap: 2px; }
.contacts { margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.contacts .contact { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.contacts .row { gap: 12px; flex-wrap: wrap; margin-top: 4px; }
@media (max-width: 860px) { .bell { top: 8px; right: 10px; } }
