/* =============================================
   HealthERP – Sistema de Gestão para Clínicas
   style.css – Versão 1.0
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@500;600&family=IBM+Plex+Sans:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@600;700;800&display=swap');

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

:root {
  --primary:        #0099BB;
  --primary-dark:   #006F8A;
  --primary-light:  #E6F7FB;
  --secondary:      #0D1F3C;
  --success:        #006F8A;
  --success-light:  #E6F7FB;
  --warning:        #8A5A00;
  --warning-light:  #FFF7E6;
  --danger:         #B42318;
  --danger-light:   #FFF1F0;
  --purple:         #0D1F3C;
  --purple-light:   #EEF3F7;
  --teal:           #0099BB;
  --teal-light:     #E6F7FB;

  --bg:             #F8FAFC;
  --surface:        #FFFFFF;
  --surface-2:      #F8FAFC;
  --border:         #E2E8F0;
  --border-light:   #F1F5F9;

  --text-primary:   #1E293B;
  --text-secondary: #64748B;
  --text-muted:     #8DA8BE;
  --text-white:     #FFFFFF;
  --navy:           #071827;
  --midnight:       #0D1F3C;

  --sidebar-w:      244px;
  --topbar-h:       68px;

  --shadow-xs:  0 1px 2px rgba(7,24,39,.04);
  --shadow-sm:  0 8px 20px rgba(7,24,39,.06);
  --shadow-md:  0 14px 34px rgba(7,24,39,.08);
  --shadow-lg:  0 22px 58px rgba(7,24,39,.10);

  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  12px;
  --radius-xl:  20px;
  --radius-full:50px;

  --font-heading: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --transition: .18s ease;
}

html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
ul { list-style: none; }
button, input, select, textarea { font-family: var(--font); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* =============================================
   LOGIN PAGE
   ============================================= */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #F8FAFC 0%, #E6F7FB 50%, #FFFFFF 100%);
  position: relative;
  overflow: hidden;
}

.login-body::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(0,153,187,.08) 0%, transparent 70%);
  top: -200px; right: -100px;
  border-radius: 50%;
}

.login-body::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(0,111,138,.06) 0%, transparent 70%);
  bottom: -100px; left: -100px;
  border-radius: 50%;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 48px 44px;
  width: 420px;
  max-width: 95vw;
  position: relative;
  z-index: 1;
  border: 1px solid rgba(255,255,255,.8);
}

.login-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 36px;
}

.login-logo-img {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0,111,138,.24);
}

.login-logo-img svg { width: 30px; height: 30px; fill: #fff; }

.login-logo-wrap h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.5px;
}

.login-logo-wrap span {
  font-size: .82rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.login-card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.login-card p { font-size: .85rem; color: var(--text-secondary); margin-bottom: 28px; }

.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 7px;
}
.form-group input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: .9rem;
  color: var(--text-primary);
  background: var(--surface-2);
  transition: var(--transition);
  outline: none;
}
.form-group input:focus {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(0,153,187,.12);
}

.btn-login {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 16px rgba(0,111,138,.24);
  margin-top: 8px;
  letter-spacing: .2px;
}
.btn-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0,111,138,.28);
}

.login-footer {
  margin-top: 28px;
  text-align: center;
  font-size: .78rem;
  color: var(--text-muted);
}

/* =============================================
   APP LAYOUT
   ============================================= */
.app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: var(--transition);
  box-shadow: var(--shadow-xs);
}

.sidebar-brand {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-light);
  min-height: var(--topbar-h);
}

.brand-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,111,138,.20);
}
.brand-icon img { width: 20px; height: 20px; }
.brand-icon svg { width: 20px; height: 20px; fill: #fff; }

.brand-text h2 {
  font-size: .92rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -.3px;
}
.brand-text span {
  font-size: .72rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
}

.nav-section {
  margin-bottom: 4px;
}
.nav-section-label {
  font-size: .66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  padding: 10px 12px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: .87rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 1px;
  position: relative;
}
.nav-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.nav-item.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,111,138,.20);
}
.nav-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  opacity: .8;
}
.nav-item.active .nav-icon { opacity: 1; }
.nav-icon img { width: 18px; height: 18px; }
.nav-icon svg { width: 18px; height: 18px; }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,.3); }

