:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --border: #dfe7f2;
  --text: #162033;
  --muted: #62738a;
  --primary: #2d6cdf;
  --primary-soft: #eaf1ff;
  --success: #1e9d67;
  --success-soft: #e5faf1;
  --warning: #e67d1d;
  --warning-soft: #fff2e3;
  --danger: #d9475d;
  --shadow: 0 12px 28px rgba(23, 38, 64, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
}

button {
  font: inherit;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: #101a2c;
  color: #f7faff;
  padding: 24px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #73a8ff, #2d6cdf);
  font-weight: 700;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: rgba(255, 255, 255, 0.74);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-item {
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  text-align: left;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.role-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 28px;
}

.role-button,
.primary-button,
.small-button {
  border: none;
  cursor: pointer;
  font: inherit;
}

.role-button {
  background: rgba(255, 255, 255, 0.08);
  color: white;
  padding: 10px 12px;
  border-radius: 10px;
}

.role-button.active {
  background: var(--primary);
}

.content {
  flex: 1;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11px;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 2vw, 2.5rem);
}

.primary-button {
  background: var(--primary);
  color: white;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.small-button {
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 600;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-value {
  margin-top: 14px;
  font-size: 2rem;
  font-weight: 700;
}

.stat-sub {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 22px;
  margin-bottom: 22px;
}

.two-column {
  grid-template-columns: 1.15fr 0.85fr;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.full-panel {
  margin-top: 10px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel h2 {
  margin: 0;
  font-size: 1.2rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--muted);
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
}

.badge.success {
  background: var(--success-soft);
  color: var(--success);
}

.badge.warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge.neutral {
  background: var(--primary-soft);
  color: var(--primary);
}

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
}

.pill.present {
  background: var(--success-soft);
  color: var(--success);
}

.pill.late {
  background: var(--warning-soft);
  color: var(--warning);
}

.item-list,
.task-list {
  display: grid;
  gap: 12px;
}

.list-item,
.task-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.list-item:last-child,
.task-item:last-child {
  border-bottom: none;
}

.list-item > div,
.task-item > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-right {
  text-align: right;
  align-items: flex-end;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.info-card {
  background: #f8faff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}

.info-card h3 {
  margin: 12px 0 10px;
}

.info-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.card-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 700;
}

.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.activity-list li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.activity-list li:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 6px;
}

.progress-list {
  display: grid;
  gap: 20px;
}

.progress-list label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 600;
}

.progress {
  height: 10px;
  border-radius: 999px;
  background: #ebf0f8;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4d8aff, #2d6cdf);
}

.auth-shell {
  min-height: calc(100vh - 56px);
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 460px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 30px 26px;
}

.auth-card h2 {
  margin: 18px 0 6px;
}

.auth-card p {
  margin: 0 0 18px;
  color: var(--muted);
}

.auth-note {
  margin: -10px 0 16px;
  font-size: 12px;
  color: var(--muted);
}

.field-label {
  display: block;
  margin-bottom: 10px;
  font-weight: 600;
}

.login-roles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.role-option {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
}

.role-option.active {
  background: var(--primary-soft);
  border-color: transparent;
  color: var(--primary);
}

input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 18px;
  font: inherit;
}

.full-width {
  width: 100%;
}

