/* ═══════════════════════════════════════════════════════════════════
   Aurora TISS — Design System v2.0
   Premium billing system interface
   ═══════════════════════════════════════════════════════════════════ */

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

/* ── Design Tokens ─────────────────────────────────────────────── */
:root {
  /* Brand */
  --brand-50: #eef2ff;
  --brand-100: #e0e7ff;
  --brand-200: #c7d2fe;
  --brand-400: #818cf8;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --brand-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
  --brand-gradient-hover: linear-gradient(135deg, #4f46e5, #7c3aed);
  --brand-glow: 0 0 20px rgba(99, 102, 241, 0.3);

  /* Surfaces */
  --bg: #f0f2f8;
  --bg-gradient: linear-gradient(160deg, #f0f2f8 0%, #e8ecf4 50%, #eee8f6 100%);
  --card: rgba(255, 255, 255, 0.82);
  --card-solid: #ffffff;
  --card-border: rgba(255, 255, 255, 0.6);
  --card-shadow: 0 8px 32px rgba(15, 23, 42, 0.06), 0 2px 8px rgba(15, 23, 42, 0.04);
  --card-shadow-hover: 0 16px 48px rgba(15, 23, 42, 0.1), 0 4px 12px rgba(15, 23, 42, 0.06);

  /* Text */
  --ink: #0f172a;
  --ink-secondary: #334155;
  --muted: #64748b;
  --muted-light: #94a3b8;

  /* Borders */
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --border-focus: #6366f1;

  /* Status */
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --info: #2563eb;
  --info-bg: #eff6ff;

  /* Navbar */
  --nav-bg: rgba(15, 23, 42, 0.92);
  --nav-blur: 20px;

  /* Inputs */
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --input-focus-ring: 0 0 0 3px rgba(99, 102, 241, 0.15);

  /* Filters */
  --filter-bg: rgba(255, 255, 255, 0.72);
  --filter-border: rgba(226, 232, 240, 0.8);
  --filter-shadow: 0 4px 24px rgba(15, 23, 42, 0.04);

  /* Modal */
  --modal-backdrop: rgba(15, 23, 42, 0.5);
  --modal-shadow: 0 32px 96px rgba(15, 23, 42, 0.24), 0 8px 24px rgba(15, 23, 42, 0.12);

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 999px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 0.2s;
  --duration-slow: 0.35s;

  /* Footer */
  --footer-bg: #f8fafc;
  --footer-border: #e2e8f0;
}

/* ── Dark Mode ─────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg: #0c0f1a;
  --bg-gradient: linear-gradient(160deg, #0c0f1a 0%, #111628 50%, #140f20 100%);
  --card: rgba(30, 35, 55, 0.75);
  --card-solid: #1e2337;
  --card-border: rgba(55, 65, 95, 0.5);
  --card-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.15);
  --card-shadow-hover: 0 16px 48px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.2);
  --ink: #f1f5f9;
  --ink-secondary: #cbd5e1;
  --muted: #94a3b8;
  --muted-light: #64748b;
  --border: #2d3555;
  --border-light: #1e2337;
  --border-focus: #818cf8;
  --nav-bg: rgba(8, 10, 22, 0.95);
  --input-bg: rgba(30, 35, 55, 0.8);
  --input-border: #3b4265;
  --input-focus-ring: 0 0 0 3px rgba(129, 140, 248, 0.2);
  --filter-bg: rgba(30, 35, 55, 0.65);
  --filter-border: rgba(55, 65, 95, 0.6);
  --filter-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
  --modal-backdrop: rgba(0, 0, 0, 0.65);
  --modal-shadow: 0 32px 96px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.3);
  --footer-bg: #0f1322;
  --footer-border: #1e2337;
  --brand-glow: 0 0 24px rgba(129, 140, 248, 0.25);
  --ok-bg: rgba(5, 150, 105, 0.12);
  --warn-bg: rgba(217, 119, 6, 0.12);
  --danger-bg: rgba(220, 38, 38, 0.12);
  --info-bg: rgba(37, 99, 235, 0.12);
}

/* ── Keyframes ─────────────────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(99, 102, 241, 0.15); }
  50% { box-shadow: 0 0 40px rgba(139, 92, 246, 0.25); }
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  background: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

a { color: var(--brand-500); text-decoration: none; transition: color var(--duration) var(--ease); }
a:hover { color: var(--brand-700); }

[data-theme="dark"] a:hover { color: var(--brand-400); }

/* ── Navbar ────────────────────────────────────────────────────── */
.top {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 28px;
  height: 60px;
  background: var(--nav-bg);
  backdrop-filter: blur(var(--nav-blur));
  -webkit-backdrop-filter: blur(var(--nav-blur));
  color: white;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}

.top .nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: white;
}

.top .nav-logo {
  width: 34px;
  height: 34px;
  background: var(--brand-gradient);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.top .nav-title {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.top .nav-subtitle {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 500;
  margin-left: 0;
  display: none;
}
@media (min-width: 768px) {
  .top .nav-subtitle { display: inline; }
}

.top .nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.top .nav-links a {
  color: #cbd5e1;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  transition: all var(--duration) var(--ease);
  position: relative;
  text-decoration: none;
}
.top .nav-links a:hover {
  color: white;
  background: rgba(255, 255, 255, 0.08);
}
.top .nav-links a.active {
  color: white;
  background: rgba(99, 102, 241, 0.2);
}
.top .nav-links a.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: var(--brand-gradient);
  border-radius: 2px;
}

.top .nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top .nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--brand-gradient);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  flex-shrink: 0;
}

