/* ============================================================
   Medicli — Design System
   Arquivo: assets/css/main.css
   ============================================================ */

/* ── Genesis Design System — Fonts ── */
@import url('https://api.fontshare.com/v2/css?f[]=general-sans@300,400,500,600,700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Variables ── */
:root {
  /* ── Genesis Colors ── */
  --primary:        #6366f1;
  --primary-light:  #eef2ff;
  --primary-dark:   #4f46e5;
  --secondary:      #20970b;
  --accent:         #6366f1;
  --success:        #10b981;
  --warning:        #f59e0b;
  --danger:         #ef4444;
  --info:           #6366f1;

  --bg:             #f8f9fc;
  /* ── Genesis Surfaces ── */
  --surface:        #ffffff;
  --surface-2:      #fafafa;
  --border:         #e8e8ec;
  --border-strong:  #d1d5db;

  /* ── Genesis Text ── */
  --text-1:         #0a0a0a;
  --text-2:         #6b6b6b;
  --text-3:         #6b6b6b;
  --text-4:         #9c9c9c;

  --sidebar-bg:     #0a0a0a;
  --sidebar-text:   #9c9c9c;
  --sidebar-hover:  #1a1a1a;
  --sidebar-active: rgba(99,102,241,.15);
  --sidebar-w:      260px;

  /* ── Genesis Radius ── */
  --radius-sm:      6px;
  --radius:         8px;
  --radius-lg:      12px;
  --radius-xl:      9999px;

  /* ── Genesis Elevation — flat by default, shadow only on hover ── */
  --shadow-sm:      none;
  --shadow:         0 8px 30px rgba(0,0,0,.08);
  --shadow-lg:      0 12px 40px rgba(0,0,0,.12);
  --shadow-primary: 0 4px 12px rgba(99,102,241,.35);

  /* ── Genesis Typography ── */
  --font-display:   'General Sans', sans-serif;
  --font-sans:      'DM Sans', sans-serif;
  --font-serif:     'General Sans', sans-serif;
  --font-mono:      'JetBrains Mono', monospace;

  --transition:     0.18s ease;
  --topbar-h:       64px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; height: auto; display: block; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-icon {
  width: 42px; height: 42px;
  background: rgba(91,103,248,.2);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 700; font-size: 1rem; color: #fff; letter-spacing: -.3px; }
.brand-tagline { font-size: .7rem; color: var(--sidebar-text); }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-section { margin-bottom: 8px; }
.nav-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(160,174,192,.4);
  padding: 10px 8px 6px;
  display: block;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: .875rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .7; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item:hover svg { opacity: 1; }
.nav-item.active { background: var(--sidebar-active); color: var(--primary); }
.nav-item.active svg { opacity: 1; }

.sidebar-footer { padding: 16px 12px 20px; border-top: 1px solid rgba(255,255,255,.06); }
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.04);
}
.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { display: block; font-size: .8rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; font-size: .7rem; color: var(--sidebar-text); }
.btn-logout {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  color: var(--sidebar-text);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  flex-shrink: 0;
}
.btn-logout svg { width: 16px; height: 16px; }
.btn-logout:hover { color: var(--danger); background: rgba(239,68,68,.1); }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

/* ── Main Content ── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky; top: 0;
  z-index: 50;
}
.btn-menu {
  display: none;
  width: 36px; height: 36px;
  border: none; background: none;
  color: var(--text-2);
  cursor: pointer;
  border-radius: var(--radius-sm);
  align-items: center; justify-content: center;
}
.btn-menu svg { width: 20px; height: 20px; }
.btn-menu:hover { background: var(--surface-2); }
.topbar-title { flex: 1; }
.topbar-title h1 { font-size: 1rem; font-weight: 600; color: var(--text-1); }
.topbar-date { font-size: .8rem; color: var(--text-3); background: var(--surface-2); padding: 4px 10px; border-radius: 20px; }

/* ── Page Content ── */
.page-content { flex: 1; padding: 24px; max-width: 1400px; width: 100%; }

/* ── Flash Messages ── */
.flash-container { padding: 0 24px; padding-top: 16px; }
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  animation: slideDown .25s ease;
}
@keyframes slideDown { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:none; } }
.flash-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.flash-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.card-title { font-size: 1rem; font-weight: 700; color: var(--text-1); }
.card-subtitle { font-size: .8rem; color: var(--text-3); margin-top: 2px; }

