/* ============================================================
   Contratos Lab · SaaS dashboard design
   Sidebar layout · rounded cards · soft shadows · DM Sans
   Brand color: deep forest green (Laboratório São Luiz)
   ============================================================ */

:root {
  /* Surfaces */
  --bg:           #F5F6F4;   /* off-white with hint of green */
  --bg-alt:       #ECEEEB;
  --surface:      #FFFFFF;
  --surface-2:    #FAFAF7;
  --border:       #E7EAE6;
  --border-soft:  #EFF1EE;

  /* Text */
  --text:         #0F1F1B;
  --text-soft:    #3F4A45;
  --text-muted:   #5A6560;  /* WCAG AA: 5.7:1 on #FAFAFA */
  --text-faint:   #A1ABA5;

  /* Brand & accents */
  --accent:       #2D4A3E;          /* deep forest green */
  --accent-2:     #4F7A4F;
  --accent-3:     #7BAA80;
  --accent-bg:    #E8F1EA;
  --accent-bg-2:  #D6E8DA;

  --gold:         #B98448;
  --gold-bg:      #F8EFE2;

  --rose:         #BF5B5B;
  --rose-bg:      #FCE5E5;

  --blue:         #4A6FA5;
  --blue-bg:      #E5EBF5;

  /* Status semantic */
  --warning:      var(--gold);
  --warning-bg:   var(--gold-bg);
  --danger:       var(--rose);
  --danger-bg:    var(--rose-bg);

  /* Type */
  --font-sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space:    16px;
  --space-md: 20px;
  --space-lg: 28px;
  --space-xl: 40px;

  /* Radii */
  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 20px;
  --radius-xl: 24px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 31, 27, 0.04);
  --shadow:    0 2px 12px rgba(15, 31, 27, 0.06);
  --shadow-lg: 0 8px 28px rgba(15, 31, 27, 0.08);

  /* Sidebar metrics */
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

h1, h2, h3 { font-family: var(--font-sans); font-weight: 600; margin: 0; letter-spacing: -0.012em; }

.tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }

/* ============================================================
   App shell — sidebar + body
   ============================================================ */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--space-md) var(--space);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.sidebar__brand {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
  padding: 4px 4px 8px;
  border-radius: 8px;
}
.sidebar__brand:hover { background: rgba(0,0,0,0.02); }
.sidebar__brand-logo {
  height: 32px;
  display: block;
  width: auto;
  align-self: flex-start;
  max-width: 100%;
  object-fit: contain;
}
.sidebar__brand-divider {
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border), transparent);
  margin: 0 2px;
}
.sidebar__system {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 2px;
}
.sidebar__system-icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: block;
}
.sidebar__system-name {
  display: flex;
  flex-direction: column;
  line-height: 1;
}
.sidebar__system-eyebrow {
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  font-weight: 600;
}
.sidebar__system-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.012em;
  margin-top: 2px;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar__group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 14px 12px 4px;
}
.sidebar__nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13.5px;
  transition: all 0.15s ease;
  position: relative;
}
.sidebar__nav a svg { color: var(--text-faint); transition: color 0.15s ease; flex-shrink: 0; }
.sidebar__nav a:hover {
  background: var(--bg);
  color: var(--text);
}
.sidebar__nav a:hover svg { color: var(--text-soft); }
.sidebar__nav a.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}
.sidebar__nav a.active svg { color: var(--accent); }
.sidebar__nav a.active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.sidebar__foot {
  margin-top: auto;
  padding-top: var(--space);
  border-top: 1px solid var(--border-soft);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
}
.user-chip__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--surface);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
}
.user-chip { position: relative; }
.user-chip__info { flex: 1; min-width: 0; }
.user-chip__name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip__role { font-size: 11px; color: var(--text-muted); }
.user-chip__logout {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.15s ease;
}
.user-chip__logout:hover {
  background: var(--rose-bg);
  color: var(--rose);
}

.app-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ============================================================
   Topbar
   ============================================================ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space) var(--space-xl);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
  gap: var(--space-md);
}

