/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --primary:        #2d7a5f;
  --primary-dark:   #1e5940;
  --primary-deeper: #143d29;
  --primary-light:  #3d9b77;
  --primary-pale:   #e8f5f0;
  --primary-faint:  #f4faf7;

  --sidebar-bg:     #162d22;
  --sidebar-hover:  rgba(255,255,255,.07);
  --sidebar-active: #2d7a5f;
  --sidebar-text:   rgba(255,255,255,.82);
  --sidebar-muted:  rgba(255,255,255,.45);
  --sidebar-border: rgba(255,255,255,.08);

  --text:           #1a2820;
  --text-2:         #4a6a58;
  --text-muted:     #8aaa98;
  --white:          #ffffff;
  --bg:             #f5faf7;
  --border:         #d0e8dc;
  --border-light:   #e8f3ee;

  --amber:          #d97706;
  --amber-bg:       #fffbeb;
  --amber-border:   #fde68a;
  --red:            #dc2626;
  --red-bg:         #fef2f2;
  --red-border:     #fecaca;
  --blue:           #2563eb;
  --blue-bg:        #eff6ff;
  --blue-border:    #bfdbfe;
  --purple:         #7c3aed;
  --purple-bg:      #f5f3ff;
  --purple-border:  #ddd6fe;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,.09), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg:  0 10px 30px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.06);

  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  16px;

  --sidebar-w:  240px;
  --sidebar-collapsed-w: 64px;
  --transition: 220ms ease;

  font-size: 14px;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { font-family: 'Lora', Georgia, serif; font-weight: 600; line-height: 1.2; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; }
.hidden { display: none !important; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(22,45,34,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; backdrop-filter: blur(3px);
}
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.25);
  border-top-color: var(--white);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   LOGIN
   ============================================================ */
.login-screen {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--primary-deeper) 0%, var(--primary-dark) 50%, var(--primary) 100%);
}
.login-bg {
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.login-card {
  position: relative; width: 100%; max-width: 400px; margin: 20px;
  background: var(--white); border-radius: var(--radius-lg);
  padding: 44px 40px; box-shadow: var(--shadow-lg);
}
.login-brand { text-align: center; margin-bottom: 36px; }
.login-logo-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; background: var(--primary-pale);
  border-radius: 16px; font-size: 24px; color: var(--primary);
  margin-bottom: 14px;
}
.login-title { font-size: 1.6rem; color: var(--text); margin-bottom: 4px; }
.login-subtitle { color: var(--text-muted); font-size: .88rem; font-weight: 500; }
.login-error {
  background: var(--red-bg); border: 1px solid var(--red-border);
  color: var(--red); border-radius: var(--radius-sm);
  padding: 10px 14px; margin-bottom: 16px; font-size: .88rem;
}

