/* ============================================================
   Kion Dental — Sistema de Autorização de Pagamentos
   Design System v3 — Modern Refresh
   ============================================================ */

/* ── CUSTOM PROPERTIES ──────────────────────────────────── */
:root {
  --navy:          #1a365d;
  --navy-dark:     #0f2440;
  --navy-mid:      #275280;
  --teal:          #0891b2;
  --teal-dark:     #0e7490;
  --teal-light:    #ecfeff;
  --lime:          #65a30d;
  --lime-light:    #f7fee7;
  --slate:         #f1f5f9;
  --white:         #ffffff;
  --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;
  --red:           #ef4444;
  --red-light:     #fef2f2;
  --orange:        #f97316;
  --orange-light:  #fff7ed;
  --green:         #22c55e;
  --green-light:   #f0fdf4;
  --yellow:        #eab308;
  --yellow-light:  #fefce8;

  --radius-sm:     8px;
  --radius:        10px;
  --radius-lg:     14px;
  --radius-xl:     18px;
  --radius-pill:   999px;

  --shadow-xs:  0 1px 2px rgba(0,0,0,.04);
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:     0 4px 12px rgba(0,0,0,.06), 0 1px 4px rgba(0,0,0,.04);
  --shadow-lg:  0 10px 32px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.04);
  --shadow-xl:  0 24px 56px rgba(0,0,0,.12), 0 8px 20px rgba(0,0,0,.06);

  --bg:         #f4f6fa;
  --surface:    var(--white);
  --border:     var(--gray-200);
  --text:       var(--gray-800);
  --text-muted: var(--gray-500);

  --transition-fast: .15s cubic-bezier(.4,0,.2,1);
  --transition:      .2s cubic-bezier(.4,0,.2,1);
}

/* ── DARK MODE TOKENS ───────────────────────────────────── */
body.dark-mode {
  --bg:         #0b0f19;
  --surface:    #141a27;
  --border:     #1e2a3a;
  --text:       #d1d9e6;
  --text-muted: #6b7a90;
  --gray-50:    #111827;
  --gray-100:   #151d2e;
  --gray-200:   #1e2a3a;
  --gray-300:   #2a3a50;
  --gray-400:   #4a5c73;
  --gray-500:   #6b7a90;
  --gray-600:   #8b9bb0;
  --gray-700:   #b0bdd0;
  --gray-800:   #e2e8f0;
  --navy:       #60a5fa;
  --teal:       #22d3ee;
  --teal-dark:  #06b6d4;
  --teal-light: #0c1e2a;
  --lime-light: #0d1f10;
  --red:        #f87171;
  --red-light:  #1e0c10;
  --orange:     #fb923c;
  --orange-light:#1e1400;
  --green:      #4ade80;
  --green-light: #0d1f10;
  --yellow:     #facc15;
  --yellow-light:#1a1800;
}

/* ── RESET & BASE ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

a { color: var(--teal-dark); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--teal); text-decoration: none; }
body.dark-mode a { color: var(--teal); }
body.dark-mode a:hover { color: #67e8f9; }

/* ── UTILITY ────────────────────────────────────────────── */
.hidden         { display: none !important; }
.d-flex         { display: flex; }
.align-center   { align-items: center; }
.justify-between{ justify-content: space-between; }
.gap-8          { gap: 8px; }
.text-muted     { color: var(--text-muted); }
.req            { color: var(--red); }
.mt-16          { margin-top: 16px; }
.form-full      { grid-column: 1 / -1; }

