/* ============================================================
   NOVA TECH — CAMPUS PORTAL SIGN IN
   Design language: the school records office. Ledger paper,
   ruled lines, index-card tabs, and an ink stamp of authority.
   ============================================================ */

:root {
  --ink: #1c2b3a;
  --ink-2: #142130;
  --parchment: #f3ecdc;
  --parchment-dark: #e9ddc3;
  --paper: #fbf7ee;
  --brass: #a9803f;
  --brass-dark: #8a6a34;
  --maroon: #7a2e2e;
  --maroon-dark: #611f1f;
  --forest: #3f5d4f;
  --forest-dark: #304a3e;
  --text: #262019;
  --text-soft: #5a5142;
  --line: rgba(38, 32, 25, 0.14);
  --error: #a13636;

  --accent: var(--maroon);
  --accent-dark: var(--maroon-dark);

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "IBM Plex Sans", -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", monospace;

  --radius: 4px;
  --shadow-card: 0 24px 48px -20px rgba(28, 43, 58, 0.35);
}

body[data-role="admin"]     { --accent: var(--maroon);  --accent-dark: var(--maroon-dark); }
body[data-role="principal"] { --accent: var(--brass);   --accent-dark: var(--brass-dark); }
body[data-role="teacher"]   { --accent: var(--forest);  --accent-dark: var(--forest-dark); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--parchment);
}

@media (prefers-reduced-motion: no-preference) {
  .card, .tab, .submit, .field__control input { transition: all 0.18s ease; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

button, input {
  font-family: inherit;
}

a {
  color: var(--accent-dark);
}

.page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 38%) 1fr;
}

/* ---------------- LEDGER PANEL (left) ---------------- */

.ledger {
  position: relative;
  background: linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
  color: var(--parchment);
  overflow: hidden;
  padding: clamp(2rem, 5vw, 4rem);
  display: flex;
  align-items: center;
}

.ledger__lines {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 43px,
    rgba(243, 236, 220, 0.06) 44px
  );
  pointer-events: none;
}

.ledger__margin {
  position: absolute;
  top: 0; bottom: 0;
  left: clamp(3.2rem, 9vw, 6.5rem);
  width: 1px;
  background: rgba(122, 46, 46, 0.35);
  pointer-events: none;
}

.ledger__content {
  position: relative;
  z-index: 1;
  max-width: 30rem;
}

.seal {
  position: relative;
  width: 84px;
  height: 84px;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.seal__ring {
  position: absolute;
  inset: 0;
  fill: none;
  stroke: var(--brass);
  stroke-width: 1.4;
}

.seal__initials {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  color: var(--brass);
  letter-spacing: 0.04em;
}

.ledger__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0 0 0.6rem;
}

.ledger__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 4vw, 2.9rem);
  line-height: 1.08;
  margin: 0 0 1.6rem;
  color: var(--paper);
}

.ledger__quote {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 500;
  font-size: 1.05rem;
  line-height: 1.55;
  color: rgba(243, 236, 220, 0.78);
  margin: 0 0 2.4rem;
  padding-left: 1rem;
  border-left: 2px solid rgba(169, 128, 63, 0.5);
}

.ledger__meta {
  display: flex;
  gap: 2rem;
  margin: 0;
  padding-top: 1.6rem;
  border-top: 1px solid rgba(243, 236, 220, 0.16);
}

.ledger__meta > div {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.ledger__meta dt {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(243, 236, 220, 0.5);
}

.ledger__meta dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--parchment);
}

/* ---------------- AUTH PANEL (right) ---------------- */

.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.5rem, 4vw, 3rem);
}

.auth__inner {
  width: 100%;
  max-width: 26rem;
}

/* Folder tabs */
.tabs {
  display: flex;
  padding-left: 0.75rem;
}