/* ============================================================
   FORMS (shared)
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--text-2); letter-spacing: .02em; text-transform: uppercase; }
.form-group input,
.form-group select,
.form-group textarea {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; color: var(--text); background: var(--white);
  outline: none; transition: border-color var(--transition);
  width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--primary); }
.form-group textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 9px 18px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: .88rem; transition: all var(--transition);
  white-space: nowrap; cursor: pointer;
}
.btn-primary {
  background: var(--primary); color: var(--white);
  border: 1.5px solid var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline {
  background: transparent; color: var(--primary);
  border: 1.5px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary); background: var(--primary-pale); }
.btn-danger {
  background: var(--red); color: var(--white);
  border: 1.5px solid var(--red);
}
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-full { width: 100%; }
.btn-icon {
  padding: 6px; border-radius: var(--radius-sm);
  color: var(--text-muted); transition: all var(--transition);
}
.btn-icon:hover { background: var(--primary-pale); color: var(--primary); }

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

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  flex-shrink: 0; overflow: hidden;
  transition: width var(--transition);
}
.sidebar.collapsed { width: var(--sidebar-collapsed-w); }
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-user-info,
.sidebar.collapsed .nav-badge { display: none; }
.sidebar.collapsed .sidebar-brand { justify-content: center; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .sidebar-user { justify-content: center; }
.sidebar.collapsed .btn-logout { display: none; }

.sidebar-header {
  padding: 18px 16px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; overflow: hidden; }
.sidebar-logo-mark { font-size: 20px; color: var(--primary-light); flex-shrink: 0; }
.sidebar-brand-name { color: var(--white); font-family: 'Lora', serif; font-weight: 600; font-size: 1rem; white-space: nowrap; }
.sidebar-brand-sub { color: var(--sidebar-muted); font-size: .72rem; white-space: nowrap; }
.sidebar-collapse-btn {
  color: var(--sidebar-muted); font-size: 18px;
  padding: 4px; flex-shrink: 0; transition: color var(--transition);
}
.sidebar-collapse-btn:hover { color: var(--white); }

.sidebar-nav {
  flex: 1; padding: 10px 8px; display: flex;
  flex-direction: column; gap: 2px; overflow-y: auto; overflow-x: hidden;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); text-decoration: none;
  transition: all var(--transition); position: relative;
  font-size: .88rem; font-weight: 500; white-space: nowrap;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--white); text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: var(--white); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: var(--red); color: var(--white);
  font-size: .7rem; font-weight: 700; padding: 1px 6px;
  border-radius: 20px; min-width: 18px; text-align: center;
}

.sidebar-footer {
  padding: 12px 8px; border-top: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: 8px;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; flex: 1; overflow: hidden; }
.sidebar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .88rem; flex-shrink: 0;
}
.sidebar-user-name { color: var(--sidebar-text); font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { color: var(--sidebar-muted); font-size: .72rem; }
.btn-logout {
  color: var(--sidebar-muted); padding: 6px; border-radius: var(--radius-sm);
  transition: all var(--transition); flex-shrink: 0;
}
.btn-logout:hover { color: var(--white); background: var(--sidebar-hover); }

/* ── Main ────────────────────────────────────────────── */
.main {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0;
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 10px 24px; display: flex; align-items: center;
  gap: 12px; flex-wrap: wrap; flex-shrink: 0;
}
.filter-presets { display: flex; gap: 4px; flex-wrap: wrap; }
.filter-btn {
  padding: 5px 12px; border-radius: 20px; font-size: .8rem; font-weight: 600;
  color: var(--text-2); border: 1.5px solid var(--border);
  background: var(--white); transition: all var(--transition);
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active { background: var(--primary); color: var(--white); border-color: var(--primary); }
.filter-custom { display: flex; align-items: center; gap: 8px; }
.filter-custom input { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 5px 10px; font-size: .82rem; color: var(--text); outline: none; }
.filter-custom input:focus { border-color: var(--primary); }
.filter-sep { color: var(--text-muted); font-size: .82rem; }
.filter-label { margin-left: auto; color: var(--text-muted); font-size: .8rem; white-space: nowrap; }

/* ============================================================
   VIEWS
   ============================================================ */
.main > section.view,
.main > .filter-bar { /* already handled */ }

section.view {
  flex: 1; overflow-y: auto; padding: 24px;
  display: flex; flex-direction: column; gap: 20px;
}

.view-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
}
.view-title { font-size: 1.5rem; color: var(--text); }
.view-period { color: var(--text-muted); font-size: .88rem; font-weight: 500; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--white); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-header h3 { font-size: 1rem; color: var(--text); }

/* ============================================================
   KPI GRID
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.kpi-card {
  background: var(--white); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 20px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0;
  width: 4px; height: 100%; border-radius: 4px 0 0 4px;
}
.kpi-green::before  { background: var(--primary); }
.kpi-amber::before  { background: var(--amber); }
.kpi-red::before    { background: var(--red); }
.kpi-blue::before   { background: var(--blue); }
.kpi-sage::before   { background: #5ba88a; }
.kpi-purple::before { background: var(--purple); }

.kpi-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 8px; }
.kpi-value { font-family: 'Lora', serif; font-size: 1.6rem; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.kpi-meta { font-size: .78rem; color: var(--text-muted); }

/* ============================================================
   ALERT
   ============================================================ */
.alert-nf {
  display: flex; align-items: center; gap: 10px;
  background: var(--amber-bg); border: 1px solid var(--amber-border);
  border-radius: var(--radius); padding: 12px 16px; color: var(--amber);
  font-size: .88rem;
}
.alert-nf svg { flex-shrink: 0; }
.alert-link { color: var(--amber); font-weight: 600; }

/* ============================================================
   DASHBOARD GRID
   ============================================================ */
.dashboard-grid {
  display: grid; grid-template-columns: 2fr 1fr; gap: 20px;
}
.chart-wrap { padding: 16px; height: 260px; position: relative; }
.recent-list { padding: 8px 0; max-height: 310px; overflow-y: auto; }
.recent-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; border-bottom: 1px solid var(--border-light);
  gap: 12px; font-size: .85rem;
}
.recent-item:last-child { border-bottom: none; }
.recent-item-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recent-item-name { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-item-meta { color: var(--text-muted); font-size: .78rem; }
.recent-item-right { text-align: right; flex-shrink: 0; }
.recent-item-value { font-weight: 700; color: var(--text); }
.recent-item-type { font-size: .75rem; color: var(--text-muted); }

/* ============================================================
   TABLES
   ============================================================ */
.table-card .table-toolbar {
  padding: 14px 20px; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--border-light);
}
.search-input {
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 12px; width: 280px; outline: none;
  transition: border-color var(--transition); font-size: .88rem;
}
.search-input:focus { border-color: var(--primary); }
.table-summary { color: var(--text-muted); font-size: .82rem; font-weight: 600; }
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse; font-size: .85rem;
}
.data-table th {
  background: var(--bg); padding: 10px 16px; font-weight: 700;
  text-align: left; color: var(--text-2); font-size: .78rem;
  text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 16px; border-bottom: 1px solid var(--border-light);
  color: var(--text); vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--primary-faint); }