.sidebar-footer {
  border-top: 1px solid var(--border-light);
  padding: 12px 10px;
}

.sidebar-toggle {
  display: none;
  width: 100%;
  padding: 9px 12px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: .87rem;
  font-weight: 500;
  cursor: pointer;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-md);
  transition: var(--transition);
}
.sidebar-toggle:hover { background: var(--bg); }

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

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 90;
  gap: 16px;
}

.topbar-breadcrumb {
  flex: 1;
}
.topbar-breadcrumb h3 {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}
.topbar-breadcrumb span {
  font-size: .75rem;
  color: var(--text-muted);
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.topbar-btn {
  width: 36px; height: 36px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  color: var(--text-secondary);
}
.topbar-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.topbar-btn svg { width: 17px; height: 17px; }

.notif-dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 7px; height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 1.5px solid var(--surface);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px 5px 5px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
}
.topbar-user:hover { background: var(--surface-2); border-color: var(--border); }

.user-avatar {
  width: 34px; height: 34px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-info { line-height: 1.2; }
.user-info strong { font-size: .82rem; font-weight: 600; display: block; color: var(--text-primary); }
.user-info span { font-size: .72rem; color: var(--text-muted); }

/* ── Page Content ── */
.page-content {
  flex: 1;
  padding: 28px;
  overflow-x: hidden;
}

.page-header {
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.4px;
  line-height: 1.2;
}
.page-header p {
  font-size: .85rem;
  color: var(--text-secondary);
  margin-top: 3px;
}

/* =============================================
   COMPONENTS
   ============================================= */

/* ── Cards ── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.card-header {
  padding: 18px 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: .92rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -.2px;
}
.card-body { padding: 18px 20px; }
.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--surface-2);
}

/* ── Stat Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow-xs);
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.blue   { background: var(--primary-light); color: var(--primary); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: var(--warning-light); color: var(--warning); }
.stat-icon.purple { background: var(--purple-light);  color: var(--purple); }
.stat-icon.teal   { background: var(--teal-light);    color: var(--teal); }
.stat-icon.red    { background: var(--danger-light);  color: var(--danger); }

.stat-info { flex: 1; min-width: 0; }
.stat-label {
  font-size: .76rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 4px;
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.5px;
  line-height: 1.1;
}
.stat-delta {
  font-size: .76rem;
  font-weight: 600;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 3px;
}
.stat-delta.up   { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ── Grid Layouts ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-65-35 { display: grid; grid-template-columns: 65fr 35fr; gap: 16px; }
.grid-60-40 { display: grid; grid-template-columns: 60fr 40fr; gap: 16px; }

/* ── Chart Area ── */
.chart-area {
  position: relative;
  height: 180px;
  margin: 10px 0 4px;
}

.chart-svg { width: 100%; height: 100%; overflow: visible; }

/* ── Bar Chart ── */
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding: 0 4px; }
.bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bar {
  width: 100%;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 4px 4px 0 0;
  transition: opacity .2s;
}
.bar:hover { opacity: .8; }
.bar-label { font-size: .7rem; color: var(--text-muted); font-weight: 500; }

/* ── Donut Chart ── */
.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.donut-svg { width: 140px; height: 140px; }

.donut-legend { width: 100%; }
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: .82rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
}
.legend-item:last-child { border-bottom: none; }
.legend-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-name { flex: 1; }
.legend-pct { font-weight: 600; color: var(--text-primary); font-size: .82rem; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
thead th {
  padding: 11px 14px;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success  { background: var(--success-light);  color: var(--success); }
.badge-warning  { background: var(--warning-light);  color: var(--warning); }
.badge-danger   { background: var(--danger-light);   color: var(--danger); }
.badge-primary  { background: var(--primary-light);  color: var(--primary); }
.badge-purple   { background: var(--purple-light);   color: var(--purple); }
.badge-gray     { background: var(--border);         color: var(--text-secondary); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,111,138,.16);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(0,111,138,.20); }
.btn-outline {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #055D73; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover { background: #8F1D14; }
.btn-sm { padding: 5px 12px; font-size: .78rem; }
.btn-xs { padding: 3px 9px;  font-size: .72rem; }

/* ── Form Elements ── */
.form-row { display: grid; gap: 16px; margin-bottom: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.field label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 6px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: .87rem;
  color: var(--text-primary);
  background: var(--surface);
  transition: var(--transition);
  outline: none;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,153,187,.10);
}
.field textarea { resize: vertical; min-height: 90px; }

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  transition: var(--transition);
}
.search-bar:focus-within { border-color: var(--primary); background: var(--surface); }
.search-bar svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.search-bar input {
  border: none;
  background: none;
  outline: none;
  font-size: .87rem;
  color: var(--text-primary);
  flex: 1;
}