/* ── TOPBAR ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 60px;
  background: var(--navy-dark);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  box-shadow: 0 1px 0 rgba(255,255,255,.04), 0 4px 24px rgba(0,0,0,.2);
}

.topbar-module {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,.35);
  letter-spacing: .12em;
  text-transform: uppercase;
}

.topbar-user {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,.85);
}

.topbar-role {
  background: linear-gradient(135deg, var(--teal), #22d3ee);
  color: #fff;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  flex-shrink: 0;
}

.theme-toggle {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.7);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.theme-toggle:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.2); }

.topbar-logout {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.65);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.topbar-logout:hover { background: rgba(239,68,68,.15); color: #fca5a5; border-color: rgba(239,68,68,.3); }

/* ── SUBNAV ─────────────────────────────────────────────── */
.subnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  padding: 0 20px;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  box-shadow: var(--shadow-xs);
}
.subnav::-webkit-scrollbar { display: none; }

.subnav a {
  padding: 0 16px;
  height: 44px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}
.subnav a:hover { color: var(--text); background: var(--gray-50); text-decoration: none; }
.subnav a.active {
  color: var(--teal-dark);
  border-bottom-color: var(--teal);
  font-weight: 600;
}
body.dark-mode .subnav a:hover { background: var(--gray-100); }
body.dark-mode .subnav a.active { color: var(--teal); }

.nav-badge {
  background: var(--red);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}
.nav-badge.badge-warn { background: var(--orange); }

/* ── PAGE LAYOUT ────────────────────────────────────────── */
.page {
  max-width: 1600px;
  margin: 0 auto;
  padding: 28px 24px 56px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 12px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -.03em;
  margin-bottom: 0;
}
body.dark-mode .page-title { color: var(--gray-800); }

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── CARD ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 22px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--navy);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--gray-100);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
body.dark-mode .card-title { color: var(--teal); border-bottom-color: var(--border); }
.card-title::before {
  content: '';
  width: 3px;
  height: 14px;
  background: linear-gradient(180deg, var(--teal), var(--lime));
  border-radius: 3px;
  flex-shrink: 0;
}

/* ── STATS ROW ─────────────────────────────────────────── */
#stats-row,
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  border-top: 3px solid var(--teal);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition-fast);
  user-select: none;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-card.active { box-shadow: 0 0 0 2px var(--teal), var(--shadow); }
.stat-card.stat-red    { border-top-color: var(--red); }
.stat-card.stat-orange { border-top-color: var(--orange); }
.stat-card.stat-green  { border-top-color: var(--green); }
.stat-card.stat-lime   { border-top-color: var(--lime); }

.stat-val,
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
body.dark-mode .stat-val,
body.dark-mode .stat-value { color: var(--gray-800); }

.stat-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: 6px;
}

/* ── ATTENTION BANNER ───────────────────────────────────── */
#attention-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--red-light);
  border-left: 4px solid var(--red);
  border-radius: var(--radius);
  color: #991b1b;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}
body.dark-mode #attention-banner { background: rgba(239,68,68,.08); color: #fca5a5; }

/* ── FORMS ──────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}

.form-control {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
}
.form-control::placeholder { color: var(--gray-400); }
.form-control:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8,145,178,.12);
  background: var(--white);
}
body.dark-mode .form-control:focus { background: var(--surface); }
.form-control:disabled {
  background: var(--gray-50);
  color: var(--gray-500);
  cursor: not-allowed;
}
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

.form-grid {
  display: grid;
  gap: 16px;
}
.form-grid.g2 { grid-template-columns: repeat(2, 1fr); }
.form-grid.g3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.g4 { grid-template-columns: repeat(4, 1fr); }

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

/* Radio pills */
.form-radio-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 2px 0;
}
.form-radio {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 16px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-pill);
  color: var(--gray-600);
  user-select: none;
  transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-radio:hover { border-color: var(--teal); color: var(--teal-dark); }
.form-radio input[type="radio"] { display: none; }
.form-radio:has(input:checked) {
  border-color: var(--teal);
  background: var(--teal-light);
  color: var(--teal-dark);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--teal);
}
body.dark-mode .form-radio { border-color: var(--border); color: var(--gray-600); }
body.dark-mode .form-radio:has(input:checked) {
  border-color: var(--teal);
  background: rgba(6,182,212,.1);
  color: var(--teal);
}