.text-right { text-align: right !important; }
.value-cell { font-weight: 700; font-variant-numeric: tabular-nums; }
.empty-row { text-align: center; color: var(--text-muted); padding: 32px 16px !important; }
.empty-state { text-align: center; color: var(--text-muted); padding: 24px 16px; font-size: .88rem; }

/* Status Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px; font-size: .75rem; font-weight: 700;
  white-space: nowrap;
}
.badge-pix      { background: #d1fae5; color: #065f46; }
.badge-pendente { background: var(--amber-bg); color: #92400e; }
.badge-gratuito { background: var(--blue-bg); color: #1e40af; }
.badge-emitida  { background: #d1fae5; color: #065f46; }
.badge-isenta   { background: var(--blue-bg); color: #1e40af; }
.badge-nf-pendente { background: var(--amber-bg); color: #92400e; }

/* Consultation type */
.type-tag {
  font-size: .75rem; font-weight: 600; color: var(--primary-dark);
  background: var(--primary-pale); padding: 3px 8px; border-radius: 4px;
  white-space: nowrap;
}
.cat-tag {
  font-size: .75rem; font-weight: 600; color: var(--text-2);
  background: var(--bg); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 4px; white-space: nowrap;
}

/* Action buttons in table */
.action-btns { display: flex; gap: 4px; align-items: center; }
.btn-edit, .btn-del { padding: 5px 10px; border-radius: var(--radius-sm); font-size: .78rem; font-weight: 600; transition: all var(--transition); }
.btn-edit { color: var(--primary); background: var(--primary-pale); }
.btn-edit:hover { background: var(--primary); color: var(--white); }
.btn-del { color: var(--red); background: var(--red-bg); }
.btn-del:hover { background: var(--red); color: var(--white); }
.btn-received { padding: 5px 10px; border-radius: var(--radius-sm); font-size: .78rem; font-weight: 600; background: var(--primary); color: var(--white); transition: all var(--transition); }
.btn-received:hover { background: var(--primary-dark); }

/* ============================================================
   INADIMPLÊNCIA
   ============================================================ */
.inadimplencia-summary {
  background: var(--red-bg); border: 1px solid var(--red-border);
  border-radius: var(--radius); padding: 14px 20px;
  display: flex; align-items: center; gap: 12px;
}
.days-badge {
  font-size: .78rem; font-weight: 700; padding: 3px 8px;
  border-radius: 4px; white-space: nowrap;
}
.days-ok      { background: #d1fae5; color: #065f46; }
.days-warning { background: var(--amber-bg); color: #92400e; }
.days-danger  { background: var(--red-bg); color: #991b1b; }

/* ============================================================
   SECRETARY PANEL
   ============================================================ */
.sec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.sec-card { padding: 0; }
.sec-card .card-header { padding: 16px 20px; }
.sec-card form { padding: 16px 20px; }

.sec-card-wide { grid-column: 1 / -1; }

.nf-actions { display: flex; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--border-light); flex-wrap: wrap; }
.nf-link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: var(--radius-sm); font-size: .8rem; font-weight: 600;
  background: var(--primary-pale); color: var(--primary); border: 1px solid var(--border);
  transition: all var(--transition); text-decoration: none;
}
.nf-link-btn:hover { background: var(--primary); color: var(--white); border-color: var(--primary); text-decoration: none; }

.badge-pill {
  background: var(--primary); color: var(--white);
  font-size: .75rem; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; min-width: 22px; text-align: center;
}

.nf-list { max-height: 280px; overflow-y: auto; }
.nf-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; border-bottom: 1px solid var(--border-light);
  gap: 12px; font-size: .83rem;
}
.nf-item:last-child { border-bottom: none; }
.nf-item-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nf-item-name { font-weight: 600; color: var(--text); }
.nf-item-meta { color: var(--text-muted); font-size: .75rem; }
.nf-item-value { font-weight: 700; color: var(--text); flex-shrink: 0; }

.notas-list { padding: 12px 20px; display: flex; flex-direction: column; gap: 10px; max-height: 400px; overflow-y: auto; }
.nota-item {
  background: var(--primary-faint); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); padding: 12px 14px;
  position: relative;
}
.nota-content { font-size: .88rem; color: var(--text); white-space: pre-wrap; line-height: 1.5; }
.nota-meta { font-size: .75rem; color: var(--text-muted); margin-top: 8px; display: flex; align-items: center; justify-content: space-between; }
.nota-actions { display: flex; gap: 6px; }

