:root {
  /* ── Identidade corporativa ─────────────────────────────────── */
  --brand:          #00313E;   /* petróleo profundo — sidebar / primário */
  --brand-mid:      #005B6E;   /* petróleo médio */
  --brand-hover:    #002730;   /* hover do primário */
  --brand-soft:     #DFF0F4;   /* superfície de destaque suave */

  /* ── Aliases para compatibilidade com o código existente ──── */
  --turquoise:      var(--brand-mid);
  --turquoise-dark: var(--brand);
  --turquoise-soft: var(--brand-soft);

  /* ── Acento âmbar / alertas ─────────────────────────────────── */
  --coral:          #C0392B;
  --coral-soft:     #FEECEC;
  --mustard:        #C97A0A;
  --mustard-soft:   #FEF3E2;

  /* ── Semântica ──────────────────────────────────────────────── */
  --danger:         #B91C1C;
  --danger-soft:    #FEECEC;
  --ok:             #15803D;
  --ok-soft:        #DCFCE7;

  /* ── Neutros ────────────────────────────────────────────────── */
  --warm-gray:      #4A5568;
  --ink:            #0D1B2A;
  --muted:          #64748B;
  --line:           #CBD5E0;
  --surface:        #FFFFFF;
  --page:           #F2F4F7;

  /* ── Sombras corporativas (mais sutis) ──────────────────────── */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow:     0 3px 10px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.05);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.10), 0 3px 8px rgba(0,0,0,0.05);
  /* alias para compatibilidade com código que usa --shadow diretamente */

  font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--page);
}

* {
  box-sizing: border-box;
}

/* garante que [hidden] funcione mesmo com display definido em seletores CSS */
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--page);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr) 380px;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px 16px;
  color: #fff;
  background: var(--brand);
  overflow-y: auto;
  border-right: 1px solid rgba(0,0,0,0.12);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-block strong {
  display: block;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1;
}

.brand-block span {
  display: block;
  margin-top: 5px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 10px;
  line-height: 1.35;
  max-width: 160px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Ícone de mostrador de calibração */
.brand-mark {
  position: relative;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(var(--mustard) 0deg 270deg, rgba(255,255,255,0.25) 270deg 360deg);
}

.brand-mark::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: var(--turquoise-dark);
}

.brand-mark::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 14%;
  width: 3px;
  height: 40%;
  background: var(--mustard);
  border-radius: 2px;
  transform: translateX(-50%) rotate(-45deg);
  transform-origin: bottom center;
}

.nav-stack {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 8px 11px;
  border: none;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  text-align: left;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
}

.nav-item.is-active {
  color: #fff;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 3px 0 0 var(--mustard);
}

.source-panel {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.source-panel span,
.source-panel small {
  display: block;
  color: rgba(255, 255, 255, 0.72);
}

.source-panel strong {
  display: block;
  margin: 5px 0;
  font-size: 18px;
}

.workspace {
  padding: 24px 28px;
  min-width: 0;
  background: var(--page);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand-mid);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(20px, 2.5vw, 28px);
  font-weight: 700;
  line-height: 1.1;
}

.last-sync {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.2;
}

h3 {
  margin: 0;
  font-size: 16px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.ghost-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  border-radius: 5px;
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.primary-button {
  padding: 0 15px;
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}

.primary-button:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

.ghost-button {
  padding: 0 13px;
  color: var(--brand);
  background: var(--surface);
  font-weight: 600;
}

.ghost-button:hover {
  border-color: var(--brand-mid);
  background: var(--brand-soft);
}

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--ink);
  background: #fff;
}

.control-band {
  display: grid;
  grid-template-columns: minmax(280px, 1fr);
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
}

.segment-control {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.segment {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--warm-gray);
  background: var(--surface);
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}

.segment:hover {
  border-color: var(--brand-mid);
  color: var(--brand);
}

.segment.is-active {
  color: var(--surface);
  border-color: var(--brand);
  background: var(--brand);
  font-weight: 700;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
}