.topbar__search {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.topbar__search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 74, 62, 0.1);
}
.topbar__search svg { color: var(--text-muted); flex-shrink: 0; }
.topbar__search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
}
.topbar__search input::placeholder { color: var(--text-muted); }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-soft);
  display: grid;
  place-items: center;
  transition: all 0.15s ease;
}
.icon-btn:hover { background: var(--bg-alt); color: var(--text); }

.app-main {
  padding: var(--space-lg) var(--space-xl) var(--space-xl);
  max-width: 1320px;
  width: 100%;
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .app-main { padding: var(--space-md); }
}

/* ============================================================
   Page header (used in views)
   ============================================================ */

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  gap: var(--space);
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.018em;
}
.page-header__sub {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 13px;
}

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ============================================================
   Cards (base)
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.card--lift:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space);
}
.card__title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card__subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================================================
   KPI cards
   ============================================================ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space);
  margin-bottom: var(--space-lg);
}

@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}
.kpi:hover { box-shadow: var(--shadow); }

.kpi__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.kpi__icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-bg);
  color: var(--accent);
}
.kpi__icon svg { width: 18px; height: 18px; }
.kpi--warning .kpi__icon { background: var(--gold-bg); color: var(--gold); }
.kpi--danger  .kpi__icon { background: var(--rose-bg); color: var(--rose); }
.kpi--blue    .kpi__icon { background: var(--blue-bg); color: var(--blue); }

.kpi__delta {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent);
}
.kpi__delta--warning { background: var(--gold-bg); color: var(--gold); }
.kpi__delta--danger  { background: var(--rose-bg); color: var(--rose); }

.kpi__label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}
.kpi__value {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.022em;
  line-height: 1.1;
}
.kpi__sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Sparkline placeholder beneath KPI value */
.kpi__spark {
  margin-top: 10px;
  height: 28px;
  width: 100%;
  display: block;
}

/* ============================================================
   Two-column dashboard grid
   ============================================================ */

.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space);
  margin-bottom: var(--space);
}
.dash-grid--equal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space);
}
@media (max-width: 1024px) {
  .dash-grid, .dash-grid--equal { grid-template-columns: 1fr; }
}

/* ============================================================
   Line chart
   ============================================================ */

.linechart {
  width: 100%;
  height: 220px;
  display: block;
}
.linechart .area  { fill: var(--accent); fill-opacity: 0.08; }
.linechart .line  { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.linechart .linechart__dot   { fill: var(--surface); stroke: var(--accent); stroke-width: 2; transition: r 0.12s ease; }
.linechart .grid  { stroke: var(--border-soft); stroke-width: 1; }
.linechart .axis  { fill: var(--text-faint); font-size: 10.5px; }

.linechart-wrap { position: relative; }
.chart-tooltip {
  position: absolute;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  font-size: 12px;
  pointer-events: none;
  z-index: 10;
}
.chart-tooltip__label {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
}
.chart-tooltip__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 2px 0;
}
.chart-tooltip__k { color: var(--text-muted); }
.chart-tooltip__foot {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-soft);
  color: var(--text-muted);
  font-size: 11px;
}

/* ============================================================
   Donut chart
   ============================================================ */