/* ============================================================
   DRE
   ============================================================ */
.dre-layout { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; }
.dre-table-card { padding: 0; }
.dre-charts { display: flex; flex-direction: column; gap: 20px; }
.chart-card-sm { }
.chart-wrap-sm { padding: 12px; height: 180px; position: relative; }

.dre-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.dre-table th {
  background: var(--bg); padding: 10px 20px;
  font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-2);
  border-bottom: 1px solid var(--border); text-align: left;
}
.dre-table th:not(:first-child) { text-align: right; }
.dre-table td { padding: 9px 20px; border-bottom: 1px solid var(--border-light); }
.dre-table td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.dre-section-header td {
  background: var(--bg); font-family: 'Lora', serif; font-weight: 600;
  color: var(--primary-dark); font-size: .9rem; padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.dre-subtotal td {
  background: var(--primary-faint); font-weight: 700;
  border-top: 2px solid var(--border); border-bottom: 2px solid var(--border);
}
.dre-total td {
  background: var(--primary-pale); font-weight: 800;
  border-top: 2px solid var(--primary); color: var(--primary-dark);
  font-size: .95rem;
}
.dre-positive { color: var(--primary) !important; }
.dre-negative { color: var(--red) !important; }

/* ============================================================
   IMPORT
   ============================================================ */
.import-card { padding: 28px; display: flex; flex-direction: column; gap: 24px; }
.import-instructions h3 { font-size: 1rem; margin-bottom: 10px; }
.import-instructions ol { padding-left: 18px; display: flex; flex-direction: column; gap: 4px; font-size: .88rem; color: var(--text-2); }
.import-note { font-size: .82rem; color: var(--text-muted); margin-top: 10px; }
.import-note code { background: var(--bg); padding: 1px 5px; border-radius: 3px; font-size: .8rem; }

.upload-area {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 40px 20px; cursor: pointer; transition: all var(--transition);
  background: var(--bg);
}
.upload-area:hover { border-color: var(--primary); background: var(--primary-pale); }
.upload-area.dragover { border-color: var(--primary); background: var(--primary-pale); }
.upload-icon { font-size: 2.5rem; }
.upload-text { font-weight: 600; color: var(--text-2); }
.upload-sub { font-size: .82rem; color: var(--text-muted); }

.import-mapping { display: flex; flex-direction: column; gap: 14px; }
.import-mapping h3 { font-size: 1rem; }
.mapping-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.mapping-item { display: flex; flex-direction: column; gap: 6px; }
.mapping-item label { font-size: .78rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
.import-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.import-result {
  background: var(--primary-pale); border: 1px solid var(--primary-light);
  border-radius: var(--radius); padding: 16px; font-size: .88rem; color: var(--primary-dark);
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; backdrop-filter: blur(3px); padding: 20px;
}
.modal {
  background: var(--white); border-radius: var(--radius-lg);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-in .18s ease;
}
.modal-sm { max-width: 420px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(-12px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; color: var(--text); }
.modal-close-btn {
  color: var(--text-muted); font-size: 1rem; padding: 4px 8px;
  border-radius: var(--radius-sm); transition: all var(--transition);
}
.modal-close-btn:hover { background: var(--bg); color: var(--text); }
.modal form { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding-top: 8px; border-top: 1px solid var(--border-light);
  margin-top: 4px;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--text); color: var(--white);
  border-radius: var(--radius); padding: 12px 18px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-lg); z-index: 2000;
  font-size: .88rem; font-weight: 600; min-width: 240px;
  animation: toast-in .2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.toast.toast-success { background: #065f46; }
.toast.toast-error   { background: #991b1b; }
.toast.toast-info    { background: #1e40af; }
.toast-icon { font-size: 1rem; }

/* ============================================================
   RESPONSIVE — collapse sidebar on narrow screens
   ============================================================ */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dre-layout { grid-template-columns: 1fr; }
  .sec-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .sec-card-wide { grid-column: auto; }
}
@media (max-width: 680px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .sidebar { width: var(--sidebar-collapsed-w); }
  .sidebar .sidebar-brand-text,
  .sidebar .nav-label,
  .sidebar .sidebar-user-info,
  .sidebar .nav-badge { display: none; }
  .sidebar .sidebar-brand { justify-content: center; }
  .sidebar .nav-item { justify-content: center; padding: 10px; }
  .sidebar .sidebar-user { justify-content: center; }
  .sidebar .btn-logout { display: none; }
  section.view { padding: 16px; }
}