.role-switch[hidden] { display: none; }
.signed-in { display: grid; gap: 10px; min-width: 0; color: rgba(255,255,255,.78); font-size: 11px; }
.signed-in .avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #304567; color: white; font-weight: 700; }
.text-button { border: 0; background: transparent; color: #9fb5e6; padding: 4px 0; text-align: left; font-size: 11px; }
.text-button:hover { color: white; }
.nav-item { width: 100%; }
.topbar h1, .auth-card h1 { letter-spacing: -.035em; }
.muted { color: var(--muted); line-height: 1.65; }
.small { font-size: 12px; }
.fine-print, .footnote { color: var(--muted); font-size: 11px; line-height: 1.6; }
.eyebrow { font-weight: 700; letter-spacing: .12em; }
.auth-card .brand { margin-bottom: 30px; }
.auth-card .eyebrow { margin: 0 0 9px; }
.auth-card h1 { margin: 0 0 9px; font-size: 27px; }
.auth-card > .muted { margin: 0 0 19px; }
.auth-card .fine-print { margin: 16px 0 0; }
.auth-tabs { display: flex; gap: 18px; border-bottom: 1px solid var(--border); margin: 20px 0; }
.auth-tabs button { border: 0; border-bottom: 2px solid transparent; background: none; padding: 10px 0; color: var(--muted); font-weight: 600; cursor: pointer; }
.auth-tabs button.selected { color: var(--primary); border-color: var(--primary); }
#auth-form { display: grid; gap: 3px; }
#auth-form label, #class-form label { display: grid; gap: 7px; margin: 0 0 12px; color: var(--text); font-weight: 600; font-size: 12px; }
#auth-form input, #class-form input { margin: 0; }
#auth-form .primary-button { margin-top: 8px; }
.primary-button:disabled { opacity: .65; cursor: wait; }
.setup-card code { padding: 2px 5px; border-radius: 4px; background: #f0f3f8; color: #334761; font-size: .9em; }
.notice { padding: 12px 14px; margin: 15px 0; border-radius: 10px; border: 1px solid #dce6f8; background: #f0f5ff; color: #435777; font-size: 12px; line-height: 1.65; }
.loading-panel { color: var(--muted); padding: 25px; }
.empty-state { padding: 34px 18px; text-align: center; border: 1px dashed var(--border); border-radius: 14px; background: #fbfcfe; }
.empty-mark { width: 42px; height: 42px; display: grid; place-items: center; margin: 0 auto 12px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); font-size: 20px; }
.empty-state h3 { margin: 0 0 7px; }
.empty-state p { max-width: 440px; margin: 0 auto 16px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.info-card p { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.card-grid { margin-top: 10px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.optional { color: var(--muted); font-weight: 400; }
.modal-backdrop { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 18px; background: #101a2ca8; backdrop-filter: blur(3px); }
.modal { position: relative; width: min(100%, 500px); padding: 28px; border-radius: 17px; background: white; box-shadow: 0 22px 70px #101a2c4a; }
.modal h2 { margin: 7px 0; font-size: 23px; }
.modal > .muted { margin: 0 0 20px; font-size: 13px; }
.modal-close { position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: #f1f3f7; color: #667085; font-size: 20px; cursor: pointer; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 12px; }
.cancel-button { border: 0; border-radius: 10px; padding: 11px 15px; background: #eef1f6; color: #4b5a70; font-weight: 600; cursor: pointer; }
.toast { position: fixed; z-index: 20; bottom: 22px; left: 50%; max-width: calc(100vw - 30px); transform: translateX(-50%); padding: 12px 16px; border-radius: 9px; background: #17263d; color: #fff; box-shadow: var(--shadow); font-size: 12px; }
.toast.error { background: #9c3d3d; }
.footnote { margin-top: 20px; }

.class-picker { display:flex; flex-direction:column; gap:6px; color:var(--muted); font-size:13px; min-width:160px; }
.class-picker select,.class-picker input,td input,td select,.auth-card select,.modal input,.modal select,.modal textarea,.grade-form input,.grade-form textarea { width:100%; padding:10px 12px; border:1px solid var(--border); border-radius:9px; background:#fff; color:var(--text); font:inherit; }
.table-wrap { width:100%; overflow-x:auto; }
table { width:100%; border-collapse:collapse; min-width:560px; }
th,td { padding:12px 14px; border-bottom:1px solid var(--border); text-align:left; vertical-align:top; }
th { color:var(--muted); font-size:12px; text-transform:uppercase; letter-spacing:.05em; }
.assignment-list { display:grid; gap:12px; }
.assignment-row,.approval-row { border:1px solid var(--border); border-radius:14px; padding:18px; margin:12px 0; background:#fff; }
.assignment-row { display:flex; align-items:center; justify-content:space-between; gap:18px; }
.assignment-row h3,.approval-row h3 { margin:10px 0 6px; }
.approval-row blockquote { margin:12px 0; padding:12px 16px; border-left:3px solid var(--primary); background:var(--primary-soft); }
.invite-code { font-family:ui-monospace,Consolas,monospace; font-size:24px; letter-spacing:.12em; padding:18px; margin:16px 0; border:1px dashed var(--primary); border-radius:12px; background:var(--primary-soft); text-align:center; }
.grade-form { border-top:1px solid var(--border); padding:16px 0; display:grid; gap:10px; }
.class-panel { display:flex; flex-direction:column; gap:14px; }
.class-panel .info-card { box-shadow:none; padding:4px; }
.modal-wide { max-width:760px; }
@media(max-width:760px) {
  .app-shell { display:block; }
  .sidebar { width:100%; padding:16px; }
  .brand { margin-bottom:14px; }
  .nav { flex-direction:row; overflow:auto; gap:6px; padding-bottom:8px; }
  .nav-item { white-space:nowrap; padding:10px 12px; }
  .content { padding:20px 14px; }
  .topbar { align-items:flex-start; flex-direction:column; gap:12px; }
  .stats { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .assignment-row { align-items:flex-start; flex-direction:column; }
  .field-row { grid-template-columns:1fr; }
  .modal-backdrop { padding:12px; }
  .modal { width:100%; padding:22px; }
}
@media print { .sidebar,button,.class-picker { display:none!important; } .app-shell,.content { display:block; padding:0; } body { background:#fff; } .panel,.stat-card { box-shadow:none; break-inside:avoid; } }

@media (max-width: 980px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    width: 100%;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
  }

  .two-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .stats {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .content { padding: 19px; }
  .sidebar { padding: 17px; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .modal { padding: 24px 18px; }
}