.tab {
  appearance: none;
  border: none;
  cursor: pointer;
  background: var(--parchment-dark);
  color: var(--text-soft);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.82rem;
  padding: 0.7rem 1.1rem 0.6rem;
  margin-right: -0.6rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  clip-path: polygon(10% 0, 100% 0, 90% 100%, 0 100%);
  position: relative;
  z-index: 1;
  transform: translateY(4px);
}

.tab__icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.tab[aria-selected="true"] {
  background: var(--paper);
  color: var(--accent-dark);
  transform: translateY(0);
  z-index: 3;
  font-weight: 600;
}

.tab:hover:not([aria-selected="true"]) {
  color: var(--text);
}

.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Card */
.card {
  position: relative;
  background: var(--paper);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  box-shadow: var(--shadow-card);
  padding: 2.4rem 2.2rem 2rem;
  z-index: 2;
}

.card__stamp {
  position: absolute;
  top: 1.4rem;
  right: 1.5rem;
  width: 58px;
  height: 58px;
  border: 1.5px dashed var(--accent);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  transform: rotate(-9deg);
  opacity: 0.9;
}

.card__stamp-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.card__stamp-label {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 0.2rem;
}

.card__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin: 0 0 0.2rem;
}

.card__heading {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.7rem;
  color: var(--text);
  margin: 0 0 0.5rem;
  max-width: 85%;
}

.card__subtext {
  font-size: 0.88rem;
  color: var(--text-soft);
  line-height: 1.5;
  margin: 0 0 1.8rem;
  max-width: 92%;
}

/* Form fields */
.field {
  margin-bottom: 1.15rem;
}

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.field__control {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--parchment);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 0 0.75rem;
}

.field__control:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.field__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: var(--text-soft);
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.field__control input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.68rem 0;
  font-size: 0.92rem;
  color: var(--text);
  outline: none;
  min-width: 0;
}

.field__control input::placeholder {
  color: #a59d8c;
}

.field__toggle {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0.3rem;
  display: flex;
  color: var(--text-soft);
}

.field__toggle-icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.field__error {
  min-height: 1.1rem;
  margin: 0.35rem 0 0;
  font-size: 0.76rem;
  color: var(--error);
}

.field--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--text-soft);
  cursor: pointer;
}

.checkbox input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

.link {
  font-size: 0.82rem;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.link:hover {
  border-bottom-color: currentColor;
}

/* Submit */
.submit {
  width: 100%;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--paper);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.submit:hover {
  background: var(--accent-dark);
}

.submit:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.submit__spinner {
  display: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 46;
  stroke-dashoffset: 0;
  animation: spin 0.8s linear infinite;
}

.submit.is-loading .submit__spinner {
  display: block;
}

.submit.is-loading .submit__label {
  opacity: 0.75;
}

.submit:disabled {
  cursor: progress;
}

@keyframes spin {
  0% { transform: rotate(0deg); stroke-dashoffset: 0; }
  100% { transform: rotate(360deg); stroke-dashoffset: 90; }
}

.form-status {
  min-height: 1.2rem;
  margin: 0.9rem 0 0;
  font-size: 0.82rem;
  text-align: center;
}

.form-status[data-state="success"] { color: var(--forest-dark); }
.form-status[data-state="error"] { color: var(--error); }

.card__footer {
  margin: 1.6rem 0 0;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--text-soft);
  text-align: center;
}

.card__footer a {
  color: var(--accent-dark);
}

.auth__fineprint {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-soft);
  margin-top: 1.3rem;
}

.auth__consent {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-soft);
  line-height: 1.5;
  margin: 1rem 0 0;
}

.auth__consent a {
  color: var(--accent-dark);
  text-decoration: underline;
}

.auth__consent a:hover {
  color: var(--accent);
}

.auth__copyright {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-soft);
  opacity: 0.75;
  margin-top: 0.5rem;
}

/* ---------------- RESPONSIVE ---------------- */