.filter-grid label,
.form-grid label,
.form-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input,
textarea {
  min-height: 36px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 7px 10px;
  color: var(--ink);
  background: var(--surface);
  font-size: 13.5px;
  transition: border-color 0.12s, box-shadow 0.12s;
}

select:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-mid);
  box-shadow: 0 0 0 3px rgba(0,91,110,0.12);
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.kpi-card,
.panel,
.metric-tile,
.doc-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.kpi-card {
  min-height: 118px;
  padding: 16px 18px;
  display: grid;
  align-content: space-between;
  border-left: 4px solid var(--brand-mid);
}

.kpi-card.is-danger {
  border-left-color: var(--coral);
}

.kpi-card.is-warning {
  border-left-color: var(--mustard);
}

.kpi-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.kpi-card strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 700;
  line-height: 1;
}

.kpi-card small {
  display: block;
  color: var(--muted);
}

.analytics-grid,
.timeline-grid,
.operation-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
}

.operation-grid {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.62fr);
  margin-bottom: 16px;
}

.panel {
  padding: 16px 18px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.bar-chart {
  display: grid;
  gap: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.32fr) minmax(160px, 1fr) 58px;
  align-items: center;
  gap: 12px;
}

.bar-label {
  font-weight: 700;
  color: var(--ink);
}

.bar-track {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9efed;
}

.bar-fill {
  height: 100%;
  min-width: 4px;
  border-radius: inherit;
  background: var(--turquoise);
}

.bar-row:nth-child(2n) .bar-fill {
  background: var(--coral);
}

.bar-row:nth-child(3n) .bar-fill {
  background: var(--mustard);
}

.compact-list,
.audit-feed,
.due-lanes,
.missing-chart,
.document-board,
.process-flow,
.action-queue,
.document-workbench-list {
  display: grid;
  gap: 10px;
}

.compact-item,
.audit-item,
.due-item,
.missing-row,
.doc-card,
.process-step,
.action-card,
.workbench-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.compact-item,
.audit-item,
.due-item,
.action-card,
.workbench-item {
  width: 100%;
  color: var(--ink);
  text-align: left;
}

.compact-item {
  display: grid;
  gap: 7px;
}

.item-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.process-step {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.process-step strong,
.action-card strong,
.workbench-item strong {
  display: block;
}

.process-step small,
.action-card small,
.workbench-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.step-index {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--turquoise-dark);
  font-weight: 700;
  font-size: 13px;
}

.step-meter {
  height: 8px;
  overflow: hidden;
  margin-top: 8px;
  border-radius: 999px;
  background: #e9efed;
}

.step-meter span {
  display: block;
  height: 100%;
  min-width: 4px;
  border-radius: inherit;
  background: var(--mustard);
}

.action-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
}

.action-card span,
.workbench-item span {
  color: var(--turquoise-dark);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.action-card strong {
  grid-row: span 2;
  align-self: center;
  font-size: 28px;
}

.action-card:hover,
.workbench-item:hover {
  border-color: var(--turquoise);
  background: var(--turquoise-soft);
}

.muted {
  color: var(--muted);
}

.count-pill,
.status-pill,
.risk-pill,
.due-pill,
.doc-status,
.source-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.count-pill,
.source-badge {
  color: var(--turquoise-dark);
  background: var(--turquoise-soft);
}

.status-pill {
  color: var(--turquoise-dark);
  background: var(--turquoise-soft);
}

.status-pill.status-vencido,
.status-pill.status-segregado,
.risk-pill.risk-critico {
  color: var(--danger);
  background: var(--danger-soft);
}

.status-pill.status-sem-rastreabilidade,
.risk-pill.risk-alto {
  color: #815000;
  background: var(--mustard-soft);
}

.risk-pill.risk-medio {
  color: var(--warm-gray);
  background: #eee9df;
}

.risk-pill.risk-baixo {
  color: var(--ok);
  background: var(--ok-soft);
}

.due-pill.is-overdue {
  color: var(--danger);
  background: var(--danger-soft);
}

.due-pill.is-soon {
  color: #815000;
  background: var(--mustard-soft);
}

.due-pill.is-ok {
  color: var(--ok);
  background: var(--ok-soft);
}

.table-panel {
  padding: 0;
  overflow: hidden;
}

.table-panel .panel-header {
  padding: 18px 18px 0;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 310px);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  padding: 10px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--ink);
  background: #EEF1F5;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--line);
}

