:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #111318;
  --muted: #69707d;
  --line: #dde1e7;
  --accent: #1463ff;
  --accent-soft: #e9f0ff;
  --danger: #b42318;
  --radius: 8px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
}

.brand {
  display: block;
  font-weight: 800;
  font-size: 20px;
  margin-bottom: 28px;
}

.brand span {
  display: block;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0;
}

.sidebar nav {
  display: grid;
  gap: 4px;
}

.sidebar nav a {
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 14px;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.main {
  padding: 32px;
  max-width: 1280px;
  width: 100%;
}

.hero {
  min-height: 72vh;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.hero-copy {
  max-width: 760px;
}

.eyebrow,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 8px 0 16px;
  font-size: clamp(38px, 7vw, 78px);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 16px;
  font-size: 28px;
  letter-spacing: 0;
}

h3 {
  margin: 10px 0 8px;
  font-size: 20px;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.lead {
  font-size: 20px;
  max-width: 780px;
}

.actions,
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn.ghost {
  background: transparent;
}

.btn.tiny {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
}

.band,
.cta-band,
.page-head {
  padding: 34px 0;
  border-bottom: 1px solid var(--line);
}

.band.compact {
  padding: 24px 0;
}

.cta-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

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

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

.card,
.panel,
.mini-card,
.pill,
.line-item,
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card,
.panel,
.line-item {
  padding: 18px;
}

.mini-card,
.pill {
  padding: 14px;
  font-weight: 700;
}

.dashboard-grid,
.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

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

.metric {
  padding: 16px;
}

.metric span,
.panel span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong,
.panel strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.progress {
  height: 8px;
  background: #edf0f4;
  border-radius: 999px;
  overflow: hidden;
}

.progress i {
  display: block;
  height: 100%;
  background: var(--accent);
}

.locked {
  position: relative;
  overflow: hidden;
}

.locked .card-content,
.locked > p,
.locked > ul {
  filter: blur(3px);
  user-select: none;
}

.lock-note {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-weight: 700;
}

.notice {
  margin: 14px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.notice.danger {
  border-color: #ffd3ce;
  background: #fff0ee;
}

.notice.danger h2 {
  color: var(--danger);
}

.form {
  display: grid;
  gap: 12px;
}

.form.wide {
  max-width: 780px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 42px;
  padding: 10px 12px;
  background: white;
  color: var(--text);
  font: inherit;
}

textarea {
  min-height: 140px;
  resize: vertical;
}

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

.check input {
  width: auto;
  min-height: auto;
}

.auth-panel {
  max-width: 520px;
  margin: 10vh auto;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.divider {
  margin: 22px 0;
  color: var(--muted);
  text-align: center;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.stack {
  display: grid;
  gap: 12px;
}

.lesson-view {
  max-width: 860px;
}

.content,
.homework-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin: 18px 0;
  line-height: 1.7;
}

.back {
  color: var(--accent);
  font-weight: 700;
}

.search {
  display: flex;
  gap: 10px;
  margin: 0 0 18px;
}

.mobile-nav {
  display: none;
}

details {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

summary {
  cursor: pointer;
  font-weight: 800;
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar nav {
    display: flex;
    overflow-x: auto;
  }

  .main {
    padding: 22px 16px 92px;
  }

  .grid.two,
  .grid.three,
  .grid.four,
  .grid.six,
  .dashboard-grid,
  .metrics {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: 60vh;
  }

  .cta-band {
    align-items: flex-start;
    flex-direction: column;
  }

  .mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: white;
    border-top: 1px solid var(--line);
    z-index: 20;
  }

  .mobile-nav a {
    padding: 12px 6px;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
  }
}

/* APL_PATCH_UI_POLISH: contrast, dark mode and mobile overflow fixes. */
html {
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  max-width: 100%;
  overflow-x: hidden;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

.main,
.hero-copy,
.card,
.panel,
.mini-card,
.pill,
.line-item,
.metric,
.content,
.homework-box,
.auth-panel,
.table-wrap,
form,
label {
  min-width: 0;
}

h1,
h2,
h3,
p,
a,
button,
.btn,
.badge,
.eyebrow,
td,
th,
summary,
input,
textarea,
select {
  overflow-wrap: anywhere;
}

.btn {
  text-align: center;
  line-height: 1.2;
}

.card,
.panel,
.metric,
.mini-card,
.line-item,
.auth-panel {
  box-shadow: 0 18px 50px rgba(17, 19, 24, 0.04);
}

.notice,
.lock-note {
  color: var(--text);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #080a0f;
    --surface: #11141b;
    --text: #f4f7fb;
    --muted: #a8b0be;
    --line: #2b313d;
    --accent: #6f9bff;
    --accent-soft: rgba(111, 155, 255, 0.14);
    --danger: #ff8b7f;
  }

  body,
  .app-shell {
    background: var(--bg);
    color: var(--text);
  }

  p,
  label,
  .metric span,
  .panel span,
  th,
  .divider {
    color: var(--muted);
  }

  .sidebar,
  .card,
  .panel,
  .mini-card,
  .pill,
  .line-item,
  .metric,
  .auth-panel,
  .table-wrap,
  .content,
  .homework-box,
  .lock-note,
  .mobile-nav,
  input,
  select,
  textarea {
    background: var(--surface);
    color: var(--text);
    border-color: var(--line);
  }

  .sidebar {
    background: rgba(17, 20, 27, 0.94);
  }

  .btn {
    background: var(--surface);
    color: var(--text);
    border-color: var(--line);
  }

  .btn.primary {
    background: var(--accent);
    color: #07101f;
    border-color: var(--accent);
  }

  .btn.ghost {
    background: transparent;
  }

  .notice {
    background: rgba(111, 155, 255, 0.12);
    border-color: rgba(111, 155, 255, 0.28);
  }

  .notice.danger {
    background: rgba(255, 139, 127, 0.12);
    border-color: rgba(255, 139, 127, 0.32);
  }

  .progress {
    background: #202633;
  }

  .card,
  .panel,
  .metric,
  .mini-card,
  .line-item,
  .auth-panel {
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.24);
  }
}

@media (max-width: 720px) {
  h1 {
    font-size: clamp(30px, 12vw, 46px);
    line-height: 1;
  }

  h2 {
    font-size: clamp(22px, 7vw, 30px);
  }

  h3 {
    font-size: 19px;
  }

  .hero {
    min-height: auto;
    padding: 34px 0;
  }

  .lead {
    font-size: 17px;
  }

  .actions,
  .quick-actions,
  .search {
    display: grid;
    grid-template-columns: 1fr;
  }

  .actions .btn,
  .quick-actions .btn,
  .search .btn {
    width: 100%;
  }

  .sidebar {
    padding: 16px;
  }

  .sidebar nav a {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .card,
  .panel,
  .line-item,
  .content,
  .homework-box,
  .auth-panel {
    padding: 16px;
  }

  .table-wrap {
    border-radius: 0;
    margin-left: -16px;
    margin-right: -16px;
    border-left: 0;
    border-right: 0;
  }

  table {
    min-width: 680px;
  }
}

