:root {
  --bg: #0c1222;
  --panel: #111827;
  --card: #1f2937;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --border: rgba(255, 255, 255, 0.18);
  --soft-line: rgba(255, 255, 255, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 10% 10%, rgba(45, 212, 191, 0.16), transparent 38%),
    radial-gradient(circle at 90% 0%, rgba(56, 189, 248, 0.14), transparent 32%),
    linear-gradient(180deg, #0b1020, #0c1222 30%, #0a1020 100%);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.loading-card {
  width: min(320px, 90vw);
  padding: 18px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: #0f172a;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  text-align: center;
}
.loading-card small {
  color: var(--muted);
}
.loading-spinner {
  width: 26px;
  height: 26px;
  border: 3px solid rgba(148, 163, 184, 0.35);
  border-top-color: #22d3ee;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.wrap { max-width: 1380px; margin: 0 auto; padding: 14px; }
.topbar { padding: 6px 0 8px; }
.topbar h1 { margin: 0 0 6px; font-size: 30px; }
.topbar p { margin: 0; color: var(--muted); }

.panel {
  margin: 12px 0;
  padding: 14px;
  border: 1px solid var(--soft-line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 18px 35px -28px rgba(0, 0, 0, 0.95);
}

.filters h2 { margin-top: 0; }
.grid-6 { display: grid; grid-template-columns: repeat(6, minmax(150px, 1fr)); gap: 10px; }

label { display: block; font-size: 13px; color: var(--muted); }
input, select, button {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0b1220;
  color: var(--text);
  padding: 9px 10px;
}

.actions { margin-top: 12px; display: grid; grid-template-columns: 220px 180px 120px; gap: 10px; align-items: end; }

.btn {
  cursor: pointer;
  background: linear-gradient(135deg, #14b8a6, #0ea5e9);
  color: #03232a;
  font-weight: 700;
}
.btn:hover { border-color: rgba(45, 212, 191, 0.55); }
.btn.ghost { background: #0f172a; color: #dbeafe; font-weight: 600; }
.btn-inline { width: auto; padding: 8px 10px; margin-top: 0; }

.tabs-panel { display: flex; gap: 10px; align-items: center; }
.tab-btn { width: auto; min-width: 120px; background: #0f172a; color: #cbd5e1; }
.tab-btn.active {
  background: linear-gradient(135deg, #14b8a6, #0ea5e9);
  border-color: rgba(186, 230, 253, 0.65);
  color: #03232a;
}

.hidden { display: none; }

.kpis { margin: 12px 0; display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--soft-line); border-radius: 12px; padding: 12px; }
.kpi span { color: var(--muted); display: block; font-size: 13px; }
.kpi strong { font-size: 24px; margin-top: 4px; display: block; }

.split { display: grid; grid-template-columns: 360px 1fr; gap: 14px; }

h2 { margin: 0 0 10px; font-size: 18px; }
h3 { margin: 10px 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }

.table-tools { margin: 8px 0 6px; display: flex; justify-content: flex-end; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-bottom: 1px solid var(--soft-line); text-align: left; vertical-align: top; padding: 8px 6px; }
th {
  color: #ffffff;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-size: 11px;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, rgba(45, 212, 191, 0.14), rgba(15, 23, 42, 0.8));
  z-index: 3;
}
.filter-row th { top: 32px; background: #0f172a; padding: 4px; z-index: 2; }
.filter-row input { margin-top: 0; padding: 6px; font-size: 12px; border-color: rgba(186, 230, 253, 0.35); }

.table-wrap {
  max-height: 70vh;
  overflow: auto;
  border: 1px solid rgba(55, 65, 81, 0.85);
  border-radius: 14px;
  background: linear-gradient(165deg, rgba(17, 24, 39, 0.98) 0%, rgba(15, 23, 42, 0.92) 50%, rgba(17, 24, 39, 0.96) 100%);
}
tbody tr:hover { background: rgba(45, 212, 191, 0.07); }

.hint { margin-top: 8px; color: var(--muted); font-size: 12px; }
.hint-box {
  border: 1px dashed rgba(94, 234, 212, 0.35);
  border-radius: 10px;
  padding: 14px;
  background: rgba(15, 23, 42, 0.45);
}
.hint-box p { margin: 8px 0; color: var(--muted); }

.click-filters { margin-top: 10px; display: flex; gap: 8px; align-items: center; color: var(--muted); flex-wrap: wrap; }
.click-filters strong { color: var(--text); }

.clickable-cell { cursor: pointer; color: #7dd3fc; }
.clickable-cell:hover { text-decoration: underline; }

.pagination-panel { display: flex; gap: 10px; justify-content: center; align-items: center; }
#statusMsg { color: var(--muted); }

@media (max-width: 1250px) {
  .grid-6 { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
  .actions { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .grid-6 { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
}

.login-shell { max-width: 480px; }
.login-card h2 { margin-top: 0; }
.login-form { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.login-form label { margin: 0; }
.topbar-actions { margin: 8px 0 0; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.topbar-actions .btn-inline { width: auto; }
.panel code { font-size: 12px; color: #a5f3fc; }
