/* OrcaPro BR — Design System
   Sem Bootstrap, sem Tailwind. CSS custom puro.
   Inter é carregada via <link> em header.php — sem @import aqui.
   ================================================== */

/* ─── Variáveis — tema claro ──────────────────────────────────────────────── */
:root {
  /* Cores */
  --color-primary:        #2563eb;
  --color-primary-hover:  #1d4ed8;
  --color-primary-light:  #eff6ff;
  --color-secondary:      #64748b;
  --color-success:        #16a34a;
  --color-success-light:  #f0fdf4;
  --color-danger:         #dc2626;
  --color-danger-light:   #fef2f2;
  --color-warning:        #d97706;
  --color-warning-light:  #fffbeb;
  --color-info:           #0891b2;
  --color-info-light:     #ecfeff;

  /* Layout */
  --bg-page:    #f1f5f9;
  --bg-card:    #ffffff;
  --bg-sidebar: #1e293b;
  --bg-input:   #ffffff;

  /* Texto */
  --text-primary:   #1e293b;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-invert:    #f8fafc;

  /* Bordas */
  --border-color:   #e2e8f0;
  --border-input:   #cbd5e1;
  --border-focus:   #2563eb;

  /* Sidebar */
  --sidebar-width:       260px;
  --sidebar-text:        #94a3b8;
  --sidebar-text-hover:  #f1f5f9;
  --sidebar-active-bg:   rgba(255,255,255,.08);
  --sidebar-active-text: #ffffff;
  --sidebar-section:     #64748b;

  /* Topbar */
  --topbar-height: 64px;
  --topbar-bg:     #ffffff;
  --topbar-border: #e2e8f0;

  /* Tipografia */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Courier New', monospace;

  /* Espaçamentos */
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;

  /* Raio de borda */
  --radius-sm: 4px;
  --radius:    8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Sombras */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 6px rgba(0,0,0,.05), 0 2px 4px rgba(0,0,0,.04);
  --shadow-md: 0 6px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 24px rgba(0,0,0,.10);

  /* Transições */
  --transition: .15s ease;
  --transition-slow: .25s ease;
}

