:root {
  --brand-50: #eafaf3;
  --brand-100: #cdf2e0;
  --brand-500: #16a06a;
  --brand-600: #0f8a5f;
  --brand-700: #0c6e4c;
  --brand-800: #0a5a3f;
  --ink-900: #10241c;
  --ink-600: #4b5f57;
  --surface: #ffffff;
  --surface-muted: #f4faf7;
  --border: #dcece4;
  --danger: #c0392b;
  --shadow: 0 2px 10px rgba(10, 90, 63, 0.08);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  background: var(--surface-muted);
  color: var(--ink-900);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

/* ---------- Tela de login ---------- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--brand-700) 0%, var(--brand-500) 45%, var(--brand-100) 100%);
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: 0 20px 45px rgba(10, 60, 40, 0.25);
  padding: 2.5rem 2.25rem;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1.75rem;
}

.login-brand .login-logo {
  max-width: 220px;
  max-height: 80px;
  object-fit: contain;
}

.login-brand .icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--brand-50);
  color: var(--brand-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}

.login-brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--brand-800);
  margin: 0;
}

.login-brand p {
  font-size: .85rem;
  color: var(--ink-600);
  margin: 0;
}

.btn-brand {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: #fff;
}
.btn-brand:hover, .btn-brand:focus {
  background: var(--brand-700);
  border-color: var(--brand-700);
  color: #fff;
}

.form-control:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 .2rem rgba(22, 160, 106, .18);
}

/* ---------- Shell principal (pos-login) ---------- */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--brand-800);
  color: #eafaf3;
  display: flex;
  flex-direction: column;
  transition: width .15s ease;
}
.sidebar.collapsed { width: 68px; }
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-module-title { display: none; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.12);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-brand .icon {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--brand-500);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand strong { font-size: .95rem; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .5rem; }

.sidebar-module-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  background: transparent;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: rgba(234,250,243,.55);
  padding: .9rem .6rem .3rem;
  cursor: pointer;
}
.sidebar-module-title:hover { color: rgba(234,250,243,.85); }
.sidebar-module-title .toggle-icon { font-size: .7rem; transition: transform .15s ease; }
.sidebar-module.collapsed .sidebar-module-title .toggle-icon { transform: rotate(-90deg); }
.sidebar-module.collapsed .sidebar-module-items { display: none; }

.menu-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem .6rem;
  border-radius: 8px;
  color: #eafaf3;
  text-decoration: none;
  font-size: .875rem;
  white-space: nowrap;
  overflow: hidden;
}
.menu-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.menu-link.active { background: var(--brand-500); color: #fff; }
.menu-link i { font-size: 1rem; width: 1.1rem; text-align: center; flex-shrink: 0; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  box-shadow: var(--shadow);
}

.topbar-logo { height: 30px; max-width: 130px; object-fit: contain; }

.topbar .user-chip {
  display: flex; align-items: center; gap: .55rem;
  font-size: .85rem;
}
.topbar .user-chip .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-50); color: var(--brand-700);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem;
}
.topbar .badge-perfil {
  background: var(--brand-50); color: var(--brand-700);
  font-weight: 600; font-size: .68rem;
}

.tabs-strip {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  padding: 0 .5rem;
}
.tabs-strip:empty { display: none; }

.tab-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .55rem .8rem;
  font-size: .82rem;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  color: var(--ink-600);
}
.tab-item.active {
  color: var(--brand-700);
  border-bottom-color: var(--brand-600);
  font-weight: 600;
}
.tab-item .close-tab {
  border: none; background: none; color: inherit; opacity: .55;
  line-height: 1; font-size: .95rem; padding: 0 .1rem;
}
.tab-item .close-tab:hover { opacity: 1; color: var(--danger); }

.tab-panes { flex: 1; overflow: auto; padding: 1.25rem; }
.tab-pane-content { display: none; }
.tab-pane-content.active { display: block; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; color: var(--ink-600); text-align: center; gap: .5rem;
}
.empty-state .icon { font-size: 2.4rem; color: var(--brand-200, #a9e0c8); }

.chart-wrapper { max-width: 700px; overflow-x: auto; }
.chart-wrapper svg { width: 100%; height: auto; min-width: 560px; }
.chart-axis-line { stroke: var(--border); stroke-width: 1; }
.chart-bar { fill: var(--brand-500); }
.chart-value-label { font-size: 11px; fill: var(--ink-600); }
.chart-date-label { font-size: 9px; fill: var(--ink-600); }

.chart-wrapper-canvas { position: relative; height: 460px; max-width: 100%; }

.config-logo-preview {
  display: block;
  max-width: 100%;
  max-height: 90px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .5rem;
  background: var(--surface-muted);
}

.paciente-foto-preview {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-muted);
}

.app-footer {
  flex-shrink: 0;
  padding: .5rem 1.25rem;
  font-size: .75rem;
  color: var(--ink-600);
  text-align: center;
  border-top: 1px solid var(--line-200, #e2ece7);
  background: #fff;
}

/* ---------- Cartões / telas de entidade ---------- */
.page-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.page-card .page-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.page-card .page-card-header h2 {
  font-size: 1.05rem; font-weight: 700; margin: 0; color: var(--brand-800);
}
.page-card .page-card-body { padding: 1.1rem 1.25rem; }

table.table-app thead th {
  background: var(--surface-muted);
  color: var(--brand-800);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 2px solid var(--border);
}
table.table-app td, table.table-app th { vertical-align: middle; }
table.table-app tbody tr:hover { background: var(--brand-50); }

.badge-status-ativo { background: var(--brand-50); color: var(--brand-700); }