/* ── Action Row ── */
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.action-row-left  { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.action-row-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── Avatar ── */
.avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 26px; height: 26px; font-size: .64rem; }
.avatar.lg { width: 48px; height: 48px; font-size: 1rem; border-radius: var(--radius-lg); }
.avatar.xl { width: 72px; height: 72px; font-size: 1.4rem; border-radius: var(--radius-lg); }

.avatar.green  { background: var(--primary-dark); }
.avatar.orange { background: var(--warning); }
.avatar.purple { background: var(--midnight); }
.avatar.teal   { background: var(--primary); }
.avatar.red    { background: var(--danger); }

/* ── Timeline ── */
.timeline { padding: 4px 0; }
.timeline-item {
  display: flex;
  gap: 12px;
  padding-bottom: 20px;
  position: relative;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 30px;
  bottom: 0;
  width: 1.5px;
  background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--primary-light);
  border: 2px solid var(--primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}
.timeline-dot svg { width: 13px; height: 13px; color: var(--primary); }
.timeline-content { flex: 1; }
.timeline-date { font-size: .72rem; color: var(--text-muted); font-weight: 500; }
.timeline-title { font-size: .87rem; font-weight: 600; color: var(--text-primary); margin: 2px 0; }
.timeline-desc { font-size: .8rem; color: var(--text-secondary); }