.donut-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}
.donut {
  width: 168px;
  height: 168px;
  flex-shrink: 0;
  position: relative;
}
.donut__center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
}
.donut__center-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.donut__center-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.donut-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.donut-legend__item {
  display: grid;
  grid-template-columns: 10px 1fr auto auto;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.donut-legend__dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.donut-legend__name {
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.donut-legend__pct {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  text-align: right;
}
.donut-legend__count {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  min-width: 24px;
  text-align: right;
}
.donut-legend__item--link {
  text-decoration: none;
  color: inherit;
  padding: 4px 8px;
  margin: -4px -8px;
  border-radius: 6px;
  transition: background 0.12s ease;
  cursor: pointer;
}
.donut-legend__item--link:hover,
.donut-legend__item--active {
  background: var(--accent-bg, rgba(45,74,62,0.06));
}

/* ============================================================
   Attention list
   ============================================================ */

.attention-list { /* uses .card */ }

.attention-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: var(--space);
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background 0.12s ease;
  border-radius: 8px;
  padding: 12px;
  margin: 0 -12px;
}
.attention-row:last-child { border-bottom: none; }
.attention-row:hover { background: var(--bg); }

.attention-row__when {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.attention-row__when[data-urgency="warning"] { background: var(--gold-bg); color: var(--gold); }
.attention-row__when[data-urgency="danger"]  { background: var(--rose-bg); color: var(--rose); }

.attention-row__title { font-weight: 600; font-size: 13.5px; }
.attention-row__meta  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.attention-row__tag {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--text-soft);
  text-transform: lowercase;
  letter-spacing: 0.01em;
}

/* ============================================================
   Lists (contratos, pessoas)
   ============================================================ */

.list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.list-item {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: var(--space);
  padding: var(--space) var(--space-md);
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background 0.12s ease;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--bg); }

.list-item__title { font-weight: 600; font-size: 14px; }
.list-item__meta  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.list-item__right { text-align: right; }
.list-item__amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  letter-spacing: -0.012em;
}
.list-item__when {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: var(--text-faint);
}
.dot[data-status="ativo"]              { background: var(--accent); }
.dot[data-status="atencao"]            { background: var(--gold); }
.dot[data-status="vencido_renegociar"] { background: var(--rose); }
.dot[data-status="encerrado"],
.dot[data-status="cancelado"]          { background: var(--text-faint); opacity: 0.6; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--text-muted);
}
.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-pill[data-status="ativo"]              { background: var(--accent-bg); color: var(--accent); }
.status-pill[data-status="vencido_renegociar"] { background: var(--rose-bg); color: var(--rose); }
.status-pill[data-status="atencao"]            { background: var(--gold-bg); color: var(--gold); }
/* Estados genéricos usados em signatários e badges do envelope */
.status-pill[data-status="ok"]     { background: var(--accent-bg); color: var(--accent); }
.status-pill[data-status="warn"]   { background: var(--gold-bg); color: var(--gold); }
.status-pill[data-status="danger"] { background: var(--rose-bg); color: var(--rose); }
.status-pill[data-status="muted"]  { background: var(--bg-alt); color: var(--text-muted); }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  font-size: 13px;
  transition: all 0.15s ease;
}
.btn:hover {
  background: var(--bg-alt);
  border-color: var(--text-faint);
}
.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn--primary:hover {
  background: #1E3329;
  border-color: #1E3329;
}
.btn--ghost {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 10px;
}
.btn--ghost:hover { color: var(--text); background: var(--bg-alt); }

/* ============================================================
   Forms
   ============================================================ */

.form-section {
  margin-bottom: var(--space-lg);
}
.form-section h2 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 var(--space) 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
}

.form-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  align-items: center;
  gap: var(--space);
  padding: var(--space-sm) 0;
}
.form-row label {
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 500;
}
.form-row input,
.form-row select,
.form-row textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  width: 100%;
  max-width: 520px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 74, 62, 0.12);
}

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   Detail page
   ============================================================ */

.detail-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space);
  margin-bottom: var(--space-lg);
}
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
}
.detail-card__label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: var(--space-sm);
}
.detail-card__value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.022em;
  font-variant-numeric: tabular-nums;
}
.detail-card__sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
}
.history-table th,
.history-table td {
  padding: 10px var(--space);
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}
.history-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.history-table td.tabular { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ============================================================
   Anexos
   ============================================================ */

.anexo-card {
  padding: var(--space) var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.anexo-card:hover { border-color: var(--text-faint); box-shadow: var(--shadow-sm); }
.anexo-card__title { font-weight: 600; font-size: 14px; }
.anexo-card__meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.upload-panel {
  margin-top: var(--space);
  padding: var(--space-md);
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.upload-panel__title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space);
}

/* ============================================================
   Search bar (list views)
   ============================================================ */

.search-bar {
  position: relative;
  margin-bottom: var(--space-md);
}
.search-bar input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}
.search-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 74, 62, 0.1);
}
.search-bar::before {
  content: "⌕";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
}

