/* ============================================================
   DentFinance - style.css
   Design moderno, azul e branco, fonte Inter
   ============================================================ */

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

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

:root {
  --blue-600:   #2563EB;
  --blue-500:   #3B82F6;
  --blue-400:   #60A5FA;
  --blue-100:   #DBEAFE;
  --blue-50:    #EFF6FF;
  --white:      #FFFFFF;
  --gray-900:   #111827;
  --gray-700:   #374151;
  --gray-600:   #4B5563;
  --gray-400:   #9CA3AF;
  --gray-200:   #E5E7EB;
  --gray-100:   #F3F4F6;
  --gray-50:    #F9FAFB;
  --green-500:  #22C55E;
  --green-100:  #DCFCE7;
  --red-500:    #EF4444;
  --red-100:    #FEE2E2;
  --amber-500:  #F59E0B;
  --amber-100:  #FEF3C7;
  --sidebar-w:  240px;
  --topbar-h:   64px;
  --radius:     10px;
  --radius-sm:  6px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:     0 4px 12px rgba(0,0,0,.08);
  --transition: .18s ease;
}

html { font-size: 14px; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--gray-50);
  color: var(--gray-700);
  min-height: 100vh;
  line-height: 1.6;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
ul { list-style: none; }

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

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

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--gray-200);
}

.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--blue-600);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--white);
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -.3px;
}

.sidebar-logo .logo-sub {
  font-size: 10px;
  color: var(--gray-400);
  font-weight: 500;
  letter-spacing: .4px;
  text-transform: uppercase;
  display: block;
  margin-top: 1px;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--gray-600);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: var(--blue-50);
  color: var(--blue-600);
}

.nav-item.active {
  background: var(--blue-600);
  color: var(--white);
}

.nav-item .nav-icon {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--gray-200);
}

.clinic-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
}

.clinic-avatar {
  width: 32px; height: 32px;
  background: var(--blue-600);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--white);
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.clinic-name { font-size: 12px; font-weight: 600; color: var(--gray-900); }
.clinic-role { font-size: 11px; color: var(--gray-400); }

.btn-logout {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--red-500); font-size: 12px; font-weight: 500;
  border: none; background: none; cursor: pointer;
  width: 100%; margin-top: 8px;
  transition: background var(--transition);
}
.btn-logout:hover { background: var(--red-100); }

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

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

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  flex: 1;
}

.date-range {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
}

.date-range input[type="date"] {
  background: none; border: none; outline: none;
  font-family: 'Inter', sans-serif;
  font-size: 13px; color: var(--gray-700);
  width: 118px;
}

.date-range .sep { color: var(--gray-400); font-size: 12px; }

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

.mobile-menu-btn {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: 6px; border-radius: var(--radius-sm);
  color: var(--gray-600);
}

/* ── Page content ─────────────────────────────────────────── */
.page-content {
  padding: 24px;
  flex: 1;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 13px; font-weight: 500;
  border: none; cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary { background: var(--blue-600); color: var(--white); }
.btn-primary:hover { background: #1D4ED8; }

.btn-secondary {
  background: var(--white); color: var(--gray-700);
  border: 1px solid var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-50); }

.btn-success { background: var(--green-500); color: var(--white); }
.btn-success:hover { background: #16A34A; }

.btn-danger { background: var(--red-500); color: var(--white); }
.btn-danger:hover { background: #DC2626; }

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px; font-weight: 600; color: var(--gray-900);
}

.card-subtitle { font-size: 12px; color: var(--gray-400); margin-top: 2px; }

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

.kpi-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.kpi-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.kpi-icon.blue   { background: var(--blue-100);  color: var(--blue-600); }
.kpi-icon.green  { background: var(--green-100); color: var(--green-500); }
.kpi-icon.red    { background: var(--red-100);   color: var(--red-500); }
.kpi-icon.amber  { background: var(--amber-100); color: var(--amber-500); }

.kpi-label { font-size: 11.5px; color: var(--gray-400); font-weight: 500; }
.kpi-value {
  font-size: 20px; font-weight: 700; color: var(--gray-900);
  letter-spacing: -.4px; margin-top: 4px;
}

.kpi-badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 20px;
  margin-top: 6px;
}
.badge-up   { background: var(--green-100); color: var(--green-500); }
.badge-down { background: var(--red-100);   color: var(--red-500); }
.badge-neu  { background: var(--gray-100);  color: var(--gray-600); }
.badge-blue { background: var(--blue-100);  color: var(--blue-600); }

/* ── Grids ───────────────────────────────────────────────── */
.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: 1.8fr 1fr; gap: 16px; }