/* ── Stat Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--stat-color, var(--primary));
}
.stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  background: var(--stat-bg, var(--primary-light));
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.stat-icon svg { width: 20px; height: 20px; color: var(--stat-color, var(--primary)); }
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--text-1); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: .8rem; color: var(--text-3); font-weight: 500; }
.stat-change { font-size: .75rem; margin-top: 8px; }
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: .875rem; font-weight: 600;
  font-family: var(--font-sans);
  border: none; cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--primary); color: #fff; box-shadow: var(--shadow-primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; transform: translateY(-1px); }
.btn-secondary { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text-1); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; color: #fff; }
.btn-ghost    { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text-1); }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 7px; width: 34px; height: 34px; border-radius: var(--radius-sm); justify-content: center; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

label {
  display: block;
  font-size: .8rem; font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
label .req { color: var(--danger); margin-left: 2px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="number"],
input[type="tel"],
textarea,
select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  font-family: var(--font-sans);
  color: var(--text-1);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  -webkit-appearance: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,103,248,.12);
}
textarea { resize: vertical; min-height: 90px; }
select { cursor: pointer; }

.form-hint { font-size: .75rem; color: var(--text-3); margin-top: 4px; }
.form-error-msg { font-size: .75rem; color: var(--danger); margin-top: 4px; }
.input-error { border-color: var(--danger) !important; }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse;
  font-size: .875rem;
}
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-3);
  border-bottom: 2px solid var(--border);
  background: var(--surface);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child { border-bottom: none; }
td { padding: 12px 14px; color: var(--text-2); vertical-align: middle; }
.td-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem; font-weight: 600;
  white-space: nowrap;
}
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-success { background: #ecfdf5; color: #065f46; }
.badge-danger  { background: #fef2f2; color: #991b1b; }
.badge-warning { background: #fffbeb; color: #92400e; }
.badge-info    { background: #eff6ff; color: #1e40af; }
.badge-gray    { background: var(--surface-2); color: var(--text-3); }
.badge-purple  { background: #f5f3ff; color: #5b21b6; }
.badge-pink    { background: #fdf2f8; color: #9d174d; }

/* ── Page header ── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 16px;
  flex-wrap: wrap;
}
.page-header-text h2 { font-size: 1.35rem; font-weight: 800; color: var(--text-1); }
.page-header-text p  { font-size: .875rem; color: var(--text-3); margin-top: 2px; }
.page-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Modals ── */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%; max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity:0; transform:scale(.95); } to { opacity:1; transform:none; } }
.modal-lg { max-width: 800px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: var(--surface-2);
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-3); font-size: 1.2rem;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--border); color: var(--text-1); }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 24px; padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── Section Tabs ── */
.tabs {
  display: flex; gap: 4px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab-btn {
  padding: 7px 16px;
  border: none; background: none;
  border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 600;
  cursor: pointer; color: var(--text-3);
  transition: all var(--transition);
  white-space: nowrap;
  font-family: var(--font-sans);
}
.tab-btn.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Avatar ── */
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

/* ── Empty State ── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-3);
}
.empty-state svg { width: 56px; height: 56px; opacity: .3; margin: 0 auto 16px; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.empty-state p { font-size: .875rem; }

/* ── Dashboard specific ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ── Agenda Calendar ── */
.agenda-day { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.agenda-day-header {
  background: var(--surface-2); padding: 10px 14px;
  font-size: .8rem; font-weight: 700; color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
.sessao-item {
  padding: 10px 14px;
  border-left: 3px solid var(--item-color, var(--primary));
  background: var(--surface);
  transition: background var(--transition);
  cursor: pointer;
}
.sessao-item:not(:last-child) { border-bottom: 1px solid var(--border); }
.sessao-item:hover { background: var(--surface-2); }
.sessao-hora { font-size: .75rem; font-weight: 700; color: var(--text-3); }
.sessao-paciente { font-size: .875rem; font-weight: 600; color: var(--text-1); margin: 2px 0; }
.sessao-prof { font-size: .75rem; color: var(--text-3); }

/* ── Patient profile ── */
.patient-header {
  display: flex; align-items: center; gap: 20px;
  padding: 24px; background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
}
.patient-avatar {
  width: 72px; height: 72px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary-light), #ddd6fe);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-family: var(--font-serif);
  color: var(--primary);
  flex-shrink: 0;
}
.patient-header-info h2 { font-size: 1.3rem; font-weight: 800; }
.patient-header-info p { font-size: .875rem; color: var(--text-3); }
.patient-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* ── Evolução card ── */
.evolucao-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 14px;
  transition: box-shadow var(--transition);
}
.evolucao-card:hover { box-shadow: var(--shadow); }
.evolucao-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface-2);
  cursor: pointer; gap: 12px;
}
.evolucao-body { padding: 18px; border-top: 1px solid var(--border); }
.evolucao-section { margin-bottom: 16px; }
.evolucao-section:last-child { margin-bottom: 0; }
.evolucao-section h4 { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); margin-bottom: 6px; }
.evolucao-section p { font-size: .875rem; color: var(--text-2); line-height: 1.65; }