/* ============================================================
   Login screen (full-screen, no sidebar)
   ============================================================ */

body.is-login .app-shell > .sidebar,
body.is-login .app-body > .topbar { display: none; }
body.is-login .app-shell { grid-template-columns: 1fr; }
body.is-login .app-main {
  padding: 0;
  max-width: none;
  display: grid;
  place-items: center;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 20%, var(--accent-bg) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, var(--gold-bg) 0%, transparent 40%),
    var(--bg);
}

.login-page {
  width: 100%;
  padding: var(--space-md);
  display: grid;
  place-items: center;
}

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

.login-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 74, 62, 0.12);
}

/* ============================================================
   Renovações row (custom — has action buttons on the right)
   ============================================================ */

.renovacao-row {
  display: flex;
  align-items: center;
  gap: var(--space);
  padding: var(--space) var(--space-md);
  background: var(--surface);
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.12s ease;
}
.renovacao-row:hover { background: var(--bg); }
.renovacao-row:last-child { border-bottom: none; }

.renovacao-row__left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
  cursor: pointer;
  min-width: 0;
}
.renovacao-row__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.list > .renovacao-row {
  border-radius: 0;
}

/* ============================================================
   Support card (Prestadores — contato de emergência em destaque)
   ============================================================ */

.support-card {
  background: linear-gradient(135deg, var(--accent-bg) 0%, var(--surface) 60%);
  border: 1px solid var(--accent-bg-2);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-sm);
}
.support-card__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 var(--space) 0;
}
.support-card__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space);
}
.support-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.support-item__label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.support-item__value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.support-item__link {
  color: var(--accent);
  border-bottom: 1px dotted transparent;
  transition: border-color 0.15s ease;
}
.support-item__link:hover { border-bottom-color: currentColor; }
.support-item--emergency .support-item__value { color: var(--danger); }

/* ============================================================
   Chip filter row (Prestadores por subtipo)
   ============================================================ */

.assinaturas-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--space-md);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chip:hover {
  border-color: var(--text-faint);
  color: var(--text);
}
.chip--active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.chip__count {
  display: inline-flex;
  min-width: 20px;
  padding: 0 6px;
  height: 18px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chip--active .chip__count {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

/* ============================================================
   Summary banner (list views)
   ============================================================ */

.summary-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space);
  margin-bottom: var(--space-md);
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.summary-card__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}
.summary-card__value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.022em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.summary-card__sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}
.summary-card--primary {
  background: linear-gradient(to bottom right, var(--accent), #1E3329);
  color: #fff;
  border-color: var(--accent);
}
.summary-card--primary .summary-card__label,
.summary-card--primary .summary-card__sub {
  color: rgba(255, 255, 255, 0.7);
}
.summary-card--primary::after {
  content: "";
  position: absolute;
  inset: auto -20px -20px auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
}

/* ============================================================
   Category selector (new contract)
   ============================================================ */

.category-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space);
  margin-top: var(--space);
}

.category-card {
  display: flex;
  align-items: center;
  gap: var(--space);
  padding: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
  box-shadow: var(--shadow-sm);
}
.category-card:hover {
  border-color: var(--accent);
  background: var(--accent-bg);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.category-card__icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent-bg);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}
.category-card__icon svg { width: 24px; height: 24px; }
.category-card:hover .category-card__icon {
  background: var(--accent);
  color: #fff;
}
.category-card__title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.012em;
}
.category-card__sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.category-card__chev {
  margin-left: auto;
  color: var(--text-faint);
  transition: color 0.2s ease, transform 0.2s ease;
  flex-shrink: 0;
}
.category-card:hover .category-card__chev {
  color: var(--accent);
  transform: translateX(2px);
}

@media (max-width: 700px) {
  .category-selector { grid-template-columns: 1fr; }
}

/* ============================================================
   Misc
   ============================================================ */

.loading {
  padding: var(--space-xl);
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.error-banner {
  background: var(--rose-bg);
  color: var(--rose);
  padding: var(--space) var(--space-md);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space);
  border-left: 3px solid var(--rose);
  font-size: 13px;
}