.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px; font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
}

tbody tr:last-child td { border: none; }
tbody tr:hover td { background: var(--gray-50); }

.td-right { text-align: right; }
.td-center { text-align: center; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600;
}
.badge-green  { background: var(--green-100); color: #166534; }
.badge-red    { background: var(--red-100);   color: #991B1B; }
.badge-amber  { background: var(--amber-100); color: #92400E; }
.badge-blue   { background: var(--blue-100);  color: var(--blue-600); }
.badge-gray   { background: var(--gray-100);  color: var(--gray-600); }

/* ── Forms ───────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 12px; font-weight: 500; color: var(--gray-600);
}

input, select, textarea {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--gray-900);
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  outline: none;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

textarea { resize: vertical; min-height: 80px; }

.input-prefix { position: relative; }
.input-prefix .prefix-sign {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400); font-size: 13px; pointer-events: none;
}
.input-prefix input { padding-left: 28px; }

/* ── Category pills ──────────────────────────────────────── */
.cat-grid {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 16px;
}

.cat-pill {
  padding: 6px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
  cursor: pointer; border: 1.5px solid var(--gray-200);
  color: var(--gray-600); background: var(--white);
  transition: all var(--transition);
  user-select: none;
}

.cat-pill:hover { border-color: var(--blue-400); color: var(--blue-600); }
.cat-pill.selected {
  background: var(--blue-600); border-color: var(--blue-600);
  color: var(--white);
}

.cat-pill.expense-pill { border-color: #FCA5A5; color: var(--red-500); background: var(--red-100); }
.cat-pill.expense-pill.selected { background: var(--red-500); border-color: var(--red-500); color: var(--white); }

.cat-pill.income-pill { border-color: #86EFAC; color: var(--green-500); background: var(--green-100); }
.cat-pill.income-pill.selected { background: var(--green-500); border-color: var(--green-500); color: var(--white); }

/* ── Payment bar ─────────────────────────────────────────── */
.payment-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--gray-100);
}
.payment-row:last-child { border: none; }
.payment-label { font-size: 12.5px; color: var(--gray-600); width: 140px; flex-shrink: 0; }
.payment-bar-bg {
  flex: 1; height: 7px; background: var(--gray-100);
  border-radius: 10px; overflow: hidden;
}
.payment-bar { height: 100%; border-radius: 10px; transition: width .5s ease; }
.payment-val {
  font-size: 12px; font-weight: 600; color: var(--gray-900);
  width: 100px; text-align: right; font-variant-numeric: tabular-nums;
}

/* ── Chart container ─────────────────────────────────────── */
.chart-container { position: relative; width: 100%; height: 260px; }

/* ── Divider ─────────────────────────────────────────────── */
.divider { height: 1px; background: var(--gray-200); margin: 18px 0; }

/* ── Contract card ───────────────────────────────────────── */
.contract-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200); background: var(--white);
  margin-bottom: 8px; transition: box-shadow var(--transition);
}
.contract-card:hover { box-shadow: var(--shadow-sm); }

.contract-icon {
  width: 38px; height: 38px; border-radius: 8px;
  background: var(--blue-100); color: var(--blue-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}

.contract-name { font-size: 13px; font-weight: 600; color: var(--gray-900); }
.contract-detail { font-size: 11.5px; color: var(--gray-400); margin-top: 2px; }
.contract-amount {
  font-size: 14px; font-weight: 700; color: var(--blue-600);
  font-variant-numeric: tabular-nums;
}

/* ── Planilha table ──────────────────────────────────────── */
.planilha-wrap {
  overflow: auto;
  max-height: calc(100vh - 180px);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}

.planilha-table {
  border-collapse: collapse;
  min-width: 1100px;
  font-size: 12.5px;
  background: var(--white);
}

.planilha-table th {
  background: var(--gray-50);
  color: var(--gray-400);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  padding: 10px 12px;
  border: 1px solid var(--gray-200);
  text-align: center;
  position: sticky; top: 0; z-index: 2;
  white-space: nowrap;
}

.planilha-table th:first-child {
  text-align: left;
  position: sticky; left: 0; z-index: 3;
  background: var(--gray-50);
  min-width: 210px;
}

.planilha-table td {
  padding: 8px 12px;
  border: 1px solid var(--gray-100);
  text-align: right;
  color: var(--gray-600);
  white-space: nowrap;
}

.planilha-table td:first-child {
  text-align: left;
  background: var(--white);
  color: var(--gray-900);
  font-weight: 500;
  position: sticky; left: 0; z-index: 1;
}

.planilha-table .row-section td {
  background: var(--gray-50) !important;
  color: var(--gray-400) !important;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .6px;
}

.planilha-table .row-total td {
  background: var(--blue-50) !important;
  font-weight: 700;
}
.planilha-table .row-total td:first-child { color: var(--blue-600) !important; }

.val-green { color: var(--green-500) !important; font-weight: 600; }
.val-red   { color: var(--red-500)   !important; font-weight: 600; }
.val-blue  { color: var(--blue-600)  !important; font-weight: 600; }

/* ── Login page ──────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  background: var(--gray-50);
}

.login-left {
  flex: 1;
  background: var(--blue-600);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px;
  position: relative;
  overflow: hidden;
}

.login-left::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 50%, rgba(255,255,255,.08), transparent 60%);
}

.login-left-content { position: relative; z-index: 1; text-align: center; color: var(--white); }
.login-left-content .big-icon {
  font-size: 72px; margin-bottom: 24px;
  filter: drop-shadow(0 4px 24px rgba(0,0,0,.2));
}
.login-left-content h1 { font-size: 32px; font-weight: 700; margin-bottom: 10px; }
.login-left-content p  { font-size: 15px; opacity: .75; max-width: 320px; line-height: 1.7; }

.login-right {
  width: 440px; min-width: 400px;
  display: flex; align-items: center; justify-content: center;
  padding: 48px;
  background: var(--white);
}

.login-box { width: 100%; }
.login-box h2 { font-size: 22px; font-weight: 700; color: var(--gray-900); margin-bottom: 6px; }
.login-box p  { font-size: 13px; color: var(--gray-400); margin-bottom: 28px; }

.login-form .form-group { margin-bottom: 16px; }
.login-form label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--gray-700); }
.login-form input {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.login-form input:focus { border-color: var(--blue-500); }

.btn-login {
  width: 100%; padding: 12px;
  background: var(--blue-600); color: var(--white);
  border: none; border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 14px; font-weight: 600;
  cursor: pointer; margin-top: 8px;
  transition: background var(--transition);
}
.btn-login:hover { background: #1D4ED8; }

.login-error {
  background: var(--red-100); color: #991B1B;
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 13px; margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }

/* ── Toast ───────────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999;
}

.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: var(--radius-sm);
  background: var(--gray-900); color: var(--white);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow);
  animation: slideInToast .25s ease forwards;
}
.toast.toast-success { background: #166534; }
.toast.toast-error   { background: #991B1B; }

@keyframes slideInToast {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Utilities ───────────────────────────────────────────── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.text-right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-65-35 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .login-left { display: none; }
  .login-right { width: 100%; min-width: unset; }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }

  .main-content { margin-left: 0; }

  .mobile-menu-btn { display: flex; }

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

@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .form-group.full { grid-column: 1; }
  .page-content { padding: 14px; }
  .kpi-card { padding: 14px; }
}

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