tbody tr {
  background: var(--surface);
  transition: background 0.08s;
}

tbody tr:nth-child(even) {
  background: #FAFBFC;
}

tbody tr:hover {
  background: var(--brand-soft);
}

tbody tr.is-selected {
  background: var(--brand-soft);
  outline: 2px solid var(--brand-mid);
  outline-offset: -2px;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 16px;
  background: #EEF1F5;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.detail-drawer {
  position: sticky;
  top: 0;
  height: 100vh;
  border-left: 2px solid var(--line);
  background: var(--surface);
  overflow-y: auto;
}

.empty-detail {
  min-height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-detail strong {
  color: var(--ink);
}

.detail-content {
  padding: 20px;
}

.detail-header {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.detail-header h2 {
  margin-bottom: 4px;
}

#detail-subtitle {
  color: var(--muted);
  font-size: 13px;
}

.detail-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.tabs {
  display: flex;
  gap: 0;
  overflow-x: auto;
  margin: 0 0 16px;
  padding: 0;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 32px;
  padding: 0 12px;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.12s, border-color 0.12s;
}

.tab:hover {
  color: var(--ink);
}

.tab.is-active {
  color: var(--brand);
  font-weight: 700;
  border-bottom-color: var(--brand-mid);
  background: transparent;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.info-field {
  min-height: 66px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--page);
}

.info-field span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.info-field strong {
  display: block;
  font-size: 14px;
  line-height: 1.3;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.doc-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.doc-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.doc-status.is-ok {
  color: var(--ok);
  background: var(--ok-soft);
}

.doc-status.is-pending {
  color: var(--danger);
  background: var(--danger-soft);
}

.audit-item {
  position: relative;
  display: grid;
  gap: 5px;
}

.audit-item::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 12px;
  bottom: 12px;
  width: 4px;
  border-radius: 999px;
  background: var(--turquoise);
}

.audit-item.is-critical::before {
  background: var(--coral);
}

.audit-item small,
.compact-item small,
.due-item small,
.doc-card small {
  color: var(--muted);
}

.due-lane {
  display: grid;
  gap: 8px;
}

.due-lane-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #fff;
  background: var(--turquoise-dark);
  font-weight: 700;
}

.due-lane.is-danger .due-lane-title {
  background: var(--coral);
}

.due-lane.is-warning .due-lane-title {
  color: var(--ink);
  background: var(--mustard);
}

.missing-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) minmax(120px, 1fr) 54px;
  gap: 10px;
  align-items: center;
}

.missing-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9efed;
}

.missing-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--coral);
}

.document-board {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
}

.doc-card {
  min-height: 150px;
  display: grid;
  align-content: space-between;
}

.doc-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.document-workbench {
  margin-top: 0;
}

.workbench-item {
  display: grid;
  gap: 4px;
}

.workbench-item span {
  color: var(--warm-gray);
}

.prontuario-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.prontuario-summary div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--turquoise-soft);
}

.prontuario-summary span {
  display: block;
  margin-bottom: 6px;
  color: var(--turquoise-dark);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.prontuario-summary strong {
  display: block;
  font-size: 13px;
}

.icon {
  position: relative;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  display: inline-block;
}

.icon-dashboard::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 2px solid currentColor;
  border-top-width: 7px;
}

.icon-list::before,
.icon-list::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 6px 0 currentColor, 0 12px 0 currentColor;
}

.icon-list::before {
  top: 2px;
}

.icon-clock::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.icon-clock::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 5px;
  width: 5px;
  height: 5px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.icon-doc::before {
  content: "";
  position: absolute;
  inset: 2px 4px 1px 3px;
  border: 2px solid currentColor;
}

.icon-doc::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 2px;
  width: 6px;
  height: 6px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  background: #fff;
}

