:root {
  --bg: #f5f7fb;
  --bg-dark: #0f172a;
  --surface: #ffffff;
  --surface-soft: #eef2ff;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #0ea5e9;
  --secondary: #16a34a;
  --accent: #f59e0b;
  --danger: #dc2626;
  --border: #e2e8f0;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: var(--bg);
}

a {
  text-decoration: none;
  color: inherit;
}

.container {
  width: min(1200px, 92%);
  margin: 0 auto;
}

.btn-primary,
.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  padding: 11px 18px;
  font-weight: 600;
  transition: all .2s ease;
}

.btn-primary {
  background: linear-gradient(120deg, var(--primary), #0284c7);
  color: #fff;
  border: 1px solid transparent;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-outline {
  border: 1px solid var(--border);
  color: var(--text);
  background: #fff;
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.full {
  width: 100%;
}

.public-body {
  background: radial-gradient(circle at top right, #dbeafe 0, #f8fafc 45%, #ecfeff 100%);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid #e2e8f0;
}

.header-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
}

.logo-wrap {
  display: flex;
  gap: 12px;
  align-items: center;
}

.logo-wrap i {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(120deg, var(--primary), var(--secondary));
  color: #fff;
}

.logo-wrap h2 {
  margin: 0;
  font-size: 18px;
}

.logo-wrap p {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.hero {
  padding: 70px 0 50px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 24px;
  align-items: center;
}

.hero-tag {
  background: #dbeafe;
  color: #1d4ed8;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}

.hero h1 {
  font-size: clamp(30px, 4.2vw, 52px);
  line-height: 1.12;
  margin: 14px 0;
}

.hero p {
  color: #334155;
  max-width: 680px;
}

.hero-actions {
  margin-top: 20px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-card {
  background: rgba(255,255,255,0.85);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.hero-card h3 {
  margin-top: 0;
}

.hero-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.hero-card li {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
  color: #1e293b;
}

.hero-card i {
  color: var(--secondary);
}

.section {
  padding: 45px 0;
}

.muted {
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
}

.cards-3 {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.feature-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.feature-card i {
  font-size: 22px;
  color: var(--primary);
}

.feature-card h4 {
  margin-bottom: 8px;
}

.feature-card p {
  margin: 0;
  color: var(--text-muted);
}

.program-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

.program-chip {
  background: #fff;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
}

.program-chip i {
  color: #0284c7;
}

.site-footer {
  background: #0b1220;
  color: #e2e8f0;
  padding: 16px 0;
}

.footer-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, #cffafe 0%, #e2e8f0 50%, #dbeafe 100%);
}

.auth-wrap {
  width: min(460px, 92%);
}

.auth-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px;
  box-shadow: var(--shadow);
}

.auth-brand {
  text-align: center;
  margin-bottom: 14px;
}

.auth-brand i {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  margin: 0 auto 10px;
  background: linear-gradient(120deg, var(--primary), var(--secondary));
  color: #fff;
}

.auth-brand h2 {
  margin: 0;
}

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

.alert-error {
  margin: 12px 0;
  padding: 10px;
  border-radius: 10px;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.auth-form {
  display: grid;
  gap: 8px;
}

.auth-form label {
  margin-top: 8px;
  font-size: 14px;
  color: #334155;
}

.auth-form input {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
}

.auth-form input:focus {
  border-color: #0ea5e9;
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.15);
}

.auth-meta {
  text-align: center;
  margin-top: 15px;
}

.auth-meta a {
  color: var(--primary);
}

.app-body {
  background: #f1f5f9;
}

.app-shell {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #0f172a;
  color: #cbd5e1;
  padding: 18px 14px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px;
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.1);
}

.brand-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(140deg, #0284c7, #16a34a);
}

.brand h3 {
  margin: 0;
  color: #fff;
}

.brand p {
  margin: 0;
  color: #94a3b8;
  font-size: 12px;
}

.nav-menu {
  margin-top: 18px;
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border-radius: 10px;
  color: #cbd5e1;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(14, 165, 233, 0.2);
  color: #f8fafc;
}

.main-panel {
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 70px;
  padding: 0 22px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.icon-btn {
  border: 1px solid var(--border);
  background: #fff;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
}

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

.badge-chip,
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 8px 12px;
  background: #fff;
}

.logout-link {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
}

.dashboard-header,
.stats-grid,
.panel-grid {
  width: calc(100% - 46px);
  margin: 22px auto 0;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.dashboard-header h1 {
  margin: 0;
}

.dashboard-header p {
  margin: 4px 0 0;
  color: #64748b;
}

.quick-actions {
  display: flex;
  gap: 8px;
}

.stats-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.stat-card p {
  margin: 0;
  color: #64748b;
  font-size: 13px;
}

.stat-card h3 {
  margin: 8px 0 0;
  font-size: 22px;
}

.panel-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 24px;
}

.panel-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  background: #fff;
  box-shadow: var(--shadow);
}

.panel-card h3 {
  margin-top: 0;
}

.simple-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.simple-list li {
  display: grid;
  gap: 4px;
  border-bottom: 1px dashed #e2e8f0;
  padding-bottom: 8px;
}

.muted-text {
  color: #64748b;
}

.flash-success,
.flash-error {
  width: calc(100% - 46px);
  margin: 12px auto 0;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
}

.flash-success {
  border: 1px solid #bbf7d0;
  background: #ecfdf3;
  color: #166534;
}

.flash-error {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.tab-strip {
  width: calc(100% - 46px);
  margin: 14px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab-item {
  display: inline-flex;
  align-items: center;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: #334155;
  font-weight: 600;
  font-size: 14px;
}

.tab-item.active,
.tab-item:hover {
  border-color: #bae6fd;
  background: #e0f2fe;
  color: #0369a1;
}

.panel-grid.single {
  grid-template-columns: 1fr;
}

.panel-grid.split-2 {
  grid-template-columns: 1fr 1fr;
}

.panel-grid.split-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.access-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.access-panels {
  grid-template-columns: 1fr;
}

.grid-form {
  display: grid;
  gap: 8px;
}

.grid-form label {
  font-size: 13px;
  color: #475569;
  margin-top: 4px;
}

.grid-form input,
.grid-form select,
.grid-form textarea,
.inline-form input,
.inline-form select {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px 11px;
  outline: none;
  background: #fff;
}

.grid-form input:focus,
.grid-form select:focus,
.grid-form textarea:focus,
.inline-form input:focus,
.inline-form select:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.15);
}

.grid-form.compact {
  gap: 10px;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.inline-form label {
  font-size: 13px;
  color: #475569;
  font-weight: 600;
}

.form-popup-trigger {
  margin: 8px 0 6px;
  gap: 7px;
}

.form-popup-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 1200;
}

.form-popup-modal.open {
  display: block;
}

.form-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.56);
}

.form-popup-dialog {
  position: relative;
  width: min(760px, calc(100% - 28px));
  max-height: calc(100vh - 40px);
  margin: 20px auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(2, 6, 23, 0.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.form-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.form-popup-header h4 {
  margin: 0;
  font-size: 16px;
  color: #0f172a;
}

.form-popup-close {
  border: none;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  color: #334155;
  cursor: pointer;
}

.form-popup-body {
  padding: 14px 16px 18px;
  overflow: auto;
}

body.popup-open {
  overflow: hidden;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  border: 1px dashed #dbeafe;
  border-radius: 10px;
  padding: 10px;
  background: #f8fbff;
}

.checkbox-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #334155;
}

.permission-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-height: 380px;
  overflow: auto;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  padding: 10px;
  background: #f8fafc;
}

.permission-grid code {
  font-size: 12px;
  background: #e2e8f0;
  padding: 2px 6px;
  border-radius: 6px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  max-height: 560px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

.app-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.app-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
}

.app-table th,
.app-table td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid #e2e8f0;
}

.app-table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}

.status-badge.ok {
  background: #dcfce7;
  color: #166534;
}

.status-badge.off {
  background: #fee2e2;
  color: #991b1b;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 84px 1fr;
}

.app-shell.sidebar-collapsed .brand h3,
.app-shell.sidebar-collapsed .brand p,
.app-shell.sidebar-collapsed .nav-item {
  font-size: 0;
}

.app-shell.sidebar-collapsed .nav-item i,
.app-shell.sidebar-collapsed .brand-badge {
  font-size: 16px;
}

@media (max-width: 1000px) {
  .hero-grid,
  .cards-3,
  .program-grid,
  .stats-grid,
  .panel-grid {
    grid-template-columns: 1fr;
  }

  .header-wrap {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .header-nav {
    width: 100%;
    flex-wrap: wrap;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .checkbox-grid,
  .permission-grid,
  .panel-grid.split-2,
  .panel-grid.split-3,
  .panel-grid.split-6,
  .access-stats {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }
}