/* ── Agenda Grid ── */
.agenda-grid {
  display: grid;
  grid-template-columns: 80px repeat(5, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.ag-header {
  background: var(--surface-2);
  padding: 12px;
  text-align: center;
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.ag-header:last-child { border-right: none; }
.ag-time {
  padding: 12px 10px;
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-align: center;
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid var(--border);
  background: var(--surface-2);
  font-family: var(--font-mono);
}
.ag-cell {
  padding: 4px;
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid var(--border);
  min-height: 52px;
  position: relative;
}
.ag-cell:last-child { border-right: none; }
.ag-appt {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  padding: 5px 8px;
  font-size: .72rem;
  color: var(--primary-dark);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1.3;
}
.ag-appt:hover { background: var(--primary); color: #fff; }
.ag-appt.green { background: var(--success-light); border-color: var(--success); color: #1B5E20; }
.ag-appt.green:hover { background: var(--success); color: #fff; }
.ag-appt.orange { background: var(--warning-light); border-color: var(--warning); color: var(--warning); }
.ag-appt strong { display: block; font-size: .72rem; }

/* ── Financeiro ── */
.fin-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px;
  width: fit-content;
  margin-bottom: 20px;
}
.fin-tab {
  padding: 7px 18px;
  border-radius: var(--radius-sm);
  font-size: .83rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: none;
}
.fin-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ── Progress Bar ── */
.progress-bar {
  height: 7px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  transition: width .4s ease;
}
.progress-fill.green  { background: var(--primary-dark); }
.progress-fill.orange { background: var(--warning); }
.progress-fill.red    { background: var(--danger); }

/* ── Estoque alert ── */
.stock-low td { color: var(--danger) !important; }
.stock-low td:first-child { font-weight: 600; }

/* ── Telemedicina ── */
.tele-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  height: calc(100vh - 180px);
  min-height: 500px;
}
.tele-video {
  background: #0D1117;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: 1px solid #2D3748;
}
.tele-video-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 40%, #1a2744 0%, #0D1117 70%);
}
.tele-avatar-big {
  width: 90px; height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem;
  color: #fff;
  font-weight: 700;
  position: relative;
  z-index: 1;
  box-shadow: 0 0 0 10px rgba(0,153,187,.15), 0 0 0 20px rgba(0,153,187,.07);
}
.tele-status {
  position: relative;
  z-index: 1;
  color: rgba(255,255,255,.6);
  font-size: .82rem;
  margin-top: 14px;
}
.tele-controls {
  position: absolute;
  bottom: 20px;
  display: flex;
  gap: 12px;
  z-index: 2;
}
.tele-btn {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.tele-btn svg { width: 20px; height: 20px; }
.tele-btn.mic  { background: rgba(255,255,255,.15); color: #fff; }
.tele-btn.cam  { background: rgba(255,255,255,.15); color: #fff; }
.tele-btn.end  { background: var(--danger); color: #fff; }
.tele-btn.start{ background: var(--success); color: #fff; }
.tele-btn:hover { transform: scale(1.08); }

.tele-chat {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}
.tele-chat-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: .9rem;
  background: var(--surface-2);
}
.tele-chat-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-msg { max-width: 85%; }
.chat-msg.sent { align-self: flex-end; }
.chat-bubble {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: .82rem;
  line-height: 1.4;
}
.chat-msg.recv .chat-bubble {
  background: var(--surface-2);
  border-bottom-left-radius: 4px;
  color: var(--text-primary);
}
.chat-msg.sent .chat-bubble {
  background: var(--primary);
  border-bottom-right-radius: 4px;
  color: #fff;
}
.chat-time { font-size: .68rem; color: var(--text-muted); margin-top: 3px; padding: 0 3px; }
.chat-msg.sent .chat-time { text-align: right; }

.tele-chat-input {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}
.tele-chat-input input {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  font-size: .85rem;
  outline: none;
  transition: var(--transition);
}
.tele-chat-input input:focus { border-color: var(--primary); }
.tele-send {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.tele-send svg { width: 16px; height: 16px; }

/* ── Portal ── */
.portal-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 32px 28px;
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
}
.portal-header::after {
  content: '';
  position: absolute;
  right: -40px; top: -40px;
  width: 200px; height: 200px;
  background: rgba(255,255,255,.06);
  border-radius: 50%;
}

/* ── Config Tabs ── */
.config-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}
.config-tab {
  padding: 11px 20px;
  font-size: .87rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.config-tab:hover { color: var(--primary); }
.config-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Color Swatches ── */
.color-swatches { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.swatch {
  width: 34px; height: 34px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
  position: relative;
}
.swatch.active::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
}
.swatch:hover { transform: scale(1.12); }

/* ── Info Box ── */
.info-box {
  background: var(--primary-light);
  border: 1px solid rgba(0,153,187,.20);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: .83rem;
  color: var(--primary-dark);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.info-box svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 12px; opacity: .4; }
.empty-state h4 { font-size: .9rem; font-weight: 600; color: var(--text-secondary); }
.empty-state p  { font-size: .8rem; margin-top: 4px; }

/* ── Next Consultations List ── */
.consult-list { display: flex; flex-direction: column; gap: 2px; }
.consult-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  transition: var(--transition);
  cursor: pointer;
}
.consult-item:hover { background: var(--surface-2); }
.consult-time-col { text-align: center; flex-shrink: 0; }
.consult-time { font-size: .82rem; font-weight: 700; color: var(--primary); font-family: var(--font-mono); }
.consult-specialty { font-size: .7rem; color: var(--text-muted); }
.consult-info { flex: 1; }
.consult-name { font-size: .87rem; font-weight: 600; color: var(--text-primary); }
.consult-sub { font-size: .75rem; color: var(--text-secondary); }

/* ── Prontuário Layout ── */
.prontuario-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  align-items: start;
}

.prontuario-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.prontuario-tab {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}
.prontuario-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.prontuario-tab:hover:not(.active) {
  border-color: var(--primary);
  color: var(--primary);
}

/* ── BI / Charts ── */
.bi-chart-placeholder {
  height: 180px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  padding: 10px 20px;
  border: 1px solid var(--border-light);
  overflow: hidden;
  position: relative;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-65-35, .grid-60-40 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    transform: translateX(-230px);
    width: 230px;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .main { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .topbar { padding: 0 16px; }
  .page-content { padding: 16px; }
  .tele-layout { grid-template-columns: 1fr; }
  .prontuario-layout { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .agenda-grid { grid-template-columns: 60px repeat(3, 1fr); }
  .agenda-grid .ag-header:nth-child(5),
  .agenda-grid .ag-header:nth-child(6),
  .agenda-grid .ag-cell:nth-child(5n+1),
  .agenda-grid .ag-cell:nth-child(5n) { display: none; }
  .form-row.cols-2,
  .form-row.cols-3 { grid-template-columns: 1fr; }
  .action-row { flex-direction: column; align-items: stretch; }
  .action-row-left, .action-row-right { width: 100%; }
}

/* =============================================
   AZPET Design System Overrides
   ============================================= */
body {
  background: var(--bg);
  color: var(--text-primary);
}

h1,
h2,
h3,
h4,
.page-header h1,
.topbar-breadcrumb h3,
.card-title,
.stat-value,
.stat-label,
.timeline-title,
.brand-text h2 {
  font-family: var(--font-heading);
  letter-spacing: 0;
}

a,
button,
input,
select,
textarea {
  font-family: var(--font);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.nav-item:focus-visible {
  outline: 3px solid rgba(0, 153, 187, .24);
  outline-offset: 3px;
}

.app {
  background: var(--bg);
}

.sidebar {
  background: var(--navy);
  border-right: 1px solid rgba(141, 168, 190, .16);
  box-shadow: 12px 0 30px rgba(7, 24, 39, .08);
}

.sidebar-brand {
  min-height: 76px;
  padding: 18px;
  border-bottom: 1px solid rgba(141, 168, 190, .14);
}

.brand-icon {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(141, 168, 190, .24);
  border-radius: var(--radius-md);
  background: #FFFFFF;
  box-shadow: none;
}

.brand-icon img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.brand-icon span {
  align-items: center;
  justify-content: center;
  color: var(--navy);
  font-family: var(--font-heading);
  font-size: .82rem;
  font-weight: 800;
}

.brand-text h2 {
  color: #FFFFFF;
  font-size: 1rem;
  font-weight: 800;
}

.brand-text span {
  color: var(--text-muted);
  font-size: .72rem;
}

.nav-section-label {
  color: var(--text-muted);
  letter-spacing: .08em;
}

.nav-item {
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
}

.nav-item:hover {
  background: rgba(0, 153, 187, .10);
  color: #FFFFFF;
  border-color: rgba(0, 153, 187, .16);
}

.nav-item.active {
  background: var(--primary-dark);
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, .08);
  box-shadow: 0 10px 22px rgba(0, 111, 138, .22);
}

.sidebar-footer {
  border-top: 1px solid rgba(141, 168, 190, .14);
}

.topbar {
  height: var(--topbar-h);
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(226, 232, 240, .55);
}

.topbar-breadcrumb h3 {
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 800;
}

.topbar-breadcrumb span,
.user-info span,
.muted,
.metric-note {
  color: var(--text-secondary);
}

.topbar-user {
  border: 1px solid var(--border);
  background: #FFFFFF;
}

.topbar-user:hover,
.topbar-btn:hover {
  background: var(--surface-2);
  border-color: rgba(0, 153, 187, .42);
  color: var(--primary-dark);
}

.user-avatar,
.avatar {
  background: var(--primary-dark);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}

.page-content {
  padding: 20px 28px 30px;
}

.page-header {
  margin-bottom: 22px;
}

.page-header h1 {
  color: var(--navy);
  font-size: clamp(1.55rem, 2vw, 2rem);
  font-weight: 800;
}

.page-header p {
  color: var(--text-secondary);
  font-size: .95rem;
}

.card,
.stat-card,
.tele-chat {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.card {
  overflow: hidden;
}

.card-header {
  padding: 20px 22px 0;
}

.card-title {
  color: var(--text-primary);
  font-size: .98rem;
  font-weight: 800;
}

.card-body {
  padding: 20px 22px 22px;
}

.card-footer {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.stat-card {
  padding: 20px;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-icon,
.stat-icon.blue,
.stat-icon.green,
.stat-icon.orange,
.stat-icon.purple,
.stat-icon.teal {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.stat-icon.red {
  background: var(--danger-light);
  color: var(--danger);
}

.stat-label {
  color: var(--text-secondary);
  font-size: .78rem;
  font-weight: 700;
}

.stat-value {
  color: var(--navy);
  font-size: 1.65rem;
  font-weight: 800;
}

.btn {
  min-height: 38px;
  border-radius: var(--radius-md);
  font-weight: 700;
  transition: background .18s ease, border-color .18s ease, color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.btn-primary {
  background: var(--primary-dark);
  color: #FFFFFF;
  box-shadow: 0 10px 20px rgba(0, 111, 138, .16);
}

.btn-primary:hover {
  background: #055D73;
  box-shadow: 0 14px 28px rgba(0, 111, 138, .20);
}

.btn-outline {
  background: #FFFFFF;
  color: var(--text-primary);
  border: 1.5px solid var(--border);
}

.btn-outline:hover {
  background: var(--surface-2);
  border-color: rgba(0, 153, 187, .42);
  color: var(--primary-dark);
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
}

.btn-danger:hover {
  background: #8F1D14;
}

.field label,
.form-group label {
  color: var(--text-secondary);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .055em;
}

.field input,
.field select,
.field textarea,
.form-group input {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: #FFFFFF;
  color: var(--text-primary);
}

.field input::placeholder,
.field textarea::placeholder,
.form-group input::placeholder {
  color: #94A3B8;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.form-group input:focus,
.search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 153, 187, .12);
}

input[type="checkbox"] {
  accent-color: var(--primary-dark);
}

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #FFFFFF;
}

table {
  font-size: .86rem;
}

thead th {
  background: var(--surface-2);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  font-size: .72rem;
  letter-spacing: .055em;
}

tbody td {
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-light);
}

tbody tr:nth-child(even) td {
  background: rgba(248, 250, 252, .46);
}

tbody tr:hover td {
  background: #F4FAFC;
}

tbody td:nth-child(2),
.ag-time,
.consult-time {
  font-family: var(--font-mono);
}

.badge,
.pill {
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-weight: 700;
}

.badge-success,
.badge-primary,
.pill.ok {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-color: rgba(0, 153, 187, .18);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning);
  border-color: rgba(138, 90, 0, .16);
}

.badge-purple,
.badge-gray,
.pill.off {
  background: #F1F5F9;
  color: var(--text-secondary);
  border-color: var(--border);
}

.badge-danger {
  background: var(--danger-light);
  color: var(--danger);
  border-color: rgba(180, 35, 24, .16);
}

.timeline-dot {
  background: var(--primary-light);
  border-color: var(--primary);
}

.timeline-title {
  color: var(--text-primary);
}

.timeline-desc {
  color: var(--text-secondary);
}

.bar,
.progress-fill,
.portal-header {
  background: var(--primary-dark);
}

.info-box {
  background: var(--primary-light);
  border-color: rgba(0, 153, 187, .18);
  color: var(--primary-dark);
}

.avatar.green,
.avatar.orange,
.avatar.purple,
.avatar.teal {
  background: var(--primary-dark);
}

.avatar.red {
  background: var(--danger);
}

.config-tab:hover,
.config-tab.active,
.prontuario-tab:hover:not(.active) {
  color: var(--primary-dark);
  border-bottom-color: var(--primary-dark);
}

.prontuario-tab.active {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

@media (max-width: 900px) {
  .sidebar {
    background: var(--navy);
  }

  .page-content {
    padding: 18px 16px 24px;
  }

  .sidebar-toggle {
    display: inline-flex;
    width: auto;
    border: 1px solid var(--border);
    background: #FFFFFF;
    color: var(--text-primary);
  }
}

@media (max-width: 600px) {
  .page-content {
    padding: 18px 14px;
  }

  .card-header,
  .card-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar-user .user-info {
    display: none;
  }
}
