*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg-main: radial-gradient(circle at top, #0f172a 0, #020617 55%, #000 100%);
  --bg-card: rgba(15, 23, 42, 0.92);
  --bg-card-soft: rgba(15, 23, 42, 0.7);
  --border-subtle: rgba(148, 163, 184, 0.18);
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.15);
  --accent-strong: #0ea5e9;
  --gold: #facc15;
  --text-main: #e5e7eb;
  --text-dim: #9ca3af;
  --error: #f97373;
  --danger: #ef4444;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-pill: 999px;
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.9);
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  background: #020617;
  color: var(--text-main);
}

body {
  background-image: var(--bg-main);
  background-attachment: fixed;
}

/* Layout */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */

.sidebar {
  width: 290px;
  max-width: 100%;
  padding: 18px 18px 20px;
  border-right: 1px solid rgba(148, 163, 184, 0.25);
  background: radial-gradient(circle at top left, #020617 0, #020617 40%, #000 100%);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 18px;
  background: radial-gradient(circle at 30% 20%, #22d3ee, #0369a1 55%, #000);
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.brand-cross {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 2px solid rgba(248, 250, 252, 0.92);
  position: relative;
}

.brand-cross::before,
.brand-cross::after {
  content: "";
  position: absolute;
  background: rgba(248, 250, 252, 0.92);
  border-radius: 999px;
}

.brand-cross::before {
  width: 60%;
  height: 2px;
  top: 50%;
  left: 20%;
  transform: translateY(-50%);
}

.brand-cross::after {
  width: 2px;
  height: 60%;
  left: 50%;
  top: 20%;
  transform: translateX(-50%);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 650;
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.student-card {
  border-radius: var(--radius-lg);
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: linear-gradient(
    135deg,
    rgba(15, 23, 42, 0.98),
    rgba(15, 23, 42, 0.8)
  );
  box-shadow: 0 0 18px rgba(15, 23, 42, 0.7);
  padding: 10px 10px 12px;
  display: flex;
  gap: 10px;
}

.student-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: radial-gradient(circle at 25% 25%, #22d3ee, #0369a1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 650;
}

.student-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.student-name {
  font-weight: 600;
}

.student-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.student-meta.small {
  font-size: 0.72rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nav-item {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  text-align: left;
  font-size: 0.86rem;
  color: var(--text-dim);
  background: transparent;
  cursor: pointer;
  transition: all 0.18s ease-out;
}

.nav-item.active {
  background: radial-gradient(circle at 20% 0, #22d3ee, #0369a1);
  color: #f9fafb;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.8);
}

.nav-item:not(.active):hover {
  background: rgba(15, 23, 42, 0.85);
  color: #e5e7eb;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-box {
  border-radius: var(--radius-md);
  border: 1px dashed rgba(148, 163, 184, 0.65);
  padding: 8px 10px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.mode-box ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.mode-title {
  font-weight: 600;
  margin-bottom: 3px;
}

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

.status-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: rgba(15, 23, 42, 0.9);
}

.status-kv {
  border-color: rgba(250, 204, 21, 0.8);
  color: #facc15;
}

.status-api {
  border-color: rgba(56, 189, 248, 0.8);
  color: #7dd3fc;
}

/* Main */

.main {
  flex: 1;
  padding: 16px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.45rem;
}

.topbar p {
  margin: 2px 0 0;
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* Tabs */

.tab {
  display: none;
}

.tab.active {
  display: block;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.1fr);
  gap: 14px;
}

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

.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.card-header {
  padding: 10px 14px 0;
}

.card-header h2 {
  margin: 0;
  font-size: 1rem;
}

.card-header p {
  margin: 4px 0 8px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.card-body {
  padding: 6px 14px 14px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.82rem;
}

.field span {
  color: var(--text-dim);
}

.field input,
.field textarea,
.field select {
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-main);
  padding: 7px 9px;
  font-size: 0.85rem;
  outline: none;
}

.field textarea {
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.35);
}

.hint {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

/* Buttons */

.btn {
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  padding: 7px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-main);
  transition: all 0.16s ease-out;
}

.btn.primary {
  background: linear-gradient(135deg, #22d3ee, #0ea5e9);
  color: #0b1220;
  font-weight: 600;
}

.btn.secondary {
  border-color: rgba(56, 189, 248, 0.7);
  background: rgba(15, 23, 42, 0.9);
  color: #e0f2fe;
}

.btn.ghost {
  border-color: rgba(148, 163, 184, 0.7);
  background: transparent;
  color: var(--text-dim);
}

.btn.danger {
  border-color: rgba(248, 113, 113, 0.9);
  background: rgba(15, 23, 42, 0.9);
  color: #fecaca;
}

.btn.chip {
  border-radius: 999px;
  border-color: rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.9);
  padding-inline: 12px;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.7);
}

/* Library */

.library-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.library-toolbar input {
  flex: 1;
}

.course-list {
  max-height: 420px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
}

.course-list.empty {
  padding: 10px;
  color: var(--text-dim);
}

.course-item {
  border-radius: 11px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  padding: 6px 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.9);
}

.course-item:hover {
  border-color: var(--accent);
}

.course-item.active {
  background: radial-gradient(circle at 0 0, #22d3ee, #0b1120);
  border-color: rgba(34, 211, 238, 0.85);
}

.course-title {
  font-weight: 500;
}

.course-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.course-badges {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.72rem;
  text-align: right;
  color: var(--text-dim);
}

.course-detail {
  min-height: 220px;
  max-height: 380px;
  overflow: auto;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  padding: 8px 10px;
  font-size: 0.8rem;
  background: rgba(15, 23, 42, 0.9);
  white-space: pre-wrap;
}

.course-detail.empty {
  color: var(--text-dim);
}

/* IA */

.ia-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Stats */

.stat-card {
  text-align: center;
  padding: 10px 6px 12px;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 2px;
}

/* Toast */

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  min-width: 220px;
  max-width: 360px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(56, 189, 248, 0.8);
  font-size: 0.8rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all 0.18s ease-out;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Spacing utils */

.mt-md {
  margin-top: 8px;
}

.mt-lg {
  margin-top: 14px;
}

/* Responsive */

@media (max-width: 960px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    padding-bottom: 10px;
  }
  .main {
    padding: 10px 10px 16px;
  }
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
  .grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }
  .course-list {
    max-height: 260px;
  }
}

@media (max-width: 640px) {
  .brand-title {
    font-size: 0.95rem;
  }
  .brand-sub {
    font-size: 0.7rem;
  }
  .student-card {
    flex-direction: row;
  }
  .library-toolbar {
    flex-direction: column;
  }
  .actions-row {
    flex-direction: column;
    align-items: stretch;
  }
  .toast {
    left: 10px;
    right: 10px;
    max-width: none;
  }
}
