* {
  box-sizing: border-box;
}

body.app-shell {
  margin: 0;
  font-family: "Manrope", sans-serif;
  --surface-1: rgba(17, 26, 46, 0.96);
  --surface-2: rgba(11, 18, 32, 0.96);
  --surface-3: rgba(17, 26, 46, 0.9);
  --surface-4: rgba(11, 18, 32, 0.85);
  --surface-5: rgba(11, 18, 32, 0.72);
  background:
    radial-gradient(80rem 80rem at -20% -30%, rgba(29, 113, 146, 0.22), transparent 45%),
    radial-gradient(60rem 60rem at 120% 0%, rgba(34, 211, 238, 0.12), transparent 40%),
    var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
}

body.app-shell[data-theme="light"],
html[data-theme="light"] body.app-shell {
  --bg-main: #f2f6fc;
  --bg-secondary: #dce8f8;
  --text-main: #0f172a;
  --text-muted: #475569;
  --border-soft: rgba(15, 23, 42, 0.16);
  --surface-1: rgba(255, 255, 255, 0.97);
  --surface-2: rgba(244, 248, 255, 0.98);
  --surface-3: rgba(255, 255, 255, 0.9);
  --surface-4: rgba(255, 255, 255, 0.95);
  --surface-5: rgba(248, 251, 255, 0.96);
  background:
    radial-gradient(65rem 65rem at -10% -20%, rgba(29, 113, 146, 0.18), transparent 45%),
    radial-gradient(50rem 50rem at 120% -10%, rgba(34, 211, 238, 0.1), transparent 38%),
    var(--bg-main);
}

.sidebar {
  width: 300px;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--surface-1), var(--surface-2));
  border-right: 1px solid var(--border-soft);
  padding: 20px 14px;
  position: sticky;
  top: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 18px;
  border-bottom: 1px solid var(--border-soft);
}

.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 10px;
  filter: drop-shadow(0 0 8px rgba(34, 211, 238, 0.25));
}

.sidebar-brand h1 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.sidebar-brand p {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.sidebar-nav {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nav-item {
  text-decoration: none;
  color: var(--text-muted);
  padding: 10px 12px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all .18s ease;
  font-size: 0.92rem;
}

.nav-item:hover,
.nav-item.active {
  color: var(--text-main);
  background: linear-gradient(90deg, rgba(29, 113, 146, 0.25), rgba(34, 211, 238, 0.12));
  border: 1px solid rgba(34, 211, 238, 0.18);
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.1);
}

.main-content {
  flex: 1;
  min-height: 100vh;
  padding: 18px 20px 24px;
}

.main-content-auth {
  max-width: 100%;
  width: 100%;
  padding: 0;
}

.topbar {
  background: linear-gradient(180deg, var(--surface-3), var(--surface-4));
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h2 {
  margin: 0;
  font-size: 1.05rem;
  font-family: "Rajdhani", sans-serif;
  letter-spacing: 0.04em;
}

.topbar span {
  color: var(--text-muted);
  font-size: 0.84rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--surface-4);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .18s ease;
}

.theme-toggle-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.18rem rgba(34, 211, 238, 0.15);
}

.user-chip {
  padding: 6px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.page-body {
  margin-top: 14px;
}

.flash-stack .alert {
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  color: var(--text-main);
}

.command-hero {
  border: 1px solid rgba(34, 211, 238, 0.22);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(130deg, rgba(20, 78, 91, 0.55), rgba(17, 26, 46, 0.85));
  box-shadow: inset 0 0 40px rgba(34, 211, 238, 0.05), 0 12px 30px rgba(0, 0, 0, 0.3);
}

.command-hero h3 {
  margin: 0;
  font-size: 1.4rem;
  font-family: "Rajdhani", sans-serif;
  font-weight: 700;
}

.command-hero p {
  margin: 6px 0 0;
  color: var(--text-muted);
}

.card-panel {
  border: 1px solid var(--border-soft);
  border-radius: 15px;
  padding: 14px;
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  box-shadow: 0 10px 26px rgba(4, 12, 24, 0.35);
}

.card-panel h4,
.card-panel h5 {
  font-family: "Rajdhani", sans-serif;
  letter-spacing: 0.03em;
}

.kpi-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.kpi-card {
  text-decoration: none;
  color: var(--text-main);
  --kpi-label-color: var(--text-muted);
  --kpi-value-color: var(--text-main);
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background:
    linear-gradient(160deg, rgba(34, 211, 238, 0.09), var(--surface-2) 60%);
  box-shadow: inset 0 0 30px rgba(34, 211, 238, 0.05);
}

.kpi-card.clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 30px rgba(34, 211, 238, 0.16);
}