.top form { display: inline; }
.top .nav-right button,
.top .nav-logout {
  color: #94a3b8;
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}
.top .nav-right button:hover,
.top .nav-logout:hover {
  color: white;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

/* Theme Toggle */
.theme-toggle {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: var(--radius-sm);
  color: #94a3b8;
  padding: 6px;
  cursor: pointer;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  transition: all var(--duration) var(--ease);
  font-size: 16px;
  line-height: 1;
}
.theme-toggle:hover {
  color: white;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline; }
:root:not([data-theme="dark"]) .theme-icon-dark,
html:not([data-theme="dark"]) .theme-icon-dark { display: none; }
:root:not([data-theme="dark"]) .theme-icon-light,
html:not([data-theme="dark"]) .theme-icon-light { display: inline; }

/* Mobile hamburger */
.nav-hamburger {
  display: none;
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
}

/* ── Container ─────────────────────────────────────────────────── */
.container {
  max-width: 1320px;
  margin: 28px auto;
  padding: 0 24px;
  animation: fadeIn 0.4s var(--ease);
}

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--card-shadow);
  transition: box-shadow var(--duration-slow) var(--ease), transform var(--duration-slow) var(--ease);
}
.card:hover {
  box-shadow: var(--card-shadow-hover);
}
.card h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

/* ── Grid ──────────────────────────────────────────────────────── */
.grid { display: grid; gap: 20px; }

.cards {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 20px 0;
}

.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* ── Metric Cards ──────────────────────────────────────────────── */
.metric {
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.5s var(--ease) both;
}
.metric:nth-child(1) { animation-delay: 0s; }
.metric:nth-child(2) { animation-delay: 0.08s; }
.metric:nth-child(3) { animation-delay: 0.16s; }
.metric:nth-child(4) { animation-delay: 0.24s; }

.metric .metric-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  font-size: 20px;
  margin-bottom: 14px;
}
.metric .metric-icon.icon-total { background: var(--brand-50); color: var(--brand-500); }
.metric .metric-icon.icon-charged { background: var(--info-bg); color: var(--info); }
.metric .metric-icon.icon-denied { background: var(--danger-bg); color: var(--danger); }
.metric .metric-icon.icon-net { background: var(--ok-bg); color: var(--ok); }

[data-theme="dark"] .metric .metric-icon.icon-total { background: rgba(99,102,241,0.15); }
[data-theme="dark"] .metric .metric-icon.icon-charged { background: rgba(37,99,235,0.15); }
[data-theme="dark"] .metric .metric-icon.icon-denied { background: rgba(220,38,38,0.15); }
[data-theme="dark"] .metric .metric-icon.icon-net { background: rgba(5,150,105,0.15); }

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.metric::after {
  content: '';
  position: absolute;
  top: -30%;
  right: -20%;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--brand-gradient);
  opacity: 0.04;
  pointer-events: none;
}

