:root {
  --bg-0: #07111f;
  --bg-1: #10233d;
  --glass: rgba(255, 255, 255, 0.07);
  --glass-strong: rgba(255, 255, 255, 0.12);
  --stroke: rgba(255, 255, 255, 0.16);
  --text: #f4f7ff;
  --muted: #a9b7d0;
  --cyan: #22d3ee;
  --violet: #a78bfa;
  --gold: #fbbf24;
  --pink: #f472b6;
  --green: #34d399;
  --danger: #fb7185;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
  --radius: 22px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: "Plus Jakarta Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at -10% -20%, #1b3b6a 0%, transparent 55%),
    radial-gradient(900px 600px at 110% 10%, #3b1d63 0%, transparent 50%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 55%, #0b1728);
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px 1fr;
}

button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }

.bg-orbs { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.45;
  animation: float 16s ease-in-out infinite;
}
.orb-1 { width: 340px; height: 340px; background: #22d3ee55; top: -80px; left: 280px; }
.orb-2 { width: 280px; height: 280px; background: #a78bfa55; right: -40px; top: 30%; animation-delay: -6s; }
.orb-3 { width: 360px; height: 360px; background: #f472b633; bottom: -120px; left: 40%; animation-delay: -10s; }
@keyframes float {
  0%, 100% { transform: translateY(0) translateX(0); }
  50% { transform: translateY(-28px) translateX(18px); }
}

.glass {
  background: var(--glass);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
}

.sidebar {
  position: sticky;
  top: 16px;
  align-self: start;
  margin: 16px 0 16px 16px;
  border-radius: 28px;
  padding: 22px 16px;
  min-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  z-index: 2;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 6px 8px 22px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  font-weight: 800; font-size: 20px; color: #081221;
}
.brand-title { font-weight: 800; font-size: 20px; letter-spacing: 0.02em; }
.brand-sub { color: var(--muted); font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 600;
  transition: 0.2s ease;
}
.nav-item:hover { background: var(--glass-strong); color: var(--text); }
.nav-item.active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.18), rgba(167, 139, 250, 0.22));
  border-color: rgba(34, 211, 238, 0.28);
}
.nav-ico { width: 22px; display: inline-block; text-align: center; }
.sidebar-foot { margin-top: auto; padding: 18px 8px 6px; }
.pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  color: var(--muted);
  font-size: 12px;
}