.icon-audit::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 2px solid currentColor;
  transform: rotate(45deg);
}

.icon-search::before {
  content: "";
  position: absolute;
  width: 9px;
  height: 9px;
  left: 2px;
  top: 2px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.icon-search::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 2px;
  left: 10px;
  top: 12px;
  background: currentColor;
  transform: rotate(45deg);
}

.icon-export::before,
.icon-reset::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 2px solid currentColor;
}

.icon-export::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 1px;
  width: 7px;
  height: 7px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(45deg);
}

.icon-reset::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 5px;
  width: 8px;
  height: 8px;
  border-top: 2px solid currentColor;
  border-left: 2px solid currentColor;
  border-radius: 50%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1280px) {
  .app-shell {
    grid-template-columns: 226px minmax(0, 1fr);
  }

  .detail-drawer {
    position: fixed;
    right: 18px;
    top: 18px;
    bottom: 18px;
    z-index: 10;
    width: min(390px, calc(100vw - 36px));
    height: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    transform: translateX(calc(100% + 24px));
    transition: transform 180ms ease;
  }

  .detail-drawer.has-selection {
    transform: translateX(0);
  }
}

@media (max-width: 920px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px 16px 12px;
    gap: 12px;
  }

  .brand-block {
    flex-shrink: 0;
  }

  .nav-stack {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .nav-stack::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 13px;
  }

  .nav-divider {
    display: none;
  }

  .sidebar-footer {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    margin-top: 0;
    padding: 10px 12px;
  }

  .session-info {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .session-info strong {
    font-size: 13px;
  }

  .logout-button {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 12px;
  }

  .source-panel {
    display: none;
  }

  .workspace {
    padding: 18px;
  }

  .topbar,
  .table-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .filter-grid,
  .kpi-grid,
  .analytics-grid,
  .timeline-grid,
  .operation-grid,
  .prontuario-summary,
  .document-board {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .workspace {
    padding: 14px;
  }

  .control-band,
  .panel {
    padding: 12px;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .bar-row,
  .missing-row {
    grid-template-columns: 1fr;
  }

  .topbar-actions > *,
  .action-row > * {
    width: 100%;
  }

  /* Formulários admin em coluna única */
  .full-form,
  .alert-form,
  .form-grid {
    grid-template-columns: 1fr !important;
  }

  /* Admin table scroll horizontal */
  .admin-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  /* Login card compacto */
  .login-card {
    padding: 28px 20px 24px;
  }

  /* Detail drawer full screen em mobile */
  .detail-drawer.has-selection {
    position: fixed;
    inset: 0;
    z-index: 20;
    width: 100%;
    border-radius: 0;
    transform: none;
    overflow-y: auto;
  }
}

/* ======================================================================
   LOGIN SCREEN
====================================================================== */

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--brand);  /* sidebar color — tela de login imersiva */
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 40px 36px 32px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo {
  position: relative;
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
}

.login-logo::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--mustard) 0deg 270deg, rgba(0,88,92,0.18) 270deg 360deg);
}

.login-logo::after {
  content: "";
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: var(--turquoise-dark);
  box-shadow: 0 0 0 2.5px var(--mustard);
}

.login-brand h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--brand);
}

.login-brand p {
  margin: 6px 0 0;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.login-field input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
  background: var(--page);
  transition: border-color 0.15s;
}

.login-field input:focus {
  outline: none;
  border-color: var(--brand-mid);
  box-shadow: 0 0 0 3px rgba(0,91,110,0.15);
}

.login-error {
  padding: 10px 12px;
  margin-bottom: 14px;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
}

.login-submit {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.03em;
  border-radius: 5px;
  background: var(--brand);
  border-color: var(--brand);
}

.login-footer {
  display: block;
  margin-top: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* ======================================================================
   SIDEBAR FOOTER / SESSION INFO
====================================================================== */

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.session-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.session-info strong {
  color: #fff;
  font-size: 14px;
}

.session-info span {
  color: rgba(255,255,255,0.65);
  font-size: 12px;
}

.logout-button {
  color: rgba(255,255,255,0.82);
  border-color: rgba(255,255,255,0.2);
  font-size: 13px;
}

.logout-button:hover {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.16);
  margin: 4px 0;
}

