:root {
  --bg: #020617;
  --bg-soft: #0b1220;
  --accent: #6366f1;
  --accent-soft: rgba(99,102,241,0.15);
  --accent-strong: #4f46e5;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --danger: #ef4444;
  --success: #22c55e;
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow-lg: 0 18px 45px rgba(15,23,42,0.7);
  --shadow-md: 0 10px 30px rgba(15,23,42,0.7);
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: radial-gradient(circle at top left, #111827 0, #020617 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* App shell – MOBILE FIRST */

.app-shell {
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  margin: 0;
  background: linear-gradient(145deg, rgba(15,23,42,0.98), rgba(17,24,39,0.99));
  border-radius: 0;
  box-shadow: none;
  border: none;
  display: flex;
  flex-direction: column;
}

/* Header */

.app-header {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(148,163,184,0.25);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(145deg, rgba(15,23,42,0.98), rgba(17,24,39,0.99));
}

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

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: conic-gradient(from 210deg, #22c55e, #6366f1, #ec4899, #22c55e);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 16px;
}

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

.brand-text span:first-child {
  font-weight: 700;
  letter-spacing: 0.03em;
  font-size: 14px;
}

.brand-text span:last-child {
  font-size: 11px;
  color: var(--muted);
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15,23,42,0.9);
  border: 1px solid rgba(148,163,184,0.3);
  font-size: 11px;
}

.logout-link {
  text-decoration: none;
  color: var(--muted);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,0.4);
  transition: all .15s ease;
}

.logout-link:hover {
  color: #f9fafb;
  border-color: rgba(249,250,251,0.7);
  background: rgba(15,23,42,0.9);
}

/* Main layout – MOBILE */

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

/* Cards */

.card {
  background: radial-gradient(circle at top left, rgba(15,23,42,0.95), rgba(15,23,42,0.99));
  border-radius: var(--radius-md);
  padding: 14px 14px 16px;
  border: 1px solid rgba(148,163,184,0.25);
  box-shadow: var(--shadow-md);
}

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

.card-title {
  font-weight: 600;
  font-size: 15px;
}

.card-subtitle {
  font-size: 12px;
  color: var(--muted);
}

/* Badge / chip */

.badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(129,140,248,0.5);
}

/* Buttons & inputs – mobile-friendly */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease, background .15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #f9fafb;
  box-shadow: 0 10px 22px rgba(79,70,229,0.7);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgba(79,70,229,0.9);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding-inline: 12px;
}

.btn-ghost:hover {
  background: rgba(15,23,42,0.9);
  color: #e5e7eb;
}

/* Forms */

.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

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

.input,
.select,
textarea {
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,0.55);
  background: rgba(15,23,42,0.98);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
  width: 100%;
}

textarea {
  border-radius: 12px;
  resize: vertical;
}

.input:focus,
.select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(129,140,248,0.5);
}

/* Login layout – stack on mobile */

.login-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-main {
  order: 1;
}

.login-side {
  order: 2;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.pill {
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15,23,42,0.9);
  border: 1px solid rgba(148,163,184,0.4);
  color: var(--muted);
}

/* Small stat cards */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 8px;
  margin-top: 6px;
}

.stat-card {
  padding: 10px 10px 8px;
  border-radius: 12px;
  background: radial-gradient(circle at top, rgba(15,23,42,0.9), rgba(15,23,42,0.99));
  border: 1px solid rgba(148,163,184,0.35);
  font-size: 11px;
}

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

.stat-value {
  font-size: 16px;
  font-weight: 600;
  margin-top: 2px;
}

/* Tables – mobile first: scrollable */

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 12px;
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}

.table thead {
  background: rgba(15,23,42,0.9);
}

.table tr {
  border-bottom: 1px solid rgba(55,65,81,0.7);
}

.table th,
.table td {
  padding: 8px 10px;
  text-align: left;
}

.table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* Tags & progress */

.tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
}

.tag-maths {
  background: rgba(34,197,94,0.14);
  color: #4ade80;
  border: 1px solid rgba(34,197,94,0.55);
}

.tag-english {
  background: rgba(249,115,22,0.14);
  color: #fdba74;
  border: 1px solid rgba(249,115,22,0.55);
}

.progress-track {
  width: 100%;
  max-width: 150px;
  height: 7px;
  border-radius: 999px;
  background: rgba(31,41,55,0.9);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #22c55e);
}

/* Alerts */

.alert {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  margin-bottom: 10px;
}

.alert-error {
  background: rgba(248,113,113,0.12);
  border: 1px solid rgba(248,113,113,0.5);
  color: #fecaca;
}

.alert-success {
  background: rgba(74,222,128,0.12);
  border: 1px solid rgba(74,222,128,0.5);
  color: #bbf7d0;
}

/* ------------------------------ */
/* BREAKPOINTS – scale up layout  */
/* ------------------------------ */

/* ≥ 640px (small tablets / landscape phones) */
@media (min-width: 640px) {
  .app-main {
    padding: 16px;
    gap: 14px;
  }

  .card {
    border-radius: var(--radius-lg);
  }

  .login-title {
    font-size: 24px;
  }

  .table {
    font-size: 13px;
  }
}

/* ≥ 768px (tablets) */
@media (min-width: 768px) {
  body {
    display: flex;
    justify-content: center;
    align-items: stretch;
  }

  .app-shell {
    max-width: 960px;
    margin: 16px;
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(148,163,184,0.25);
  }

  .app-main {
    padding: 18px;
  }

  .login-layout {
    flex-direction: row;
  }

  .login-main {
    flex: 1.5;
  }

  .login-side {
    flex: 1.2;
  }
}

/* ≥ 1024px (desktops) */
@media (min-width: 1024px) {
  .app-main {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(0, 1.1fr);
    gap: 18px;
  }

  .card {
    padding: 18px 18px 20px;
  }

  .table {
    display: table;
    white-space: normal;
  }
}

/* ≥ 1280px (large desktops) */
@media (min-width: 1280px) {
  .app-shell {
    max-width: 1100px;
  }
}