/* =============================================================================
   SIM Seguros — Dashboards · Folha de estilos partilhada
   ============================================================================= */

:root {
  --sim-red: #c8102e;
  --sim-red-dark: #9a0c23;
  --sim-red-soft: #fdecef;
  --ink: #14171a;
  --ink-soft: #4a5058;
  --line: #e5e7eb;
  --bg: #fafaf7;
  --paper: #ffffff;

  --green: #0f7a3a;
  --green-mid: #15a04a;
  --green-soft: #e6f5ec;
  --green-deep: #064e25;

  --red: #c8102e;
  --red-mid: #e63946;
  --red-soft: #fdecef;
  --red-deep: #8a0a1f;

  --warning: #b45309;
  --warning-soft: #fef3c7;
  --blue-soft: #eff6ff;
  --blue: #1e40af;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ---------- HEADER ---------- */
header.brand {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 20px;
  margin-bottom: 32px;
}
.brand-mark { display: flex; align-items: center; gap: 14px; }
.logo-square {
  width: 44px; height: 44px;
  background: var(--sim-red); color: white;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Fraunces', serif; font-weight: 800;
  font-size: 20px; letter-spacing: -0.02em;
}
.brand-name { font-family: 'Fraunces', serif; font-weight: 700; font-size: 22px; letter-spacing: -0.02em; }
.brand-sub { color: var(--ink-soft); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; margin-top: 4px; }
.brand-meta { text-align: right; font-size: 12px; color: var(--ink-soft); }
.brand-meta strong { color: var(--ink); font-weight: 600; }
.user-bar {
  display: flex; gap: 8px; align-items: center; margin-top: 6px;
  font-size: 11px;
}
.user-bar button {
  background: none; border: 1px solid var(--line); border-radius: 4px;
  padding: 3px 10px; cursor: pointer; color: var(--ink-soft);
  font-size: 11px;
}
.user-bar button:hover { border-color: var(--sim-red); color: var(--sim-red); }

/* ---------- NAV ---------- */
nav.tabs {
  display: flex; gap: 4px; margin-bottom: 24px;
  border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
nav.tabs a {
  padding: 10px 18px; text-decoration: none;
  color: var(--ink-soft); font-size: 13px; font-weight: 500;
  border: 1px solid transparent; border-bottom: none;
  margin-bottom: -1px; transition: all 0.15s;
}
nav.tabs a:hover { color: var(--ink); background: #f3f3ee; }
nav.tabs a.active {
  color: var(--ink); background: var(--paper);
  border-color: var(--line); font-weight: 600;
}
nav.tabs a.disabled {
  color: #b8bcc2; cursor: not-allowed; pointer-events: none;
}
nav.tabs a.disabled::after {
  content: " · em breve";
  font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 400;
}

/* ---------- HERO ---------- */
.hero { margin-bottom: 40px; }
.hero-eyebrow {
  font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--sim-red); font-weight: 600; margin-bottom: 8px;
}
.hero h1 {
  font-family: 'Fraunces', serif; font-weight: 700;
  font-size: clamp(28px, 4vw, 44px); line-height: 1.05;
  letter-spacing: -0.02em; margin: 0 0 12px 0;
}
.hero-period { color: var(--ink-soft); font-size: 15px; }

/* ---------- KPIs ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
  margin-bottom: 48px;
}
.kpi {
  background: var(--paper); padding: 20px 22px;
  border-top: 3px solid transparent;
}
.kpi.is-novas, .kpi.is-pos {
  border-top-color: var(--green);
  background: linear-gradient(180deg, var(--green-soft) 0%, var(--paper) 50%);
}
.kpi.is-anuladas, .kpi.is-neg, .kpi.is-saldo-neg {
  border-top-color: var(--red);
  background: linear-gradient(180deg, var(--red-soft) 0%, var(--paper) 50%);
}
.kpi.is-saldo-pos {
  border-top-color: var(--green);
}
.kpi-label {
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 600; margin-bottom: 6px;
}
.kpi.is-novas .kpi-label, .kpi.is-pos .kpi-label { color: var(--green-deep); }
.kpi.is-anuladas .kpi-label, .kpi.is-neg .kpi-label, .kpi.is-saldo-neg .kpi-label { color: var(--red-deep); }
.kpi-value {
  font-family: 'Fraunces', serif; font-size: 28px; font-weight: 700;
  letter-spacing: -0.02em; line-height: 1.1;
}
.kpi-value.is-positive { color: var(--green); }
.kpi-value.is-negative { color: var(--red); }
.kpi-sub { font-size: 11px; color: var(--ink-soft); margin-top: 4px; }

/* ---------- SECTION ---------- */
section.tabela-section { margin-bottom: 56px; }
.section-header {
  display: flex; align-items: baseline; gap: 16px;
  margin-bottom: 16px; padding: 0 0 8px 14px;
  border-bottom: 1px solid var(--line);
  border-left: 4px solid var(--ink);
}
.section-header.is-novas { border-left-color: var(--green); }
.section-header.is-anuladas { border-left-color: var(--red); }
.section-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; color: var(--sim-red); font-weight: 600;
}
.section-header.is-novas .section-num { color: var(--green); }
.section-header.is-anuladas .section-num { color: var(--red); }
.section-title {
  font-family: 'Fraunces', serif; font-size: 22px;
  font-weight: 600; letter-spacing: -0.01em; margin: 0; flex: 1;
}
.section-pill {
  display: inline-block; padding: 3px 10px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; border-radius: 999px;
  background: var(--ink); color: white;
}
.section-pill.is-novas { background: var(--green); }
.section-pill.is-anuladas { background: var(--red); }
.section-hint { font-size: 12px; color: var(--ink-soft); }

/* ---------- TABELAS ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  background: var(--paper);
}
.table-wrap.is-novas { border-top: 3px solid var(--green); }
.table-wrap.is-anuladas { border-top: 3px solid var(--red); }
.table-wrap.is-saldo { border-top: 3px solid var(--ink); }
table.dash {
  width: 100%; border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
table.dash thead th {
  background: #f6f6f1;
  color: var(--ink); font-weight: 600;
  font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 11px 12px; text-align: right;
  border-bottom: 2px solid var(--ink);
  white-space: nowrap;
}
table.dash thead th:first-child { text-align: left; }
table.dash thead th.col-total { background: #1a1f24; color: white; border-bottom-color: var(--sim-red); }
table.dash thead th.group-h { border-left: 1px solid var(--line); }
table.dash thead tr.groups th {
  background: #efeee8;
  font-family: 'Fraunces', serif; font-style: italic;
  font-weight: 600; font-size: 12px;
  border-bottom: 1px solid var(--line);
  padding: 8px 10px; color: var(--ink-soft);
  text-align: center;
}
.is-novas table.dash thead th { background: var(--green-soft); border-bottom-color: var(--green); }
.is-anuladas table.dash thead th { background: var(--red-soft); border-bottom-color: var(--red); }
.is-novas table.dash thead tr.groups th { background: #d6ecdf; color: var(--green-deep); }
.is-anuladas table.dash thead tr.groups th { background: #f5d8de; color: var(--red-deep); }

table.dash tbody td {
  padding: 10px 12px; text-align: right;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.dash tbody td:first-child {
  text-align: left; font-weight: 500;
}
table.dash tbody td.group-l { border-left: 1px solid var(--line); }
table.dash tbody td.col-total {
  background: #f3f3ee;
  font-weight: 700;
  border-left: 1px solid var(--ink);
}
table.dash tbody tr:hover { background: #fbfaf3; }
.is-novas table.dash tbody tr:hover { background: var(--green-soft); }
.is-anuladas table.dash tbody tr:hover { background: var(--red-soft); }
table.dash tbody tr.row-vida-fin {
  background: rgba(180, 83, 9, 0.04);
}
table.dash tbody tr.row-vida-fin td {
  color: var(--warning); font-style: italic;
  border-top: 1px dashed var(--warning);
}

table.dash tfoot td {
  padding: 13px 12px; text-align: right;
  font-weight: 700; background: var(--ink);
  color: white; font-size: 13px;
}
table.dash tfoot td:first-child {
  text-align: left;
  font-family: 'Fraunces', serif; letter-spacing: 0.02em;
}
table.dash tfoot td.col-total { background: var(--sim-red); }
table.dash tfoot td.group-l { border-left: 1px solid #2a2e34; }
.is-novas table.dash tfoot td { background: var(--green); }
.is-anuladas table.dash tfoot td { background: var(--red); }

/* Cores semânticas para Δ */
.delta-pos { color: var(--green); font-weight: 600; }
.delta-neg { color: var(--red); font-weight: 600; }
.delta-pos::before { content: "+"; }
.delta-neg::before { content: "−"; }
.delta-zero { color: var(--ink-soft); }
tfoot .delta-pos { color: #6ee7a3; }
tfoot .delta-neg { color: #ff8c95; }
.neg { color: var(--negative, var(--red)); font-weight: 600; }
.neg::before { content: "−"; margin-right: 1px; }
.zero { color: var(--ink-soft); }

/* ---------- TABELA % (acumulado) ---------- */
.table-pcts { margin-top: 20px; }
.table-pcts .table-wrap { border-top: 3px solid var(--blue); }
table.pcts {
  font-size: 12px;
}
table.pcts thead th {
  background: var(--blue-soft); color: var(--blue);
  padding: 9px 8px;
  font-size: 10px;
  white-space: nowrap;
}
table.pcts thead th.col-total { background: #1e3a8a; color: white; }
table.pcts tbody td {
  padding: 8px 8px;
  white-space: nowrap;
}
table.pcts tbody td:first-child {
  position: sticky;
  left: 0;
  background: var(--paper);
  z-index: 2;
  border-right: 1px solid var(--line);
}
table.pcts tbody tr:hover td:first-child { background: #fbfaf3; }
table.pcts tbody tr.row-vida-fin td:first-child {
  background: rgba(180, 83, 9, 0.04);
}
.pct-bar-cell { position: relative; padding-right: 12px; }
.pct-bar {
  display: inline-block; height: 8px;
  background: var(--blue); border-radius: 2px;
  vertical-align: middle; margin-right: 8px;
  max-width: 60px; min-width: 2px; opacity: 0.7;
}
.contrib-cell { padding: 8px 12px !important; }
.contrib-bar-container {
  display: flex; align-items: center; gap: 8px; justify-content: flex-end;
}
.contrib-bar-track {
  flex: 1; max-width: 80px; height: 14px;
  background: var(--bg); border-radius: 2px;
  position: relative; overflow: hidden;
  border: 1px solid var(--line);
}
.contrib-bar-fill {
  position: absolute; top: 0; bottom: 0;
  border-radius: 1px; min-width: 2px;
}
.contrib-bar-fill.is-pos {
  background: linear-gradient(90deg, var(--green-mid), var(--green));
  left: 50%;
}
.contrib-bar-fill.is-neg {
  background: linear-gradient(90deg, var(--red-mid), var(--red));
  right: 50%;
}
.contrib-bar-track::before {
  content: ""; position: absolute;
  left: 50%; top: 0; bottom: 0; width: 1px;
  background: var(--ink-soft); opacity: 0.3;
}
.contrib-value { min-width: 50px; text-align: right; font-variant-numeric: tabular-nums; }
.pct-positive { color: var(--green); font-weight: 600; }
.pct-positive::before { content: "+"; }
.pct-negative { color: var(--red); font-weight: 600; }
.pct-negative::before { content: "−"; }
.pct-na { color: var(--ink-soft); font-style: italic; font-weight: 400; }

/* ---------- ACTIONS / UPLOAD ---------- */
.actions {
  background: var(--paper); border: 1px solid var(--line);
  padding: 20px 24px; margin-bottom: 32px;
  display: flex; flex-wrap: wrap; gap: 16px;
  justify-content: space-between; align-items: center;
}
.actions-left { display: flex; gap: 12px; flex-wrap: wrap; }
.actions-info { font-size: 12px; color: var(--ink-soft); }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; background: var(--ink); color: white;
  border: none; font-family: inherit; font-size: 13px;
  font-weight: 600; letter-spacing: 0.02em;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--sim-red); }
.btn.primary { background: var(--sim-red); }
.btn.primary:hover { background: var(--sim-red-dark); }
.btn.ghost {
  background: transparent; color: var(--ink); border: 1px solid var(--line);
}
.btn.ghost:hover { background: var(--ink); color: white; border-color: var(--ink); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.upload-zone {
  background: var(--paper); border: 1px solid var(--line);
  padding: 24px; margin-bottom: 32px;
}
.upload-zone h3 { margin: 0 0 12px; font-family: 'Fraunces', serif; font-size: 18px; }
.upload-zone p { font-size: 13px; color: var(--ink-soft); margin: 0 0 16px; }
.upload-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.upload-form input[type="file"] {
  font-family: inherit;
  font-size: 13px;
  max-width: 320px;
}
.file-list {
  margin-top: 14px; font-size: 12px; color: var(--ink-soft);
  font-family: 'JetBrains Mono', monospace;
  list-style: none; padding: 0;
}
.file-list li { padding: 2px 0; }

/* ---------- FLASH messages ---------- */
#flash-container {
  position: fixed; top: 16px; right: 16px;
  z-index: 1000; display: flex; flex-direction: column; gap: 8px;
  max-width: 360px;
}
.flash {
  padding: 12px 18px;
  border-left: 3px solid var(--sim-red);
  background: var(--sim-red-soft);
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  animation: slide-in 0.2s ease-out;
}
.flash.success { border-color: var(--green); background: var(--green-soft); color: var(--green-deep); }
.flash.error { border-color: var(--red); background: var(--red-soft); color: var(--red-deep); }
.flash.info { border-color: var(--ink); background: #f3f3ee; }

@keyframes slide-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---------- ALERTS ---------- */
.alert-warning {
  background: var(--warning-soft);
  border-left: 3px solid var(--warning);
  padding: 12px 18px; margin: 12px 0;
  font-size: 13px; color: var(--warning);
}

/* ---------- EMPTY STATE ---------- */
.empty-state {
  background: var(--paper); border: 2px dashed var(--line);
  padding: 60px 32px; text-align: center; color: var(--ink-soft);
}
.empty-state h3 {
  font-family: 'Fraunces', serif; color: var(--ink);
  margin: 0 0 12px; font-size: 22px;
}

/* ---------- HISTÓRICO ---------- */
.history-list { list-style: none; padding: 0; margin: 0; }
.history-list li {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.history-list a { color: var(--sim-red); text-decoration: none; font-weight: 500; }
.history-list a:hover { text-decoration: underline; }

/* ---------- NOTAS + ENVIAR EMAIL ---------- */
.notes-zone {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 24px; margin: 32px 0;
}
.notes-zone h3 {
  margin: 0 0 12px; font-family: 'Fraunces', serif; font-size: 18px;
}
.notes-zone textarea {
  width: 100%; min-height: 100px;
  padding: 12px; font-family: inherit; font-size: 14px;
  border: 1px solid var(--line); border-radius: 4px;
  resize: vertical;
}
.notes-zone textarea:focus { outline: 2px solid var(--sim-red); border-color: var(--sim-red); }

.footnote {
  font-size: 12px; color: var(--ink-soft);
  font-style: italic; margin-top: 12px;
}

/* ---------- FOOTER ---------- */
footer {
  margin-top: 64px; padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: 11px; color: var(--ink-soft);
  letter-spacing: 0.06em; text-transform: uppercase;
  display: flex; justify-content: space-between;
}

/* ---------- LOGIN PAGE ---------- */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 40px;
  width: 100%; max-width: 380px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.04);
}
.login-card h1 {
  font-family: 'Fraunces', serif; font-size: 24px;
  margin: 0 0 8px; letter-spacing: -0.02em;
}
.login-card .login-sub {
  color: var(--ink-soft); font-size: 13px;
  margin-bottom: 28px;
}
.login-card .form-row { margin-bottom: 16px; }
.login-card label {
  display: block; font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-soft); margin-bottom: 6px;
}
.login-card input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line);
  font-family: inherit; font-size: 14px;
  border-radius: 4px;
}
.login-card input:focus { outline: 2px solid var(--sim-red); border-color: var(--sim-red); }
.login-card .btn { width: 100%; justify-content: center; padding: 12px; }

