/* ============================================================
   GASTROVIEW - Sistema Financeiro
   Design System baseado na identidade visual da clínica
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=Playfair+Display:wght@400;600&display=swap');

:root {
  --primary:       #3DBDBD;
  --primary-dark:  #2A9898;
  --primary-light: #7DD8D8;
  --primary-pale:  #EBF9F9;
  --accent:        #1A6B6B;
  --danger:        #E05555;
  --danger-light:  #FFF0F0;
  --success:       #3AB87A;
  --success-light: #EDF9F3;
  --warning:       #F5A623;
  --warning-light: #FFF8EC;

  --bg:            #F4F7F9;
  --surface:       #FFFFFF;
  --surface-2:     #F9FBFC;
  --border:        #E2EAF0;
  --border-focus:  #3DBDBD;

  --text-primary:  #1A2E3B;
  --text-secondary:#4A6375;
  --text-muted:    #8AA4B5;

  --sidebar-w:     260px;
  --header-h:      64px;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 2px 12px rgba(61,189,189,0.08);
  --shadow-md:     0 4px 24px rgba(61,189,189,0.12);
  --shadow-lg:     0 8px 40px rgba(26,107,107,0.16);

  --font-body:     'DM Sans', sans-serif;
  --font-display:  'Playfair Display', serif;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 99px; }

/* ---- LOGIN PAGE ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary-dark) 50%, var(--primary) 100%);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
  top: -200px; right: -100px;
}
.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
  bottom: -150px; left: -50px;
}

.login-panel {
  width: 100%;
  max-width: 420px;
  margin: auto;
  background: var(--surface);
  border-radius: 20px;
  padding: 48px 40px;
  box-shadow: var(--shadow-lg);
  position: relative; z-index: 1;
  animation: slideUp 0.5s cubic-bezier(0.34,1.56,0.64,1);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo img { max-height: 70px; }
.login-logo .subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-panel h2 {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--text-primary);
  margin-bottom: 24px;
}

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

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--accent) 0%, #0F4444 100%);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  text-align: center;
}
.sidebar-logo img { max-height: 50px; filter: brightness(0) invert(1); }
.sidebar-logo span {
  display: block;
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 6px;
}

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

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  padding: 16px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  margin-bottom: 2px;
}
.nav-item:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.nav-item.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(61,189,189,0.3);
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.8);
}
.user-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
  flex-shrink: 0;
}
.user-info-text { flex: 1; overflow: hidden; }
.user-info-text strong { display: block; font-size: 13px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info-text span { font-size: 11px; color: rgba(255,255,255,0.5); }

.btn-logout {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 8px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}
.btn-logout:hover { background: rgba(224,85,85,0.2); color: #ff9999; border-color: rgba(224,85,85,0.3); }

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

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

.topbar-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.topbar-title span {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 8px;
}

.page-content { padding: 28px; }

/* ---- CARDS ---- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.card-body { padding: 24px; }

/* KPI CARDS */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.kpi-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow 0.2s;
}
.kpi-card:hover { box-shadow: var(--shadow-md); }

.kpi-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--text-primary); }
.kpi-value.receita { color: var(--success); }
.kpi-value.despesa { color: var(--danger); }
.kpi-value.lucro { color: var(--primary-dark); }
.kpi-sub { font-size: 12px; color: var(--text-muted); }

.kpi-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 4px;
}
.kpi-icon.verde { background: var(--success-light); color: var(--success); }
.kpi-icon.vermelho { background: var(--danger-light); color: var(--danger); }
.kpi-icon.azul { background: var(--primary-pale); color: var(--primary-dark); }
.kpi-icon.amarelo { background: var(--warning-light); color: var(--warning); }

/* ---- FORMULÁRIOS ---- */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(61,189,189,0.12);
}
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }

/* ---- BOTÕES ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(61,189,189,0.3); }

.btn-outline { background: transparent; color: var(--primary-dark); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-pale); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c94040; }

.btn-ghost { background: transparent; color: var(--text-secondary); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 13px 28px; font-size: 15px; }
.btn-full { width: 100%; }

.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- TABELAS ---- */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

/* ---- BADGES ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-primary { background: var(--primary-pale); color: var(--primary-dark); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-neutral { background: var(--bg); color: var(--text-muted); }

/* ---- ALERTS ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: var(--success-light); color: #1e7a4e; border: 1px solid #b3e6ce; }
.alert-danger  { background: var(--danger-light);  color: #c0392b; border: 1px solid #f5c6c6; }
.alert-info    { background: var(--primary-pale);  color: var(--accent); border: 1px solid #b3e0e0; }

/* ---- MODAL ---- */
.modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 200;
  background: rgba(26,46,59,0.5);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; animation: fadeIn 0.2s; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 20px; padding: 4px;
  line-height: 1; transition: color 0.2s;
}
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---- FILTROS ---- */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.filter-bar .form-group { margin-bottom: 0; min-width: 140px; }

/* ---- TABS ---- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tab-btn {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.tab-btn.active { color: var(--primary-dark); border-bottom-color: var(--primary); }
.tab-btn:hover { color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ---- ANIMATIONS ---- */
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) }
  to   { opacity: 1; transform: translateY(0) }
}

/* ---- UTILITIES ---- */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-muted   { color: var(--text-muted); }
.fw-bold { font-weight: 700; }
.mt-4 { margin-top: 28px; }
.mb-4 { margin-bottom: 28px; }
.gap-2 { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }

/* ---- PRINT ---- */
@media print {
  .sidebar, .topbar, .btn, .filter-bar, .no-print { display: none !important; }
  .main-content { margin-left: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  body { background: white; }
}

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-260px); }
  .sidebar.open { transform: translateX(0); width: 260px; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .col-span-2, .col-span-3 { grid-column: span 1; }
  .page-content { padding: 16px; }
}