/* ======================================================================
   ADMIN FORMS
====================================================================== */

.full-form {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.form-section-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  color: var(--turquoise-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.form-section-title::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.form-hint {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.alert-form {
  grid-template-columns: 1fr 1fr auto auto;
  align-items: end;
}

/* ======================================================================
   RECIPIENTS LIST / USERS LIST / ADMIN TABLE
====================================================================== */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  font-size: 14px;
}

.admin-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: var(--page);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-sm.is-danger {
  color: var(--danger);
  border-color: var(--danger-soft);
}

/* ======================================================================
   BULK UPLOAD
====================================================================== */

.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 36px 20px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  transition: border-color 0.15s, background 0.15s;
  grid-column: 1 / -1;
}

.file-drop:hover {
  border-color: var(--turquoise);
  background: var(--turquoise-soft);
}

.file-drop input[type="file"] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.bulk-results {
  margin-top: 20px;
  padding: 16px;
  border-radius: 10px;
  background: var(--page);
}

.bulk-summary {
  margin-bottom: 12px;
  font-size: 15px;
}

.bulk-summary .ok   { color: var(--ok); font-weight: 700; }
.bulk-summary .warn { color: var(--warm-gray); font-weight: 700; }
.bulk-summary .err  { color: var(--danger); font-weight: 700; }

.bulk-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 360px;
  overflow-y: auto;
  font-size: 13px;
}

.bulk-list li {
  padding: 8px 12px;
  border-radius: 6px;
}

.bulk-list li.ok   { background: var(--ok-soft);     color: var(--ok); }
.bulk-list li.warn { background: var(--mustard-soft); color: var(--warm-gray); }
.bulk-list li.err  { background: var(--danger-soft);  color: var(--danger); }

/* ======================================================================
   CALIBRATION HISTORY (viewer)
====================================================================== */

.calibration-history {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.calib-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  background: var(--page);
  border: 1px solid var(--line);
  font-size: 13px;
}

.calib-item small {
  color: var(--muted);
}

/* ======================================================================
   DOCUMENT LINK
====================================================================== */

.doc-link {
  padding: 4px 10px;
  font-size: 12px;
  color: var(--turquoise-dark);
  text-decoration: none;
  border: 1px solid var(--turquoise-soft);
  border-radius: 6px;
  white-space: nowrap;
}

.doc-link:hover {
  background: var(--turquoise-soft);
}

/* ======================================================================
   ERROR TEXT
======================================================================= */

.error-text {
  color: var(--danger);
  font-size: 14px;
}

/* ======================================================================
   EXTRA ICONS (admin sidebar)
====================================================================== */

.icon-edit::before {
  content: "";
  position: absolute;
  left: 2px;
  bottom: 2px;
  right: 2px;
  height: 2px;
  background: currentColor;
}

.icon-edit::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 2px;
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  transform: rotate(45deg);
  transform-origin: top right;
}

.icon-upload::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 1px;
  width: 2px;
  height: 11px;
  background: currentColor;
}

.icon-upload::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 2px;
  width: 8px;
  height: 8px;
  border-top: 2px solid currentColor;
  border-left: 2px solid currentColor;
  transform: rotate(45deg);
  transform-origin: center;
  box-shadow: inset -2px 0 0 0 var(--turquoise-dark), 0 12px 0 0 currentColor;
}

.icon-bell::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 2px;
  width: 12px;
  height: 11px;
  border: 2px solid currentColor;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}

.icon-bell::after {
  content: "";
  position: absolute;
  left: 6px;
  bottom: 2px;
  width: 6px;
  height: 4px;
  border: 2px solid currentColor;
  border-top: none;
  border-radius: 0 0 4px 4px;
}

.icon-user::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 8px;
  height: 8px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.icon-user::after {
  content: "";
  position: absolute;
  left: 2px;
  bottom: 1px;
  right: 2px;
  height: 6px;
  border: 2px solid currentColor;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}