/* Form tabs */
.form-tabs {
  display: flex;
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}
.form-tab {
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  color: var(--gray-500);
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.form-tab:hover { color: var(--text); }
.form-tab-active {
  background: var(--surface);
  color: var(--navy);
  box-shadow: var(--shadow-sm);
}
body.dark-mode .form-tab-active { color: var(--teal); }
.form-tab-badge {
  background: var(--teal);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* Queue tabs */
.queue-tabs {
  display: flex;
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}
.queue-tab {
  padding: 7px 18px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  color: var(--gray-500);
  background: none;
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.queue-tab:hover { color: var(--text); }
.queue-tab-active {
  background: var(--surface);
  color: var(--navy);
  box-shadow: var(--shadow-sm);
}
body.dark-mode .queue-tab-active { color: var(--teal); }

/* Request header strip */
.request-header {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  background: var(--teal-light);
  border: 1px solid rgba(8,145,178,.12);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  margin-bottom: 18px;
  font-size: 13px;
}
body.dark-mode .request-header {
  background: rgba(6,182,212,.04);
  border-color: rgba(6,182,212,.15);
}
.request-header .label {
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.request-header .value {
  font-weight: 600;
  color: var(--navy);
}
body.dark-mode .request-header .value { color: var(--teal); }

/* ── BUTTONS ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1.5px solid transparent;
  line-height: 1.2;
  white-space: nowrap;
  transition: all var(--transition-fast);
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
  box-shadow: 0 1px 3px rgba(8,145,178,.25);
}
.btn-primary:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
  box-shadow: 0 4px 12px rgba(8,145,178,.3);
  text-decoration: none;
  color: #fff;
}

.btn-success {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  box-shadow: 0 1px 3px rgba(34,197,94,.25);
}
.btn-success:hover {
  background: #16a34a;
  border-color: #16a34a;
  box-shadow: 0 4px 12px rgba(34,197,94,.3);
  text-decoration: none;
  color: #fff;
}

.btn-outline {
  background: var(--surface);
  color: var(--gray-700);
  border-color: var(--gray-200);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-300); text-decoration: none; }
body.dark-mode .btn-primary {
  background: #0e7490;
  border-color: #0e7490;
  color: #fff;
}
body.dark-mode .btn-primary:hover {
  background: #0891b2;
  border-color: #0891b2;
  color: #fff;
}
body.dark-mode .btn-success {
  background: #16a34a;
  border-color: #16a34a;
}
body.dark-mode .btn-success:hover {
  background: var(--green);
  border-color: var(--green);
  color: #0b0f19;
}
body.dark-mode .btn-danger {
  background: #dc2626;
  border-color: #dc2626;
}
body.dark-mode .btn-outline { color: var(--gray-600); border-color: var(--border); }
body.dark-mode .btn-outline:hover { background: var(--gray-100); border-color: var(--gray-300); }

.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
  box-shadow: 0 1px 3px rgba(239,68,68,.25);
}
.btn-danger:hover { background: #dc2626; border-color: #dc2626; box-shadow: 0 4px 12px rgba(239,68,68,.3); }

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-icon {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--gray-400);
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover {
  background: var(--teal-light);
  border-color: rgba(8,145,178,.15);
  color: var(--teal-dark);
}
body.dark-mode .btn-icon { color: var(--gray-500); }
body.dark-mode .btn-icon:hover { background: rgba(6,182,212,.1); color: var(--teal); border-color: rgba(6,182,212,.2); }

.btn-desc-icon {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  line-height: 1;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
}
.btn-desc-icon:hover {
  background: rgba(8,145,178,.08);
  border-color: rgba(8,145,178,.15);
}
body.dark-mode .btn-desc-icon:hover { background: rgba(6,182,212,.12); }

.btn-comment-icon,
.btn-trash-icon {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--gray-400);
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-comment-icon:hover {
  background: var(--teal-light);
  border-color: rgba(8,145,178,.15);
  color: var(--teal-dark);
}
.btn-trash-icon:hover {
  background: var(--red-light);
  border-color: rgba(239,68,68,.15);
  color: var(--red);
}
body.dark-mode .btn-comment-icon { color: var(--gray-500); }
body.dark-mode .btn-comment-icon:hover { background: rgba(6,182,212,.1); color: var(--teal); border-color: rgba(6,182,212,.2); }
body.dark-mode .btn-trash-icon { color: var(--gray-500); }
body.dark-mode .btn-trash-icon:hover { background: rgba(239,68,68,.1); color: #f87171; border-color: rgba(239,68,68,.2); }

.btn-comment-icon { position: relative; }
.btn-comment-icon.has-comments { color: var(--teal-dark); }
body.dark-mode .btn-comment-icon.has-comments { color: var(--teal); }

.comment-count-badge {
  position: absolute;
  top: -4px;
  right: -5px;
  background: var(--teal);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
  border: 2px solid var(--surface);
  pointer-events: none;
}

/* ── BADGES ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge-draft       { background: var(--gray-100);   color: var(--gray-600);   border-color: var(--gray-200); }
.badge-pending     { background: #fffbeb;            color: #92400e;           border-color: #fde68a; }
.badge-approved    { background: var(--green-light); color: #166534;           border-color: #bbf7d0; }
.badge-rejected    { background: var(--red-light);   color: #991b1b;           border-color: #fecaca; }
.badge-provisioned { background: var(--teal-light);  color: #0e7490;           border-color: #a5f3fc; }
.badge-director    { background: #eef2ff;            color: #4338ca;           border-color: #c7d2fe; }
.badge-ceo         { background: #fdf4ff;            color: #9333ea;           border-color: #e9d5ff; }
.badge-finance     { background: #eff6ff;            color: #2563eb;           border-color: #bfdbfe; }

body.dark-mode .badge-draft       { background: #1a2030; color: #8b9bb0; border-color: #2a3a50; }
body.dark-mode .badge-pending     { background: #1e1a00; color: #fbbf24; border-color: #4a3800; }
body.dark-mode .badge-approved    { background: #0a1f12; color: #4ade80; border-color: #166534; }
body.dark-mode .badge-rejected    { background: #1e0a0a; color: #f87171; border-color: #7f1d1d; }
body.dark-mode .badge-provisioned { background: #0a1a22; color: #22d3ee; border-color: #155e75; }
body.dark-mode .badge-director    { background: #12102a; color: #a5b4fc; border-color: #3730a3; }
body.dark-mode .badge-ceo         { background: #1a0a2e; color: #c084fc; border-color: #581c87; }
body.dark-mode .badge-finance     { background: #0c1530; color: #93c5fd; border-color: #1d4ed8; }

/* ── TABLE ──────────────────────────────────────────────── */
.table-wrap,
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

th {
  text-align: left;
  padding: 10px 14px;
  background: var(--gray-50);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
body.dark-mode th { background: var(--gray-100); border-bottom-color: var(--border); }

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
  color: var(--gray-700);
}
body.dark-mode td { border-bottom-color: var(--border); color: var(--gray-700); }

tbody tr { transition: background var(--transition-fast); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(8,145,178,.03); }
body.dark-mode tbody tr:hover td { background: rgba(6,182,212,.04); }

.th-sort { cursor: pointer; user-select: none; }
.th-sort:hover { color: var(--teal-dark); }
.sort-icon { font-size: 9px; opacity: .4; margin-left: 2px; }

/* ── PIPELINE ────────────────────────────────────────────── */
.pipeline-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: 12px;
}
.pipeline-arrow { color: var(--gray-400); font-size: 16px; }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 540px;
  animation: slideUp .25s cubic-bezier(.4,0,.2,1);
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--gray-100);
  font-weight: 700;
  font-size: 15px;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 10px;
}
body.dark-mode .modal-header { border-bottom-color: var(--border); color: var(--teal); }
.modal-header::before {
  content: '';
  width: 3px;
  height: 16px;
  background: linear-gradient(180deg, var(--teal), var(--lime));
  border-radius: 3px;
  flex-shrink: 0;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  font-size: 18px;
  margin-left: auto;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.modal-close:hover { background: var(--gray-100); color: var(--text); }

.modal-body { padding: 22px 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
body.dark-mode .modal-footer { border-top-color: var(--border); }

/* ── ALERTS ─────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
  border-left: 4px solid transparent;
}
.alert-error   { background: var(--red-light);    color: #991b1b; border-left-color: var(--red);    }
.alert-success { background: var(--green-light);  color: #166534; border-left-color: var(--green);  }
.alert-info    { background: var(--teal-light);   color: #0e7490; border-left-color: var(--teal);   }
.alert-warning { background: var(--orange-light); color: #9a3412; border-left-color: var(--orange); }

body.dark-mode .alert-error   { background: rgba(239,68,68,.08);  color: #fca5a5; border-left-color: var(--red);    }
body.dark-mode .alert-success { background: rgba(34,197,94,.08);  color: #6ee7b7; border-left-color: var(--green);  }
body.dark-mode .alert-info    { background: rgba(6,182,212,.08);  color: #67e8f9; border-left-color: var(--teal);   }
body.dark-mode .alert-warning { background: rgba(249,115,22,.08); color: #fdba74; border-left-color: var(--orange); }

/* ── FILE DROP ──────────────────────────────────────────── */
.file-drop {
  position: relative;
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--gray-500);
}
.file-drop:hover { border-color: var(--teal); background: var(--teal-light); color: var(--teal-dark); }
.file-drop.has-file { border-color: var(--teal); border-style: solid; background: rgba(8,145,178,.03); }
.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.file-name {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--teal-dark);
  word-break: break-all;
  text-align: center;
}
.req-badge {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--red);
  letter-spacing: .05em;
}
body.dark-mode .file-drop { border-color: var(--border); color: var(--text-muted); }
body.dark-mode .file-drop:hover { border-color: var(--teal); background: rgba(6,182,212,.06); }