@media (max-width: 880px) {
  .page {
    grid-template-columns: 1fr;
  }

  .ledger {
    padding: 2rem 1.5rem;
  }

  .ledger__quote,
  .ledger__meta {
    display: none;
  }

  .ledger__title {
    font-size: 1.6rem;
    margin-bottom: 0;
  }

  .seal {
    width: 56px;
    height: 56px;
    margin-bottom: 1rem;
  }

  .seal__initials {
    font-size: 1.1rem;
  }
}

@media (max-width: 480px) {
  .tabs {
    padding-left: 0.3rem;
  }

  .tab {
    font-size: 0.72rem;
    padding: 0.6rem 0.7rem 0.55rem;
  }

  .tab__icon {
    width: 13px;
    height: 13px;
  }

  .card {
    padding: 1.8rem 1.3rem 1.6rem;
  }

  .card__stamp {
    width: 46px;
    height: 46px;
    top: 1rem;
    right: 1rem;
  }

  .card__heading {
    font-size: 1.4rem;
    max-width: 100%;
  }
}

/* ---------------- BS (NEPALI) CALENDAR ---------------- */
.npc {
  border: 1.5px solid var(--line);
  border-radius: 0.7rem;
  background: var(--paper);
  padding: 1rem;
}
.npc__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.9rem;
}
.npc__title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.npc__subtitle {
  font-size: 0.8rem;
  color: var(--text-soft);
  margin: 0.1rem 0 0;
  text-transform: lowercase;
}
.npc__controls { display: flex; align-items: center; gap: 0.35rem; flex-shrink: 0; }
.npc__today {
  border: none;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
}
.npc__nav {
  border: 1.5px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius);
  width: 1.9rem;
  height: 1.9rem;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-soft);
}
.npc__nav:hover { border-color: var(--accent); color: var(--accent); }

.npc__weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 0.35rem;
}
.npc__weekday--weekend { color: var(--error); }

.npc__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.25rem;
}
.npc__day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  border: 1.5px solid transparent;
  background: transparent;
  border-radius: 0.55rem;
  padding: 0.4rem 0;
  cursor: pointer;
  color: var(--text);
  font: inherit;
  min-height: 2.9rem;
}
.npc__day-bs { font-size: 0.95rem; font-weight: 600; line-height: 1.1; }
.npc__day-ad { font-size: 0.68rem; color: var(--text-soft); line-height: 1.1; }
.npc__day:hover { background: var(--parchment); }
.npc__day--blank { visibility: hidden; cursor: default; }
.npc__day--weekend .npc__day-bs { color: var(--error); }
.npc__day--today { border-color: var(--accent); }

/* Days carrying an event: green while still ahead, amber once past. */
.npc__day--event { background: rgba(63, 93, 79, 0.16); }
.npc__day--event:hover { background: rgba(63, 93, 79, 0.26); }
.npc__day--event-past { background: rgba(169, 128, 63, 0.18); }
.npc__day--event-past:hover { background: rgba(169, 128, 63, 0.28); }

.npc__day--selected,
.npc__day--selected.npc__day--event,
.npc__day--selected.npc__day--event-past {
  background: var(--accent);
  border-color: var(--accent);
}
.npc__day--selected .npc__day-bs,
.npc__day--selected .npc__day-ad { color: #fff; }

.npc__selected {
  margin: 0.8rem 0 0;
  font-size: 0.82rem;
  color: var(--text-soft);
}

/* Legend + the calendar/list pairing on the Calendar page */
.npc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 0.7rem;
  font-size: 0.78rem;
  color: var(--text-soft);
}
.npc-legend__item { display: flex; align-items: center; gap: 0.35rem; }
.npc-legend__swatch {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 0.25rem;
  display: inline-block;
}
.npc-legend__swatch--upcoming { background: rgba(63, 93, 79, 0.35); }
.npc-legend__swatch--past { background: rgba(169, 128, 63, 0.4); }
.npc-legend__swatch--today { border: 1.5px solid var(--accent); }