.kpi-card span {
  color: var(--kpi-label-color);
  font-size: 0.8rem;
}

.kpi-card h4 {
  margin: 5px 0 0;
  font-size: 1.65rem;
  font-family: "Rajdhani", sans-serif;
  color: var(--kpi-value-color);
}

.kpi-card.danger {
  --kpi-value-color: var(--warning);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 12px;
}

.grid-2 .wide {
  grid-column: 1 / -1;
}

.chart-box {
  min-height: 260px;
}

.alert-item,
.insight-item {
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
  background: var(--surface-5);
}

.alert-item.warning {
  border-left: 4px solid var(--warning);
}

.alert-item.critical {
  border-left: 4px solid var(--danger);
}

.insight-item {
  border-left: 4px solid var(--accent);
}

.table-dark {
  --bs-table-bg: transparent;
  --bs-table-border-color: rgba(148, 163, 184, 0.18);
  --bs-table-hover-bg: rgba(34, 211, 238, 0.06);
}

.input-dark {
  background: var(--surface-4);
  color: var(--text-main);
  border: 1px solid var(--border-soft);
}

.input-dark:focus {
  background: var(--surface-4);
  color: var(--text-main);
  border-color: var(--accent);
  box-shadow: 0 0 0 .2rem rgba(34, 211, 238, 0.12);
}

body.app-shell[data-theme="light"] .table-dark,
html[data-theme="light"] body.app-shell .table-dark {
  --bs-table-color: #0f172a;
  --bs-table-bg: transparent;
  --bs-table-border-color: rgba(15, 23, 42, 0.12);
  --bs-table-hover-color: #0f172a;
  --bs-table-hover-bg: rgba(29, 113, 146, 0.08);
}

.btn-glow {
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.25);
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(50rem 50rem at 10% 10%, rgba(29, 113, 146, .25), transparent 45%),
    radial-gradient(45rem 45rem at 90% 20%, rgba(34, 211, 238, .12), transparent 40%),
    #080f1d;
}

.login-panel {
  width: 100%;
  max-width: 440px;
  padding: 22px;
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  background: linear-gradient(180deg, rgba(17, 26, 46, .96), rgba(11, 18, 32, .95));
  box-shadow: 0 20px 45px rgba(0, 0, 0, .4), 0 0 30px rgba(34, 211, 238, 0.08);
}

.login-header {
  text-align: center;
  margin-bottom: 16px;
}

.login-header img {
  width: 60px;
  height: 60px;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(34, 211, 238, 0.35));
}

.login-header h3 {
  margin: 10px 0 4px;
  font-family: "Rajdhani", sans-serif;
}

.login-header p {
  margin: 0;
  color: var(--text-muted);
}

@media (max-width: 1400px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1200px) {
  .sidebar { width: 250px; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  body.app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    min-height: auto;
    position: relative;
  }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Global modern UI overrides */
body.app-shell {
  --ui-cyan: #22d3ee;
  --ui-blue: #3b82f6;
  --ui-indigo: #6366f1;
  --ui-violet: #8b5cf6;
  --ui-pink: #ec4899;
  --ui-orange: #f97316;
  --ui-amber: #f59e0b;
  --ui-green: #22c55e;
  --ui-slate: #0f172a;
  background:
    radial-gradient(90rem 90rem at -25% -35%, rgba(236, 72, 153, 0.14), transparent 42%),
    radial-gradient(70rem 70rem at 115% -10%, rgba(59, 130, 246, 0.18), transparent 38%),
    radial-gradient(55rem 55rem at 50% 115%, rgba(34, 211, 238, 0.12), transparent 34%),
    var(--bg-main);
}

body.app-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at center, #000 30%, transparent 92%);
  opacity: 0.35;
}