/* ── NF-e IMPORT CARD ──────────────────────────────────── */
.nfe-import-card {
  border: 1px solid var(--teal);
  background: linear-gradient(135deg, var(--teal-light) 0%, var(--surface) 100%);
}
body.dark-mode .nfe-import-card {
  background: linear-gradient(135deg, rgba(6,182,212,.06) 0%, var(--surface) 100%);
  border-color: rgba(6,182,212,.3);
}
.nfe-xml-drop {
  border-color: var(--teal) !important;
  border-style: dashed;
}

/* ── COMMENTS ───────────────────────────────────────────── */
.comment-bubble {
  padding: 12px 16px;
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  max-width: 88%;
}
.comment-me {
  background: rgba(8,145,178,.04);
  border-color: rgba(8,145,178,.12);
  margin-left: auto;
}
.comment-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12px;
  flex-wrap: wrap;
}
.comment-meta strong { color: var(--navy); font-weight: 600; }
body.dark-mode .comment-meta strong { color: var(--teal); }
.comment-role {
  background: var(--gray-200);
  color: var(--gray-600);
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}
.comment-time { color: var(--text-muted); font-size: 11px; margin-left: auto; }
.comment-body {
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
body.dark-mode .comment-bubble { background: var(--gray-100); border-color: var(--border); }
body.dark-mode .comment-me     { background: rgba(6,182,212,.06); border-color: rgba(6,182,212,.15); }
body.dark-mode .comment-role   { background: var(--gray-300); color: var(--gray-600); }

/* ── SPINNER ────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── SUCCESS SCREEN ─────────────────────────────────────── */
.success-screen {
  text-align: center;
  padding: 56px 24px;
}
.success-icon {
  font-size: 56px;
  margin-bottom: 16px;
  display: block;
}
.success-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 8px;
}
body.dark-mode .success-title { color: var(--teal); }
.success-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ── EMPTY STATE ───────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── LOGIN ───────────────────────────────────────────────── */
/* ── LOGIN SPLIT LAYOUT ────────────────────────────────── */
.login-page {
  display: flex;
  min-height: 100vh;
}