.calendar-layout {
  display: grid;
  gap: 1.2rem;
  grid-template-columns: minmax(0, 22rem) minmax(0, 1fr);
  align-items: start;
}
@media (max-width: 820px) {
  .calendar-layout { grid-template-columns: 1fr; }
}

/* ---------------- MOBILE APP SHELL (phone-width home screen) ---------------- */
/* The real dashboard (.shell) is untouched — this is an overlay that
   only appears below 640px, and the real .content node gets physically
   moved inside it (see mobile-app-shell.js) so all existing IDs/handlers
   keep working exactly as they do on desktop. */

#mshell { display: none; }

@media (max-width: 640px) {
  .sidebar { display: none !important; }
  .topbar { display: none !important; }
  .main { display: none !important; }

  #mshell {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: var(--paper);
  }

  .mshell__header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.1rem 1.6rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    border-radius: 0 0 1.4rem 1.4rem;
    color: #fff;
  }

  .mshell__account { display: flex; align-items: center; gap: 0.7rem; }

  .mshell__avatar {
    width: 2.7rem;
    height: 2.7rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
  }

  .mshell__name { font-weight: 600; font-size: 1rem; margin: 0; }
  .mshell__role { font-size: 0.8rem; opacity: 0.85; margin: 0.1rem 0 0; }

  .mshell__bell {
    width: 2.3rem;
    height: 2.3rem;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
  }
  .mshell__bell svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

  .mshell__body {
    flex: 1;
    overflow-y: auto;
    padding: 1.1rem;
  }

  .mshell__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem;
  }

  .mshell__tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    background: var(--paper);
    border: 1.5px solid var(--line);
    border-radius: 0.9rem;
    padding: 1.6rem 0.6rem;
    cursor: pointer;
  }
  .mshell__tile-icon svg { width: 30px; height: 30px; color: var(--accent); }
  .mshell__tile-label { font-size: 0.88rem; font-weight: 600; color: var(--text); }

  .mshell__settings { display: flex; flex-direction: column; gap: 0.7rem; }
  .mshell__settings-btn {
    display: block;
    text-align: left;
    padding: 0.9rem 1rem;
    border-radius: var(--radius);
    border: 1.5px solid var(--line);
    background: var(--paper);
    color: var(--text);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
  }
  .mshell__settings-btn--danger { color: var(--error); border-color: rgba(161, 54, 54, 0.3); }

  /* .mshell__content wraps the back/title bar plus the real .content
     node once it's moved in here. Negative margin cancels .mshell__body's
     own padding so the real content's existing internal padding/panels
     render the same as they do on desktop. */
  .mshell__content-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: -1.1rem -1.1rem 1rem;
    padding: 0.9rem 1.1rem;
    background: var(--parchment);
    border-bottom: 1.5px solid var(--line);
  }
  .mshell__back {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 1.5px solid var(--line);
    background: var(--paper);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text);
    flex-shrink: 0;
  }
  .mshell__content-title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    margin: 0;
    color: var(--text);
  }

  .mshell__tabbar {
    flex-shrink: 0;
    display: flex;
    background: var(--paper);
    border-top: 1.5px solid var(--line);
    padding: 0.4rem 0.2rem calc(0.4rem + env(safe-area-inset-bottom));
  }
  .mshell__tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    border: none;
    background: transparent;
    padding: 0.3rem 0;
    color: var(--text-soft);
    cursor: pointer;
  }
  .mshell__tab-icon svg { width: 20px; height: 20px; }
  .mshell__tab-label { font-size: 0.68rem; font-weight: 600; }
  .mshell__tab.is-active { color: var(--accent); }
}
/* Brief highlight when a calendar day jumps to its event card. */
.event-card--flash {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  transition: outline-color 0.4s ease;
}

/* ---------------- BS DATE FIELD + DIALOG ---------------- */
.npc-field {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}
.npc-field:hover { border-color: var(--accent); }
.npc-field__icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  color: var(--text-soft);
}
.npc-field__label { overflow: hidden; text-overflow: ellipsis; }