body.app-shell[data-theme="light"],
html[data-theme="light"] body.app-shell {
  background:
    radial-gradient(70rem 70rem at -20% -25%, rgba(236, 72, 153, 0.12), transparent 45%),
    radial-gradient(60rem 60rem at 120% -15%, rgba(59, 130, 246, 0.12), transparent 40%),
    radial-gradient(44rem 44rem at 40% 110%, rgba(20, 184, 166, 0.12), transparent 34%),
    var(--bg-main);
}

.sidebar {
  background:
    radial-gradient(circle at 0% 0%, rgba(34, 211, 238, 0.13), transparent 35%),
    radial-gradient(circle at 100% 5%, rgba(236, 72, 153, 0.1), transparent 30%),
    linear-gradient(180deg, var(--surface-1), var(--surface-2));
  border-right: 1px solid rgba(148, 163, 184, 0.24);
  box-shadow: 8px 0 28px rgba(2, 8, 24, 0.3);
  backdrop-filter: blur(10px);
}

.sidebar-brand {
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
}

.brand-logo {
  border: 1px solid rgba(34, 211, 238, 0.35);
}

.nav-item {
  position: relative;
  border: 1px solid transparent;
  background: rgba(15, 23, 42, 0.26);
  padding: 9px 10px;
}

.nav-item i {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(135deg, var(--ui-cyan), var(--ui-blue));
  box-shadow: 0 8px 16px rgba(2, 8, 24, 0.35);
  transition: transform 0.18s ease, filter 0.18s ease;
}

.sidebar-nav .nav-item:nth-child(6n + 1) i {
  background: linear-gradient(135deg, #22d3ee, #3b82f6);
}

.sidebar-nav .nav-item:nth-child(6n + 2) i {
  background: linear-gradient(135deg, #60a5fa, #6366f1);
}

.sidebar-nav .nav-item:nth-child(6n + 3) i {
  background: linear-gradient(135deg, #2dd4bf, #06b6d4);
}

.sidebar-nav .nav-item:nth-child(6n + 4) i {
  background: linear-gradient(135deg, #f59e0b, #f97316);
}

.sidebar-nav .nav-item:nth-child(6n + 5) i {
  background: linear-gradient(135deg, #22c55e, #14b8a6);
}

.sidebar-nav .nav-item:nth-child(6n + 6) i {
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
}

.nav-item:hover,
.nav-item.active {
  background:
    linear-gradient(90deg, rgba(59, 130, 246, 0.2), rgba(236, 72, 153, 0.15));
  border-color: rgba(125, 211, 252, 0.35);
  box-shadow: 0 12px 28px rgba(2, 8, 24, 0.3);
}

.nav-item:hover i,
.nav-item.active i {
  transform: scale(1.06);
  filter: saturate(1.15);
}

.topbar {
  background:
    radial-gradient(circle at 80% 0%, rgba(59, 130, 246, 0.14), transparent 36%),
    linear-gradient(160deg, var(--surface-3), var(--surface-4));
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 14px 30px rgba(2, 8, 24, 0.32);
  backdrop-filter: blur(8px);
}

.theme-toggle-btn {
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.95), rgba(17, 24, 39, 0.82));
}

.theme-toggle-btn:hover {
  border-color: rgba(34, 211, 238, 0.8);
}

.user-chip {
  background: rgba(15, 23, 42, 0.58);
}

.flash-stack .alert {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 12px;
  background:
    linear-gradient(160deg, rgba(15, 23, 42, 0.94), rgba(10, 16, 28, 0.92));
}

.command-hero {
  border: 1px solid rgba(34, 211, 238, 0.34);
  background:
    radial-gradient(circle at 85% 10%, rgba(236, 72, 153, 0.24), transparent 34%),
    radial-gradient(circle at 10% 90%, rgba(59, 130, 246, 0.2), transparent 36%),
    linear-gradient(130deg, rgba(12, 74, 110, 0.55), rgba(30, 27, 75, 0.55), rgba(17, 26, 46, 0.88));
}

.card-panel {
  border: 1px solid rgba(148, 163, 184, 0.22);
  background:
    radial-gradient(circle at 100% 0%, rgba(59, 130, 246, 0.1), transparent 36%),
    radial-gradient(circle at 0% 100%, rgba(236, 72, 153, 0.08), transparent 34%),
    linear-gradient(175deg, var(--surface-3), var(--surface-2));
  box-shadow: 0 14px 32px rgba(2, 8, 24, 0.34);
}

.card-panel h4,
.card-panel h5 {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.card-panel h4::before,
.card-panel h5::before {
  content: "";
  width: 0.58rem;
  height: 0.58rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ui-cyan), var(--ui-violet));
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.14), 0 6px 14px rgba(2, 8, 24, 0.35);
}

.kpi-card {
  border: 1px solid rgba(148, 163, 184, 0.24);
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 100% 0%, rgba(59, 130, 246, 0.22), transparent 36%),
    linear-gradient(155deg, rgba(34, 211, 238, 0.12), var(--surface-2) 65%);
}

