/* ============================================================
   ERP SOPHISTIC — Design System
   ============================================================ */

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

/* --- Tokens --- */
:root {
  --blue-50:  #EFF6FF; --blue-100: #DBEAFE; --blue-200: #BFDBFE;
  --blue-500: #3B82F6; --blue-600: #2563EB; --blue-700: #1D4ED8;
  --slate-50:  #F8FAFC; --slate-100: #F1F5F9; --slate-200: #E2E8F0;
  --slate-300: #CBD5E1; --slate-400: #94A3B8; --slate-500: #64748B;
  --slate-600: #475569; --slate-700: #334155; --slate-800: #1E293B;
  --slate-900: #0F172A;
  --green-100:#D1FAE5; --green-600:#059669; --green-700:#047857;
  --amber-100:#FEF3C7; --amber-600:#D97706; --amber-700:#B45309;
  --red-100:  #FEE2E2; --red-500:  #EF4444; --red-600:  #DC2626;

  --bg:       var(--slate-50);
  --surface:  #fff;
  --border:   var(--slate-200);
  --text:     var(--slate-900);
  --muted:    var(--slate-500);

  --sidebar-w: 240px;
  --topbar-h:  60px;

  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.10);
  --transition: 160ms ease;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ============================================================
   SPLASH
   ============================================================ */