/* ── Typography ────────────────────────────────────────────────── */
h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.2;
}
h2 { letter-spacing: -0.02em; }

.muted, small { color: var(--muted); }
small { font-size: 12.5px; }
.muted { font-size: 14px; line-height: 1.5; }

/* ── Buttons ───────────────────────────────────────────────────── */
.button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--brand-500);
  background: var(--card-solid);
  color: var(--brand-500);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
  line-height: 1.2;
}
.button:hover, button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}
.button:active, button:active {
  transform: translateY(0);
}

.primary {
  background: var(--brand-gradient);
  color: white;
  border: none;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}
.primary:hover {
  background: var(--brand-gradient-hover);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
  color: white;
}

.secondary {
  border-color: var(--border);
  color: var(--ink-secondary);
  background: var(--card-solid);
}
.secondary:hover {
  border-color: var(--brand-200);
  color: var(--brand-600);
  background: var(--brand-50);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.08);
}

[data-theme="dark"] .secondary {
  background: var(--input-bg);
  border-color: var(--input-border);
  color: var(--ink-secondary);
}
[data-theme="dark"] .secondary:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: var(--brand-400);
  color: var(--brand-400);
}
[data-theme="dark"] .button, [data-theme="dark"] button {
  background: var(--input-bg);
  color: var(--ink-secondary);
  border-color: var(--input-border);
}

/* ── Labels / Inputs / Selects ─────────────────────────────────── */
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-secondary);
}

input, select, textarea {
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font: inherit;
  font-size: 14px;
  min-width: 150px;
  background: var(--input-bg);
  color: var(--ink);
  transition: all var(--duration) var(--ease);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--input-focus-ring);
}
input::placeholder, textarea::placeholder {
  color: var(--muted-light);
}
textarea { min-height: 80px; resize: vertical; }
select[multiple] { min-height: 180px; }

.check { flex-direction: row; align-items: center; cursor: pointer; }
.check input { width: auto; min-width: 0; accent-color: var(--brand-500); cursor: pointer; }

/* ── Currency Field ────────────────────────────────────────────── */
.currency-field {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  overflow: hidden;
  transition: all var(--duration) var(--ease);
}
.currency-field:focus-within {
  border-color: var(--border-focus);
  box-shadow: var(--input-focus-ring);
}
.currency-prefix {
  padding: 10px 12px;
  background: var(--border-light);
  color: var(--muted);
  border-right: 1.5px solid var(--input-border);
  font-weight: 700;
  font-size: 13px;
}
.currency-field input {
  border: 0 !important;
  border-radius: 0 !important;
  flex: 1;
  min-width: 0;
  box-shadow: none !important;
}
.currency-field input:focus {
  outline: none;
  box-shadow: none !important;
}

[data-theme="dark"] .currency-prefix {
  background: rgba(30, 35, 55, 0.6);
  border-color: var(--input-border);
}

/* ═══════════════════════════════════════════════════════════════════
   FILTERS — Premium Redesign (Priority)
   ═══════════════════════════════════════════════════════════════════ */
.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
  background: var(--filter-bg);
  border: 1px solid var(--filter-border);
  padding: 16px;
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.compact-erp-filters {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--filter-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--filter-border);
  border-radius: var(--radius-xl);
  padding: 0;
  margin-bottom: 22px;
  box-shadow: var(--filter-shadow);
  overflow: hidden;
  transition: box-shadow var(--duration-slow) var(--ease);
}
.compact-erp-filters:focus-within {
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.08);
  border-color: var(--brand-200);
}
[data-theme="dark"] .compact-erp-filters:focus-within {
  border-color: rgba(129, 140, 248, 0.25);
}

.compact-erp-filters label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-secondary);
  letter-spacing: 0.01em;
}

.compact-erp-filters input,
.compact-erp-filters select {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  background: var(--input-bg);
  font-size: 14px;
  color: var(--ink);
  transition: all var(--duration) var(--ease);
}
.compact-erp-filters input:focus,
.compact-erp-filters select:focus {
  border-color: var(--border-focus);
  box-shadow: var(--input-focus-ring);
}

/* Filter sections as rows with dividers */
.filter-row-line {
  width: 100%;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}