.kpi-card:nth-child(4n + 2) {
  background:
    radial-gradient(circle at 100% 0%, rgba(236, 72, 153, 0.24), transparent 36%),
    linear-gradient(155deg, rgba(139, 92, 246, 0.14), var(--surface-2) 65%);
}

.kpi-card:nth-child(4n + 3) {
  background:
    radial-gradient(circle at 100% 0%, rgba(34, 197, 94, 0.2), transparent 36%),
    linear-gradient(155deg, rgba(20, 184, 166, 0.16), var(--surface-2) 65%);
}

.kpi-card:nth-child(4n + 4) {
  background:
    radial-gradient(circle at 100% 0%, rgba(249, 115, 22, 0.22), transparent 36%),
    linear-gradient(155deg, rgba(245, 158, 11, 0.16), var(--surface-2) 65%);
}

.kpi-card.clickable:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(2, 8, 24, 0.35), 0 0 22px rgba(56, 189, 248, 0.22);
}

.alert-item,
.insight-item {
  border-color: rgba(148, 163, 184, 0.28);
  background:
    linear-gradient(160deg, rgba(15, 23, 42, 0.86), rgba(10, 16, 28, 0.88));
}

.table-dark {
  --bs-table-bg: rgba(2, 6, 23, 0.26);
  --bs-table-border-color: rgba(100, 116, 139, 0.45);
  --bs-table-hover-bg: rgba(30, 64, 175, 0.16);
}

.table-dark thead th,
.table.table-dark thead th {
  color: #bfdbfe;
  border-bottom-color: rgba(56, 189, 248, 0.45);
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.95), rgba(10, 16, 30, 0.92));
}

.input-dark,
.form-control.input-dark,
.form-select.input-dark {
  border-color: rgba(100, 116, 139, 0.58);
  background:
    linear-gradient(170deg, rgba(8, 12, 24, 0.94), rgba(9, 14, 26, 0.88));
}

.input-dark:focus,
.form-control.input-dark:focus,
.form-select.input-dark:focus {
  border-color: rgba(56, 189, 248, 0.84);
  box-shadow: 0 0 0 0.2rem rgba(34, 211, 238, 0.18);
}