/* ---------- PRINT ---------- */
@media print {
  .actions, .upload-zone, .notes-zone { display: none; }
  body { background: white; }
  .layout { max-width: none; padding: 0; }
}

@media (max-width: 720px) {
  header.brand { flex-direction: column; align-items: flex-start; gap: 12px; }
  .brand-meta { text-align: left; }
  .actions { flex-direction: column; align-items: stretch; }
}


/* =============================================================================
   SINISTROS — Estilos específicos do separador
   ============================================================================= */

.hidden { display: none !important; }

/* ---------- Variáveis cromáticas (linhas por nº de contactos) ---------- */
:root {
  --amber-fill: #fef9f3;
  --amber-border: #d97706;
  --amber-ink: #633806;
  --amber-chip: #FAC775;

  --red-fill: #fdecec;
  --red-border-strong: #dc2626;
  --red-ink: #501313;
  --red-chip: #F09595;

  --dev-bg: #eff6ff;
  --dev-ink: #1e40af;
}

/* ---------- Sub-navegação dentro de Sinistros ---------- */
nav.subnav {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  padding: 4px;
  background: #f3f3ee;
  border: 1px solid var(--line);
  border-radius: 6px;
  width: fit-content;
}
nav.subnav a {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: 4px;
  transition: background 0.12s, color 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
nav.subnav a:hover { color: var(--ink); }
nav.subnav a.active {
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
nav.subnav .badge {
  background: var(--sim-red);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  letter-spacing: 0.02em;
}

/* ---------- Cabeçalho de cada vista ---------- */
.vista-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.vista-titulo {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.vista-resumo {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 4px 0 0;
}

/* ---------- Toolbar (pesquisa + filtros) ---------- */
.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar-input,
.toolbar-select {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
  background: var(--paper);
  color: var(--ink);
}
.toolbar-input:focus,
.toolbar-select:focus {
  outline: 2px solid var(--sim-red);
  border-color: var(--sim-red);
}
.toolbar-input { flex: 1; min-width: 200px; }
.toolbar-select { min-width: 150px; }
.toolbar-mes { min-width: 150px; max-width: 200px; }
.toolbar-pill {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 13px;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.toolbar-pill:hover { color: var(--ink); border-color: var(--ink); }
.toolbar-pill.active {
  background: var(--sim-red-soft);
  border-color: var(--sim-red);
  color: var(--sim-red-dark);
  font-weight: 600;
}

/* ---------- Tabela de sinistros ---------- */
table.sinistros-table {
  font-size: 13px;
}
table.sinistros-table thead th {
  text-align: left;
  padding: 11px 14px;
}
table.sinistros-table thead th.col-acoes { text-align: right; }
table.sinistros-table tbody td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.sinistros-table tbody tr {
  border-left: 3px solid var(--ink);
  transition: background 0.1s;
}
table.sinistros-table tbody tr:hover { background: #fbfaf3; }

/* Linhas coloridas por nº de ocorrências */
table.sinistros-table tbody tr.row-amber {
  background: var(--amber-fill);
  border-left-color: var(--amber-border);
}
table.sinistros-table tbody tr.row-amber:hover { background: #fdf2e3; }
table.sinistros-table tbody tr.row-amber .proc-num,
table.sinistros-table tbody tr.row-amber td { color: var(--amber-ink); }
table.sinistros-table tbody tr.row-amber .chip {
  background: var(--amber-chip);
  color: var(--amber-ink);
  border-color: rgba(0,0,0,0.05);
}

table.sinistros-table tbody tr.row-red {
  background: var(--red-fill);
  border-left-color: var(--red-border-strong);
}
table.sinistros-table tbody tr.row-red:hover { background: #fbdfdf; }
table.sinistros-table tbody tr.row-red .proc-num,
table.sinistros-table tbody tr.row-red td { color: var(--red-ink); }
table.sinistros-table tbody tr.row-red .chip {
  background: var(--red-chip);
  color: var(--red-ink);
  border-color: rgba(0,0,0,0.05);
}

/* Devolvido para mim */
table.sinistros-table tbody tr.row-devolvido { background: var(--dev-bg); }
table.sinistros-table tbody tr.row-devolvido:hover { background: #e3eef9; }
table.sinistros-table tbody tr.row-devolvido.row-amber { background: var(--amber-fill); }
table.sinistros-table tbody tr.row-devolvido.row-red { background: var(--red-fill); }

/* Pendente de validação (criador tratou após devolução, aguarda OK sinistros) */
table.sinistros-table tbody tr.row-pendente-validacao {
  background: #fff8e1;
  border-left-color: #b45309;
}
table.sinistros-table tbody tr.row-pendente-validacao:hover { background: #fff3c4; }

/* Pedido de eliminação — destaque visual claro */
table.sinistros-table tbody tr.row-elim-pedida {
  border-left-color: var(--red-border-strong);
  background: linear-gradient(90deg, rgba(220,38,38,0.06) 0%, transparent 50%);
}
table.sinistros-table tbody tr.row-elim-pedida .proc-num {
  text-decoration: line-through;
  text-decoration-color: rgba(220,38,38,0.6);
}

/* Botão azul "Tratar" no fluxo devolvido → pendente_validacao */
.btn-mini.btn-tratar-azul {
  background: var(--dev-ink);
  color: white;
  border-color: var(--dev-ink);
  font-weight: 600;
}
.btn-mini.btn-tratar-azul:hover {
  background: #1e3a8a;
  border-color: #1e3a8a;
}

/* Botão verde "Validar" — sinistros valida pendente_validacao */
.btn-mini.btn-validar {
  background: var(--green);
  color: white;
  border-color: var(--green);
  font-weight: 600;
}
.btn-mini.btn-validar:hover {
  background: var(--green-deep);
  border-color: var(--green-deep);
}

/* Nº de processo clicável -> abre histórico */
.proc-num.proc-link { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 2px; }
.proc-num.proc-link:hover { color: var(--dev-ink); }

/* Histórico / linha do tempo do processo */
.hist-resumo { margin: 2px 0 0; font-size: 12px; color: var(--ink-soft); }
.hist-lista { display: flex; flex-direction: column; gap: 0; }
.hist-vazio { color: var(--ink-soft); font-size: 13px; }
.hist-item {
  display: flex; gap: 12px; padding: 10px 2px 10px 14px;
  border-left: 2px solid var(--border, #e3e3e3); position: relative;
}
.hist-item::before {
  content: ''; position: absolute; left: -5px; top: 14px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--ink-soft, #888);
}
.hist-item.hist-tratado::before { background: var(--green, #0f7a3a); }
.hist-item.hist-devolvido::before { background: var(--dev-ink, #1d4ed8); }
.hist-item.hist-em_tratamento::before { background: var(--blue, #2563eb); }
.hist-item.hist-pendente_validacao::before { background: #b45309; }
.hist-quando { flex: 0 0 96px; font-size: 12px; font-weight: 600; color: var(--ink); }
.hist-detalhe { flex: 1; }
.hist-linha1 { margin-bottom: 4px; }
.hist-meta { font-size: 12px; color: var(--ink-soft); }

/* Em tratamento (reservado a um colaborador) */
table.sinistros-table tbody tr.row-em-tratamento {
  background: var(--dev-bg);
  border-left-color: var(--dev-ink);
}
table.sinistros-table tbody tr.row-em-tratamento:hover { background: #e3eef9; }

/* Botão "Em tratamento" */
.btn-mini.btn-em-tratamento {
  background: #fff;
  color: var(--dev-ink);
  border-color: var(--dev-ink);
  font-weight: 600;
}
.btn-mini.btn-em-tratamento:hover {
  background: var(--dev-ink);
  color: #fff;
}

/* Itens da legenda novos */
.leg-pendente     { color: #b45309; font-weight: 600; }
.leg-elim         { color: var(--red-border-strong); font-weight: 600; }
.leg-em-tratamento { color: var(--dev-ink); font-weight: 600; }

/* Ordenação clicável */
table.sinistros-table .sortable {
  cursor: pointer;
  user-select: none;
}
table.sinistros-table .sortable::after {
  content: " ↕";
  opacity: 0.3;
  font-size: 10px;
}
table.sinistros-table .sortable.sorted::after {
  content: " ↓";
  opacity: 1;
}
table.sinistros-table .sortable.sorted.asc::after {
  content: " ↑";
}

/* Colunas */
.col-urgente { width: 28px; text-align: center !important; padding-left: 8px !important; padding-right: 0 !important; }
.col-processo { width: 100px; }
.col-tempo { width: 110px; white-space: nowrap; }
.col-pedido { min-width: 180px; }
.col-meio { width: 100px; }
.col-por { width: 130px; color: var(--ink-soft); }
.col-gestor { width: 110px; font-weight: 500; white-space: nowrap; }
.col-gestor.empty { color: var(--ink-soft); font-weight: 400; }
.col-acoes { width: 160px; text-align: right !important; }

.proc-num {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: -0.01em;
}

/* Chips */
.chip {
  display: inline-block;
  background: #f3f3ee;
  color: var(--ink);
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11.5px;
  border: 1px solid var(--line);
  white-space: nowrap;
}
.chip-meio {
  background: var(--paper);
  color: var(--ink-soft);
}

.urgente-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--red-border-strong);
  vertical-align: middle;
}

.dev-icon {
  color: var(--dev-ink);
  font-weight: 700;
  margin-right: 4px;
}

/* Acções na linha */
.btn-mini {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 4px;
  font-size: 11px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  margin-left: 3px;
  transition: all 0.1s;
}
.btn-mini:hover { background: var(--ink); color: white; border-color: var(--ink); }
.btn-mini.btn-tratar {
  background: var(--green);
  color: white;
  border-color: var(--green);
  font-weight: 600;
}
.btn-mini.btn-tratar:hover { background: var(--green-deep); border-color: var(--green-deep); }
.btn-mini.btn-perigo:hover { background: var(--red); border-color: var(--red); }
.btn-mini[disabled] { opacity: 0.4; cursor: not-allowed; }
.acoes-vazio { font-size: 11px; color: var(--ink-soft); }

/* Linha vazia */
.empty-row {
  text-align: center !important;
  padding: 40px 20px !important;
  color: var(--ink-soft);
  font-style: italic;
}

/* Legenda em baixo da tabela */
.legenda {
  display: flex;
  gap: 18px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--ink-soft);
  flex-wrap: wrap;
  align-items: center;
}
.legenda strong { color: var(--ink); font-weight: 600; }
.leg-item { display: inline-flex; align-items: center; gap: 5px; }
.leg-swatch { display: inline-block; width: 11px; height: 11px; border-radius: 2px; }
.leg-preto { background: var(--ink); }
.leg-amber { background: var(--amber-border); }
.leg-red { background: var(--red-border-strong); }
.leg-devolvido { color: var(--dev-ink); font-weight: 600; }

/* ---------- Relatórios ---------- */
.periodo-pills {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: #f3f3ee;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 20px;
}
.periodo-pill {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: var(--ink-soft);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.periodo-pill.active {
  background: var(--paper);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.sinistros-kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 24px;
}

.paineis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.painel {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 18px;
}
.painel-titulo {
  font-family: 'Fraunces', serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 0 0 14px;
  letter-spacing: 0.02em;
}
.painel-nota {
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-top: 14px;
}

/* Barras horizontais nos relatórios */
.bar-row { margin-bottom: 10px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  margin-bottom: 4px;
}
.bar-meta .count { color: var(--ink-soft); }
.bar-track {
  height: 6px;
  background: #f3f3ee;
  border-radius: 3px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--sim-red);
  transition: width 0.3s;
}
.bar-fill.bar-dark { background: var(--ink); }

.list-row {
  display: flex;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: none; }
.list-row.row-amber { color: var(--amber-ink); }
.list-row.row-amber strong { color: var(--amber-ink); }
.list-row.row-red { color: var(--red-ink); }
.list-row.row-red strong { color: var(--red-ink); }
.muted { color: var(--ink-soft); font-size: 13px; font-style: italic; }

/* ---------- Gestão de recados ---------- */
.recado-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.recado-row:last-child { border-bottom: none; }
.recado-input {
  flex: 1;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
}
.recado-input:focus { outline: 2px solid var(--sim-red); border-color: var(--sim-red); }
.recado-add {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.recado-add input {
  flex: 1;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
}
.recado-add input:focus { outline: 2px solid var(--sim-red); border-color: var(--sim-red); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 23, 26, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px 20px;
  z-index: 1000;
  overflow-y: auto;
}
.modal {
  background: var(--paper);
  border: 1px solid var(--line);
  width: 100%;
  max-width: 500px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}
.modal-close {
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--ink-soft);
  cursor: pointer;
  line-height: 1;
  padding: 0 6px;
}
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: #fafaf7;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.form-erro {
  background: var(--red-soft);
  border-left: 3px solid var(--red);
  color: var(--red-deep);
  padding: 10px 14px;
  font-size: 12.5px;
  margin-bottom: 14px;
}

.form-field { margin-bottom: 16px; }
.form-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.form-hint {
  font-size: 11.5px;
  color: var(--ink-soft);
  margin: 6px 0 0;
}
.form-hint code {
  background: #f3f3ee;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

.proc-input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 600;
}
.proc-input:focus { outline: 2px solid var(--sim-red); border-color: var(--sim-red); }

.chip-toggles {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.chip-toggle {
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 18px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s;
}
.chip-toggle:hover { border-color: var(--sim-red); color: var(--sim-red); }
.chip-toggle.selected {
  background: var(--sim-red);
  color: white;
  border-color: var(--sim-red);
  font-weight: 600;
}

.meio-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.meio-opt {
  padding: 14px 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.12s;
}
.meio-opt:hover { border-color: var(--sim-red); color: var(--sim-red); }
.meio-opt.selected {
  border-color: var(--sim-red);
  background: var(--sim-red-soft);
  color: var(--sim-red-dark);
  font-weight: 600;
}
.meio-icon { font-size: 18px; }

.urgente-box {
  padding: 14px;
  background: var(--sim-red-soft);
  border: 1px solid var(--red-soft);
  border-radius: 4px;
}
.urgente-label {
  display: flex !important;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  text-transform: none !important;
  letter-spacing: 0 !important;
  color: var(--ink) !important;
  font-weight: 400 !important;
  font-size: 13px !important;
  margin-bottom: 0 !important;
}
.urgente-label input { display: none; }
.toggle-switch {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: 38px;
  height: 22px;
  background: #d3d1c7;
  border-radius: 11px;
  margin-top: 2px;
  transition: background 0.18s;
}
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.18s;
}
.urgente-label input:checked + .toggle-switch { background: var(--sim-red); }
.urgente-label input:checked + .toggle-switch::after { transform: translateX(16px); }
.urgente-titulo {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}
.urgente-help {
  display: block;
  font-size: 11.5px;
  color: var(--ink-soft);
  line-height: 1.4;
}

/* ---------- Responsivo ---------- */
@media (max-width: 720px) {
  .col-pedido { min-width: 120px; }
  .col-por, .col-meio { display: none; }
  .meio-grid { grid-template-columns: repeat(3, 1fr); }
  table.sinistros-table thead th,
  table.sinistros-table tbody td { padding: 8px 10px; font-size: 12px; }
  .vista-header { flex-direction: column; align-items: stretch; }
  nav.subnav { width: 100%; }
  nav.subnav a { flex: 1; justify-content: center; text-align: center; }
}