.filter-row-line:last-child {
  border-bottom: none;
}

[data-theme="dark"] .filter-row-line {
  border-bottom-color: rgba(45, 53, 85, 0.5);
}

.filter-line-grid {
  display: grid;
  gap: 14px;
}

/* Search band */
.busca { display: block; }

.filter-field-search { display: flex; flex-direction: column; }

.search-input-wrap {
  position: relative;
}
.search-input-wrap input {
  height: 46px;
  padding-left: 48px;
  font-size: 15px;
  border-radius: var(--radius-lg);
  background: var(--input-bg);
  border: 1.5px solid var(--input-border);
  width: 100%;
  transition: all var(--duration) var(--ease);
}
.search-input-wrap input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--input-focus-ring);
}
.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--muted-light);
  pointer-events: none;
  transition: color var(--duration) var(--ease);
}
.search-input-wrap:focus-within .search-icon {
  color: var(--brand-500);
}

/* Filter grid layouts */
.main-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.procedure-payer-band {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
}
.dates-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.dates-label {
  grid-column: 1 / -1;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dates-label::before {
  content: '';
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--brand-gradient);
}

/* Filter action buttons */
.actions-band {
  display: flex;
  justify-content: flex-end;
  padding: 14px 20px !important;
  background: var(--border-light);
  border-bottom: none !important;
}
[data-theme="dark"] .actions-band {
  background: rgba(15, 20, 35, 0.3);
}

.acoes {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.acoes button,
.acoes .button {
  height: 40px;
  min-width: 110px;
  border-radius: var(--radius-md);
  padding: 8px 18px;
  font-size: 14px;
}
.acoes .primary::before {
  content: '⬆';
  display: inline-block;
  margin-right: 6px;
  font-size: 11px;
}
.acoes .secondary::before {
  content: '↻';
  margin-right: 6px;
  font-size: 13px;
}

.filter-field-small,
.filter-field-medium,
.filter-field-wide,
.filter-field-dates { flex: initial; }

/* ── Dashboard ─────────────────────────────────────────────────── */
.dashboard-header {
  align-items: flex-start;
  margin-bottom: 22px;
}
.dashboard-greeting {
  margin: 0 0 2px;
  color: var(--muted);
  font-weight: 600;
  font-size: 15px;
}
.dashboard-header h1 { margin: 0; }

.dashboard-filter-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.dashboard-filter-button::before {
  content: '⚙';
  font-size: 14px;
}

.dashboard-filter-modal {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(1120px, calc(100vw - 40px));
  max-height: 88vh;
  border: 0;
  border-radius: var(--radius-xl);
  padding: 0;
  background: var(--card-solid);
  box-shadow: var(--modal-shadow);
  overflow: hidden;
}
.dashboard-filter-modal::backdrop {
  background: var(--modal-backdrop);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.dashboard-filter-modal .modal-header {
  margin-bottom: 0;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.dashboard-filter-modal .compact-erp-filters {
  margin-bottom: 0;
  box-shadow: none;
  border: none;
  border-radius: 0;
}
.dashboard-filter-modal .search-input-wrap input { font-size: 16px; }
.dashboard-filter-modal .dates-label {
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}
.dashboard-filter-modal .acoes { align-items: flex-end; }

.summary-table { margin-top: 16px; }

/* ── Tables ────────────────────────────────────────────────────── */
.overflow { overflow-x: auto; }

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

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--card-solid);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 14px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  text-align: left;
}

[data-theme="dark"] thead th {
  background: var(--card-solid);
  border-bottom-color: var(--border);
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
  color: var(--ink-secondary);
  white-space: nowrap;
  text-align: left;
  transition: background var(--duration) var(--ease);
}

tbody tr { transition: background var(--duration) var(--ease); }
tbody tr:hover { background: rgba(99, 102, 241, 0.03); }
[data-theme="dark"] tbody tr:hover { background: rgba(99, 102, 241, 0.06); }

/* Zebra-striping */
tbody tr:nth-child(even) { background: rgba(248, 250, 252, 0.5); }
[data-theme="dark"] tbody tr:nth-child(even) { background: rgba(30, 35, 55, 0.3); }
tbody tr:nth-child(even):hover { background: rgba(99, 102, 241, 0.03); }
[data-theme="dark"] tbody tr:nth-child(even):hover { background: rgba(99, 102, 241, 0.06); }

/* Sorting */
.sortable-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: space-between;
}
.sort-controls {
  display: inline-flex;
  gap: 2px;
}
.sort-controls a {
  font-size: 11px;
  text-decoration: none;
  color: var(--muted-light);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  background: var(--card-solid);
  transition: all var(--duration) var(--ease);
  line-height: 1.4;
}
.sort-controls a:hover {
  color: var(--brand-500);
  border-color: var(--brand-200);
  background: var(--brand-50);
}
[data-theme="dark"] .sort-controls a {
  background: var(--input-bg);
  border-color: var(--input-border);
}
[data-theme="dark"] .sort-controls a:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: var(--brand-400);
  color: var(--brand-400);
}