.main { position: relative; z-index: 1; padding: 16px 22px 32px 18px; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 18px;
}
.topbar h1 { margin: 0; font-size: 26px; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.topbar-meta { color: var(--muted); font-size: 13px; text-align: right; }

.page { animation: fade 0.28s ease; }
.hidden { display: none !important; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.stat {
  border-radius: 20px;
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: "";
  position: absolute; right: -20px; top: -20px;
  width: 110px; height: 110px; border-radius: 50%;
  background: rgba(255,255,255,0.06);
}
.stat .label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.stat .value { font-size: 24px; font-weight: 800; letter-spacing: -0.03em; }
.stat .note { margin-top: 8px; color: var(--muted); font-size: 12px; }
.stat.s1 { border-top: 3px solid var(--cyan); }
.stat.s2 { border-top: 3px solid var(--gold); }
.stat.s3 { border-top: 3px solid var(--pink); }
.stat.s4 { border-top: 3px solid var(--green); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.panel { border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.panel-head h2, .toolbar h2 { margin: 0; font-size: 18px; }
.hint { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.chart-wrap { position: relative; height: 280px; margin-top: 10px; }
.chart-wide { height: 300px; }

.toolbar {
  display: flex; gap: 10px; align-items: center; justify-content: space-between;
  margin-bottom: 14px; flex-wrap: wrap;
}
.search {
  flex: 1; min-width: 220px;
  background: rgba(8, 18, 33, 0.35);
  border: 1px solid var(--stroke);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
}
.search:focus, input:focus, select:focus, textarea:focus {
  border-color: rgba(34, 211, 238, 0.55);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

.btn-primary, .btn-ghost, .btn-tiny {
  border-radius: 12px;
  border: 1px solid transparent;
  padding: 11px 16px;
  font-weight: 700;
}
.btn-primary {
  background: linear-gradient(135deg, #22d3ee, #818cf8);
  color: #081221;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-color: var(--stroke);
}
.btn-tiny {
  padding: 7px 10px;
  font-size: 12px;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border-color: var(--stroke);
  margin-right: 6px;
}
.btn-tiny.danger { color: #fecdd3; border-color: rgba(251, 113, 133, 0.35); }
.btn-tiny.ok { color: #bbf7d0; border-color: rgba(52, 211, 153, 0.35); }

.table-panel { overflow: hidden; }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 13px;
}
th { color: var(--muted); font-weight: 700; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.col-actions { width: 150px; text-align: right; }
tbody tr:hover { background: rgba(255,255,255,0.04); }
tfoot td { font-weight: 800; border-bottom: none; }
.empty {
  text-align: center; color: var(--muted); padding: 28px 12px;
}

.form-stack { display: grid; gap: 12px; }
.form-stack label, .modal-body label {
  display: grid; gap: 6px;
  font-size: 13px; color: var(--muted); font-weight: 600;
}
input, select, textarea {
  width: 100%;
  background: rgba(8, 18, 33, 0.45);
  border: 1px solid var(--stroke);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
}
textarea { min-height: 84px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.preview-box {
  border: 1px dashed rgba(34, 211, 238, 0.35);
  background: rgba(34, 211, 238, 0.08);
  border-radius: 14px;
  padding: 12px;
  font-size: 13px;
}
.preview-box strong { display: block; margin-bottom: 4px; }

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(4, 10, 20, 0.55);
  backdrop-filter: blur(10px);
  display: grid; place-items: center;
  z-index: 50; padding: 20px;
}
.modal {
  width: min(620px, 100%);
  border-radius: 24px;
  padding: 8px 8px 16px;
}
.modal-head, .modal-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
}
.modal-head h3 { margin: 0; }
.modal-body { padding: 6px 16px 10px; display: grid; gap: 12px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--stroke);
  background: transparent; color: var(--text); font-size: 22px;
}

.glass-swal {
  background: rgba(14, 24, 42, 0.86) !important;
  color: var(--text) !important;
  border: 1px solid var(--stroke) !important;
  backdrop-filter: blur(18px);
  border-radius: 22px !important;
}
.glass-swal .swal2-title, .glass-swal .swal2-html-container { color: var(--text) !important; }

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
  border: 1px solid var(--stroke);
}
.badge.warn { color: #fecaca; border-color: rgba(251,113,133,0.4); }
.badge.ok { color: #bbf7d0; border-color: rgba(52,211,153,0.4); }

@media (max-width: 1100px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: relative; top: 0; margin: 12px; min-height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-item { width: auto; }
  .cards, .grid-2, .form-row { grid-template-columns: 1fr; }
  .main { padding: 0 12px 24px; }
}

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  grid-template-columns: 1fr;
}
.login-wrap { width: min(420px, calc(100% - 32px)); position: relative; z-index: 1; }
.login-card { border-radius: 28px; padding: 28px 26px; display: grid; gap: 14px; }
.login-card h1 { margin: 8px 0 0; font-size: 24px; }
.login-brand { padding: 0 0 8px; }
.form-error { color: #fecaca; margin: 0; font-size: 13px; }

.topbar-right { display: flex; align-items: center; gap: 16px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip span { color: var(--muted); font-size: 13px; font-weight: 600; }

.nav-item { position: relative; }
.nav-badge {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #fb7185;
  color: #2b0710;
  font-size: 11px;
  font-weight: 800;
  display: inline-grid;
  place-items: center;
}
.nav-badge.warn { background: #fbbf24; color: #2b1903; }

.alert-stack { display: grid; gap: 10px; margin-bottom: 16px; }
.alert-banner {
  border-radius: 16px;
  padding: 14px 16px;
  border: 1px solid var(--stroke);
}
.alert-banner h3 { margin: 0 0 6px; font-size: 15px; }
.alert-banner ul { margin: 0; padding-left: 18px; color: var(--muted); }
.alert-banner.expired { border-color: rgba(251, 113, 133, 0.45); background: rgba(251, 113, 133, 0.12); }
.alert-banner.expiring { border-color: rgba(251, 191, 36, 0.45); background: rgba(251, 191, 36, 0.12); }

.split-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.calc-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.calc-card {
  border-radius: 14px;
  padding: 12px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.04);
}
.calc-card .k { color: var(--muted); font-size: 12px; }
.calc-card .v { font-weight: 800; margin-top: 4px; }

.rp-field { display: grid; gap: 6px; }
.rp-input {
  display: flex;
  align-items: center;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: rgba(8, 18, 33, 0.45);
  overflow: hidden;
}
.rp-input span {
  padding: 0 12px;
  color: var(--muted);
  font-weight: 700;
  border-right: 1px solid var(--stroke);
}
.rp-input input {
  border: 0;
  background: transparent;
  border-radius: 0;
}

.badge.soon { color: #fde68a; border-color: rgba(251, 191, 36, 0.45); }

.brand-title { font-size: 16px; line-height: 1.25; max-width: 170px; }
.user-link {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--stroke);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 12px;
}
.user-link:hover { background: rgba(255,255,255,0.1); }
.role-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 800; letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(34, 211, 238, 0.16);
  color: #a5f3fc;
  border: 1px solid rgba(34, 211, 238, 0.28);
}
.role-badge.superadmin { background: rgba(167, 139, 250, 0.2); color: #ddd6fe; border-color: rgba(167,139,250,0.35); }
.role-badge.admin { background: rgba(251, 191, 36, 0.16); color: #fde68a; border-color: rgba(251,191,36,0.35); }

.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 12px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
}
.filter-chip span {
  min-width: 18px; height: 18px; padding: 0 6px;
  border-radius: 999px;
  display: inline-grid; place-items: center;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-size: 11px;
}
.filter-chip.active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.18), rgba(167, 139, 250, 0.22));
  border-color: rgba(34, 211, 238, 0.35);
}
.filter-chip.expired.active { border-color: rgba(251, 113, 133, 0.45); background: rgba(251, 113, 133, 0.16); }
.filter-chip.exp7.active, .filter-chip.exp30.active { border-color: rgba(251, 191, 36, 0.45); background: rgba(251, 191, 36, 0.14); }

.count-cards { margin-bottom: 14px; }
.count-cards .stat .value { font-size: 22px; }

.table-pager {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; flex-wrap: wrap;
  padding-top: 12px;
  color: var(--muted); font-size: 12px;
}
.pager-btns { display: flex; gap: 6px; align-items: center; }
.pager-btns button {
  min-width: 32px; height: 32px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font-weight: 700;
}
.pager-btns button.active {
  background: linear-gradient(135deg, #22d3ee, #818cf8);
  color: #081221;
  border-color: transparent;
}
.pager-btns button:disabled { opacity: 0.4; cursor: default; }

.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.th-sort::after { content: " ↕"; opacity: 0.35; font-size: 10px; }
.th-sort.asc::after { content: " ↑"; opacity: 0.9; }
.th-sort.desc::after { content: " ↓"; opacity: 0.9; }

.badge.critical { color: #fecaca; border-color: rgba(251,113,133,0.45); background: rgba(251,113,133,0.12); }
