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

:root {
  --blue-50:  #EFF6FF;
  --blue-100: #DBEAFE;
  --blue-400: #3B82F6;
  --blue-500: #2563EB;  /* primary */
  --blue-600: #1D4ED8;
  --blue-700: #1E3A8A;
  --green-50: #F0FDF4;
  --green-400:#22C55E;
  --green-500:#16A34A;
  --gray-50:  #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;
  --red-50:   #FFF1F2;
  --red-400:  #F87171;
  --red-500:  #EF4444;
  --amber-50: #FFFBEB;
  --amber-400:#FBBF24;
  --amber-500:#F59E0B;

  --sidebar-w: 255px;
  --sidebar-bg: #0F172A;
  --sidebar-hover: rgba(255,255,255,0.06);
  --sidebar-active: rgba(59,130,246,0.18);
  --sidebar-border: rgba(255,255,255,0.07);
  --topbar-h: 64px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.1);

  --font: 'Poppins', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--blue-500); text-decoration: none; }
a:hover { color: var(--blue-600); }

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

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page-body {
  flex: 1;
  padding: 32px 32px 48px;
  max-width: 1280px;
  width: 100%;
}

/* ── SIDEBAR ─────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

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

.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--blue-500);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo .logo-icon svg { color: #fff; }

.sidebar-logo .logo-text {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.sidebar-logo .logo-sub {
  font-size: 10px;
  color: var(--gray-400);
  font-weight: 400;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sidebar-section {
  padding: 20px 12px 8px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-500);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 0 8px;
  margin-bottom: 4px;
}

.sidebar-nav { list-style: none; }

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--gray-400);
  font-size: 13.5px;
  font-weight: 400;
  transition: all .15s ease;
  margin-bottom: 2px;
}

.sidebar-nav li a svg {
  width: 17px; height: 17px;
  flex-shrink: 0;
  opacity: .7;
}

.sidebar-nav li a:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-nav li a:hover svg { opacity: 1; }

.sidebar-nav li a.active {
  background: var(--sidebar-active);
  color: var(--blue-400);
  font-weight: 500;
}

.sidebar-nav li a.active svg { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: default;
}

.sidebar-user .avatar {
  width: 34px; height: 34px;
  background: var(--blue-500);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user .user-info { min-width: 0; }

.sidebar-user .user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-200);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .user-empresa {
  font-size: 11px;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer .logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--gray-500);
  font-size: 12.5px;
  margin-top: 4px;
  transition: all .15s;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
}

.sidebar-footer .logout-btn:hover { color: var(--red-400); background: rgba(239,68,68,.06); }

/* ── TOPBAR ─────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-800);
  letter-spacing: -0.3px;
}

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

/* ── BUTTONS ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all .15s ease;
  white-space: nowrap;
  text-decoration: none;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--blue-500);
  color: #fff;
  border-color: var(--blue-500);
}
.btn-primary:hover { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }

.btn-secondary {
  background: #fff;
  color: var(--gray-700);
  border-color: var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-300); color: var(--gray-800); }

.btn-success {
  background: var(--green-500);
  color: #fff;
  border-color: var(--green-500);
}
.btn-success:hover { background: #15803D; border-color: #15803D; color: #fff; }

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

.btn-warning {
  background: var(--amber-500);
  color: #fff;
  border-color: var(--amber-500);
}
.btn-warning:hover { background: #D97706; color: #fff; }

.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-icon { padding: 7px; border-radius: var(--radius-sm); }
.btn-icon svg { width: 15px; height: 15px; }

/* ── CARDS ─────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.card-body { padding: 24px; }

/* ── STAT CARDS ─────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}

.stat-card:hover { box-shadow: var(--shadow-md); }

.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(--blue-50);   color: var(--blue-500); }
.stat-icon.green  { background: var(--green-50);  color: var(--green-500); }
.stat-icon.amber  { background: var(--amber-50);  color: var(--amber-500); }
.stat-icon.red    { background: var(--red-50);    color: var(--red-500); }
.stat-icon.gray   { background: var(--gray-100);  color: var(--gray-600); }

.stat-info { min-width: 0; }
.stat-label { font-size: 12px; color: var(--gray-500); font-weight: 400; margin-bottom: 2px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--gray-800); letter-spacing: -0.5px; line-height: 1.2; }

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

table { width: 100%; border-collapse: collapse; }

table th {
  background: var(--gray-50);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  font-size: 13.5px;
  vertical-align: middle;
}

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

.table-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ── FORMS ─────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
}

.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--gray-800);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.form-control:focus {
  border-color: var(--blue-400);
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}

.form-control::placeholder { color: var(--gray-400); }

select.form-control { cursor: pointer; }

textarea.form-control { resize: vertical; min-height: 100px; }

.form-hint { font-size: 11.5px; color: var(--gray-400); }
.form-error { font-size: 12px; color: var(--red-500); }

.form-footer {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  padding-top: 20px;
  margin-top: 20px;
  border-top: 1px solid var(--gray-100);
}

/* ── STATUS BADGES ─────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.status-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .7;
}

.status-rascunho  { background: var(--gray-100);  color: var(--gray-600); }
.status-enviado   { background: var(--blue-50);   color: var(--blue-600); }
.status-aprovado  { background: var(--green-50);  color: var(--green-500); }
.status-reprovado { background: var(--red-50);    color: var(--red-500); }

/* ── ALERTS / FLASH ─────────────────────────── */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  margin-bottom: 20px;
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; }
.alert-success { background: var(--green-50); color: #166534; border: 1px solid #BBF7D0; }
.alert-danger  { background: var(--red-50);   color: #991B1B; border: 1px solid #FECACA; }
.alert-info    { background: var(--blue-50);  color: #1E40AF; border: 1px solid var(--blue-100); }
.alert-warning { background: var(--amber-50); color: #92400E; border: 1px solid #FDE68A; }

/* ── FILTERS ─────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-bar .form-control { max-width: 200px; }

/* ── EMPTY STATE ─────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
}

.empty-state svg {
  width: 52px; height: 52px;
  color: var(--gray-300);
  margin: 0 auto 16px;
}

.empty-state h3 {
  font-size: 15px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.empty-state p { font-size: 13px; color: var(--gray-400); }

/* ── AUTH PAGES ─────────────────────────────── */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--gray-900) 0%, #0F2549 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.auth-logo .logo-icon {
  width: 42px; height: 42px;
  background: var(--blue-500);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
}

.auth-logo .logo-icon svg { color: #fff; width: 24px; height: 24px; }

.auth-logo .brand { font-size: 20px; font-weight: 700; color: var(--gray-900); letter-spacing: -0.4px; }
.auth-logo .tagline { font-size: 11px; color: var(--gray-400); font-weight: 400; }

.auth-title  { font-size: 20px; font-weight: 600; color: var(--gray-800); margin-bottom: 4px; }
.auth-subtitle { font-size: 13.5px; color: var(--gray-500); margin-bottom: 24px; }

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-footer { margin-top: 20px; text-align: center; font-size: 13px; color: var(--gray-500); }

/* ── PROPOSTA PÚBLICA ─────────────────────────── */
.public-page {
  min-height: 100vh;
  background: var(--gray-50);
}

.public-header {
  background: var(--gray-900);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.public-logo { display: flex; align-items: center; gap: 8px; }
.public-logo .icon { width: 32px; height: 32px; background: var(--blue-500); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; }
.public-logo .text { font-size: 15px; font-weight: 700; color: #fff; }

.public-body { max-width: 820px; margin: 0 auto; padding: 40px 24px; }

.proposta-header-card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: 32px;
  margin-bottom: 20px;
}

.proposta-numero {
  font-size: 12px;
  font-weight: 600;
  color: var(--blue-500);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.proposta-titulo { font-size: 24px; font-weight: 700; color: var(--gray-900); margin-bottom: 16px; letter-spacing: -0.4px; }

.proposta-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-100);
}

.meta-item .meta-label { font-size: 11px; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500; }
.meta-item .meta-value { font-size: 14px; color: var(--gray-700); font-weight: 500; margin-top: 2px; }

.itens-table-card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  margin-bottom: 20px;
}

.total-card {
  background: var(--gray-900);
  border-radius: var(--radius-lg);
  padding: 24px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.total-label { font-size: 14px; color: var(--gray-400); }
.total-value { font-size: 28px; font-weight: 700; color: #fff; letter-spacing: -0.5px; }

.action-bar {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── CHART ─────────────────────────────────── */
.chart-container { position: relative; height: 250px; }

/* ── FOLLOWUP TABLE ─────────────────────────── */
.followup-list { list-style: none; }
.followup-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
  flex-wrap: wrap;
}
.followup-item:last-child { border-bottom: none; }
.followup-info { min-width: 0; }
.followup-titulo { font-size: 13.5px; font-weight: 500; color: var(--gray-800); }
.followup-cliente { font-size: 12px; color: var(--gray-400); margin-top: 2px; }

/* ── MOBILE SIDEBAR ─────────────────────────── */
.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 200;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--blue-500);
  color: #fff;
  border: none;
  cursor: pointer;
  align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg);
}

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

/* ── ITENS TABLE ─────────────────────────────── */
.itens-table th, .itens-table td { padding: 10px 12px; font-size: 13px; }
.itens-table .btn-icon { padding: 5px; }

/* ── PAGINATION / MISC ─────────────────────────── */
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.4px;
  margin-bottom: 4px;
}
.page-subtitle { font-size: 13px; color: var(--gray-500); margin-bottom: 24px; }

.badge-tipo {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}
.badge-produto { background: var(--blue-50); color: var(--blue-600); }
.badge-servico { background: var(--amber-50); color: #B45309; }

/* ── DASHBOARD GRID ─────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-top: 24px;
}

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

/* ── RESPONSIVE ─────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .sidebar-toggle { display: flex; }
  .main-content { margin-left: 0; }
  .page-body { padding: 20px 16px 40px; }
  .topbar { padding: 0 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .filter-bar .form-control { max-width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 28px 20px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .table-actions { flex-direction: column; align-items: flex-start; }
}

/* ── UTILITÁRIOS ─────────────────────────────── */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 12.5px; }
.text-muted { color: var(--gray-400); }
.fw-600 { font-weight: 600; }
.w-100 { width: 100%; }