/* ── Badges ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  font-weight: 700;
  font-size: 11.5px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--brand-50);
  color: var(--brand-600);
}

/* Status-based badge colors (applied via JS data attribute or EJS) */
.badge--pendente, .badge[data-status="PENDENTE"] { background: var(--warn-bg); color: var(--warn); }
.badge--pago, .badge[data-status="PAGO"] { background: var(--ok-bg); color: var(--ok); }
.badge--glosado, .badge[data-status="GLOSADO"],
.badge--negado, .badge[data-status="NEGADO"] { background: var(--danger-bg); color: var(--danger); }
.badge--enviado, .badge[data-status="ENVIADO"] { background: var(--info-bg); color: var(--info); }
.badge--recurso, .badge[data-status="RECURSO"] { background: #faf5ff; color: #7c3aed; }
[data-theme="dark"] .badge--recurso, [data-theme="dark"] .badge[data-status="RECURSO"] { background: rgba(124, 58, 237, 0.12); }

[data-theme="dark"] .badge { background: rgba(99, 102, 241, 0.12); color: var(--brand-400); }
[data-theme="dark"] .badge--pendente, [data-theme="dark"] .badge[data-status="PENDENTE"] { background: rgba(217, 119, 6, 0.12); color: #fbbf24; }
[data-theme="dark"] .badge--pago, [data-theme="dark"] .badge[data-status="PAGO"] { background: rgba(5, 150, 105, 0.12); color: #34d399; }
[data-theme="dark"] .badge--glosado, [data-theme="dark"] .badge[data-status="GLOSADO"],
[data-theme="dark"] .badge--negado, [data-theme="dark"] .badge[data-status="NEGADO"] { background: rgba(220, 38, 38, 0.12); color: #f87171; }
[data-theme="dark"] .badge--enviado, [data-theme="dark"] .badge[data-status="ENVIADO"] { background: rgba(37, 99, 235, 0.12); color: #60a5fa; }

/* ── Modals ─────────────────────────────────────────────────────── */
dialog,
.modal-card {
  position: fixed;
  inset: 0;
  margin: auto;
  border: 0;
  border-radius: var(--radius-xl);
  box-shadow: var(--modal-shadow);
  padding: 22px;
  max-width: min(720px, 92vw);
  width: 640px;
  background: var(--card-solid);
  animation: modalIn 0.3s var(--ease);
  color: var(--ink);
}
dialog::backdrop,
.modal-card::backdrop {
  background: var(--modal-backdrop);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-header, .modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-header h2 {
  margin: 0;
  font-size: 18px;
}
.modal-picker { margin: 16px 0; }
.select-visible { white-space: nowrap; font-weight: 700; }
.hint { color: var(--muted); font-size: 14px; margin: 8px 0 16px; }

/* ── Row Layout ────────────────────────────────────────────────── */
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

/* ── Login ──────────────────────────────────────────────────────── */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg-gradient);
  background-size: 200% 200%;
  animation: gradientShift 12s ease infinite;
  padding: 20px;
  position: relative;
}
.login::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(99, 102, 241, 0.04) 0%, transparent 50%);
  pointer-events: none;
}
[data-theme="dark"] .login::before {
  background:
    radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
}

.login-card {
  max-width: 440px;
  width: 100%;
  padding: 36px;
  text-align: center;
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.6s var(--ease);
}

.login-card .login-logo {
  width: 56px;
  height: 56px;
  background: var(--brand-gradient);
  border-radius: var(--radius-md);
  display: inline-grid;
  place-items: center;
  font-size: 28px;
  font-weight: 900;
  color: white;
  margin-bottom: 20px;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
  animation: pulseGlow 3s ease infinite;
}

.login-card h1 {
  font-size: 26px;
  margin-bottom: 8px;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-card > p {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 24px;
  line-height: 1.5;
}

.login-card form {
  text-align: left;
}
.login-card label {
  margin-bottom: 4px;
}
.login-card input[type="email"],
.login-card input[type="password"] {
  width: 100%;
  padding: 12px 16px;
  height: 46px;
  font-size: 15px;
}
.login-card .primary {
  width: 100%;
  padding: 12px;
  height: 46px;
  font-size: 15px;
  margin-top: 8px;
}

/* ── Alert ─────────────────────────────────────────────────────── */
.alert {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.15);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideDown 0.3s var(--ease);
}
.alert::before {
  content: '⚠';
  font-size: 16px;
  flex-shrink: 0;
}

/* ── Guide Header ──────────────────────────────────────────────── */
.guide-header-actions {
  align-items: center;
}
.guide-header-actions .actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Bulk Receipt ──────────────────────────────────────────────── */
.bulk-receipt { margin-top: 12px; }
.bulk-actions {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  background: var(--border-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
}
.bulk-actions label { min-width: 180px; }

/* ── Column Picker ─────────────────────────────────────────────── */
.column-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}
.column-picker legend { font-weight: 700; color: var(--ink-secondary); }
.column-picker .check { font-weight: 500; }
.modal-picker .column-picker {
  border-style: solid;
  border-color: var(--border-light);
}

/* ── Date Filters ──────────────────────────────────────────────── */
.date-filters {
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.date-filters legend { font-weight: 700; color: var(--ink-secondary); }

/* ── Reports ───────────────────────────────────────────────────── */
.reports-grid { margin-top: 4px; }

.report-panel {
  padding: 0;
  overflow: hidden;
  transition: box-shadow var(--duration-slow) var(--ease);
}
.report-panel:hover {
  box-shadow: var(--card-shadow-hover);
}
.report-panel summary {
  list-style: none;
  cursor: pointer;
  padding: 18px 22px;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background var(--duration) var(--ease);
}
.report-panel summary:hover {
  background: rgba(99, 102, 241, 0.03);
}
[data-theme="dark"] .report-panel summary:hover {
  background: rgba(99, 102, 241, 0.06);
}
.report-panel summary::-webkit-details-marker { display: none; }
.report-panel summary::after {
  content: '+';
  width: 30px;
  height: 30px;
  border-radius: var(--radius-pill);
  background: var(--brand-50);
  color: var(--brand-500);
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 16px;
  transition: all var(--duration) var(--ease);
}
[data-theme="dark"] .report-panel summary::after {
  background: rgba(99, 102, 241, 0.12);
  color: var(--brand-400);
}
.report-panel[open] summary {
  border-bottom: 1px solid var(--border);
}
.report-panel[open] summary::after {
  content: '−';
  background: var(--brand-gradient);
  color: white;
}
.report-panel table { margin: 0; }
.report-panel[open] > :not(summary) {
  animation: fadeIn 0.3s var(--ease);
}

/* ── Admin ─────────────────────────────────────────────────────── */
.admin-header {
  margin-bottom: 20px;
  gap: 16px;
}
.admin-header h1 { margin-bottom: 4px; }
.inline-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}
.admin-header .inline-actions .button { white-space: nowrap; }

.admin-modal {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(760px, 94vw);
  max-height: 88vh;
  overflow: auto;
}
.admin-modal .form { display: grid; gap: 14px; }
.admin-modal .actions { display: flex; justify-content: flex-end; margin-top: 8px; }

/* ── Error Page ────────────────────────────────────────────────── */
.error-page {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.error-card {
  text-align: center;
  max-width: 480px;
  padding: 40px;
}
.error-illustration {
  font-size: 64px;
  margin-bottom: 20px;
  opacity: 0.6;
}
.error-card h1 {
  margin-bottom: 12px;
}
.error-card p {
  color: var(--muted);
  margin-bottom: 24px;
  font-size: 15px;
}

/* ── Form card in guide-form ───────────────────────────────────── */
.form { display: grid; gap: 14px; }
.form .actions { margin-top: 8px; }

/* Fieldset visual groups */
.form-section {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 18px;
  background: rgba(248, 250, 252, 0.5);
}
[data-theme="dark"] .form-section {
  background: rgba(15, 20, 35, 0.2);
  border-color: var(--border);
}
.form-section-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-section-title::before {
  content: '';
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--brand-gradient);
}

/* ── Footer ────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 20px 24px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  border-top: 1px solid var(--footer-border);
  background: var(--footer-bg);
  margin-top: 40px;
}
footer .footer-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--brand-50);
  color: var(--brand-500);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 11px;
  margin-right: 6px;
}
[data-theme="dark"] footer .footer-badge {
  background: rgba(99, 102, 241, 0.12);
  color: var(--brand-400);
}

/* ── Pagination ────────────────────────────────────────────────── */
.pagination {
  margin-top: 14px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════════
   Responsive Design
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main-band,
  .procedure-payer-band,
  .dates-band { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-header { gap: 12px; }
}

@media (max-width: 760px) {
  .top { padding: 0 16px; }
  .top .nav-links { display: none; }
  .nav-hamburger { display: block; }

  /* Mobile nav overlay */
  .top .nav-links.open {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--nav-bg);
    backdrop-filter: blur(var(--nav-blur));
    -webkit-backdrop-filter: blur(var(--nav-blur));
    padding: 16px;
    gap: 4px;
    z-index: 99;
    animation: fadeIn 0.2s var(--ease);
  }
  .top .nav-links.open a {
    padding: 14px 16px;
    font-size: 16px;
    border-radius: var(--radius-md);
  }

  .container { padding: 0 16px; margin: 20px auto; }

  h1 { font-size: 22px; }

  .cards,
  .two { grid-template-columns: 1fr; }
  .reports-grid { grid-template-columns: 1fr; }

  .main-band,
  .procedure-payer-band,
  .dates-band { grid-template-columns: 1fr; }

  .guide-header-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .guide-header-actions .actions { width: 100%; }

  .acoes {
    flex-direction: column;
    width: 100%;
  }
  .acoes button,
  .acoes .button { width: 100%; }

  .dashboard-header { flex-direction: column; align-items: flex-start; }
  .dashboard-filter-button { margin-top: 8px; }

  .dashboard-filter-modal {
    width: calc(100vw - 24px);
    padding: 0;
  }

  .admin-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .inline-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .row {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .login-card { padding: 28px 22px; }
  .metric strong { font-size: 22px; }
}

/* ── Scrollbar Styling ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--muted-light);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ── Selection ─────────────────────────────────────────────────── */
::selection {
  background: rgba(99, 102, 241, 0.2);
  color: var(--ink);
}

/* ── Print ─────────────────────────────────────────────────────── */
@media print {
  .top, footer, .acoes, .dashboard-filter-button { display: none !important; }
  body { background: white; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}


.row-actions{white-space:nowrap;font-size:.86rem}.row-actions a{display:inline-block;margin:2px 0}.print-toolbar{max-width:1180px;margin:18px auto;display:flex;gap:10px;align-items:center;flex-wrap:wrap}.print-body{background:#eef2f7}.tiss-sadt-page{width:1120px;min-height:790px;margin:14px auto;background:white;color:#111;border:1.5px solid #222;padding:8px;font-family:Arial,Helvetica,sans-serif;font-size:10px;box-shadow:0 18px 50px rgba(15,23,42,.12)}.tiss-header{display:grid;grid-template-columns:180px 1fr 250px;align-items:start;gap:8px;margin-bottom:8px}.tiss-header h1{text-align:center;font-size:18px;line-height:1.12;margin:10px 0 4px;text-transform:uppercase}.tiss-logo-box{height:54px;display:flex;align-items:center;justify-content:center}.tiss-provider-guide{text-align:right;font-size:11px}.tiss-provider-guide strong{display:block;font-size:20px;letter-spacing:1px}.tiss-band{background:#bdbdbd;color:#111;font-size:10px;line-height:1;margin:3px 0 2px;padding:3px 5px;border:1px solid #999}.tiss-grid{display:grid;gap:3px;margin-bottom:3px}.tiss-grid-top{grid-template-columns:1fr 3fr 1.15fr 2.8fr 1.35fr 3fr}.beneficiary-grid{grid-template-columns:3fr 1.45fr 4.2fr 2.1fr .8fr}.requester-grid{grid-template-columns:1.8fr 6fr 3.2fr .7fr 1.9fr .55fr 1.1fr 3.2fr}.request-data-grid{grid-template-columns:.8fr 1.6fr 8fr}.executor-grid{grid-template-columns:2fr 7fr 1.2fr}.attendance-grid{grid-template-columns:1.1fr 2.7fr 1.2fr 2.4fr}.tiss-field{border:1px solid #222;min-height:29px;padding:3px 5px;overflow:hidden}.tiss-field b{display:block;font-size:9.3px;line-height:1.05}.tiss-field span{display:block;min-height:14px;padding-top:3px;font-size:11px}.tiss-table{width:100%;border-collapse:collapse;margin-bottom:3px;table-layout:fixed}.tiss-table th,.tiss-table td{border:1px solid #222;padding:3px 4px;height:20px;font-size:9.4px;vertical-align:top}.tiss-table th{text-align:left;font-weight:700}.tiss-table.compact th,.tiss-table.compact td{font-size:8.8px;height:18px}.tiss-series{border:1px solid #222;margin-top:3px;padding:3px}.tiss-series>b{display:inline-block;width:49%;font-size:9.3px}.series-lines{display:grid;grid-template-columns:repeat(5,1fr);gap:4px;margin-top:4px}.series-lines span{font-size:9px;white-space:nowrap}.tiss-observation{border:1px solid #222;background:#c7c7c7;min-height:44px;padding:4px;margin-top:3px}.tiss-observation p{margin:4px 0 0}.tiss-totals{display:grid;grid-template-columns:repeat(7,1fr);gap:3px;margin-top:3px}.tiss-signatures{display:grid;grid-template-columns:1fr 1fr 1fr;gap:0;margin-top:3px}.tiss-signatures div{border:1px solid #222;height:36px;padding:4px}.tiss-gap-note{max-width:1120px;margin:14px auto 30px}.tiss-gap-note h2{margin-top:0}@media print{body.print-body{background:white}.no-print,.top,footer{display:none!important}.tiss-sadt-page{width:100%;height:auto;margin:0;box-shadow:none;border:1px solid #222;page-break-after:auto;transform-origin:top left}.tiss-gap-note{display:none!important}@page{size:A4 landscape;margin:6mm}}


/* Digitalized guide upload/OCR review */
.scan-upload-card{max-width:920px}.security-note{border:1px solid var(--border);background:rgba(59,130,246,.08);color:var(--ink-secondary);border-radius:var(--radius-md);padding:12px 14px;font-size:13.5px;line-height:1.45}.steps-list{margin:0;padding-left:22px;color:var(--ink-secondary);line-height:1.75}.scan-review-grid{display:grid;grid-template-columns:minmax(0,2fr) minmax(280px,1fr);gap:20px}.guide-review-form{min-width:0}.form-grid-2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.ocr-preview-panel{border-left:1px solid var(--border);padding-left:18px}.ocr-preview-panel pre{white-space:pre-wrap;word-break:break-word;max-height:520px;overflow:auto;background:var(--input-bg);border:1px solid var(--border);border-radius:var(--radius-md);padding:12px;font-size:12.5px;color:var(--ink-secondary)}.alert.warning{border:1px solid #f59e0b;background:#fffbeb;color:#92400e;border-radius:var(--radius-md);padding:12px 14px;margin-bottom:16px}.alert.danger{border:1px solid #ef4444;background:#fef2f2;color:#991b1b;border-radius:var(--radius-md);padding:12px 14px;margin-bottom:16px}
@media (max-width:900px){.scan-review-grid{grid-template-columns:1fr}.form-grid-2{grid-template-columns:1fr}.ocr-preview-panel{border-left:0;border-top:1px solid var(--border);padding-left:0;padding-top:16px}}
