:root {
  color-scheme: light;
  font-family: Helvetica, Arial, sans-serif;
  color: #111827;
  background: #f4f6f8;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #111827;
  --slate-950: #0f172a;
  --slate-800: #1f2937;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --green: #15803d;
  --red: #b91c1c;
}

* { box-sizing: border-box; }
body { min-width: 320px; min-height: 100vh; min-height: 100svh; margin: 0; background: #f4f6f8; }
button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.shell { width: min(1120px, calc(100% - 48px)); margin: 0 auto; }

.login-card {
  width: min(430px, 100%);
  margin: 10vh auto 6vh;
  padding: 42px;
  border: 1px solid var(--slate-200);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 40px #0f172a0a;
}
.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 7px;
  background: var(--slate-950);
  color: #fff;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -.08em;
}
.eyebrow {
  margin: 27px 0 9px;
  color: var(--slate-500);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .15em;
  text-transform: uppercase;
}
.login-card h1, .welcome-row h1 {
  margin: 0;
  color: var(--ink);
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -.055em;
  line-height: 1.08;
}
.login-card h1 span { color: var(--slate-500); }
.muted { color: var(--slate-500); font-size: 13px; line-height: 1.65; }
.login-card > .muted { margin: 16px 0 28px; }
.login-card form { display: grid; gap: 9px; }
.login-card label, .filters label { color: var(--slate-600); font-size: 11px; font-weight: 700; }
.login-card input {
  width: 100%;
  margin: 0 0 10px;
  padding: 12px 13px;
  border: 1px solid var(--slate-300);
  border-radius: 5px;
  outline: 0;
  background: #fff;
  color: var(--slate-950);
  font-size: 13px;
}
.login-card input:focus, .filters input:focus { border-color: var(--slate-600); box-shadow: 0 0 0 3px #64748b1a; }
.button {
  padding: 10px 13px;
  border: 1px solid var(--slate-300);
  border-radius: 5px;
  background: #fff;
  color: var(--slate-800);
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
  transition: background .15s ease, border-color .15s ease;
}
.button:hover { border-color: var(--slate-500); background: var(--slate-100); }
.button:disabled { cursor: wait; opacity: .6; }
.primary { border-color: var(--slate-950); background: var(--slate-950); color: #fff; }
.primary:hover { border-color: #334155; background: #334155; }
.full { width: 100%; margin-top: 7px; padding: 13px; text-align: left; }
.full span { float: right; }
.fine-print { margin: 24px 0 0; padding-top: 17px; border-top: 1px solid var(--slate-200); color: var(--slate-500); font-size: 10px; text-align: center; }
.error { min-height: 16px; color: var(--red); font-size: 12px; }

.dashboard { padding: 25px 0 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 2px 0 17px; border-bottom: 1px solid var(--slate-300); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--slate-950); font-size: 13px; font-weight: 800; text-decoration: none; }
.brand-light { color: var(--slate-500); font-weight: 500; }
.brand-mark.small { width: 30px; height: 30px; border-radius: 5px; font-size: 17px; }
.user-area { display: flex; align-items: center; gap: 14px; }
.user-name { color: var(--slate-600); font-size: 11px; font-weight: 700; }
.welcome-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 34px 0 31px; }
.welcome-row .eyebrow, .section-heading .eyebrow { margin: 0 0 8px; }
.welcome-row h1 { font-size: 31px; }
.welcome-row .muted { margin: 8px 0 0; }
.overall-card {
  display: grid;
  min-width: 245px;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 15px;
  padding: 16px 18px;
  border: 1px solid var(--slate-300);
  border-radius: 6px;
  background: #fff;
}
.overall-label { color: var(--slate-500); font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.overall-card strong { grid-column: 2; grid-row: 1 / 3; color: var(--slate-950); font-size: 29px; font-weight: 800; letter-spacing: -.06em; }
.overall-card > span:last-child { color: var(--slate-500); font-size: 10px; }
.section-block { padding: 12px 0 30px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.section-heading h2 { margin: 0; color: var(--slate-950); font-size: 19px; font-weight: 800; letter-spacing: -.035em; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.summary-card {
  position: relative;
  overflow: hidden;
  padding: 17px;
  border: 1px solid var(--slate-200);
  border-radius: 6px;
  background: #fff;
  color: var(--slate-950);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.summary-card:hover, .summary-card:focus-visible { transform: translateY(-1px); border-color: var(--slate-400); box-shadow: 0 7px 20px #0f172a0b; outline: none; }
.course-code { color: var(--slate-500); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.course-name { min-height: 40px; margin: 8px 22px 14px 0; color: var(--slate-950); font-size: 14px; font-weight: 800; line-height: 1.4; }
.card-bottom { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.percent { color: var(--slate-950); font-size: 25px; font-weight: 800; letter-spacing: -.06em; }
.stats { color: var(--slate-500); font-size: 10px; line-height: 1.7; white-space: pre-line; text-align: right; }
.progress-meter { display: block; width: 100%; height: 4px; margin-top: 13px; appearance: none; border: 0; border-radius: 4px; background: var(--slate-100); overflow: hidden; }
.progress-meter::-webkit-progress-bar { border-radius: 4px; background: var(--slate-100); }
.progress-meter::-webkit-progress-value { border-radius: 4px; background: #475569; }
.progress-meter::-moz-progress-bar { border-radius: 4px; background: #475569; }
.summary-card.below-target { border-color: #fecaca; }
.below-target-text { color: var(--red) !important; }
.summary-card.below-target .progress-meter::-webkit-progress-value { background: #dc2626; }
.summary-card.below-target .progress-meter::-moz-progress-bar { background: #dc2626; }
.loading-card { padding: 21px; border: 1px solid var(--slate-200); border-radius: 6px; background: #fff; color: var(--slate-500); font-size: 12px; }

.history-panel { padding: 19px; border: 1px solid var(--slate-200); border-radius: 6px; background: #fff; }
.history-heading { align-items: flex-start; }
.history-heading .muted { margin: 5px 0 0; }
.filters { display: flex; align-items: flex-end; gap: 11px; padding: 0 0 15px; }
.filters label { display: grid; gap: 6px; }
.filters input { padding: 8px 9px; border: 1px solid var(--slate-300); border-radius: 4px; outline: 0; background: #fff; color: var(--slate-800); font-size: 11px; }
.table-wrap { overflow: auto; border: 1px solid var(--slate-200); border-radius: 4px; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { background: var(--slate-100); color: var(--slate-600); font-size: 9px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
td, th { padding: 12px 14px; border-bottom: 1px solid var(--slate-200); }
td { color: var(--slate-800); font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
.status { display: inline-block; padding: 5px 8px; border-radius: 3px; font-size: 10px; font-weight: 800; }
.status.present { background: #dcfce7; color: #166534; }
.status.absent { background: #fee2e2; color: #991b1b; }
.status.other { background: var(--slate-100); color: var(--slate-600); }
.empty-state, .notice { padding: 14px; color: var(--slate-600); font-size: 12px; }
.notice { margin: 12px 0; border: 1px solid #fecaca; border-radius: 5px; background: #fef2f2; color: #991b1b; }
footer { padding: 30px 0 0; color: var(--slate-400); font-size: 10px; text-align: center; }

@media (max-width: 760px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .welcome-row { align-items: flex-start; flex-direction: column; }
  .overall-card { width: 100%; }
  .login-card { margin-top: 5vh; padding: 32px 25px; }
}
@media (max-width: 480px) {
  .shell { width: calc(100% - 24px); }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-card { padding: 15px; }
  .course-name { min-height: 0; }
  .user-name { display: none; }
  .history-panel { padding: 14px; }
  .filters { flex-wrap: wrap; }
  .filters label { min-width: 125px; flex: 1; }
  .filters input { width: 100%; }
  .section-heading h2 { font-size: 17px; }
  .login-card h1 { font-size: 34px; }
}

/* Touch-first refinements for iPhone and other narrow devices. */
@media (max-width: 600px) {
  .shell {
    width: auto;
    margin-right: calc(16px + env(safe-area-inset-right));
    margin-left: calc(16px + env(safe-area-inset-left));
  }
  .dashboard { padding-top: max(15px, env(safe-area-inset-top)); padding-bottom: calc(30px + env(safe-area-inset-bottom)); }
  .login-card {
    width: 100%;
    margin-top: max(22px, 3svh);
    margin-bottom: calc(22px + env(safe-area-inset-bottom));
    padding: 29px 22px 24px;
  }
  .login-card input { min-height: 48px; font-size: 16px; }
  .login-card form { gap: 7px; }
  .button { min-height: 44px; padding-right: 14px; padding-left: 14px; touch-action: manipulation; }
  .topbar { gap: 10px; padding-bottom: 12px; }
  .user-area { gap: 7px; }
  .user-area .button { min-width: 76px; }
  .welcome-row { gap: 17px; padding: 25px 0 21px; }
  .welcome-row h1 { font-size: clamp(25px, 7vw, 30px); }
  .welcome-row .muted { font-size: 12px; }
  .overall-card { min-width: 0; min-height: 76px; padding: 13px 15px; }
  .overall-card strong { font-size: 27px; }
  .section-heading { gap: 10px; }
  .section-heading h2 { font-size: 18px; }
  .summary-grid { grid-template-columns: 1fr; gap: 9px; }
  .summary-card { min-height: 124px; padding: 15px; touch-action: manipulation; }
  .summary-card:active { background: var(--slate-100); }
  .course-name { min-height: 0; margin-bottom: 11px; font-size: 14px; }
  .stats { font-size: 11px; }
  .history-panel { scroll-margin-top: 12px; padding: 14px; }
  .history-heading { align-items: flex-start; }
  .history-heading .button { flex: 0 0 auto; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; align-items: end; gap: 10px; }
  .filters label { min-width: 0; }
  .filters input { width: 100%; min-height: 46px; padding: 8px; font-size: 16px; }
  .filters .button { grid-column: 1 / -1; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table { table-layout: fixed; }
  td, th { padding: 11px 9px; }
  td { font-size: 12px; overflow-wrap: anywhere; }
  th { font-size: 8px; }
  .status { padding: 6px 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