/* ─── Tema escuro ─────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg-page:    #0f172a;
  --bg-card:    #1e293b;
  --bg-input:   #1e293b;
  --bg-sidebar: #0a1628;

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;

  --border-color: #334155;
  --border-input: #475569;

  --topbar-bg:     #1e293b;
  --topbar-border: #334155;

  --sidebar-active-bg: rgba(255,255,255,.06);

  --color-primary-light: rgba(37,99,235,.15);
  --color-success-light: rgba(22,163,74,.12);
  --color-danger-light:  rgba(220,38,38,.12);
  --color-warning-light: rgba(217,119,6,.12);
  --color-info-light:    rgba(8,145,178,.12);

  --shadow-xs: 0 1px 2px rgba(0,0,0,.3);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow:    0 4px 6px rgba(0,0,0,.3);
  --shadow-md: 0 6px 16px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 24px rgba(0,0,0,.5);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: .9375rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

button { cursor: pointer; font-family: var(--font); }

hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: var(--space-4) 0;
}

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

/* ─── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: transform var(--transition-slow);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-5);
  border-bottom: 1px solid rgba(255,255,255,.06);
  text-decoration: none;
}
.sidebar-logo:hover { text-decoration: none; }

.sidebar-logo .logo-icon-wrap {
  width: 34px; height: 34px;
  background: var(--color-primary);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-logo .logo-name {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-invert);
  letter-spacing: -.01em;
}
.sidebar-logo .logo-tagline {
  font-size: .7rem;
  color: var(--sidebar-section);
  margin-top: 1px;
  font-weight: 400;
}

.sidebar-nav { flex: 1; padding: var(--space-4) var(--space-3); }

.nav-section {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--sidebar-section);
  padding: var(--space-5) var(--space-3) var(--space-2);
}
.nav-section:first-child { padding-top: var(--space-2); }

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--sidebar-text);
  font-size: .875rem;
  font-weight: 400;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
  position: relative;
}
.nav-link:hover { background: var(--sidebar-active-bg); color: var(--sidebar-text-hover); text-decoration: none; }
.nav-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 500;
}
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--color-primary);
  border-radius: 0 3px 3px 0;
}

.nav-link .nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: .7;
}
.nav-link:hover .nav-icon,
.nav-link.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid rgba(255,255,255,.06);
}

.sidebar-user {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--sidebar-text);
  font-size: .8125rem;
  transition: background var(--transition);
}
.sidebar-user:hover { background: var(--sidebar-active-bg); color: var(--sidebar-text-hover); text-decoration: none; }

.user-avatar {
  width: 30px; height: 30px;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info .name { font-weight: 500; color: var(--sidebar-text-hover); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info .company { font-size: .7rem; color: var(--sidebar-section); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

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

/* ─── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: var(--space-2);
  border-radius: var(--radius);
}
.topbar-toggle:hover { background: var(--bg-page); }

.topbar-breadcrumb { flex: 1; }
.topbar-breadcrumb h1 {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
}
.breadcrumb-path {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 1px;
}
.breadcrumb-path a { color: var(--text-muted); }
.breadcrumb-path a:hover { color: var(--color-primary); }

.topbar-actions { display: flex; align-items: center; gap: var(--space-3); }

.topbar-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: var(--space-2);
  border-radius: var(--radius);
  display: flex; align-items: center; gap: var(--space-2);
  font-size: .875rem;
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}
.topbar-btn:hover { background: var(--bg-page); color: var(--text-primary); text-decoration: none; }

/* ─── Main content ────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: var(--space-6);
  max-width: 1400px;
  width: 100%;
}

/* ─── Page header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.page-header-left h2 { font-size: 1.375rem; font-weight: 700; color: var(--text-primary); }
.page-header-left p { font-size: .875rem; color: var(--text-secondary); margin-top: var(--space-1); }
.page-header-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-color);
  gap: var(--space-4);
  flex-wrap: wrap;
}
.card-header h3 { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.card-body { padding: var(--space-5); }
.card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-color);
  background: var(--bg-page);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ─── Metric cards ────────────────────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.metric-card .metric-label {
  font-size: .8125rem;
  color: var(--text-secondary);
  font-weight: 500;
  display: flex; align-items: center; gap: var(--space-2);
}
.metric-card .metric-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}
.metric-card .metric-value {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.metric-card .metric-sub {
  font-size: .8rem;
  color: var(--text-muted);
}
.metric-card.primary .metric-icon { background: var(--color-primary-light); color: var(--color-primary); }
.metric-card.success .metric-icon { background: var(--color-success-light); color: var(--color-success); }
.metric-card.danger  .metric-icon { background: var(--color-danger-light);  color: var(--color-danger); }
.metric-card.warning .metric-icon { background: var(--color-warning-light); color: var(--color-warning); }
.metric-card.info    .metric-icon { background: var(--color-info-light);    color: var(--color-info); }

/* ─── Botões ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
  text-decoration: none;
  line-height: 1.5;
  white-space: nowrap;
  font-family: var(--font);
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[disabled] { opacity: .55; pointer-events: none; }

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

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-secondary:hover { background: var(--bg-page); border-color: var(--border-input); }

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

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

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-page); color: var(--text-primary); }

.btn-sm { padding: var(--space-1) var(--space-3); font-size: .8125rem; }
.btn-lg { padding: .625rem var(--space-6); font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: var(--space-2); width: 36px; height: 36px; justify-content: center; }
.btn-icon.btn-sm { width: 30px; height: 30px; padding: var(--space-1); }

/* ─── Formulários ─────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}
.form-group:last-child { margin-bottom: 0; }

.form-label {
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.form-label-link {
  font-size: .8rem;
  font-weight: 400;
  color: var(--color-primary);
}

.form-control,
.form-select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  font-size: .9375rem;
  color: var(--text-primary);
  font-family: var(--font);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.form-control:focus,
.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-control::placeholder { color: var(--text-muted); }

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
  cursor: pointer;
}

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

.form-control.is-invalid { border-color: var(--color-danger); }
.form-control.is-valid   { border-color: var(--color-success); }

.form-error {
  font-size: .8rem;
  color: var(--color-danger);
  margin-top: var(--space-1);
}

.form-hint {
  font-size: .8rem;
  color: var(--text-muted);
}

.form-row {
  display: grid;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.form-row .form-group { margin-bottom: 0; }
.form-row.col-2 { grid-template-columns: 1fr 1fr; }
.form-row.col-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.col-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-row.col-1-2 { grid-template-columns: 1fr 2fr; }
.form-row.col-2-1 { grid-template-columns: 2fr 1fr; }
.form-row.col-3-1 { grid-template-columns: 3fr 1fr; }

.input-password { position: relative; }
.input-password .form-control { padding-right: 2.5rem; }
.btn-toggle-pwd {
  position: absolute;
  right: var(--space-2);
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  padding: var(--space-1);
  cursor: pointer;
  display: flex; align-items: center;
}
.btn-toggle-pwd:hover { color: var(--text-primary); }

.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .btn { border-radius: 0 var(--radius) var(--radius) 0; border-left: none; }

/* ─── Tabelas ─────────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead th {
  background: var(--bg-page);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

tbody td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-page); }

.table-actions {
  display: flex;
  gap: var(--space-1);
  justify-content: flex-end;
  white-space: nowrap;
}

td.td-right, th.th-right { text-align: right; }
td.td-center, th.th-center { text-align: center; }
td.td-nowrap { white-space: nowrap; }
td.td-mono { font-family: var(--font-mono); font-size: .8rem; }

/* ─── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.badge-primary   { background: var(--color-primary-light);  color: var(--color-primary); }
.badge-success   { background: var(--color-success-light);  color: var(--color-success); }
.badge-danger    { background: var(--color-danger-light);   color: var(--color-danger); }
.badge-warning   { background: var(--color-warning-light);  color: var(--color-warning); }
.badge-info      { background: var(--color-info-light);     color: var(--color-info); }
.badge-secondary { background: var(--bg-page); color: var(--text-secondary); border: 1px solid var(--border-color); }

/* ─── Alertas ─────────────────────────────────────────────────────────────── */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: var(--space-4);
  border-left: 4px solid transparent;
}
.alert-success { background: var(--color-success-light); color: #14532d; border-color: var(--color-success); }
.alert-danger  { background: var(--color-danger-light);  color: #7f1d1d; border-color: var(--color-danger); }
.alert-warning { background: var(--color-warning-light); color: #78350f; border-color: var(--color-warning); }
.alert-info    { background: var(--color-info-light);    color: #164e63; border-color: var(--color-info); }

[data-theme="dark"] .alert-success { color: #bbf7d0; }
[data-theme="dark"] .alert-danger  { color: #fecaca; }
[data-theme="dark"] .alert-warning { color: #fde68a; }
[data-theme="dark"] .alert-info    { color: #a5f3fc; }

/* ─── Toasts ──────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-lg);
  font-size: .875rem;
  color: var(--text-primary);
  min-width: 240px;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  pointer-events: all;
  animation: toast-in .2s ease forwards;
}
.toast.toast-success { border-left: 4px solid var(--color-success); }
.toast.toast-danger  { border-left: 4px solid var(--color-danger); }
.toast.toast-warning { border-left: 4px solid var(--color-warning); }
.toast.toast-info    { border-left: 4px solid var(--color-info); }
.toast.toast-out     { animation: toast-out .2s ease forwards; }

@keyframes toast-in  { from { opacity:0; transform: translateX(1rem); } to { opacity:1; transform: none; } }
@keyframes toast-out { from { opacity:1; transform: none; } to { opacity:0; transform: translateX(1rem); } }

.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-body { flex: 1; }
.toast-close { background:none; border:none; color: var(--text-muted); cursor:pointer; font-size:1rem; padding:0; }

/* ─── Modais ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
  backdrop-filter: blur(2px);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(.75rem) scale(.97);
  transition: transform var(--transition-slow);
}
.modal-overlay.open .modal { transform: none; }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5);
  border-bottom: 1px solid var(--border-color);
}
.modal-header h4 { font-size: 1rem; font-weight: 600; }
.modal-close { background:none; border:none; color: var(--text-muted); font-size:1.25rem; cursor:pointer; }
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: var(--space-5); }

.modal-footer {
  display: flex; justify-content: flex-end; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-color);
  background: var(--bg-page);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ─── Paginação ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: var(--space-1);
  justify-content: center;
  margin-top: var(--space-5);
  flex-wrap: wrap;
}
.pagination a,
.pagination span {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius);
  font-size: .875rem;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  text-decoration: none;
  transition: background var(--transition);
}
.pagination a:hover { background: var(--bg-page); color: var(--text-primary); text-decoration: none; }
.pagination .active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); font-weight: 600; }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* ─── Busca / filtros ─────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.search-bar .form-control { max-width: 320px; }
.search-bar .form-select  { max-width: 160px; }

/* ─── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-10) var(--space-6);
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: var(--space-4); opacity: .4; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: var(--space-2); }
.empty-state p  { font-size: .875rem; margin-bottom: var(--space-4); }

/* ─── Dashboard — layout grid ────────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-6);
}

.dashboard-section-title {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  display: flex; align-items: center; gap: var(--space-2);
}

/* ─── Orçamento — form de itens ───────────────────────────────────────────── */
.items-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.items-table th {
  background: var(--bg-page);
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}
.items-table td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border-color); }
.items-table td input, .items-table td select { padding: var(--space-1) var(--space-2); font-size: .875rem; }
.items-table .total-row td { background: var(--bg-page); font-weight: 600; border-bottom: none; }

/* ─── Autocomplete ────────────────────────────────────────────────────────── */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 220px;
  overflow-y: auto;
  width: 100%;
  top: 100%; left: 0;
  margin-top: 2px;
  display: none;
}
.autocomplete-list.open { display: block; }
.autocomplete-item {
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  font-size: .875rem;
  color: var(--text-primary);
}
.autocomplete-item:hover,
.autocomplete-item.highlighted { background: var(--bg-page); }
.autocomplete-item strong { color: var(--color-primary); }

/* ─── Impressão ───────────────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .page-header-actions, .btn, .no-print { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .main-content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }

  .print-header { display: flex !important; }
  body { font-size: 12px; }
  table { page-break-inside: auto; }
  tr { page-break-inside: avoid; }
}

.print-header {
  display: none;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #1e293b;
}

/* ─── Auth pages ──────────────────────────────────────────────────────────── */
.auth-page {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

.auth-wrapper { width: 100%; max-width: 420px; }

.auth-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  text-align: center;
  margin-bottom: var(--space-6);
}
.auth-logo a {
  display: inline-flex; align-items: center; gap: var(--space-2);
  text-decoration: none;
  justify-content: center;
}
.logo-icon { font-size: 1.75rem; }
.logo-text { font-size: 1.5rem; font-weight: 800; color: var(--text-primary); letter-spacing: -.03em; }

.auth-subtitle {
  color: var(--text-muted);
  font-size: .875rem;
  margin-top: var(--space-2);
}

.auth-form { display: flex; flex-direction: column; gap: var(--space-1); }
.auth-footer-text { text-align: center; font-size: .875rem; color: var(--text-muted); margin-top: var(--space-5); }

/* ─── Misc utilitários ────────────────────────────────────────────────────── */
.text-muted     { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary   { color: var(--color-primary) !important; }
.text-success   { color: var(--color-success); }
.text-danger    { color: var(--color-danger); }
.text-warning   { color: var(--color-warning); }
.text-right     { text-align: right; }
.text-center    { text-align: center; }
.font-bold      { font-weight: 700; }
.font-semibold  { font-weight: 600; }
.font-mono      { font-family: var(--font-mono); }
.d-none         { display: none !important; }
.d-flex         { display: flex; }
.d-block        { display: block; }
.gap-2          { gap: var(--space-2); }
.gap-3          { gap: var(--space-3); }
.gap-4          { gap: var(--space-4); }
.w-100          { width: 100%; }
.mt-1           { margin-top: var(--space-1); }
.mt-2           { margin-top: var(--space-2); }
.mt-3           { margin-top: var(--space-3); }
.mt-4           { margin-top: var(--space-4); }
.mt-5           { margin-top: var(--space-5); }
.mb-1           { margin-bottom: var(--space-1); }
.mb-2           { margin-bottom: var(--space-2); }
.mb-3           { margin-bottom: var(--space-3); }
.mb-4           { margin-bottom: var(--space-4); }
.mb-5           { margin-bottom: var(--space-5); }
.me-2           { margin-right: var(--space-2); }
.ms-auto        { margin-left: auto; }
.p-0            { padding: 0 !important; }
.align-center   { align-items: center; }
.justify-between{ justify-content: space-between; }
.flex-wrap      { flex-wrap: wrap; }

/* Spinner */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Divider */
.divider { border: none; border-top: 1px solid var(--border-color); margin: var(--space-5) 0; }

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, var(--border-color) 25%, var(--bg-page) 50%, var(--border-color) 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.4s infinite;
  border-radius: var(--radius);
  height: 1rem;
}
@keyframes skeleton-loading { to { background-position: -200% 0; } }

/* Estoque baixo */
.estoque-baixo { color: var(--color-danger); font-weight: 600; }

/* Valor financeiro positivo/negativo */
.valor-pos { color: var(--color-success); font-weight: 600; }
.valor-neg { color: var(--color-danger); font-weight: 600; }

/* ─── Responsivo ──────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-width: 220px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }

  .main-wrapper { margin-left: 0; }
  .topbar-toggle { display: flex; }

  .main-content { padding: var(--space-4); }

  .form-row.col-2,
  .form-row.col-3,
  .form-row.col-4,
  .form-row.col-1-2,
  .form-row.col-2-1,
  .form-row.col-3-1 { grid-template-columns: 1fr; }

  .page-header { flex-direction: column; align-items: flex-start; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }

  .auth-card { padding: var(--space-6); }
}

@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .table-actions .btn-icon span { display: none; }
}

/* Overlay sidebar mobile */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}
.sidebar-overlay.open { display: block; }