.npc-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(28, 43, 58, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.npc-dialog {
  width: min(24rem, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--paper);
  border-radius: 0.9rem;
  box-shadow: var(--shadow-card);
  padding: 0.4rem;
}
.npc-dialog .npc { border: none; padding: 0.8rem; }
.npc-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  padding: 0.3rem 0.9rem 0.8rem;
}
.npc-dialog__btn {
  border: none;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  cursor: pointer;
}
.npc-dialog__btn:hover { background: var(--parchment); }
.npc-dialog__btn--primary {
  background: var(--accent);
  color: #fff;
}
.npc-dialog__btn--primary:hover { background: var(--accent-dark); }

/* ---------------- SELECT / DROPDOWN ---------------- */
/* Native selects render very differently across browsers and look out
   of place next to the custom inputs, so the arrow is replaced with an
   inline SVG chevron and the box is styled to match .field__control. */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  padding: 0.6rem 2.1rem 0.6rem 0.75rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background-color: var(--parchment);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  background-size: 1rem;
  max-width: 100%;
  text-overflow: ellipsis;
}

select:hover:not(:disabled) { border-color: var(--accent); }

select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.14);
}

select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: var(--parchment-dark);
}

/* Inside a .field__control wrapper the border already exists on the
   wrapper — a second one on the select looks like a box in a box. */
.field__control select,
.field__control--plain select {
  border: none;
  background-color: transparent;
  width: 100%;
  padding-left: 0;
  padding-top: 0.62rem;
  padding-bottom: 0.62rem;
  box-shadow: none;
  background-position: right 0.1rem center;
}
.field__control select:hover,
.field__control--plain select:hover { border-color: transparent; }

/* Dropdown list items — limited styling is possible, but this keeps the
   open list from falling back to stark white on themed browsers. */
select option {
  background: var(--paper);
  color: var(--text);
  padding: 0.4rem;
}

/* Compact selects used inside table cells and toolbars. */
.routine-teacher,
.staff-status,
.assignment-add select {
  font-size: 0.82rem;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}
.routine-teacher { width: 100%; margin-top: 0.3rem; }
.staff-status { min-width: 7.5rem; }

/* Text inputs sitting bare in toolbars (no .field__control wrapper)
   should match the select treatment rather than the browser default. */
.pf-toolbar input[type="text"],
.pf-toolbar input[type="number"],
.routine-subject,
.staff-note {
  font: inherit;
  font-size: 0.88rem;
  color: var(--text);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 0.5rem 0.65rem;
  max-width: 100%;
}
.routine-subject { width: 100%; }
.staff-note { width: 100%; }
.pf-toolbar input[type="text"]:focus,
.pf-toolbar input[type="number"]:focus,
.routine-subject:focus,
.staff-note:focus {
  outline: none;
  border-color: var(--accent);
}

/* Label above a group of buttons (check in / check out). */
.attend-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
  margin: 1rem 0 0.4rem;
  font-weight: 600;
}
.attend-label:first-of-type { margin-top: 0.6rem; }

/* ---------------- SUBJECT FORM + CHECK GRID ---------------- */
.subject-form {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--parchment);
  margin-bottom: 1.1rem;
}
.subject-form .field { margin: 0; }
.subject-form .btn { align-self: flex-start; }

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 0.4rem 0.9rem;
  margin-top: 0.5rem;
  padding: 0.7rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  max-height: 12rem;
  overflow-y: auto;
  transition: opacity 0.15s ease;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
  padding: 0.15rem 0;
}
.check-row input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.check-row input:disabled { cursor: not-allowed; }
.check-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Routine cells hold two stacked selects. */
.routine-subject { width: 100%; }
td .routine-subject,
td .routine-teacher { font-size: 0.8rem; }

.class-handle-badge {
  display: inline-block;
  margin: 0.9rem 0 0;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  background: rgba(63, 93, 79, 0.16);
  color: var(--forest-dark, var(--text));
  font-size: 0.82rem;
  font-weight: 600;
}