/* ── Login page ── */
.login-wrap {
  min-height: 100vh; width: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f1117 0%, #1a1d2e 50%, #0f1117 100%);
  position: relative; overflow: hidden;
}
.login-bg-decor {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
}
.login-bg-decor span {
  position: absolute; border-radius: 50%; opacity: .05;
  background: var(--primary);
  animation: float 8s ease-in-out infinite;
}
.login-bg-decor span:nth-child(1) { width: 400px; height: 400px; top: -100px; right: -100px; animation-delay: 0s; }
.login-bg-decor span:nth-child(2) { width: 250px; height: 250px; bottom: -80px; left: -80px; animation-delay: 3s; }
.login-bg-decor span:nth-child(3) { width: 150px; height: 150px; top: 50%; left: 10%; animation-delay: 5s; background: var(--secondary); }
@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-20px) scale(1.03); }
}
.login-card {
  background: rgba(255,255,255,.03);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-xl);
  padding: 44px 40px;
  width: 100%; max-width: 420px;
  position: relative;
}
.login-brand { text-align: center; margin-bottom: 32px; }
.login-brand-icon {
  width: 64px; height: 64px;
  background: rgba(91,103,248,.2);
  border: 2px solid rgba(91,103,248,.3);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.login-brand-icon svg { width: 34px; height: 34px; }
.login-brand h1 { font-family: 'Satoshi', sans-serif; font-weight: 800; font-size: 2rem; color: #fff; margin-bottom: 4px; }
.login-brand p { color: rgba(255,255,255,.4); font-size: .875rem; }
.login-card label { color: rgba(255,255,255,.6); }
.login-card input {
  background: rgba(255,255,255,.06);
  border-color: rgba(255,255,255,.1);
  color: #fff;
}
.login-card input:focus { border-color: var(--primary); background: rgba(255,255,255,.08); }
.login-card input::placeholder { color: rgba(255,255,255,.25); }
.login-footer { text-align: center; margin-top: 20px; font-size: .8rem; color: rgba(255,255,255,.3); }

/* ── Inadimplência highlight ── */
.row-danger td { background: #fff5f5 !important; }
.row-warning td { background: #fffdf0 !important; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .btn-menu { display: flex; }
  .page-content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .modal { padding: 20px; }
  .login-card { padding: 30px 24px; margin: 20px; }
  .patient-header { flex-direction: column; align-items: flex-start; }
  .page-header { flex-direction: column; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

/* ── Utilities ── */
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger)  !important; }
.text-warning { color: var(--warning) !important; }
.text-muted   { color: var(--text-3)  !important; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.fw-bold      { font-weight: 700; }
.fw-semibold  { font-weight: 600; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.gap-2        { gap: 8px; }
.gap-3        { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.separator { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Print ── */
@media print {
  .sidebar, .topbar, .btn, .page-header-actions { display: none !important; }
  .main-content { margin: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  body { font-size: 12px; }
}

/* ── Topbar notification ── */
.topbar-notif {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  font-size: .8rem; font-weight: 600;
  text-decoration: none;
  position: relative;
  transition: background var(--transition);
}
.topbar-notif:hover { background: #dde0fd; color: var(--primary-dark); }
.notif-badge {
  background: var(--primary); color: #fff;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .68rem; font-weight: 800;
}
.topbar-profile-link { display: flex; align-items: center; text-decoration: none; }
.topbar-profile-link:hover .user-avatar { opacity: .85; }

/* ── Dirty-form guard ── */
.form-dirty-guard { display: none; }

/* ── Global Search overlay ── */
.search-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 300;
  align-items: flex-start; justify-content: center;
  padding-top: 80px;
}
.search-overlay.open { display: flex; }
.search-box {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.search-input-wrap {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.search-input-wrap svg { width: 20px; height: 20px; color: var(--text-3); flex-shrink:0; }
.search-input-wrap input {
  flex: 1; border: none; outline: none;
  font-size: 1rem; font-family: var(--font-sans);
  background: none; color: var(--text-1);
}
.search-results { max-height: 380px; overflow-y: auto; }
.search-result-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px;
  cursor: pointer; transition: background var(--transition);
  text-decoration: none; color: var(--text-1);
}
.search-result-item:hover { background: var(--surface-2); }
.search-result-item .sr-icon {
  width: 36px; height: 36px; border-radius: var(--radius);
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: .75rem; font-weight: 700;
}
.search-result-item .sr-text { flex: 1; min-width: 0; }
.search-result-item .sr-name { font-weight: 600; font-size: .9rem; }
.search-result-item .sr-sub  { font-size: .75rem; color: var(--text-3); margin-top: 1px; }
.search-result-item .sr-type { font-size: .72rem; color: var(--text-4); }
.search-empty { padding: 30px; text-align: center; color: var(--text-3); font-size: .875rem; }
.search-hint { padding: 10px 20px; font-size: .75rem; color: var(--text-4); border-top: 1px solid var(--border); display: flex; gap: 16px; }
.search-hint kbd { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: .7rem; }

/* ── Perfil do usuário ── */
.perfil-avatar-lg {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.75rem; font-weight: 700; color: #fff;
  margin: 0 auto 16px;
}

/* ── Paginação ── */
.pagination {
  display: flex; align-items: center; gap: 4px;
  justify-content: center; margin-top: 20px;
}
.page-item {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 600;
  cursor: pointer; color: var(--text-2);
  text-decoration: none; transition: all var(--transition);
  border: 1px solid var(--border);
}
.page-item:hover { background: var(--surface-2); color: var(--text-1); }
.page-item.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-item.disabled { opacity: .4; cursor: not-allowed; }

/* ================================================================
   MEDICLI — RESPONSIVIDADE COMPLETA (Mobile-first corrections)
   Cobre todos os layouts inline que quebram em telas < 768px
   ================================================================ */

/* ── Topbar: empilha ações em tela muito pequena ── */
@media (max-width: 480px) {
  .topbar { gap: 8px; padding: 0 12px; min-height: 56px; }
  .topbar-actions { gap: 6px; }
  .topbar-notif span:not(.notif-badge) { display: none; } /* esconde texto, mantém ícone */
  .topbar-notif kbd { display: none; }
  .topbar-date { display: none; } /* data some em tela muito pequena */
  .topbar-title h1 { font-size: .875rem; }
}

/* ── Agenda semanal: 7 colunas -> scroll horizontal em mobile ── */
@media (max-width: 768px) {
  .agenda-semanal-grid {
    grid-template-columns: repeat(7, minmax(120px, 1fr)) !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: grid;
  }
  .agenda-semanal-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
  }
}

/* ── Grids de 2 colunas: empilhar em mobile ── */
@media (max-width: 768px) {
  /* Dashboard, Relatorios, Evolucao view, Pacientes view */
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Agenda view (1fr 1fr), Recorrente (1fr 360px, 1fr 300px) */
  [style*="grid-template-columns:1fr 360px"],
  [style*="grid-template-columns:1fr 300px"] {
    grid-template-columns: 1fr !important;
  }

  /* Meu Perfil (280px 1fr), Documentos (380px 1fr) */
  [style*="grid-template-columns: 280px 1fr"],
  [style*="grid-template-columns:380px 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Sticky sidebar de formulário: não fica sticky em mobile */
  [style*="position:sticky"],
  [style*="position: sticky"] {
    position: static !important;
  }

  /* Recorrente: 4 stats em 2x2 */
  [style*="grid-template-columns:1fr 1fr 1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Plano terapêutico: meta editor 4col -> 2col */
  [style*="grid-template-columns:1fr 1fr 1fr auto"],
  [style*="grid-template-columns: 1fr 1fr 1fr auto"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Evolucao view: 4 mini-stats */
  [style*="grid-template-columns:repeat(4, 1fr)"] {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* ── Tabelas: scroll horizontal universal ── */
@media (max-width: 768px) {
  .card > table,
  .card > .table-wrapper > table,
  /* Tabelas diretas sem wrapper */
  table {
    font-size: .8rem;
  }

  /* Força scroll em tabelas que não têm wrapper */
  .card > table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  td, th { padding: 8px 10px; }

  /* Esconde colunas menos importantes em telas pequenas */
  .col-hide-mobile { display: none !important; }

  /* Botões de ação em tabela: ícones apenas */
  .td-actions .btn span { display: none; }
  .td-actions .btn { padding: 6px; width: 30px; height: 30px; }
}

/* ── Page header: botões abaixo do título em mobile ── */
@media (max-width: 640px) {
  .page-header { gap: 12px; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { flex: 1; justify-content: center; }
}

/* ── Filtros de busca: empilhar em mobile ── */
@media (max-width: 640px) {
  .card > form[method="GET"] {
    flex-direction: column !important;
  }
  .card > form[method="GET"] .form-group {
    min-width: 100% !important;
    width: 100%;
  }
  .card > form[method="GET"] button,
  .card > form[method="GET"] a {
    width: 100%;
    justify-content: center;
  }
}

/* ── Tabs: scroll horizontal quando não cabem ── */
@media (max-width: 600px) {
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { white-space: nowrap; flex-shrink: 0; }
}

/* ── Modal: tela cheia em mobile ── */
@media (max-width: 540px) {
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal {
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 92vh;
    max-width: 100% !important;
    padding: 20px 16px;
  }
  .modal-lg { max-width: 100% !important; }
}

/* ── Agenda semanal: forçar scroll horizontal ── */
@media (max-width: 900px) {
  .agenda-semana-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── Cards de paciente: 1 coluna abaixo de 480px ── */
@media (max-width: 480px) {
  /* já coberto pelo stats-grid 1col, mas garante os cards de paciente */
  [style*="minmax(300px, 1fr)"],
  [style*="minmax(320px, 1fr)"],
  [style*="minmax(280px, 1fr)"] {
    grid-template-columns: 1fr !important;
  }
}

/* ── Patient header: avatar + info compactos ── */
@media (max-width: 540px) {
  .patient-header { padding: 16px; gap: 12px; }
  .patient-avatar, [style*="width:72px"][style*="height:72px"] {
    width: 52px !important;
    height: 52px !important;
    font-size: 1.2rem !important;
  }
  .patient-badges { gap: 4px; }
  .badge { font-size: .68rem; padding: 2px 8px; }
}

/* ── Lembretes WhatsApp: layout compacto ── */
@media (max-width: 640px) {
  /* Preview da mensagem some em mobile (economia de espaço) */
  .wa-msg-preview { display: none !important; }

  /* Card de lembrete: empilhar */
  .wa-card-inner {
    flex-direction: column !important;
    gap: 10px !important;
  }
}

/* ── Agendamento recorrente: lista de datas ── */
@media (max-width: 768px) {
  /* Remove sticky do painel de confirmação */
  .recorrente-confirm { position: static !important; }
}

/* ── Formulários: inputs não transbordam ── */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="date"],
  input[type="time"],
  input[type="number"],
  input[type="tel"],
  input[type="month"],
  textarea,
  select {
    font-size: 16px; /* previne zoom automático do iOS */
  }

  /* Selects com min-width fixo */
  select[style*="min-width"],
  input[style*="min-width"] {
    min-width: 0 !important;
    width: 100%;
  }
}

/* ── Botões de ação em cards: reorganizar ── */
@media (max-width: 540px) {
  .card-header { flex-wrap: wrap; gap: 8px; }
  .card-header .btn { font-size: .78rem; padding: 5px 10px; }
}

/* ── Plano terapêutico: meta editor ── */
@media (max-width: 640px) {
  .meta-item [style*="grid-template-columns:1fr 1fr 1fr auto"],
  .meta-item [style*="grid-template-columns: 1fr 1fr 1fr auto"] {
    grid-template-columns: 1fr !important;
  }
  .meta-item { padding: 12px !important; }
}

/* ── Meu perfil: avatar centralizado ── */
@media (max-width: 768px) {
  .perfil-avatar-lg {
    width: 64px !important;
    height: 64px !important;
    font-size: 1.4rem !important;
  }
}

/* ── Stat cards: texto não estoura ── */
@media (max-width: 380px) {
  .stat-value { font-size: 1.4rem; }
  .stat-card { padding: 14px; }
}

/* ── Busca global: tela cheia em mobile ── */
@media (max-width: 600px) {
  .search-overlay { padding: 0; align-items: flex-start; }
  .search-box {
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    max-width: 100%;
  }
  .search-results { max-height: 60vh; }
}

/* ── Financeiro: tabs de navegação ── */
@media (max-width: 600px) {
  .tabs a.tab-btn { font-size: .78rem; padding: 6px 10px; }
}

/* ── PDF reports: nunca responsivos (são para impressão) ── */
/* Os PDFs têm layout fixo propositalmente — não aplicar mobile styles */

/* ── Utilitários extras para mobile ── */
.mobile-only  { display: none; }
.desktop-only { display: block; }

@media (max-width: 768px) {
  .mobile-only  { display: block; }
  .desktop-only { display: none; }
  .mobile-flex  { display: flex !important; }
  .mobile-hide  { display: none !important; }
  .mobile-full  { width: 100% !important; }
  .mobile-center { text-align: center !important; justify-content: center !important; }
}

/* ================================================================
   MEDICLI — RESPONSIVIDADE COMPLETA v2
   ================================================================ */

/* ── Topbar: compactar em mobile ── */
@media (max-width: 480px) {
  .topbar { gap: 8px; padding: 0 12px; }
  .topbar-notif span:not(.notif-badge) { display: none; }
  .topbar-notif kbd { display: none; }
  .topbar-date { display: none; }
  .topbar-title h1 { font-size: .875rem; }
}

/* ── Grids inline de 2 colunas: colapsar em mobile ── */
@media (max-width: 768px) {
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns:1fr 360px"],
  [style*="grid-template-columns:1fr 300px"],
  [style*="grid-template-columns: 280px 1fr"],
  [style*="grid-template-columns:380px 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* 4 colunas → 2 */
  [style*="grid-template-columns:1fr 1fr 1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr 1fr 1fr"],
  [style*="grid-template-columns:repeat(4, 1fr)"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Remove sticky nos formulários laterais */
  [style*="position:sticky"],
  [style*="position: sticky"] { position: static !important; }
}

/* ── Plano terapêutico: campo de meta ── */
@media (max-width: 640px) {
  [style*="grid-template-columns:1fr 1fr 1fr auto"],
  [style*="grid-template-columns: 1fr 1fr 1fr auto"] {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* ── Tabelas: scroll horizontal universal ── */
@media (max-width: 768px) {
  table { font-size: .78rem; }
  td, th { padding: 7px 8px; }
  .col-hide-mobile { display: none !important; }

  /* Força overflow em tabelas soltas sem .table-wrapper */
  .card > table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── Agenda semanal 7 colunas: scroll horizontal ── */
@media (max-width: 900px) {
  .agenda-semana-outer {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px 8px;
  }
  .agenda-semana-outer > [style*="grid-template-columns: repeat(7"] {
    min-width: 700px;
  }
}

/* ── Modal: bottom-sheet em mobile ── */
@media (max-width: 540px) {
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal {
    border-radius: 20px 20px 0 0 !important;
    max-height: 90vh;
    max-width: 100% !important;
    width: 100%;
    padding: 20px 16px 28px;
  }
  .modal-lg { max-width: 100% !important; }
}

/* ── Tabs: scroll horizontal ── */
@media (max-width: 600px) {
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { white-space: nowrap; flex-shrink: 0; font-size: .78rem; }
}

/* ── Page header: botões em coluna ── */
@media (max-width: 640px) {
  .page-header-actions { width: 100%; flex-direction: column; }
  .page-header-actions .btn { width: 100%; justify-content: center; }
}

/* ── Filtros de busca: empilhar ── */
@media (max-width: 640px) {
  form[method="GET"] { flex-direction: column !important; }
  form[method="GET"] .form-group { min-width: 0 !important; width: 100%; margin-bottom: 8px; }
  form[method="GET"] button { width: 100%; }
}

/* ── Inputs: font-size 16px evita zoom no iOS ── */
@media (max-width: 768px) {
  input[type="text"], input[type="email"], input[type="password"],
  input[type="date"], input[type="time"], input[type="number"],
  input[type="tel"], input[type="month"], textarea, select {
    font-size: 16px;
  }
  select[style*="min-width"], input[style*="min-width"] {
    min-width: 0 !important;
    width: 100% !important;
  }
}

/* ── Card header: wrap em mobile ── */
@media (max-width: 540px) {
  .card-header { flex-wrap: wrap; gap: 8px; }
}

/* ── Patient header: compactar avatar ── */
@media (max-width: 480px) {
  .patient-header { padding: 14px; gap: 10px; }
  .badge { font-size: .68rem; padding: 2px 7px; }
}

/* ── Busca global: tela cheia em mobile ── */
@media (max-width: 600px) {
  .search-overlay { padding: 0; align-items: flex-start; }
  .search-box { border-radius: 0 0 16px 16px; max-width: 100%; }
  .search-results { max-height: 55vh; }
  .search-hint { display: none; }
}

/* ── Stat value: não estoura em tela pequena ── */
@media (max-width: 360px) {
  .stat-value { font-size: 1.3rem; }
  .stat-card { padding: 12px; }
  .stat-icon { width: 34px; height: 34px; }
}

/* ── Stats grid: sempre 2 colunas no mínimo, 1 em muito pequeno ── */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr !important; }
}

/* ── Evolução cards: ações no rodapé em mobile ── */
@media (max-width: 600px) {
  .evolucao-header { flex-wrap: wrap; gap: 8px; }
}

/* ── Lembretes WA: esconder preview da msg em mobile ── */
@media (max-width: 640px) {
  .wa-preview-col { display: none !important; }
  .wa-card-inner { flex-wrap: wrap !important; }
}

/* ── Financeiro tabs ── */
@media (max-width: 520px) {
  .tabs a.tab-btn, .tabs button.tab-btn { font-size: .74rem; padding: 5px 9px; }
}

/* ── Login: padding menor em mobile ── */
@media (max-width: 380px) {
  .login-card { padding: 24px 16px; }
  .login-brand h1 { font-size: 1.6rem; }
}

/* ── Sidebar brand: compactar ── */
@media (max-width: 360px) {
  .sidebar-brand { padding: 18px 14px 16px; }
  .brand-name { font-size: .9rem; }
}

/* ── Utilitários mobile ── */
.mobile-only  { display: none !important; }
.desktop-only { display: initial; }
@media (max-width: 768px) {
  .mobile-only  { display: initial !important; }
  .desktop-only { display: none !important; }
  .mobile-full  { width: 100% !important; }
  .mobile-hide  { display: none !important; }
  .mobile-stack { flex-direction: column !important; }
  .mobile-center { text-align: center !important; justify-content: center !important; }
}

/* ── Classes de grid responsivo (usadas nos PHP corrigidos) ── */
@media (max-width: 768px) {
  .responsive-grid-2 { grid-template-columns: 1fr !important; }
  .recorrente-layout { grid-template-columns: 1fr !important; }
  .documentos-grid   { grid-template-columns: 1fr !important; }
  .perfil-grid       { grid-template-columns: 1fr !important; }
  .evolucao-stats-grid { grid-template-columns: 1fr 1fr !important; }
}

@media (max-width: 480px) {
  .evolucao-stats-grid { grid-template-columns: 1fr !important; }
}

/* ================================================================
   MEDICLI — CSS DOS MÓDULOS REESCRITOS (Agenda, Evolução,
   Financeiro, Backup) — Mobile-first
   ================================================================ */

/* ── Agenda: toolbar ── */
.agenda-toolbar { padding: 14px 16px !important; }

.agenda-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.agenda-nav-dates {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}
.agenda-nav-btn { min-width: 34px; justify-content: center; flex-shrink: 0; }
.agenda-date-label {
  font-weight: 700;
  font-size: .9rem;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.agenda-view-toggle {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: var(--radius);
  flex-shrink: 0;
}

.agenda-filters-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.agenda-filter-select {
  flex: 1;
  min-width: 130px;
  max-width: 220px;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .85rem;
  font-family: var(--font-sans);
  background: var(--surface);
}

/* ── Agenda: semana ── */
.agenda-semana-outer {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
  padding: 0 4px 4px;
}
.agenda-semana-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(110px, 1fr));
  gap: 8px;
  min-width: 700px;
}
.agenda-dia-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.agenda-dia-hoje { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(91,103,248,.12); }
.agenda-dia-header {
  padding: 8px 10px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}
.agenda-dia-hoje .agenda-dia-header { background: var(--primary-light); }
.agenda-dia-nome {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-3);
}
.agenda-dia-hoje .agenda-dia-nome { color: var(--primary); }
.agenda-dia-num {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-1);
  line-height: 1;
}
.agenda-dia-hoje .agenda-dia-num { color: var(--primary); }
.agenda-dia-count { font-size: .65rem; color: var(--text-3); }
.agenda-dia-body {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 100px;
}
.agenda-sessao-card {
  display: block;
  padding: 5px 7px;
  border-radius: 5px;
  border-left: 3px solid var(--sc, var(--primary));
  background: color-mix(in srgb, var(--sc, var(--primary)) 12%, transparent);
  text-decoration: none;
  transition: opacity .15s;
}
.agenda-sessao-card:hover { opacity: .85; }
.agenda-sessao-hora {
  display: block;
  font-size: .68rem;
  font-weight: 700;
  color: var(--text-3);
}
.agenda-sessao-pac {
  display: block;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agenda-sessao-status {
  display: block;
  font-size: .67rem;
  color: var(--sc, var(--primary));
}
.agenda-dia-empty {
  display: block;
  text-align: center;
  padding: 8px 6px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  font-size: .72rem;
  color: var(--text-4);
  text-decoration: none;
  margin-top: auto;
}
.agenda-dia-empty:hover { border-color: var(--primary); color: var(--primary); }

/* ── Agenda: lista ── */
.agenda-lista-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}
.agenda-lista-grupo { border-bottom: 1px solid var(--border); }
.agenda-lista-grupo:last-child { border-bottom: none; }
.agenda-lista-data {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: .82rem;
  font-weight: 700;
  flex-wrap: wrap;
}
.agenda-lista-data-hoje { background: var(--primary-light); color: var(--primary); }
.agenda-lista-qtd { margin-left: auto; font-weight: 400; color: var(--text-3); font-size: .75rem; }
.agenda-lista-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  border-left: 3px solid var(--sc, var(--primary));
  transition: background .12s;
}
.agenda-lista-item:last-child { border-bottom: none; }
.agenda-lista-item:hover { background: var(--surface-2); }
.ali-hora {
  width: 56px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.ali-hora strong { font-size: .88rem; }
.ali-hora small  { font-size: .72rem; color: var(--text-3); }
.ali-info { flex: 1; min-width: 0; }
.ali-info strong { display: block; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ali-info small  { display: block; font-size: .75rem; color: var(--text-3); margin-top: 2px; }
.ali-status { flex-shrink: 0; }
.ali-arrow { width: 16px; height: 16px; color: var(--text-4); flex-shrink: 0; }

/* ── Agenda: legenda ── */
.agenda-legenda {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 10px 0 2px;
}
.agenda-legenda-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .75rem;
  color: var(--text-3);
}

/* ── Responsivo: Agenda toolbar ── */
@media (max-width: 640px) {
  .agenda-nav-row { flex-direction: column; align-items: stretch; }
  .agenda-nav-dates { justify-content: space-between; }
  .agenda-date-label { max-width: 140px; font-size: .82rem; }
  .agenda-view-toggle { align-self: flex-end; }
  .agenda-filter-select { max-width: 100%; width: 100%; }
  .agenda-filters-row { flex-direction: column; }
  .agenda-filters-row .btn { width: 100%; justify-content: center; }
}
@media (max-width: 480px) {
  .agenda-lista-item { padding: 10px 12px; gap: 10px; }
  .ali-status { display: none; } /* status some, fica só a cor da borda */
  .ali-arrow { display: none; }
}

/* ── Evoluções ── */
.ev-filtros { padding: 14px 16px !important; }
.ev-filtros-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.ev-filtros-btns { display: flex; gap: 8px; align-items: flex-end; padding-bottom: 0; }

.ev-grupo { margin-bottom: 20px; }
.ev-grupo-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 0 2px;
}
.ev-grupo-data {
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.ev-grupo-count {
  font-size: .72rem;
  color: var(--text-4);
  margin-left: auto;
}
.ev-grupo-header::after {
  content: '';
  display: block;
  flex: 1;
  height: 1px;
  background: var(--border);
  order: -1;
  min-width: 20px;
}
.ev-grupo-data { order: -2; }

.ev-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 8px;
  transition: box-shadow .15s;
}
.ev-card:hover { box-shadow: var(--shadow); }
.ev-num {
  width: 42px;
  height: 42px;
  background: var(--primary-light);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: .85rem;
  color: var(--primary);
  flex-shrink: 0;
}
.ev-info { flex: 1; min-width: 0; }
.ev-paciente { display: block; font-size: .92rem; font-weight: 700; }
.ev-meta    { display: block; font-size: .78rem; color: var(--text-3); margin-top: 2px; }
.ev-preview {
  font-size: .78rem;
  color: var(--text-3);
  margin-top: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 420px;
}
.ev-acoes {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
.ev-btns { display: flex; gap: 6px; }

@media (max-width: 600px) {
  .ev-filtros-form { flex-direction: column; }
  .ev-filtros-form .form-group { min-width: 0 !important; width: 100%; }
  .ev-filtros-btns { flex-direction: row; width: 100%; }
  .ev-filtros-btns .btn { flex: 1; justify-content: center; }
  .ev-card { flex-wrap: wrap; gap: 10px; }
  .ev-acoes { flex-direction: row; align-items: center; width: 100%; justify-content: space-between; }
  .ev-preview { max-width: 100%; }
}
@media (max-width: 400px) {
  .ev-num { width: 36px; height: 36px; font-size: .78rem; }
}

/* ── Financeiro: tabs ── */
.fin-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  flex-wrap: nowrap;
}
.fin-tabs::-webkit-scrollbar { display: none; }
.fin-tab-btn {
  white-space: nowrap;
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-3);
  text-decoration: none;
  transition: all var(--transition);
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font-sans);
}
.fin-tab-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.fin-tab-alerta { color: var(--danger) !important; }
.fin-tab-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

/* Gerar cobranças */
.fin-gerar-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.fin-gerar-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* Planos grid */
.fin-planos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

@media (max-width: 480px) {
  .fin-tab-btn { font-size: .76rem; padding: 6px 10px; }
  .fin-gerar-bar { flex-direction: column; align-items: flex-start; }
  .fin-gerar-form { width: 100%; }
  .fin-gerar-form input[type=month] { flex: 1; }
  .fin-gerar-form .btn { flex: 1; justify-content: center; }
  .fin-planos-grid { grid-template-columns: 1fr; }
}

/* ── Backup ── */
.bkp-info-card { padding: 16px 18px !important; }
.bkp-info-inner {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.bkp-total { text-align: right; flex-shrink: 0; }

.bkp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.bkp-file-card {}
.bkp-file-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.bkp-file-meta {
  display: flex;
  gap: 14px;
  font-size: .75rem;
  color: var(--text-3);
  flex-wrap: wrap;
}

.bkp-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.bkp-stat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius);
}
.bkp-info-footer {
  display: flex;
  gap: 16px;
  font-size: .8rem;
  color: var(--text-3);
  flex-wrap: wrap;
}
.bkp-alerta { display: flex; gap: 12px; }

@media (max-width: 480px) {
  .bkp-info-inner { flex-direction: column; align-items: flex-start; }
  .bkp-total { text-align: left; }
  .bkp-grid { grid-template-columns: 1fr; }
  .bkp-stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 360px) {
  .bkp-stats-grid { grid-template-columns: 1fr; }
}

/* ================================================================
   MEDICLI — TOPBAR CORRIGIDO + BUSCA + CONFIGURAÇÕES
   ================================================================ */

/* ── Topbar: layout limpo ── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  position: sticky; top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 var(--border);
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

/* Botão busca */
.topbar-btn-busca {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text-3);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: .82rem;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}
.topbar-btn-busca svg { width: 14px; height: 14px; flex-shrink: 0; }
.topbar-btn-busca:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.topbar-btn-busca-kbd {
  font-size: .65rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-4);
  font-family: var(--font-mono);
}

/* Badge sessões hoje */
.topbar-notif-sessoes {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition);
}
.topbar-notif-sessoes svg { width: 15px; height: 15px; flex-shrink: 0; }
.topbar-notif-sessoes:hover { background: #dde0fd; }
.topbar-sessoes-texto { /* escondido em mobile */ }

/* Avatar link */
.topbar-avatar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border-radius: 20px;
  text-decoration: none;
  transition: background var(--transition);
}
.topbar-avatar-link:hover { background: var(--surface-2); }
.topbar-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex; align-items: center; justify-content: center;
  font-size: .68rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.topbar-avatar-nome {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}

/* Data */
.topbar-data {
  font-size: .78rem;
  color: var(--text-3);
  padding: 4px 8px;
  background: var(--surface-2);
  border-radius: 20px;
  white-space: nowrap;
}

/* ── Busca: overlay ── */
.search-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 300;
  align-items: flex-start;
  justify-content: center;
  padding-top: 70px;
}
.search-overlay.open { display: flex; animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.search-box {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 580px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  overflow: hidden;
  animation: slideDown .18s ease;
}
@keyframes slideDown { from { opacity:0; transform:translateY(-12px); } to { opacity:1; transform:none; } }

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.search-input-wrap svg { width: 18px; height: 18px; color: var(--text-3); flex-shrink: 0; }
.search-input-wrap input {
  flex: 1;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  font-size: .975rem;
  font-family: var(--font-sans);
  background: none;
  color: var(--text-1);
  padding: 0 !important;
  width: 100%;
}
.search-input-wrap input::placeholder { color: var(--text-4); }

.search-results { max-height: 400px; overflow-y: auto; }

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
  color: var(--text-1);
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover,
.search-result-item.search-active { background: var(--surface-2); }
.search-result-item .sr-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700;
  flex-shrink: 0;
}
.search-result-item .sr-text { flex: 1; min-width: 0; }
.search-result-item .sr-name {
  font-weight: 600;
  font-size: .875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-item .sr-sub {
  font-size: .75rem;
  color: var(--text-3);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-item .sr-badge {
  flex-shrink: 0;
  font-size: .68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

.search-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: .875rem;
}
.search-hint {
  display: flex;
  gap: 16px;
  padding: 9px 18px;
  font-size: .72rem;
  color: var(--text-4);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.search-hint kbd {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: .68rem;
  font-family: var(--font-mono);
}

/* ── Configurações: layout ── */
.cfg-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  align-items: start;
}
.cfg-nav {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.cfg-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text-2);
  font-size: .875rem;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.cfg-nav-item:last-child { border-bottom: none; }
.cfg-nav-item:hover { background: var(--surface-2); }
.cfg-nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}
.cfg-nav-icon { font-size: 1.1rem; flex-shrink: 0; }
.cfg-nav-label { flex: 1; }
.cfg-nav-arrow { width: 14px; height: 14px; flex-shrink: 0; opacity: .4; }
.cfg-nav-item.active .cfg-nav-arrow { opacity: .8; }

/* Preview de identidade */
.cfg-preview-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--sidebar-bg);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
}
.cfg-logo-preview {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 800;
  flex-shrink: 0;
}
.cfg-nome-preview { font-size: 1rem; font-weight: 700; color: #fff; }
.cfg-sub-preview  { font-size: .72rem; color: rgba(255,255,255,.4); margin-top: 2px; }

/* Preview de aparência */
.cfg-color-preview {
  display: flex;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 24px;
  height: 140px;
}
.cpv-sidebar {
  width: 110px;
  flex-shrink: 0;
  background: #0f1117;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background .3s;
}
.cpv-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 4px 8px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 4px;
}
.cpv-logo {
  width: 22px; height: 22px;
  border-radius: 5px;
  background: rgba(91,103,248,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: .65rem; font-weight: 800;
  color: var(--primary);
  flex-shrink: 0;
}
.cpv-brand span { font-size: .65rem; font-weight: 700; color: #fff; }
.cpv-items { display: flex; flex-direction: column; gap: 2px; }
.cpv-item {
  padding: 5px 6px;
  border-radius: 4px;
  font-size: .6rem;
  font-weight: 500;
  color: rgba(255,255,255,.5);
  cursor: default;
}
.cpv-item.cpv-active {
  font-weight: 700;
  transition: background .3s, color .3s;
}
.cpv-main {
  flex: 1;
  background: var(--surface);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cpv-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.cpv-topbar-title { font-size: .7rem; font-weight: 700; color: var(--text-1); }
.cpv-btn {
  font-size: .6rem;
  font-weight: 700;
  color: #fff;
  padding: 3px 8px;
  border-radius: 5px;
  transition: background .3s;
}
.cpv-stat {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 8px;
  border: 2px solid var(--primary);
  background: var(--primary-light);
  transition: border-color .3s;
}

/* Grade de cores */
.cfg-cores-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.cfg-cor-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}
.cfg-cor-swatch {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  border: 2px solid rgba(0,0,0,.1);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.1);
  transition: background .2s;
}

/* Presets de cor */
.cfg-presets { display: flex; gap: 10px; flex-wrap: wrap; }
.cfg-preset-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
  font-family: var(--font-sans);
}
.cfg-preset-btn:hover { border-color: var(--primary); transform: translateY(-1px); }
.cfg-preset-btn span {
  width: 18px; height: 18px;
  border-radius: 50%;
  display: inline-block;
}
.cfg-preset-btn small { font-size: .68rem; color: var(--text-3); font-weight: 600; }

/* Toggle label */
.cfg-toggle-label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  font-weight: 400;
}
.cfg-toggle-label:hover { background: var(--border); }
.cfg-toggle-label input[type=checkbox] {
  width: 18px !important;
  height: 18px !important;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.cfg-toggle-info { display: flex; flex-direction: column; }
.cfg-toggle-info span { font-size: .875rem; font-weight: 600; color: var(--text-1); }
.cfg-toggle-info small { font-size: .75rem; color: var(--text-3); margin-top: 1px; }

/* ── Responsivo: Topbar ── */
@media (max-width: 900px) {
  .topbar-btn-busca-kbd { display: none; }
  .topbar-avatar-nome { display: none; }
}
@media (max-width: 768px) {
  .topbar { padding: 0 14px; gap: 8px; }
  .topbar-btn-busca-texto { display: none; }
  .topbar-btn-busca { padding: 7px; border-radius: 8px; }
  .topbar-btn-busca svg { width: 17px; height: 17px; }
  .topbar-sessoes-texto { display: none; }
  .topbar-data { display: none; }
  .topbar-notif-sessoes { padding: 5px 7px; }
}
@media (max-width: 480px) {
  .topbar-actions { gap: 4px; }
}

/* ── Responsivo: Busca ── */
@media (max-width: 640px) {
  .search-overlay { padding: 0; align-items: flex-start; }
  .search-box {
    border-radius: 0 0 14px 14px;
    max-width: 100%;
    box-shadow: 0 8px 30px rgba(0,0,0,.25);
  }
  .search-results { max-height: 55vh; }
  .search-hint { display: none; }
}

/* ── Responsivo: Configurações ── */
@media (max-width: 900px) {
  .cfg-layout { grid-template-columns: 1fr; gap: 14px; }
  .cfg-nav { display: flex; flex-wrap: nowrap; overflow-x: auto; border-radius: var(--radius-lg); scrollbar-width: none; }
  .cfg-nav::-webkit-scrollbar { display: none; }
  .cfg-nav-item { border-bottom: none; border-right: 1px solid var(--border); flex-direction: column; gap: 4px; padding: 10px 14px; min-width: 80px; text-align: center; font-size: .78rem; }
  .cfg-nav-item:last-child { border-right: none; }
  .cfg-nav-label { font-size: .72rem; white-space: nowrap; }
  .cfg-nav-arrow { display: none; }
  .cfg-cores-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .cfg-color-preview { height: 120px; }
  .cpv-sidebar { width: 90px; }
  .cfg-presets { gap: 6px; }
  .cfg-preset-btn { padding: 6px 8px; }
  .cfg-preset-btn span { width: 14px; height: 14px; }
}

/* ================================================================
   TABELAS: alinhamento de valores monetários e numéricos
   Colunas de valor sempre à direita, com fonte tabular (tnum)
   ================================================================ */

/* Classe utilitária aplicada nos <th> e <td> de valor */
.col-valor, .col-num {
  text-align: right !important;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  white-space: nowrap;
}
.col-valor strong, .col-num strong {
  font-variant-numeric: tabular-nums;
}

/* Classe para colunas de status/ação centradas */
.col-center { text-align: center !important; }

/* Tabela financeira: garantir bordas e padding consistentes */
.doc-table .col-valor,
table .col-valor {
  padding-right: 16px;
}
table .col-valor:last-child,
.doc-table .col-valor:last-child {
  padding-right: 12px;
}

/* Totalizador de tabela (linha de soma) */
.table-total td {
  background: var(--surface-2);
  font-weight: 700;
  border-top: 2px solid var(--border) !important;
}
.table-total .col-valor {
  color: var(--primary);
}

/* ── Ícones SVG globais ── */
.ic { display:inline-block; vertical-align:middle; }
svg.ic { flex-shrink:0; }

/* Módulos na landing */
.module-icon svg { display:block; }

/* Ícones nos botões */
.btn svg.ic { margin-top:-1px; }

/* Sidebar nav */
.nav-item svg.ic { opacity:.7; transition:opacity .15s; }
.nav-item:hover svg.ic,
.nav-item.active svg.ic { opacity:1; }

/* CFG nav */
.cfg-nav-icon svg.ic { display:block; }

/* ================================================================
   DOCUMENTOS — Cards de seleção de tipo
   ================================================================ */
.doc-tipos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.doc-tipo-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 16px 18px 18px;
  text-decoration: none;
  color: inherit;
  transition: border-color .18s, box-shadow .18s, transform .18s;
  position: relative;
  overflow: hidden;
}
.doc-tipo-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
  opacity: 0;
  transition: opacity .18s;
}
.doc-tipo-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 18px rgba(91,103,248,.12);
  transform: translateY(-2px);
}
.doc-tipo-card:hover::before { opacity: 1; }

.doc-tipo-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.doc-tipo-icon svg {
  width: 24px; height: 24px;
}

.doc-tipo-body { flex: 1; min-width: 0; }
.doc-tipo-titulo {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-tipo-desc {
  font-size: .78rem;
  color: var(--text-3);
  line-height: 1.4;
}

.doc-tipo-arrow {
  width: 20px; height: 20px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity .18s, transform .18s;
}
.doc-tipo-arrow svg { width: 20px; height: 20px; }
.doc-tipo-card:hover .doc-tipo-arrow {
  opacity: 1;
  transform: translateX(3px);
}

/* Responsivo */
@media (max-width: 600px) {
  .doc-tipos-grid { grid-template-columns: 1fr; }
  .doc-tipo-titulo { white-space: normal; }
  .doc-tipo-arrow { opacity: .4; }
}

/* ================================================================
   GENESIS DESIGN SYSTEM — Refinamentos Visuais
   ================================================================ */

/* ── Tipografia: General Sans para headings ── */
.page-header h2,
.card-title,
.section-title,
.modal-title,
.login-brand h1,
.brand-name {
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}

/* ── Flat cards com hover lift ── */
.card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
/* Não levantar cards que são containers estáticos */
.card.no-hover:hover,
.login-card:hover,
.modal:hover {
  box-shadow: none;
  transform: none;
}

/* ── Botões: tamanhos Genesis ── */
.btn-sm  { height: 32px; padding: 0 12px; font-size: 13px; }
.btn     { height: 38px; padding: 0 16px; font-size: 14px; }
.btn-lg  { height: 44px; padding: 0 24px; font-size: 15px; }
.btn     { border-radius: 6px; font-weight: 500; }

/* Hover lift universal em botões */
.btn:hover { transform: translateY(-1px); }

/* ── Inputs: Genesis spec ── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="number"],
input[type="tel"],
input[type="month"],
input[type="url"],
textarea,
select {
  border-radius: 6px !important;
  border: 1px solid var(--border) !important;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-sans);
  background: var(--surface);
  color: var(--text-1);
  transition: border-color 150ms, box-shadow 150ms;
  outline: none;
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(99,102,241,.12) !important;
}

/* ── Badges: Genesis pill ── */
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #ecfdf5; color: #065f46; }
.badge-warning { background: #fffbeb; color: #92400e; }
.badge-danger  { background: #fef2f2; color: #991b1b; }
.badge-gray    { background: #f3f4f6; color: #6b7280; }
.badge-info    { background: #eff6ff; color: #1e40af; }

/* ── Nav/Sidebar refinamentos Genesis ── */
.sidebar { border-right: 1px solid rgba(255,255,255,.06); }
.nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: rgba(255,255,255,.25);
  padding: 14px 16px 6px;
}
.nav-item {
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  margin: 1px 8px;
}

/* ── Topbar: backdrop-blur Genesis ── */
.topbar {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(255,255,255,.85) !important;
}

/* ── Navegação topbar: Genesis link style ── */
.topbar-btn-busca {
  border-radius: 6px;
}
.topbar-btn-busca:hover {
  background: #f5f5f5 !important;
  color: var(--text-1) !important;
  border-color: var(--border) !important;
}

/* ── Tables: Genesis list-style ── */
table th {
  font-family: var(--font-sans);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--text-3);
  background: #fafafa;
}
table td {
  font-size: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: #fafafa; }

/* ── Page header ── */
.page-header h2 { font-size: 24px; font-weight: 700; }

/* ── Empty state: Genesis style ── */
.empty-state svg { color: #e8e8ec; }
.empty-state h3  { font-family: var(--font-display); letter-spacing: -0.02em; }

/* ── Flash mensagens: Genesis borders ── */
.flash {
  border-radius: 8px;
  border-width: 1px;
  border-style: solid;
  font-size: 14px;
}
.flash-success { border-color: #a7f3d0; background: #ecfdf5; color: #065f46; }
.flash-error   { border-color: #fca5a5; background: #fef2f2; color: #991b1b; }
.flash-warning { border-color: #fcd34d; background: #fffbeb; color: #92400e; }
.flash-info    { border-color: #93c5fd; background: #eff6ff; color: #1e40af; }

/* ── Modal: Genesis style ── */
.modal {
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.12);
}
.modal-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}
.modal-footer {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

/* ── Monospace: JetBrains Mono ── */
code, pre, kbd, .font-mono,
input[type="url"],
.api-key, .url-field {
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ── Spacing: 4px grid ── */
.section { padding: 64px 0; }
@media (max-width: 768px) { .section { padding: 32px 0; } }

/* ── Stat cards: Genesis flat ── */
.stat-card {
  box-shadow: none;
  border: 1px solid var(--border);
}
.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

/* ── Container: 1280px max ── */
.main-content {
  max-width: 1280px;
}

/* ── Cor dos links ── */
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* ── Body background Genesis ── */
body { background: #fafafa; }