.btn {
  border-radius: 11px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.btn-info,
.btn.btn-primary {
  border: 0;
  color: #f8fafc;
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  box-shadow: 0 12px 24px rgba(14, 116, 255, 0.3);
}

.btn.btn-info:hover,
.btn.btn-primary:hover {
  color: #ffffff;
  background: linear-gradient(135deg, #22d3ee, #3b82f6);
}

.btn.btn-success {
  border: 0;
  background: linear-gradient(135deg, #22c55e, #10b981);
}

.btn.btn-warning {
  border: 0;
  color: #111827;
  background: linear-gradient(135deg, #fbbf24, #f97316);
}

.btn.btn-outline-light {
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.58);
  background: rgba(15, 23, 42, 0.42);
}

.btn.btn-outline-light:hover {
  color: #fff7ed;
  border-color: rgba(251, 146, 60, 0.85);
  background: linear-gradient(130deg, rgba(249, 115, 22, 0.24), rgba(236, 72, 153, 0.2));
}

.btn.btn-outline-info {
  color: #67e8f9;
  border-color: rgba(34, 211, 238, 0.64);
  background: rgba(8, 20, 38, 0.55);
}

.btn.btn-outline-info:hover {
  color: #ecfeff;
  border-color: rgba(34, 211, 238, 0.85);
  background: rgba(7, 45, 64, 0.7);
}

.btn.btn-outline-danger {
  color: #fecdd3;
  border-color: rgba(248, 113, 113, 0.74);
  background: rgba(127, 29, 29, 0.22);
}

.btn.btn-outline-danger:hover {
  color: #fff1f2;
  border-color: rgba(248, 113, 113, 0.96);
  background: rgba(153, 27, 27, 0.54);
}

.badge.text-bg-dark {
  background: linear-gradient(135deg, rgba(14, 116, 144, 0.44), rgba(79, 70, 229, 0.48)) !important;
  color: #e0f2fe !important;
}

.badge.text-bg-secondary {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.52), rgba(99, 102, 241, 0.58)) !important;
  color: #e2f4ff !important;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  border-radius: 10px;
  border: 1px solid rgba(100, 116, 139, 0.55);
  background: rgba(15, 23, 42, 0.58);
  color: var(--text-main);
}

.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.82);
  box-shadow: 0 0 0 0.2rem rgba(34, 211, 238, 0.18);
}

.login-wrap {
  background:
    radial-gradient(56rem 56rem at 0% 0%, rgba(236, 72, 153, 0.16), transparent 45%),
    radial-gradient(52rem 52rem at 100% 5%, rgba(59, 130, 246, 0.2), transparent 40%),
    radial-gradient(40rem 40rem at 50% 110%, rgba(34, 197, 94, 0.1), transparent 40%),
    #080f1d;
}

.login-panel {
  border: 1px solid rgba(148, 163, 184, 0.28);
  background:
    radial-gradient(circle at 100% 0%, rgba(59, 130, 246, 0.18), transparent 32%),
    linear-gradient(180deg, rgba(17, 26, 46, 0.96), rgba(11, 18, 32, 0.95));
}

body.app-shell[data-theme="light"] .sidebar,
html[data-theme="light"] body.app-shell .sidebar {
  box-shadow: 8px 0 24px rgba(15, 23, 42, 0.08);
}

body.app-shell[data-theme="light"] .nav-item,
html[data-theme="light"] body.app-shell .nav-item {
  background: rgba(255, 255, 255, 0.62);
}

body.app-shell[data-theme="light"] .card-panel,
html[data-theme="light"] body.app-shell .card-panel {
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.1);
}

body.app-shell[data-theme="light"] .table-dark,
html[data-theme="light"] body.app-shell .table-dark {
  --bs-table-hover-bg: rgba(59, 130, 246, 0.1);
}

.hero-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.hero-sync-chip {
  min-width: 220px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 0.45rem 0.65rem;
  background: linear-gradient(180deg, rgba(8, 13, 24, 0.7), rgba(15, 23, 42, 0.38));
  display: grid;
  gap: 0.08rem;
}

.hero-sync-chip span {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.hero-sync-chip strong {
  font-size: 0.95rem;
  color: var(--text-main);
  line-height: 1.2;
}

.hero-sync-chip small {
  color: var(--text-muted);
  font-size: 0.72rem;
}

.section-subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0.35rem 0 0;
}

.kpi-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

.kpi-head .kpi-label {
  color: var(--kpi-label-color);
  font-size: 0.8rem;
}

.kpi-icon {
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  color: #ffffff;
  font-size: 0.84rem;
  background: linear-gradient(135deg, var(--ui-cyan), var(--ui-blue));
  box-shadow: 0 8px 16px rgba(2, 8, 24, 0.35);
}

