/* Painel SEGUROS FROTA — usa os mesmos tokens de cor e fonte do app (app.css) */

.view { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.btn-seguros { border-color: var(--brand); color: var(--brand); font-weight: 700; letter-spacing: .04em; }
.btn-seguros:hover { background: var(--brand-soft); border-color: var(--brand); }
.btn-seguros[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }

/* ---------- cabeçalho ---------- */
.sg-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 20px; }
.sg-head h2 { font-size: 1.6rem; font-weight: 800; font-stretch: 85%; letter-spacing: -.01em; line-height: 1.1; }
.sg-head .sub { color: var(--muted); font-size: .9rem; margin: 2px 0 0; }
.sg-head-acoes { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sg-vig { display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.sg-vig select { width: auto; padding: 8px 34px 8px 10px; }

/* ---------- filtros ---------- */
.sg-filtros { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.sg-filtros-linha { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.sg-filtros .search-box { flex: 1 1 240px; max-width: none; }
.sg-filtros select { width: auto; flex: 1 1 160px; min-width: 0; max-width: 230px; padding: 9px 34px 9px 10px; font-size: .9rem; }
.sg-seg button { padding: 8px 12px; }
.sg-seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.sg-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .82rem; color: var(--muted); }
.sg-chips:empty { display: none; }
.sg-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink); border-radius: 999px; padding: 3px 6px 3px 10px; font-size: .8rem; font-weight: 600; }
.sg-chip button { border: 0; background: transparent; color: var(--muted); width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; padding: 0; }
.sg-chip button:hover { background: var(--line); color: var(--ink); }
.sg-limpar { border: 0; background: none; color: var(--brand); font-weight: 700; padding: 2px 4px; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- índices ---------- */
.sg-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.sg-kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0; text-align: left; color: var(--ink); }
button.sg-kpi:hover { border-color: var(--line-strong); }
.sg-kpi .rot { font-size: .84rem; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.sg-kpi .val { font-family: var(--font-display); font-weight: 800; font-stretch: 80%; font-size: 2.1rem; line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: -.01em; overflow-wrap: anywhere; }
.sg-kpi .val small { font-size: 1.1rem; font-weight: 700; color: var(--muted); margin-left: 2px; }
.sg-kpi .rod { font-size: .8rem; color: var(--muted); }
.sg-kpi.destaque { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.sg-kpi.destaque .rot, .sg-kpi.destaque .rod { color: color-mix(in srgb, var(--bg) 72%, transparent); }
.sg-kpi.alerta { border-color: color-mix(in srgb, var(--warn) 60%, var(--line)); background: color-mix(in srgb, var(--warn-soft) 60%, var(--surface)); }

/* ---------- gráficos ---------- */
.sg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.sg-card { padding: 0; display: flex; flex-direction: column; }
.sg-card .panel-head { padding: 14px 18px; }
.sg-card .panel-head h3 { font-family: var(--font-display); font-size: 1.02rem; font-weight: 700; font-stretch: 95%; margin: 0; }
.sg-card .panel-head .sub { font-size: .8rem; }
.sg-card-corpo { padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.sg-wide { grid-column: 1 / -1; }
.sg-nota { margin: 0; font-size: .78rem; color: var(--muted); }

.sg-barras { display: flex; flex-direction: column; gap: 10px; }
.sg-barra { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; border: 0; background: none; padding: 4px 6px; margin: 0 -6px; border-radius: 8px; text-align: left; color: var(--ink); width: calc(100% + 12px); }
.sg-barra:hover, .sg-barra:focus-visible { background: var(--surface-2); }
.sg-barra[aria-pressed="true"] { background: var(--brand-soft); }
.sg-barra .nome { font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-barra .nome small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.sg-barra .num { font-family: var(--font-mono); font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
.sg-barra .num small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.sg-barra .trilho { grid-column: 1 / -1; height: 10px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.sg-barra .enche { display: block; height: 100%; width: 0; background: var(--chart-1); border-radius: 0 4px 4px 0; transition: width .35s ease; }
.sg-barras.empresa .enche { background: var(--ink-2); }

/* colunas mensais empilhadas */
.sg-legenda { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .82rem; color: var(--ink-2); }
.sg-legenda span { display: inline-flex; align-items: center; gap: 7px; }
.sg-legenda i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sg-legenda .c1 { background: var(--chart-1); } .sg-legenda .c2 { background: var(--chart-2); }
.sg-colunas-wrap { overflow-x: auto; }
.sg-colunas { position: relative; display: grid; grid-template-columns: 56px repeat(12, minmax(34px, 1fr)); min-width: 560px; height: 230px; align-items: end; }
.sg-eixo { position: relative; height: 200px; align-self: start; margin-top: 4px; }
.sg-eixo span { position: absolute; right: 8px; transform: translateY(50%); font-family: var(--font-mono); font-size: .68rem; color: var(--muted); white-space: nowrap; }
.sg-grade { position: absolute; left: 56px; right: 0; top: 4px; height: 200px; pointer-events: none; }
.sg-grade i { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.sg-col { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 0; border: 0; background: none; padding: 0 4px; cursor: default; color: var(--ink); }
.sg-col .pilha { width: 100%; max-width: 38px; height: 200px; display: flex; flex-direction: column-reverse; gap: 2px; margin-bottom: 26px; }
.sg-col .seg1, .sg-col .seg2 { display: block; width: 100%; height: 0; min-height: 0; }
.sg-col .seg1 { background: var(--chart-1); }
.sg-col .seg2 { background: var(--chart-2); }
.sg-col .pilha > :last-child { border-radius: 4px 4px 0 0; }
.sg-col .mes { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; font-family: var(--font-mono); font-size: .7rem; text-transform: uppercase; color: var(--muted); }
.sg-col:hover .pilha, .sg-col:focus-visible .pilha { filter: brightness(1.12); }
.sg-col:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* renovações */
.sg-renov { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.sg-renov li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.sg-renov .dt { font-family: var(--font-display); font-weight: 800; font-stretch: 80%; font-size: 1.35rem; line-height: 1; font-variant-numeric: tabular-nums; grid-row: span 2; min-width: 64px; }
.sg-renov .dt small { display: block; font-family: var(--font-mono); font-size: .68rem; font-weight: 600; color: var(--muted); margin-top: 3px; }
.sg-renov .quem { font-weight: 600; font-size: .9rem; min-width: 0; overflow-wrap: anywhere; }
.sg-renov .det { font-size: .8rem; color: var(--muted); grid-column: 2; }
.sg-renov .pill { grid-row: span 2; }

/* ---------- tabela ---------- */
.sg-tabela-wrap { overflow-x: auto; }
.sg-tabela { min-width: 980px; }
.sg-tabela th button { border: 0; background: none; padding: 0; color: inherit; font: inherit; letter-spacing: inherit; text-transform: inherit; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.sg-tabela th button:hover { color: var(--ink); }
.sg-tabela th[aria-sort="ascending"] button::after { content: "▲"; font-size: .6rem; }
.sg-tabela th[aria-sort="descending"] button::after { content: "▼"; font-size: .6rem; }
.sg-tabela th.n, .sg-tabela td.n { text-align: right; }
.sg-tabela tbody tr { cursor: pointer; }
.sg-tabela tbody tr:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.sg-tabela td small { display: block; color: var(--muted); font-size: .78rem; }
/* coluna Frota / placa ~0,5 cm mais estreita: título com menos espaçamento e menos margem à direita */
.sg-tabela th:first-child { letter-spacing: .04em; padding-right: 6px; }
.sg-tabela td:first-child { padding-right: 6px; }
.sg-tabela td.bem { min-width: 202px; width: 202px; font-weight: 500; }   /* ~1 cm mais estreita que antes (240px) */
.sg-tabela tfoot td { font-weight: 700; border-top: 2px solid var(--line-strong); background: var(--surface-2); }
.sg-cat { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .04em; border-radius: 6px; padding: 2px 7px; white-space: nowrap; }
.sg-cat.TRATORES { background: color-mix(in srgb, var(--chart-1) 16%, transparent); color: var(--chart-1); }
.sg-cat.CAMINHOES { background: color-mix(in srgb, var(--chart-2) 16%, transparent); color: var(--chart-2); }
.sg-sinistro { display: flex; align-items: center; gap: 5px; margin-top: 6px; width: max-content; max-width: 100%; font-size: .74rem; font-weight: 700; letter-spacing: .02em; color: var(--bad-ink); background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--bad) 45%, transparent); border-radius: 6px; padding: 2px 7px; white-space: nowrap; }
.sg-sinistro svg { width: 13px; height: 13px; flex: none; }
.sg-sin-campo { justify-content: flex-start; }
.sg-sin-rot { font-weight: 600; font-size: .86rem; color: var(--ink-2); }
.sg-check { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); font-weight: 600; cursor: pointer; }
.sg-check input { width: 20px; height: 20px; padding: 0; accent-color: var(--bad); flex: none; }
.sg-check:has(input:checked) { border-color: var(--bad); background: var(--bad-soft); color: var(--bad-ink); }
select:disabled { opacity: .55; cursor: not-allowed; }
.pill.neutro { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }

/* ---------- dica flutuante ---------- */
.sg-tip { position: fixed; z-index: 80; pointer-events: none; background: var(--ink); color: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: .8rem; line-height: 1.4; box-shadow: var(--shadow-lg); max-width: 260px; }
.sg-tip b { font-weight: 700; }
.sg-tip .l { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.sg-tip i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.sg-tip .c1 { background: var(--chart-1); } .sg-tip .c2 { background: var(--chart-2); }

/* ---------- detalhes e formulário ---------- */
#ov-seguro .modal, #ov-sg-det .modal { width: min(720px, 100%); }
.sg-det-grade { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; margin: 0; }
.sg-det-grade div { min-width: 0; }
.sg-det-grade dt { font-size: .74rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.sg-det-grade dd { margin: 2px 0 0; font-size: .92rem; overflow-wrap: anywhere; }
.sg-det-titulo { font-family: var(--font-display); font-size: 1rem; font-weight: 700; margin: 6px 0 0; }
.sg-parcelas { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.sg-parcelas div { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: .78rem; }
.sg-parcelas b { display: block; font-family: var(--font-mono); text-transform: uppercase; font-size: .68rem; color: var(--muted); }
.sg-form-grade { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; }
.sg-form-grade .full { grid-column: 1 / -1; }
.sg-form-grade .dois { grid-column: span 2; }

@media (max-width: 980px) {
  .sg-grid { grid-template-columns: 1fr; }
  .sg-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .sg-kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .sg-kpi { padding: 12px; }
  .sg-kpi .val { font-size: 1.55rem; }
  .sg-filtros select { max-width: none; flex-basis: calc(50% - 5px); }
  .sg-det-grade, .sg-form-grade { grid-template-columns: 1fr; }
  .sg-form-grade .dois { grid-column: auto; }
  .sg-parcelas { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sg-head-acoes { width: 100%; }
}
