:root {
  --bg: #f4f4f5;
  --card: #ffffff;
  --line: #dfe2e7;
  --text: #21252f;
  --muted: #666f7f;
  --sidebar: #1e2026;
  --sidebar-line: #2a2e37;
  --sidebar-text: #e6e8ef;
  --sidebar-muted: #9ea6b7;
  --highlight: #d8ef2f;
  --highlight-border: #b8d021;
  --danger: #ad3f3f;
  --pink: #ce9bbc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.admin-app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--sidebar-line);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
}

.school-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
  border-bottom: 1px solid var(--sidebar-line);
}

.school-brand img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}

.school-name {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-nav {
  padding: 8px;
  overflow: auto;
  flex: 1;
}

.nav-group {
  margin: 14px 8px 4px;
  font-size: 11px;
  color: var(--sidebar-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.nav-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--sidebar-text);
  text-align: left;
  padding: 9px 11px;
  min-height: 44px;
  cursor: pointer;
  font-size: 14px;
}

.nav-item:hover {
  background: #2b2f39;
}

.nav-item.active {
  background: #f8f9fc;
  color: #1e2026;
  border-color: #d8dde7;
}

.sidebar-footer {
  border-top: 1px solid var(--sidebar-line);
  padding: 12px 14px;
}

.sidebar-link {
  color: #edf1fb;
  text-decoration: none;
  font-size: 13px;
}

.sidebar-link:hover {
  text-decoration: underline;
}

.main-area {
  min-width: 0;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: 37px;
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.menu-btn {
  display: none;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 13px;
  font-weight: 700;
}

.view {
  padding: 16px 20px 32px;
}

.card,
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}

.panel + .panel {
  margin-top: 12px;
}

.grid-2,
.grid-3,
.grid-4 {
  display: grid;
  gap: 12px;
}

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

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

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

.kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}

.kpi p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.kpi strong {
  display: block;
  margin-top: 6px;
  font-size: 36px;
  line-height: 1;
  font-weight: 700;
}

.btn {
  border: 1px solid #1f2430;
  background: #1f2430;
  color: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 44px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn:hover {
  filter: brightness(0.97);
}

.btn.ghost {
  background: #fff;
  color: #1f2430;
  border-color: #c2c8d5;
}

.btn.success {
  background: var(--highlight);
  border-color: var(--highlight-border);
  color: #1e2026;
}

.btn.danger {
  background: #fff;
  border-color: #e0b3b3;
  color: var(--danger);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid #c4cad7;
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  padding: 10px 11px;
  min-height: 44px;
}

.textarea {
  min-height: 110px;
  resize: vertical;
}

.search-input {
  width: min(440px, 100%);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.data-table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid #eceef2;
  text-align: left;
  padding: 10px;
  vertical-align: top;
  font-size: 14px;
}

.data-table th {
  text-transform: uppercase;
  font-size: 11px;
  color: #667081;
  letter-spacing: 0.04em;
  background: #fafbfe;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid #cfd4e0;
  border-radius: 999px;
  font-size: 11px;
  padding: 3px 8px;
  background: #f7f8fb;
}

.badge.published {
  background: #eef8f0;
  border-color: #9bccab;
  color: #145d2d;
}

.badge.unpublished {
  background: #fff3f3;
  border-color: #e5b2b2;
  color: #8d2e2e;
}

.badge.draft {
  background: #f3f4f8;
  border-color: #d2d6e0;
  color: #4e5664;
}

.helper {
  color: var(--muted);
  font-size: 13px;
}

.muted {
  color: var(--muted);
}

.warning {
  border: 1px solid #ead395;
  background: #fff8e8;
  color: #7b5e1a;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}

.empty-state {
  border: 1px dashed #ccd2de;
  border-radius: 10px;
  padding: 34px 18px;
  text-align: center;
  color: #697183;
  background: #fafbfd;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 10px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 12px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  font-size: 39px;
  line-height: 1;
}

.tab-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}

.tab-btn {
  border: 1px solid #c4cad7;
  background: #fff;
  border-radius: 8px;
  min-height: 44px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  color: #2b313d;
}

.tab-btn.active {
  border-color: #1f2430;
  color: #1f2430;
}

.kv {
  margin: 8px 0;
  font-size: 14px;
}

.kv b {
  display: inline-block;
  min-width: 170px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
}

.switch input {
  width: 19px;
  height: 19px;
  accent-color: #1f2430;
}

.course-shell {
  display: grid;
  grid-template-columns: 126px minmax(0, 1fr);
  gap: 12px;
}

.course-side {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.course-side button {
  width: 100%;
  border: 0;
  border-bottom: 1px solid #edf0f5;
  background: #fff;
  text-align: left;
  padding: 11px 10px;
  min-height: 44px;
  font-size: 14px;
  cursor: pointer;
}

.course-side button.active {
  background: #f3f6fb;
  font-weight: 700;
}

.course-side button:last-child {
  border-bottom: 0;
}

.preview-box {
  border: 1px solid #d9deea;
  border-radius: 10px;
  background: #f4f7ff;
  padding: 12px;
}

.preview-box ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.preview-box li {
  margin-bottom: 4px;
}

.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.app-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 12px;
}

.app-card h3 {
  margin: 0;
  font-size: 18px;
}

.app-card p {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(12, 16, 24, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 18px;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(640px, 100%);
  max-height: calc(100vh - 30px);
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #cfd4df;
  padding: 14px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.modal-header h2 {
  margin: 0;
  font-size: 30px;
  font-weight: 500;
}

.modal-form {
  display: grid;
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 13px;
  font-weight: 700;
  color: #3d4656;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.inline-select {
  display: grid;
  gap: 5px;
}

.inline-select label {
  font-size: 12px;
  color: var(--muted);
}

.mega-note {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 12px;
}

.course-catalog-categories .row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 8px;
  margin-bottom: 8px;
}

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

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

@media (max-width: 940px) {
  .admin-app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 90vw);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 190;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .topbar {
    padding: 14px;
  }

  .topbar h1 {
    font-size: clamp(24px, 6vw, 32px);
  }

  .view {
    padding: 12px 12px 26px;
  }

  .grid-2,
  .grid-3,
  .metric-row {
    grid-template-columns: 1fr;
  }

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

  .course-side {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .course-side button {
    border-right: 1px solid #edf0f5;
  }
}

@media (max-width: 640px) {
  .data-table {
    min-width: 620px;
  }

  .course-catalog-categories .row {
    grid-template-columns: 1fr;
  }

  .modal-card {
    padding: 12px;
  }

  .modal-header h2 {
    font-size: 25px;
  }
}