/* Brand (left) */
.login-brand {
  flex: 1 1 55%;
  background: linear-gradient(140deg, #007fa0 0%, #00b1d2 50%, #005f80 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px 64px;
}
.login-brand-content { position: relative; z-index: 2; }
.login-brand-logo {
  height: 180px;
  width: auto;
  margin-bottom: 48px;
}
.login-brand-title {
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
  margin: 0 0 20px;
}
.login-brand-title span { color: #ffcd00; }
.login-brand-desc {
  font-size: 16px;
  color: rgba(255,255,255,.78);
  line-height: 1.6;
  max-width: 400px;
  margin: 0;
}

/* Decorative blobs */
.brand-blob {
  position: absolute;
  border-radius: 50%;
  background: rgba(0,0,0,.08);
  pointer-events: none;
}
.brand-blob-1 {
  width: 520px; height: 520px;
  bottom: -200px; right: -120px;
}
.brand-blob-2 {
  width: 320px; height: 320px;
  top: -120px; left: -80px;
}

/* Concentric decorative circles */
.dec-circles {
  position: absolute;
  width: 400px; height: 400px;
  bottom: 40px; right: -50px;
  pointer-events: none;
  z-index: 1;
}
.dec-circle {
  position: absolute;
  border-radius: 50%;
  border: 2px solid transparent;
}
.dec-circle-1 {
  width: 360px; height: 360px;
  top: 20px; left: 20px;
  border-color: rgba(0,245,255,.45);
}
.dec-circle-2 {
  width: 280px; height: 280px;
  top: 60px; left: 80px;
  border-color: rgba(250,235,30,.55);
}
.dec-circle-3 {
  width: 180px; height: 180px;
  top: 110px; left: 130px;
  border-color: rgba(0,245,255,.25);
  background: rgba(0,245,255,.1);
}

/* Form panel (right) */
.login-panel {
  flex: 1 1 45%;
  max-width: 576px;
  background: #091525;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
}
.login-panel-inner {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}
.login-panel-header { margin-bottom: 32px; }
.login-panel-header h2 {
  font-size: 28px;
  font-weight: 700;
  color: #e8eaf0;
  margin: 0 0 6px;
}
.login-subtitle {
  font-size: 14px;
  color: #6b8aad;
  margin: 0;
}

.login-panel .form-label {
  color: #6b8aad;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .4px;
}
.login-panel .form-control {
  background: #122444;
  border: 1px solid #1a3354;
  border-radius: 8px;
  color: #e8eaf0;
  padding: 12px 14px;
}
.login-panel .form-control::placeholder { color: rgba(107,138,173,.5); }
.login-panel .form-control:focus {
  border-color: #00b1d2;
  background: #152a4d;
  box-shadow: 0 0 0 3px rgba(0,177,210,.15);
}
.login-page .login-panel .btn-primary {
  background: #00b1d2;
  border-color: #00b1d2;
  color: #fff;
  font-weight: 700;
  border-radius: 8px;
}
.login-page .login-panel .btn-primary:hover {
  background: #00c4e8;
  border-color: #00c4e8;
}

.login-footer {
  margin-top: 48px;
  text-align: center;
  font-size: 11px;
  color: #3d5a7e;
}
.login-footer strong { font-weight: 600; color: #4a6d94; }

/* ── ROLE CHIP (admin user form) ─────────────────────────── */
.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  user-select: none;
  transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}
.role-chip:hover { border-color: var(--teal); color: var(--teal-dark); }
.role-chip input[type="radio"] { display: none; }
.role-chip:has(input:checked) {
  border-color: var(--teal);
  background: var(--teal-light);
  color: var(--teal-dark);
  font-weight: 600;
}
body.dark-mode .role-chip { border-color: var(--border); color: var(--gray-500); }
body.dark-mode .role-chip:has(input:checked) {
  border-color: var(--teal);
  background: rgba(6,182,212,.1);
  color: var(--teal);
}

/* Department checkbox label */
.dept-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--gray-600);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.dept-checkbox-label:hover { border-color: var(--teal); }
.dept-checkbox-label:has(input:checked) {
  border-color: var(--teal);
  background: var(--teal-light);
  color: var(--teal-dark);
}

/* ── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 900px) {
  .form-grid.g3 { grid-template-columns: repeat(2, 1fr); }
  .form-grid.g4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .topbar { padding: 0 14px; gap: 8px; }
  .topbar-module { display: none; }
  .subnav { padding: 0 10px; }
  .page { padding: 20px 16px 40px; }
  #stats-row,
  .stats-row { grid-template-columns: repeat(3, 1fr); }
  .login-page { flex-direction: column; }
  .login-brand { flex: none; min-height: 280px; padding: 32px 24px; }
  .login-brand-title { font-size: 28px; }
  .login-brand-logo { height: 100px; margin-bottom: 24px; }
  .login-panel { flex: 1; max-width: none; padding: 32px 24px; }
  .dec-circles { display: none; }
  .page-header { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 600px) {
  .form-grid.g2,
  .form-grid.g3,
  .form-grid.g4 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  #stats-row,
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

/* ── ACCESSIBILITY ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ── AUTOCOMPLETE DE FORNECEDOR (OMIE) ──────────────────── */
.autocomplete-wrap { position: relative; }

.autocomplete-list {
  position: absolute;
  z-index: 40;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  max-height: 280px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  line-height: 1.4;
  transition: background var(--transition-fast);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.active { background: var(--teal-light); }
body.dark-mode .autocomplete-item:hover,
body.dark-mode .autocomplete-item.active { background: rgba(6,182,212,.08); }

.autocomplete-item .ac-name {
  font-weight: 600;
  color: var(--text);
  font-size: 13.5px;
}
.autocomplete-item .ac-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.autocomplete-empty {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.omie-link-status {
  margin-top: 10px;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.omie-link-status.linked     { color: var(--green); }
.omie-link-status.unlinked   { color: var(--orange); }
body.dark-mode .omie-link-status.linked   { color: #4ade80; }
body.dark-mode .omie-link-status.unlinked { color: #fb923c; }

/* Omie badge variants */
.badge-omie-sent    { background: var(--green-light); color: #166534; border-color: #bbf7d0; }
.badge-omie-error   { background: var(--red-light);   color: #991b1b; border-color: #fecaca; }
.badge-omie-pending { background: #fffbeb;            color: #92400e; border-color: #fde68a; }
body.dark-mode .badge-omie-sent    { background: #0a1f12; color: #4ade80; border-color: #166534; }
body.dark-mode .badge-omie-error   { background: #1e0a0a; color: #f87171; border-color: #7f1d1d; }
body.dark-mode .badge-omie-pending { background: #1e1a00; color: #fbbf24; border-color: #4a3800; }

/* Admin tabs */
.admin-tabs {
  display: flex;
  gap: 2px;
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.admin-tab {
  padding: 7px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  border: none;
  color: var(--gray-500);
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.admin-tab:hover { background: var(--gray-50); color: var(--text); }
.admin-tab.active {
  background: var(--surface);
  color: var(--navy);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
body.dark-mode .admin-tab.active { color: var(--teal); }

/* Bills filter bar */
.bills-filter.active { background: var(--teal); color: #fff; border-color: var(--teal); }
body.dark-mode .bills-filter.active { background: var(--teal); color: var(--bg); border-color: var(--teal); }

/* ── SCROLLBAR ──────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: var(--radius-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
body.dark-mode ::-webkit-scrollbar-thumb { background: var(--gray-300); }
body.dark-mode ::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