.kpi-card:nth-child(4n + 2) .kpi-icon {
  background: linear-gradient(135deg, #a855f7, #6366f1);
}

.kpi-card:nth-child(4n + 3) .kpi-icon {
  background: linear-gradient(135deg, #10b981, #06b6d4);
}

.kpi-card:nth-child(4n + 4) .kpi-icon {
  background: linear-gradient(135deg, #f59e0b, #f97316);
}

.kpi-grid-compact {
  margin-top: 0.85rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.table-toolbar .toolbar-left,
.table-toolbar .toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.report-export-grid {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
}

.report-export-grid .btn {
  justify-content: center;
}

.btn .bi:not(:only-child) {
  margin-right: 0.35rem;
}

.source-checklist {
  max-height: 118px;
  overflow: auto;
  border: 1px solid rgba(100, 116, 139, 0.55);
  border-radius: 10px;
  padding: 0.4rem 0.45rem;
  background: linear-gradient(170deg, rgba(8, 12, 24, 0.94), rgba(9, 14, 26, 0.88));
}

.source-check-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.3rem 0.35rem;
  border-radius: 8px;
  color: var(--text-main);
  font-size: 0.96rem;
  cursor: pointer;
}

.source-check-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  width: 100%;
  line-height: 1.1;
}

.source-check-label {
  color: var(--text-main);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.98rem;
  font-weight: 600;
}

.source-sync-inline {
  color: var(--text-muted);
  font-size: 0.84rem;
  white-space: nowrap;
  text-align: right;
}

.source-sync-summary {
  display: block;
  margin: -0.12rem 0 0.38rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.source-check-item:hover {
  background: rgba(59, 130, 246, 0.16);
}

.source-check-item input[type="checkbox"] {
  width: 0.95rem;
  height: 0.95rem;
  accent-color: #22d3ee;
  margin-top: 0.1rem;
}

body.app-shell[data-theme="light"] .source-checklist,
html[data-theme="light"] body.app-shell .source-checklist {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(15, 23, 42, 0.22);
}

@media (max-width: 1400px) {
  .kpi-grid-compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 992px) {
  .report-export-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .report-export-grid {
    grid-template-columns: 1fr;
  }
  .table-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Dropdown/select readability fix (all screens) */
.form-select,
.form-select.input-dark,
.dataTables_wrapper .dataTables_length select {
  color: var(--text-main);
}

.form-select option,
.form-select optgroup,
.dataTables_wrapper .dataTables_length select option {
  background-color: #ffffff;
  color: #0f172a;
}

body.app-shell[data-theme="light"] .form-select option,
html[data-theme="light"] body.app-shell .form-select option,
body.app-shell[data-theme="light"] .form-select optgroup,
html[data-theme="light"] body.app-shell .form-select optgroup,
body.app-shell[data-theme="light"] .dataTables_wrapper .dataTables_length select option,
html[data-theme="light"] body.app-shell .dataTables_wrapper .dataTables_length select option {
  background-color: #ffffff;
  color: #0f172a;
}

.dropdown-menu {
  background: linear-gradient(170deg, rgba(15, 23, 42, 0.98), rgba(10, 16, 30, 0.96));
  border: 1px solid rgba(56, 189, 248, 0.28);
  box-shadow: 0 14px 30px rgba(2, 8, 24, 0.36);
}

.dropdown-item {
  color: #e5eefb;
}

.dropdown-item:hover,
.dropdown-item:focus {
  color: #ffffff;
  background: linear-gradient(120deg, rgba(14, 165, 233, 0.24), rgba(99, 102, 241, 0.2));
}

.dropdown-item.active,
.dropdown-item:active {
  color: #ffffff;
  background: linear-gradient(120deg, rgba(59, 130, 246, 0.5), rgba(124, 58, 237, 0.45));
}

body.app-shell[data-theme="light"] .dropdown-menu,
html[data-theme="light"] body.app-shell .dropdown-menu {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.14);
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.1);
}

body.app-shell[data-theme="light"] .dropdown-item,
html[data-theme="light"] body.app-shell .dropdown-item {
  color: #0f172a;
}

body.app-shell[data-theme="light"] .dropdown-item:hover,
html[data-theme="light"] body.app-shell .dropdown-item:hover,
body.app-shell[data-theme="light"] .dropdown-item:focus,
html[data-theme="light"] body.app-shell .dropdown-item:focus {
  color: #0f172a;
  background: rgba(59, 130, 246, 0.12);
}

/* Data source config assistant */
.config-assistant {
  margin-top: 0.35rem;
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 14px;
  padding: 0.9rem;
  background:
    radial-gradient(circle at 100% 0%, rgba(59, 130, 246, 0.15), transparent 36%),
    linear-gradient(170deg, rgba(11, 18, 32, 0.9), rgba(8, 14, 26, 0.92));
}

.config-assistant-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.config-assistant-head h5 {
  margin: 0;
  font-size: 1.02rem;
}

.config-assistant-head p {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.assistant-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.config-block {
  border: 1px solid rgba(100, 116, 139, 0.4);
  border-radius: 12px;
  padding: 0.75rem;
  background: rgba(15, 23, 42, 0.45);
  min-height: 100%;
}

.config-block h6 {
  margin: 0 0 0.7rem;
  font-size: 0.92rem;
  letter-spacing: 0.03em;
  color: #dbeafe;
}

.config-hint {
  border: 1px dashed rgba(148, 163, 184, 0.55);
  border-radius: 10px;
  padding: 0.55rem 0.6rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.config-separator {
  height: 1px;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.08), rgba(56, 189, 248, 0.5), rgba(236, 72, 153, 0.22));
}

.config-uri-example {
  border: 1px dashed rgba(56, 189, 248, 0.45);
  border-radius: 10px;
  padding: 0.42rem 0.58rem;
  background: rgba(8, 19, 36, 0.62);
  display: grid;
  gap: 0.25rem;
}

.config-uri-label {
  font-size: 0.76rem;
  color: #93c5fd;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.config-uri-example code {
  color: #cffafe;
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-all;
}

.config-uri-note {
  margin-top: 0.25rem;
  font-size: 0.77rem;
  color: var(--text-muted);
}

.frequency-builder {
  border: 1px solid rgba(100, 116, 139, 0.45);
  border-radius: 10px;
  padding: 0.55rem 0.6rem;
  background: rgba(15, 23, 42, 0.35);
}

.frequency-builder .form-label {
  margin-bottom: 0.35rem;
}

body.app-shell[data-theme="light"] .frequency-builder,
html[data-theme="light"] body.app-shell .frequency-builder {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(15, 23, 42, 0.18);
}

.config-feedback {
  min-height: 1.1rem;
  margin: 0.55rem 0 0;
  font-size: 0.82rem;
  color: #7dd3fc;
}

.config-feedback.is-error {
  color: #fca5a5;
}

.config-advanced {
  border-top: 1px dashed rgba(148, 163, 184, 0.45);
  padding-top: 0.55rem;
}

.config-advanced summary {
  cursor: pointer;
  color: #bae6fd;
  font-size: 0.88rem;
}

body.app-shell[data-theme="light"] .config-assistant,
html[data-theme="light"] body.app-shell .config-assistant {
  background:
    radial-gradient(circle at 100% 0%, rgba(59, 130, 246, 0.1), transparent 34%),
    linear-gradient(170deg, rgba(255, 255, 255, 0.95), rgba(248, 251, 255, 0.96));
  border-color: rgba(59, 130, 246, 0.26);
}

body.app-shell[data-theme="light"] .config-block,
html[data-theme="light"] body.app-shell .config-block {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(15, 23, 42, 0.16);
}

body.app-shell[data-theme="light"] .config-block h6,
html[data-theme="light"] body.app-shell .config-block h6 {
  color: #0f172a;
}

@media (max-width: 992px) {
  .config-assistant {
    padding: 0.75rem;
  }

  .assistant-actions {
    width: 100%;
  }
}

/* Help page responsive layout */
.help-manual section[id] {
  scroll-margin-top: 88px;
}

.help-manual .table td,
.help-manual .table th {
  vertical-align: top;
}

.help-manual code {
  white-space: normal;
  overflow-wrap: anywhere;
}

@media (max-width: 992px) {
  .help-manual .command-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.85rem;
  }

  .help-manual .hero-actions {
    width: 100%;
  }

  .help-manual .hero-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .help-manual .card-panel {
    padding: 0.95rem;
  }

  .help-manual .list-group-item {
    font-size: 0.9rem;
    line-height: 1.25;
    padding: 0.58rem 0.68rem;
  }

  .help-manual .table th,
  .help-manual .table td {
    font-size: 0.85rem;
    white-space: nowrap;
  }
}

@media (max-width: 640px) {
  .help-manual .command-hero h3 {
    font-size: 1.15rem;
    line-height: 1.15;
  }

  .help-manual .command-hero p {
    font-size: 0.86rem;
    margin-top: 0.38rem;
  }

  .help-manual .card-panel h4 {
    font-size: 1.05rem;
  }

  .help-manual .card-panel h5 {
    font-size: 0.95rem;
  }

  .help-manual p,
  .help-manual li,
  .help-manual .text-secondary {
    font-size: 0.86rem;
    line-height: 1.38;
  }

  .help-manual .form-label {
    font-size: 0.84rem;
  }

  .help-manual #helpSearchInput {
    height: 40px;
    font-size: 0.9rem;
  }

  .help-manual .hero-actions .btn {
    width: 100%;
    flex: 1 1 100%;
  }
}

