/* =============================================================================
   Padrão visual Mosaic Sistemas e Soluções — versão para HTML/JS puro
   (mesmas cores, fontes e componentes do Mosaic Postos e dos Emissores NF-e/NFS-e)
   Fontes no <head>:
   <link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Sora:wght@500;600;700&display=swap" rel="stylesheet">
   ============================================================================= */
:root {
  /* marca (extraída da logo) */
  --navy: #1a0b8f;
  --navy-deep: #0f0766;
  --blue: #1e5aae;
  --sky: #4fa3de;
  --teal: #2fbf9b;
  --mint: #7fe0c8;
  --graphite: #262626;
  --silver: #9aa3ae;

  /* interface */
  --bg: #f3f5fa;
  --card: #ffffff;
  --ink: #1b1d2a;
  --ink-2: #4b5165;
  --muted: #7c8397;
  --line: #e4e8f1;
  --good: #1fa981;
  --bad: #e5484d;
  --warn: #e8a317;
  --warn-text: #a86f00;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 24, 60, .05), 0 6px 22px rgba(20, 24, 60, .06);
  --font: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
  --font-num: 'Sora', 'Plus Jakarta Sans', 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 14px; display: flex; -webkit-font-smoothing: antialiased; }
a { color: var(--blue); cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }

/* ---------- Sidebar ---------- */
.sidebar { width: 250px; flex: 0 0 250px; height: 100vh; position: sticky; top: 0; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--navy-deep) 0%, var(--navy) 55%, #1b2f9c 100%); color: #dfe3ff; overflow-y: auto; }
.brand { display: block; background: #fff; margin: 14px; border-radius: 12px; padding: 10px 12px; }
.brand img { width: 100%; display: block; }
nav { padding: 4px 10px 16px; flex: 1; }
.nav-label { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--mint); opacity: .8; margin: 16px 10px 6px; font-weight: 700; }
nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: #dfe3ff; text-decoration: none; font-weight: 500; margin: 2px 0; transition: background .15s; }
nav a:hover { background: rgba(255, 255, 255, .08); }
nav a.active { background: linear-gradient(90deg, var(--teal), #27a6a0); color: #fff; box-shadow: 0 4px 14px rgba(47, 191, 155, .35); }
nav .ico { width: 20px; text-align: center; font-size: 15px; }
.sidebar-foot { font-size: 11px; line-height: 1.45; padding: 12px 20px 18px; }
.sidebar-foot b { color: #fff; }
.sidebar-foot span { opacity: .7; display: block; }
.sidebar-foot a { color: var(--mint); text-decoration: none; }
.sidebar-foot a:hover { text-decoration: underline; }
.status-pill { margin: 0 12px; display: flex; align-items: center; gap: 8px; border-radius: 10px; background: rgba(255, 255, 255, .06); padding: 8px 12px; font-size: 12px; color: #dfe3ff; }
.status-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); flex: 0 0 8px; }
.status-pill.off i { background: var(--bad); } .status-pill.warn i { background: var(--warn); }

/* ---------- Área principal / topbar ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 16px 28px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.topbar-title { flex: 1; min-width: 200px; }
.topbar-title h1 { font-size: 21px; }
.topbar-title .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.topbar-controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.view { padding: 22px 28px 60px; }

/* ---------- Formulários ---------- */
.ctl, .field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ctl > span { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.field > label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .erro { font-size: 12px; color: var(--bad); }
select, input, textarea { font-family: var(--font); font-size: 13.5px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; outline: none; }
select:focus, input:focus, textarea:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(79, 163, 222, .18); }
input[aria-invalid="true"] { border-color: var(--bad); }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- Botões ---------- */
.btn { font-family: var(--font); display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 10px; padding: 9px 16px; font-weight: 600; font-size: 13.5px; cursor: pointer; background: var(--navy); color: #fff; text-decoration: none; transition: transform .08s, box-shadow .15s, background .15s; }
.btn:hover { box-shadow: 0 6px 16px rgba(26, 11, 143, .25); }
.btn:active { transform: translateY(1px); }
.btn.teal { background: var(--teal); } .btn.teal:hover { box-shadow: 0 6px 16px rgba(47, 191, 155, .3); }
.btn.blue { background: var(--blue); } .btn.blue:hover { box-shadow: 0 6px 16px rgba(30, 90, 174, .25); }
.btn.ghost { background: transparent; color: var(--navy); border: 1px solid var(--line); }
.btn.ghost:hover { background: #f4f6fd; box-shadow: none; }
.btn.danger { background: var(--bad); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-icon { background: transparent; border: 0; font-size: 18px; cursor: pointer; color: var(--ink-2); padding: 6px; border-radius: 8px; }
.btn-icon:hover { background: #eef1f8; }
.only-mobile { display: none; }

/* ---------- Cards e grades ---------- */
.grid { display: grid; gap: 16px; }
.g-kpi { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; border: 1px solid rgba(228, 232, 241, .6); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h3 { font-size: 15.5px; }
.card-head .hint { color: var(--muted); font-size: 12px; margin-top: 3px; font-weight: 500; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); margin: 26px 0 12px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.mt { margin-top: 16px; }

/* ---------- KPI ---------- */
.kpi { position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent, var(--blue)); }
.kpi.teal { --accent: var(--teal); } .kpi.navy { --accent: var(--navy); } .kpi.sky { --accent: var(--sky); }
.kpi.bad { --accent: var(--bad); } .kpi.warn { --accent: var(--warn); }
.kpi .lbl { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi .val { font-family: var(--font-num); font-size: 24px; font-weight: 600; margin: 8px 0 6px; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .val small { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .foot { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: 11.5px; padding: 2px 7px; border-radius: 99px; background: #eef1f8; color: var(--ink-2); }
.chip.up { background: rgba(31, 169, 129, .12); color: var(--good); }
.chip.down { background: rgba(229, 72, 77, .1); color: var(--bad); }
.chip.warn { background: rgba(232, 163, 23, .14); color: var(--warn-text); }
.chip.blue { background: rgba(30, 90, 174, .1); color: var(--blue); }
.chip.navy { background: rgba(26, 11, 143, .08); color: var(--navy); }

/* ---------- Gráficos ---------- */
.chart { position: relative; height: 300px; }
.chart.tall { height: 380px; } .chart.short { height: 240px; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfe; position: sticky; top: 0; }
table.t td { padding: 8px 10px; border-bottom: 1px solid #f0f2f7; vertical-align: middle; }
table.t tr:hover td { background: #f8f9fd; }
table.t .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t tfoot td { font-weight: 700; background: #f6f8fc; border-top: 1px solid var(--line); }
table.t tr.grp td { background: #eef3fb; font-weight: 700; color: var(--navy); }
.bar-inline { height: 6px; border-radius: 99px; background: #eef1f8; overflow: hidden; min-width: 70px; }
.bar-inline > i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--teal)); }

/* ---------- Status (selos) ---------- */
.st { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; white-space: nowrap; background: rgba(26, 11, 143, .08); color: var(--navy); }
.st.ok { background: rgba(31, 169, 129, .12); color: var(--good); }
.st.bad { background: rgba(229, 72, 77, .1); color: var(--bad); }
.st.warn { background: rgba(232, 163, 23, .14); color: var(--warn-text); }
.st.muted { background: #eef1f8; color: var(--muted); }
.st.blue { background: rgba(30, 90, 174, .1); color: var(--blue); }
.st.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Alertas, vazio, abas, filtros ---------- */
.alert { display: flex; gap: 12px; padding: 12px 14px; border-radius: 12px; background: #fff; border: 1px solid var(--line); margin-bottom: 10px; align-items: flex-start; }
.alert .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex: 0 0 10px; }
.alert.alto .dot { background: var(--bad); } .alert.medio .dot { background: var(--warn); } .alert.info .dot { background: var(--sky); }
.alert h4 { font-size: 13.5px; margin-bottom: 3px; }
.alert p { margin: 0; color: var(--ink-2); font-size: 12.5px; line-height: 1.5; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 8px; }
.note { font-size: 12px; color: var(--muted); line-height: 1.5; }
.note b { color: var(--ink-2); }
.pill-tabs { display: inline-flex; background: #eef1f8; padding: 3px; border-radius: 10px; gap: 2px; flex-wrap: wrap; }
.pill-tabs button { font-family: var(--font); border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; font-weight: 600; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.pill-tabs button.on { background: #fff; color: var(--navy); box-shadow: 0 1px 4px rgba(20, 24, 60, .1); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.drop { border: 2px dashed #cfd6e6; border-radius: 14px; padding: 22px; text-align: center; background: #fbfcff; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--teal); background: rgba(47, 191, 155, .06); }

/* ---------- Modal e aviso (toast) ---------- */
.modal { position: fixed; inset: 0; background: rgba(15, 7, 102, .35); backdrop-filter: blur(2px); z-index: 100; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 16px; width: min(640px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(15, 7, 102, .3); }
.modal-card.lg { width: min(980px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; bottom: 22px; right: 22px; background: var(--graphite); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 200; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: 420px; font-size: 13px; }
.toast.ok { background: var(--good); } .toast.err { background: var(--bad); }

/* ---------- Tela de acesso (login / liberação) ---------- */
.acesso { width: 100%; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 40px 16px;
  background: linear-gradient(180deg, var(--navy-deep) 0%, var(--navy) 55%, #1b2f9c 100%); }
.acesso-box { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 16px; }
.acesso-logo { width: 256px; margin: 0 auto; background: #fff; border-radius: 12px; padding: 12px 16px; }
.acesso-logo img { width: 100%; display: block; }
.acesso-rodape { text-align: center; font-size: 11.5px; color: #dfe3ff; }
.acesso-rodape a { color: var(--mint); text-decoration: none; }

/* ---------- Responsivo e impressão ---------- */
@media (max-width: 1100px) { .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) {
  body { display: block; }
  .sidebar { position: fixed; left: -270px; z-index: 50; transition: left .2s; }
  .sidebar.open { left: 0; box-shadow: 0 0 40px rgba(15, 7, 102, .4); }
  .only-mobile { display: inline-block; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .topbar, .view { padding-left: 16px; padding-right: 16px; }
}
@media print { .sidebar, .topbar, .no-print { display: none !important; } .view { padding: 0; } body { background: #fff; } }