.empty-state {
  padding: var(--space-lg);
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: var(--space);
}

/* Page reveal */
.app-main > * {
  animation: pageReveal 0.35s ease both;
}
@keyframes pageReveal {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ==========================================================
   Toast notification region (bottom-right stack)
   ========================================================== */
.toast-region {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 48px));
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e6e6e6);
  border-radius: var(--radius-sm, 8px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text, #111);
  animation: toastIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.toast--leaving {
  animation: toastOut 0.18s ease both;
}
.toast--success { border-left: 3px solid var(--accent, #2D4A3E); }
.toast--success .toast__icon { color: var(--accent, #2D4A3E); }
.toast--error   { border-left: 3px solid var(--danger, #BF5B5B); }
.toast--error   .toast__icon { color: var(--danger, #BF5B5B); }
.toast--info    { border-left: 3px solid var(--blue, #4A6FA5); }
.toast--info    .toast__icon { color: var(--blue, #4A6FA5); }
.toast__icon { flex-shrink: 0; display: inline-flex; }
.toast__msg  { flex: 1; line-height: 1.4; }
.toast__close {
  background: transparent;
  border: none;
  color: var(--text-muted, #7f7f7f);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  margin: -4px -4px -4px 0;
}
.toast__close:hover { color: var(--text, #111); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px); }
}

/* ==========================================================
   Modal overlay + card
   ========================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 22, 0.42);
  backdrop-filter: blur(2px);
  z-index: 9990;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modalOverlayIn 0.18s ease both;
}
.modal-card {
  background: var(--surface, #fff);
  border-radius: var(--radius, 14px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.24);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 48px);
  overflow: auto;
  animation: modalCardIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.modal-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 12px;
  gap: 12px;
}
.modal-card__title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.014em;
  margin: 0;
}
.modal-card__close {
  background: transparent;
  border: none;
  color: var(--text-muted, #7f7f7f);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.modal-card__close:hover { background: var(--bg-alt, #f2f2f2); color: var(--text, #111); }
.modal-card__body {
  padding: 4px 24px 24px;
}
@keyframes modalOverlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modalCardIn {
  from { opacity: 0; transform: scale(0.96) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ==========================================================
   KPI cards como links (mantém visual, adiciona affordance)
   ========================================================== */
a.kpi {
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
a.kpi:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}
a.kpi:focus-visible {
  outline: 2px solid var(--accent, #2D4A3E);
  outline-offset: 2px;
}

/* ==========================================================
   Summary card danger variant (renovações · vencidos)
   ========================================================== */
.summary-card--danger {
  background: linear-gradient(to bottom right, #FEF2F2, #FEE2E2);
  color: var(--danger, #B91C1C);
  border-left: 3px solid var(--danger, #BF5B5B);
}
.summary-card--danger .summary-card__label,
.summary-card--danger .summary-card__value,
.summary-card--danger .summary-card__sub {
  color: inherit;
}
.summary-card--danger .summary-card__value {
  color: #991B1B;
}

/* ==========================================================
   Configurações → Modelos de assinatura
   ========================================================== */
.info-banner {
  background: var(--accent-bg, rgba(45,74,62,0.06));
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 16px;
}
.template-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}
.template-row {
  display: grid;
  grid-template-columns: 20px 1fr 80px;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  transition: background 0.12s ease;
}
.template-row:last-child { border-bottom: none; }
.template-row:hover { background: var(--bg-alt, rgba(0,0,0,0.02)); }
.template-row--on { background: var(--accent-bg, rgba(45,74,62,0.06)); }
.template-row--on:hover { background: var(--accent-bg, rgba(45,74,62,0.1)); }
.template-row__name {
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.template-row__id {
  font-size: 11px;
  color: var(--text-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: right;
}

/* ==========================================================
   Modal de envio pra assinatura (Assina AI)
   ========================================================== */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 12px;
  margin-top: 8px;
  border-top: 1px solid var(--border-soft);
}
.toggle-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.form-section__header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 var(--space) 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
}
.form-section__header-row h2 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.btn--small {
  font-size: 12px;
  padding: 4px 10px;
}
.signatarios-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.signatario-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 10px 14px 14px;
}
.signatario-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.signatario-card__label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.signatario-card--fixo {
  background: var(--accent-bg, rgba(45,74,62,0.06));
  border-left: 3px solid var(--accent);
}
/* Dentro do modal os form-rows ficam mais compactos e limitam label a 130px */
.modal-card .form-row {
  grid-template-columns: 130px 1fr;
  padding: 4px 0;
}
.modal-card .form-row input,
.modal-card .form-row select,
.modal-card .form-row textarea {
  max-width: 100%;
}

/* ==========================================================
   Botão inline "+ Nova pessoa" ao lado do select
   ========================================================== */
.form-row-with-inline-action {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.form-row-with-inline-action > *:first-child { flex: 1; min-width: 0; }
.btn--inline-new {
  flex-shrink: 0;
  white-space: nowrap;
  padding-left: 10px;
  padding-right: 12px;
}

/* ==========================================================
   Legenda de status na lista
   ========================================================== */
.status-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted, #7f7f7f);
  margin-top: -4px;
  margin-bottom: 12px;
  padding-left: 4px;
}
.status-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.status-legend__dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
}

/* ==========================================================
   Refresh + timestamp no dashboard
   ========================================================== */
.page-header__timestamp {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted, #7f7f7f);
  margin-top: 4px;
}
.page-header__refresh {
  background: transparent;
  border: none;
  color: var(--accent, #2D4A3E);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.page-header__refresh:hover { background: var(--accent-bg, #EEF2EE); }

/* ==========================================================
   Focus visible global (WCAG 2.4.7)
   ========================================================== */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent, #2D4A3E);
  outline-offset: 2px;
}
a.list-item:focus-visible,
a.attention-row:focus-visible {
  outline-offset: -2px;
  border-radius: 8px;
}

/* Skip link (acessibilidade) */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 8px 12px;
  background: var(--accent, #2D4A3E);
  color: #fff;
  z-index: 10000;
  border-radius: 0 0 8px 0;
}
.skip-link:focus {
  left: 0;
}

/* ==========================================================
   Lab switcher (topbar) — chip clicável com dropdown
   ========================================================== */
.topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.lab-switcher {
  position: relative;
}
.lab-switcher__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e6e6e6);
  border-radius: 999px;
  padding: 6px 12px 6px 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #111);
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.lab-switcher__btn:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}
.lab-switcher__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.lab-switcher__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0,0,0,0.08);
}
.lab-switcher__label { letter-spacing: -0.006em; }
.lab-switcher__caret { font-size: 10px; color: var(--text-muted, #7f7f7f); margin-left: 2px; }
.lab-switcher__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e6e6e6);
  border-radius: var(--radius-sm, 10px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.12);
  min-width: 240px;
  padding: 4px;
  z-index: 100;
  animation: labMenuIn 0.16s ease both;
}
@keyframes labMenuIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.lab-switcher__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  color: var(--text);
  transition: background 0.12s ease;
}
.lab-switcher__item:hover { background: var(--bg-alt, #f2f2f2); }
.lab-switcher__item--active { background: var(--accent-bg, #eef5ef); }
.lab-switcher__item-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0,0,0,0.08);
}
.lab-switcher__item-text { flex: 1; min-width: 0; }
.lab-switcher__item-name { font-weight: 600; letter-spacing: -0.008em; }
.lab-switcher__item-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.lab-switcher__check {
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  margin-left: 4px;
}

/* Estilo do sidebar__system__title já usa --accent, então troca de cor automática */
body[data-lab="vida"] .sidebar__system-title {
  color: var(--accent);
}

/* Ajuste do system-icon (ícone do doc) quando lab=vida — troca lima → tom
   compatível com bordô. Filtro CSS pra recolorir SVG stroke=#006333 → --accent */
body[data-lab="vida"] .sidebar__system-icon {
  filter: hue-rotate(210deg) saturate(1.6);
}