/* Configuracoes page responsive layout */
.config-page .table-responsive {
  -webkit-overflow-scrolling: touch;
}

.config-page .config-rules-table {
  min-width: 980px;
}

.config-page .config-kpi-table {
  min-width: 1240px;
}

.config-page .config-source-map-table {
  min-width: 860px;
}

.config-page .config-mobile-hint {
  display: none;
  margin-bottom: 0.55rem;
}

.config-page .config-rule-actions form {
  margin: 0;
}

.config-page .config-kpi-actions .btn {
  white-space: nowrap;
}

@media (max-width: 992px) {
  .config-page .config-mobile-hint {
    display: block;
  }

  .config-page .config-kpi-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }

  .config-page .config-kpi-toolbar .btn {
    width: 100%;
  }

  .config-page .config-kpi-toolbar small {
    font-size: 0.84rem;
    line-height: 1.35;
  }

  .config-page .config-rules-table th,
  .config-page .config-rules-table td,
  .config-page .config-source-map-table th,
  .config-page .config-source-map-table td {
    font-size: 0.86rem;
    white-space: nowrap;
  }
}

@media (max-width: 768px) {
  .config-page .card-panel {
    padding: 0.95rem;
  }

  .config-page .config-kpi-table {
    min-width: 0;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.6rem;
  }

  .config-page .config-kpi-table thead {
    display: none;
  }

  .config-page .config-kpi-table tbody,
  .config-page .config-kpi-table tr {
    display: block;
  }

  .config-page .config-kpi-table tbody tr {
    border: 1px solid rgba(100, 116, 139, 0.44);
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.46);
    padding: 0.72rem;
    margin-bottom: 0.72rem;
  }

  .config-page .config-kpi-table tbody td {
    display: block;
    width: 100%;
    border: 0;
    padding: 0.34rem 0;
  }

  .config-page .config-kpi-table tbody td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.2rem;
    color: var(--text-muted);
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
  }

  .config-page .config-kpi-table .config-kpi-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    padding-top: 0.45rem;
  }

  .config-page .config-kpi-table .config-kpi-actions .btn {
    flex: 1 1 calc(33.333% - 0.4rem);
  }
}

body.app-shell[data-theme="light"] .config-page .config-kpi-table tbody tr,
html[data-theme="light"] body.app-shell .config-page .config-kpi-table tbody tr {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(15, 23, 42, 0.16);
}

.fontes-table {
  min-width: 1140px;
}

.table-info-subtle {
  --bs-table-bg: rgba(59, 130, 246, 0.12);
}

/* Usuarios page layout */
.users-page .users-table {
  min-width: 760px;
}

.users-page .users-actions form {
  margin: 0;
}

.users-page [data-password-tools] .form-control {
  min-width: 260px;
}

@media (max-width: 1200px) {
  .users-page [data-password-tools] {
    flex-wrap: wrap;
  }

  .users-page [data-password-tools] .form-control {
    width: 100%;
    min-width: 100%;
    flex: 1 1 100%;
  }

  .users-page [data-password-tools] .btn {
    flex: 1 1 calc(33.333% - 0.4rem);
  }
}

@media (max-width: 768px) {
  .users-page [data-password-tools] .btn {
    flex: 1 1 100%;
  }
}