#splash {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 9999;
  transition: opacity .3s ease;
}
.splash-inner { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.splash-logo  { animation: splashPop .4s cubic-bezier(.34,1.56,.64,1) both; }
.splash-spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--blue-200);
  border-top-color: var(--blue-600);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes splashPop { from { opacity:0; transform:scale(.6); } to { opacity:1; transform:scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   LAYOUT SHELL
   ============================================================ */
#app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--slate-900);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
  z-index: 100;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand-logo {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--blue-600);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-weight: 700; font-size: 16px; color: #fff;
  overflow: hidden;
}
.sidebar-brand-logo img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-brand-name {
  font-size: 15px; font-weight: 700;
  color: #fff; letter-spacing: -.3px;
  line-height: 1.2;
}
.sidebar-brand-sub {
  font-size: 10px; color: var(--slate-400);
  text-transform: uppercase; letter-spacing: .5px;
}

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sidebar-section-label {
  font-size: 10px; font-weight: 600;
  color: var(--slate-600); text-transform: uppercase;
  letter-spacing: .8px; padding: 12px 8px 4px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  color: var(--slate-400);
  font-size: 13.5px; font-weight: 500;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
}
.sidebar-link svg { flex-shrink: 0; opacity: .7; }
.sidebar-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-link:hover svg { opacity: 1; }
.sidebar-link.active {
  background: var(--blue-600);
  color: #fff;
}
.sidebar-link.active svg { opacity: 1; }
.sidebar-badge {
  margin-left: auto;
  background: var(--red-500);
  color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 18px; text-align: center;
}

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,.07);
  padding: 12px;
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--transition);
}
.sidebar-user:hover { background: rgba(255,255,255,.07); }
.sidebar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--blue-700);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; overflow: hidden; }
.sidebar-user-name {
  font-size: 13px; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 11px; color: var(--slate-400);
  text-transform: capitalize;
}
.sidebar-logout-btn {
  background: none; border: none; color: var(--slate-500);
  display: flex; align-items: center; justify-content: center;
  padding: 4px; border-radius: 4px;
  transition: color var(--transition);
}
.sidebar-logout-btn:hover { color: var(--red-500); }

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.main-area {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title {
  font-size: 16px; font-weight: 700; color: var(--text);
  flex: 1;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.page-content { padding: 24px; flex: 1; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text); flex: 1; }
.card-body  { padding: 20px; }

/* ============================================================
   STAT CARDS (Dashboard)
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  display: flex; flex-direction: column; gap: 8px;
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-icon {
  width: 40px; height: 40px; border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
}
.stat-icon.blue  { background: var(--blue-50);  color: var(--blue-600); }
.stat-icon.green { background: var(--green-100); color: var(--green-600); }
.stat-icon.amber { background: var(--amber-100); color: var(--amber-600); }
.stat-icon.red   { background: var(--red-100);   color: var(--red-600); }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text); letter-spacing: -1px; }
.stat-sub   { font-size: 12px; color: var(--muted); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r-md);
  font-size: 13.5px; font-weight: 500;
  border: none;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--blue-600); color: #fff;
}
.btn-primary:hover { background: var(--blue-700); box-shadow: 0 4px 12px rgba(37,99,235,.3); }
.btn-secondary {
  background: var(--surface); color: var(--slate-700);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--slate-100); }
.btn-danger  { background: var(--red-600); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--green-600); color: #fff; }
.btn-success:hover { background: var(--green-700); }
.btn-ghost   { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--slate-100); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-icon {
  padding: 7px; border-radius: var(--r-md);
  background: transparent; border: none;
  color: var(--muted); display: flex; align-items: center;
  transition: background var(--transition), color var(--transition);
}
.btn-icon:hover { background: var(--slate-100); color: var(--text); }

/* ============================================================
   BADGES / STATUS
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
}
.badge::before {
  content: ''; width: 6px; height: 6px;
  border-radius: 50%; background: currentColor;
  opacity: .8;
}
.badge-blue   { background: var(--blue-50);   color: var(--blue-700); }
.badge-green  { background: var(--green-100);  color: var(--green-700); }
.badge-amber  { background: var(--amber-100);  color: var(--amber-700); }
.badge-red    { background: var(--red-100);    color: var(--red-600); }
.badge-slate  { background: var(--slate-100);  color: var(--slate-600); }

.tag-urgent {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  background: #FFF1F2; color: #BE123C;
  border: 1px solid #FECDD3;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  animation: urgentPulse 2s ease-in-out infinite;
}
@keyframes urgentPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(190,18,60,.2); }
  50%      { box-shadow: 0 0 0 4px rgba(190,18,60,.0); }
}

/* ============================================================
   FORMS
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label {
  font-size: 12.5px; font-weight: 600;
  color: var(--slate-700);
}
.form-label .required { color: var(--red-500); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-control::placeholder { color: var(--slate-400); }
.form-control:disabled { background: var(--slate-100); color: var(--muted); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394A3B8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11.5px; color: var(--muted); }
.form-row   { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 1.5px solid var(--border); }
th {
  padding: 10px 14px;
  font-size: 11.5px; font-weight: 600;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: .4px; text-align: left;
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  font-size: 13.5px; color: var(--text);
  border-bottom: 1px solid var(--slate-100);
}
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--slate-50); }
tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--slate-900) 0%, #1a2744 50%, var(--slate-900) 100%);
  padding: 24px;
  position: relative; overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 60% 50% at 50% -10%, rgba(37,99,235,.35), transparent);
}
.login-card {
  background: rgba(255,255,255,.97);
  border-radius: var(--r-xl);
  box-shadow: 0 24px 60px rgba(0,0,0,.4);
  padding: 40px 36px;
  width: 100%; max-width: 400px;
  position: relative; z-index: 1;
  animation: loginSlide .4s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes loginSlide {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.login-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 28px;
}
.login-logo-icon {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--blue-600);
  display: flex; align-items: center; justify-content: center;
}
.login-logo-text h1 {
  font-size: 18px; font-weight: 800;
  color: var(--text); letter-spacing: -.5px;
}
.login-logo-text p { font-size: 12px; color: var(--muted); margin-top: 1px; }
.login-title    { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-subtitle { font-size: 13px; color: var(--muted); margin-bottom: 28px; }
.login-error {
  background: var(--red-100); color: var(--red-600);
  border-radius: var(--r-md); padding: 10px 14px;
  font-size: 13px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}

/* ============================================================
   DASHBOARD GRID
   ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }

.activity-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--slate-100);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--blue-500); flex-shrink: 0; margin-top: 5px;
}
.activity-text { font-size: 13px; line-height: 1.5; }
.activity-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

.deadline-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  transition: box-shadow var(--transition);
}
.deadline-item:hover { box-shadow: var(--shadow-sm); }
.deadline-days {
  font-size: 22px; font-weight: 800; min-width: 36px; text-align: center;
  letter-spacing: -1px;
}
.deadline-days.overdue { color: var(--red-500); }
.deadline-days.soon    { color: var(--amber-600); }
.deadline-days.ok      { color: var(--green-600); }
.deadline-info { flex: 1; }
.deadline-code { font-size: 13px; font-weight: 600; color: var(--text); }
.deadline-client { font-size: 12px; color: var(--muted); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty-state svg { margin-bottom: 16px; opacity: .4; }
.empty-state h3 { font-size: 15px; font-weight: 600; color: var(--slate-600); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  animation: modalSlide .2s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modalSlide {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex; align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.modal-title { font-size: 16px; font-weight: 700; flex: 1; }
.modal-body  { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9000;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--slate-900); color: #fff;
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  pointer-events: all;
  animation: toastIn .25s cubic-bezier(.34,1.56,.64,1);
  min-width: 260px; max-width: 380px;
}
.toast.toast-success { border-left: 4px solid var(--green-600); }
.toast.toast-error   { border-left: 4px solid var(--red-500); }
.toast.toast-info    { border-left: 4px solid var(--blue-500); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   MISC UTILITIES
   ============================================================ */
.flex        { display: flex; }
.items-center{ align-items: center; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.gap-4       { gap: 16px; }
.ml-auto     { margin-left: auto; }
.text-muted  { color: var(--muted); }
.text-sm     { font-size: 12.5px; }
.text-xs     { font-size: 11.5px; }
.font-semibold{ font-weight: 600; }
.font-bold   { font-weight: 700; }
.mb-1        { margin-bottom: 4px; }
.mb-2        { margin-bottom: 8px; }
.mb-4        { margin-bottom: 16px; }
.mb-6        { margin-bottom: 24px; }
.mt-4        { margin-top: 16px; }
.truncate    { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.divider     { height: 1px; background: var(--border); margin: 16px 0; }
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .main-area { overflow: visible; }
  .page-content { padding: 0; }
  body { background: #fff; }
}

/* ============================================================
   EXTRAS (Módulo Orçamentos / Clientes)
   ============================================================ */
.modal-close {
  background: none; border: none;
  color: var(--muted); font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--slate-100); color: var(--text); }

/* Overlay animation state */
.modal-overlay { opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.modal-overlay.active { opacity: 1; pointer-events: all; }

/* Badge aliases */
.badge-success { background: var(--green-100);  color: var(--green-700); }
.badge-warning { background: var(--amber-100);  color: var(--amber-700); }
.badge-danger  { background: var(--red-100);    color: var(--red-600); }
.badge-primary { background: var(--blue-50);    color: var(--blue-700); }

/* Table helper class */
.table { width: 100%; border-collapse: collapse; }

/* Spinner centered */
.spinner-center {
  display: flex; justify-content: center; align-items: center;
  padding: 60px 0;
}
.spinner-center .spinner {
  border-color: var(--blue-200);
  border-top-color: var(--blue-600);
  width: 28px; height: 28px;
}

/* Modal large */
.modal-lg { max-width: 760px !important; }

/* Item row background alternado */
.item-row { border: 1px solid var(--border) !important; }

/* bg helpers */
.bg-secondary { background: var(--slate-50); }
.bg-tertiary  { background: var(--slate-100); }

