:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9dee7;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --warn: #f59e0b;
  --danger: #dc2626;
  --blue: #2563eb;
  --orange: #ea580c;
  --font-main: system-ui;
  color-scheme: light;
  font-family: var(--font-main);
}

* { box-sizing: border-box; }
@media (min-width: 761px) {
  html {
    font-size: 90%;
  }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-main);
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
  padding: 10px clamp(14px, 3.2vw, 38px);
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand, .nav { display: flex; align-items: center; gap: 10px; }
.brand { font-weight: 800; letter-spacing: .02em; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
}
.nav { flex-wrap: wrap; justify-content: flex-end; color: var(--muted); font-weight: 650; }
.nav a { padding: 7px 9px; border-radius: 8px; }
.nav a:hover { background: #eef7f6; color: var(--brand-dark); }
.pill {
  display: inline-flex;
  min-width: 22px;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 999px;
  background: #dff3f0;
  color: var(--brand-dark);
}

main { padding: clamp(16px, 3.2vw, 36px); }
.page { display: none; max-width: 1180px; margin: 0 auto; }
.page.active { display: block; }
#admin {
  max-width: min(1760px, calc(100vw - 32px));
}
#detail {
  max-width: min(1580px, calc(100vw - 32px));
}
.hero {
  min-height: calc(100vh - 124px);
  display: none;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  align-items: center;
  gap: clamp(24px, 4vw, 52px);
}
.hero.active { display: grid; }
.hero-copy h1 {
  max-width: 760px;
  margin: 0 0 18px;
  font-size: clamp(42px, 7vw, 78px);
  line-height: .98;
}
.lead {
  margin: 0 0 10px;
  font-size: 1.28rem;
  color: #344054;
}
.eyebrow {
  margin: 0 0 10px;
  color: var(--brand-dark);
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.hero-actions, .section-head, .form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.user-delete-button { margin-left: auto; }
.section-head { justify-content: space-between; margin-bottom: 18px; }
h2 { margin: 0; font-size: clamp(27px, 3.6vw, 38px); }
h3 { margin: 0 0 14px; }
.button, .ghost {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 750;
  transition: background-color .14s ease, color .14s ease, filter .14s ease;
}
.primary { background: var(--brand); color: #fff; }
.primary:not(:disabled):hover { background: var(--brand-dark); }
.secondary { background: #e7ecef; color: #17202a; }
.secondary:not(:disabled):hover { background: #d8e0e5; }
.ghost { background: transparent; color: var(--brand-dark); padding-left: 0; }
.ghost:not(:disabled):hover { background: #eef7f6; }
.danger { background: #fee2e2; color: var(--danger); }
.danger:not(:disabled):hover { background: #fecaca; }

.hours-panel, .info-panel, .form-panel, .login-card, .admin-card, .success-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 18px 45px rgba(16, 24, 40, .08);
}
.hero-side-panels {
  display: grid;
  gap: 18px;
  width: 100%;
}
.hero-side-panels > .hours-panel,
.hero-side-panels > .info-panel {
  width: 100%;
  min-height: 264px;
}
.info-panel {
  align-self: start;
}
.hours-panel h2,
.info-panel h2 {
  margin-bottom: 12px;
}
.current-info-text {
  tab-size: 4;
  line-height: 1.45;
  color: #344054;
}
.formatted-text {
  tab-size: 4;
  line-height: 1.5;
}
.formatted-text p {
  white-space: pre-wrap;
  margin: 0 0 18px;
}
.formatted-text p:last-child,
.formatted-text ul:last-child,
.formatted-text ol:last-child {
  margin-bottom: 0;
}
.formatted-text h3,
.formatted-text h4,
.formatted-text h5 {
  margin: 18px 0 8px;
  color: var(--ink);
  line-height: 1.2;
}
.formatted-text h3:first-child,
.formatted-text h4:first-child,
.formatted-text h5:first-child {
  margin-top: 0;
}
.formatted-text ul,
.formatted-text ol {
  margin: 0 0 18px 1.4em;
  padding-left: 1.1em;
}
.formatted-text li {
  margin: 5px 0;
}
.formatted-text strong {
  font-weight: 900;
  color: var(--ink);
}
.formatted-text em {
  font-style: italic;
}
.formatted-text code {
  padding: 1px 5px;
  border-radius: 5px;
  background: #e5e7eb;
  font-family: inherit;
  font-weight: 800;
}
.success-panel {
  max-width: 620px;
  margin: 72px auto;
  text-align: center;
}
.success-panel h2 { margin-bottom: 22px; }
.list-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid #eef1f5;
}
.hour-row {
  display: grid;
  grid-template-columns: minmax(118px, 38%) minmax(0, 1fr);
  align-items: start;
  column-gap: 22px;
  padding: 10px 0;
  border-bottom: 1px solid #eef1f5;
}
.hour-row:last-child, .list-row:last-child { border-bottom: 0; }
.hour-row > strong {
  min-width: 0;
}
.hour-row span,
.hours-list-row span {
  display: grid;
  gap: 3px;
  justify-items: start;
}
.hour-row small,
.hours-list-row small {
  color: var(--muted);
  font-size: .84rem;
  font-weight: 650;
}
.input, input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
}
.wide-date-input {
  cursor: pointer;
}
.wide-date-input::-webkit-calendar-picker-indicator {
  display: none;
}
textarea {
  resize: vertical;
  max-width: 100%;
}
#loan-terms-form textarea[name="terms"],
#current-info-form textarea[name="info"] {
  max-width: 100%;
}
input[type="number"] {
  min-height: 42px;
  font-size: 1rem;
  font-weight: 750;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.wide-date-picker {
  position: fixed;
  z-index: 90;
  padding: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(16, 24, 40, .22);
}
.wide-date-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.wide-date-picker-head strong {
  color: #344054;
  font-size: 1rem;
  font-weight: 850;
}
.wide-date-picker-head button,
.wide-date-picker-day {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.wide-date-picker-head button {
  min-width: 36px;
  min-height: 34px;
  font-size: 1.25rem;
  line-height: 1;
}
.wide-date-picker-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}
.wide-date-picker-weekdays {
  margin-bottom: 5px;
}
.wide-date-picker-weekdays span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 850;
  text-align: center;
}
.wide-date-picker-empty,
.wide-date-picker-day {
  min-height: 34px;
}
.wide-date-picker-day:hover,
.wide-date-picker-head button:hover {
  background: #eef4f7;
}
.wide-date-picker-day.today {
  border-color: #99f6e4;
}
.wide-date-picker-day.selected {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.wide-date-picker-day.disabled {
  color: #b8c0cc;
  background: #f8fafc;
  cursor: not-allowed;
}
.quantity-stepper {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 56px;
  align-items: stretch;
  width: 100%;
}
.quantity-stepper input[type="number"] {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.quantity-stepper-buttons {
  display: grid;
  grid-template-rows: 1fr 1fr;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  overflow: hidden;
  background: #eef4f7;
}
.quantity-stepper-button {
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #eef4f7;
  color: var(--brand-dark);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}
.quantity-stepper-button:last-child {
  border-bottom: 0;
}
.quantity-stepper-button:hover {
  background: #dfeaf0;
}
.quantity-stepper-button:active {
  background: #cddde6;
}
.input { max-width: 360px; }
label { display: grid; gap: 7px; color: #344054; font-weight: 650; }
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-start;
  width: fit-content;
}
.checkbox-label input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--brand);
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}
.category-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.dashboard-stats-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
.teacher-board {
  margin-top: 14px;
}
.teacher-board-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.teacher-board h3 {
  margin: 0 0 6px;
  font-size: 1.35rem;
}
.teacher-note-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.teacher-note-card {
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid #d9b55f;
  border-radius: 8px;
  background: #fff7cc;
  box-shadow: 0 8px 18px rgba(16, 24, 40, .08);
  cursor: grab;
}
.teacher-note-card.dragging {
  opacity: .58;
  cursor: grabbing;
}
.teacher-note-card.custom-color {
  background: color-mix(in srgb, var(--teacher-note-color) 28%, white);
  border-color: color-mix(in srgb, var(--teacher-note-color) 72%, #d0d7e2);
}
.teacher-note-card p {
  margin: 0;
  white-space: pre-wrap;
  color: var(--text);
  line-height: 1.35;
}
.drag-handle {
  align-self: flex-start;
  display: inline-flex;
  border-radius: 999px;
  background: rgba(255, 255, 255, .62);
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  padding: 4px 8px;
  user-select: none;
}
.teacher-note-card footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-end;
  color: var(--muted);
  font-size: .9rem;
}
.teacher-note-card footer span {
  display: grid;
  gap: 2px;
}
.teacher-note-card footer small {
  font-weight: 650;
}
.small-button {
  min-height: 34px;
  padding: 7px 11px;
  font-size: .85rem;
}
.teacher-note-card.empty-note {
  border-style: dashed;
  background: #f8fafc;
  box-shadow: none;
}
.teacher-note-form {
  display: grid;
  grid-template-columns: 1fr minmax(180px, 240px) minmax(110px, 140px) auto;
  gap: 12px;
  align-items: end;
  margin-top: 16px;
}
.teacher-note-color-input {
  min-height: 46px;
  padding: 6px;
  cursor: pointer;
}
.category-card, .item-card, .stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.item-card {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 390px;
}
.category-card {
  position: relative;
  overflow: visible;
  min-width: 104px;
  min-height: 0;
  padding: 9px 13px;
  cursor: pointer;
  background: #eef4f7;
  border-color: #d1dde5;
  color: #243447;
}
.category-card h3 {
  margin: 0;
  font-size: .96rem;
  line-height: 1.2;
}
.category-card.active,
.category-card:hover {
  border-color: var(--brand);
  background: #e6f5f2;
  box-shadow: 0 8px 20px rgba(15,118,110,.10);
}
.category-hint {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 10;
  width: max-content;
  max-width: 260px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #17202a;
  color: #fff;
  font-size: .82rem;
  line-height: 1.35;
  box-shadow: 0 12px 28px rgba(16, 24, 40, .18);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: .16s ease;
}
.category-card:hover .category-hint,
.category-card:focus-within .category-hint {
  opacity: 1;
  transform: translateY(0);
}
.admin-category-grid {
  margin: 10px 0 0;
}
.admin-category-button {
  font: inherit;
  text-align: left;
}
.admin-category-button .category-title {
  display: block;
  font-weight: 800;
  font-size: .96rem;
  line-height: 1.2;
}
.item-card img, .detail-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #e7ecef;
}
.item-card img {
  object-fit: contain;
  padding: 10px;
}
.item-card-body {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 9px;
  padding: 13px;
}
.item-card-body > .button {
  align-self: end;
  justify-self: stretch;
  text-align: center;
}
.item-card-actions {
  align-self: end;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.item-card-actions .button {
  min-height: 48px;
  padding: 10px 12px;
  text-align: center;
}
.item-card-main { display: grid; gap: 8px; }
.item-title, .item-description, .item-info {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-title {
  min-height: 2.8em;
  margin: 0;
  -webkit-line-clamp: 2;
  line-height: 1.4;
}
.item-description, .item-info {
  min-height: 2.6em;
  margin: 0;
  -webkit-line-clamp: 2;
  line-height: 1.3;
}
.meta { color: var(--muted); font-size: .92rem; }
.availability { font-weight: 800; color: var(--brand-dark); }
.unavailable { color: var(--danger); }
.item-grid { margin-top: 18px; }

.detail-layout {
  display: grid;
  grid-template-columns: minmax(360px, .9fr) minmax(620px, 1.1fr);
  gap: 12px;
  align-items: start;
}
.detail-back-button {
  width: fit-content;
  margin-bottom: 8px;
}
.detail-content, .calendar, .cart-row {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  min-width: 0;
}
.calendar {
  align-self: start;
}
.calendar-lock-note {
  margin: 10px 0 12px;
  padding: 10px 12px;
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 750;
}
.detail-content {
  display: grid;
  gap: 8px;
}
.detail-content h2,
.detail-content p {
  margin: 0;
}
.detail-content h2 {
  font-size: clamp(22px, 1.8vw, 28px);
  line-height: 1.1;
}
.detail-content p {
  line-height: 1.28;
}
.detail-content .form-panel {
  margin-top: 2px;
  padding: 10px;
}
.detail-content .form-grid {
  margin-bottom: 8px;
}
.detail-content .button {
  width: 100%;
  text-align: center;
}
.detail-image {
  max-height: 170px;
  object-fit: contain;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.calendar-head h3 {
  margin: 0;
}
.calendar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}
.calendar-controls .button {
  min-height: 38px;
  padding: 7px 10px;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}
.calendar-weekday {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  text-align: center;
}
.calendar-empty {
  min-height: 1px;
}
.day {
  min-width: 0;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px;
  text-align: left;
  font-size: .74rem;
  background: #fff;
  color: var(--ink);
  font: inherit;
}
.day strong {
  display: block;
  margin-bottom: 4px;
}
.day-halves {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 4px;
}
.day-half {
  position: relative;
  min-width: 0;
  min-height: 25px;
  border: 1px solid #bbf7d0;
  border-radius: 5px;
  padding: 2px;
  background: #ecfdf5;
  color: var(--ink);
  font: inherit;
  font-size: .68rem;
  line-height: 1;
  cursor: pointer;
}
.day-half[data-tooltip]::after {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 30;
  width: max-content;
  max-width: 230px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .16);
  color: var(--ink);
  content: attr(data-tooltip);
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.25;
  opacity: 0;
  pointer-events: none;
  text-align: left;
  transform: translate(-50%, 4px);
  transition: opacity .12s ease, transform .12s ease;
  visibility: hidden;
  white-space: normal;
}
.day-half[data-tooltip]::before {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 3px);
  z-index: 31;
  width: 8px;
  height: 8px;
  border-right: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;
  background: #ffffff;
  content: "";
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px) rotate(45deg);
  transition: opacity .12s ease, transform .12s ease;
  visibility: hidden;
}
.day-half[data-tooltip]:hover::after,
.day-half[data-tooltip]:hover::before,
.day-half[data-tooltip]:focus-visible::after,
.day-half[data-tooltip]:focus-visible::before {
  opacity: 1;
  transform: translate(-50%, 0);
  visibility: visible;
}
.day-half[data-tooltip]:hover::before,
.day-half[data-tooltip]:focus-visible::before {
  transform: translate(-50%, 0) rotate(45deg);
}
.day-half span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.day-half.free {
  background: #ecfdf5;
}
.day-half.locked {
  cursor: not-allowed;
}
.calendar-locked .day-half.free:not(.selected) {
  background: #f8fafc;
}
.day-half.occupied {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #b91c1c;
  cursor: help;
  opacity: .72;
}
.day.weekend {
  background: #f8fafc;
}
.day-half.weekend {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #98a2b3;
  cursor: help;
  opacity: .75;
}
.day-half.past {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #98a2b3;
  cursor: help;
  opacity: .68;
}
.day-half:disabled {
  cursor: help;
}
.day-half.selected {
  border-color: var(--brand);
  background: #cdeee8;
  box-shadow: inset 0 0 0 2px rgba(15,118,110,.18);
}
.day.pending { background: #fef3c7; }
.day.approved { background: #dbeafe; }
.day.borrowed { background: #ffedd5; }
.day.overdue { background: #fee2e2; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; color: var(--muted); font-size: .86rem; }
.occupancy-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 520px) 1fr;
  gap: 18px;
  align-items: end;
}
.occupancy-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  color: var(--muted);
  font-weight: 800;
}
.occupancy-summary strong {
  flex-basis: 100%;
  color: var(--ink);
  font-size: 1.05rem;
}
.occupancy-calendar-card {
  margin-top: 14px;
}
.occupancy-calendar-grid {
  gap: 8px;
}
.occupancy-day {
  min-height: 104px;
}
.occupancy-half {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  border: 1px solid #bbf7d0;
  border-radius: 5px;
  padding: 5px 6px;
  background: #ecfdf5;
  color: var(--ink);
  font-size: .72rem;
  line-height: 1;
}
.occupancy-half span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.occupancy-half strong {
  margin: 0;
  font-size: .72rem;
}
.occupancy-half.reserved {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}
.occupancy-half.borrowed {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}
.occupancy-half.full {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}
.occupancy-half[data-tooltip]::after {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 40;
  width: max-content;
  max-width: 270px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .16);
  color: var(--ink);
  content: attr(data-tooltip);
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.3;
  opacity: 0;
  pointer-events: none;
  text-align: left;
  transform: translate(-50%, 4px);
  transition: opacity .12s ease, transform .12s ease;
  visibility: hidden;
  white-space: pre-line;
}
.occupancy-half[data-tooltip]::before {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 3px);
  z-index: 41;
  width: 8px;
  height: 8px;
  border-right: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;
  background: #fff;
  content: "";
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px) rotate(45deg);
  transition: opacity .12s ease, transform .12s ease;
  visibility: hidden;
}
.occupancy-half[data-tooltip]:hover::after,
.occupancy-half[data-tooltip]:hover::before {
  opacity: 1;
  transform: translate(-50%, 0);
  visibility: visible;
}
.occupancy-half[data-tooltip]:hover::before {
  transform: translate(-50%, 0) rotate(45deg);
}
.dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 6px;
  border-radius: 999px;
  vertical-align: -1px;
}
.free-dot { background: #22c55e; }
.reserved-dot { background: #60a5fa; }
.borrowed-dot { background: #f59e0b; }
.full-dot { background: #dc2626; }
.legend-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: -2px;
}
.legend-dot.free { background: #22c55e; }
.legend-dot.occupied { background: #dc2626; }
.selected-range {
  margin: 0 0 12px;
  color: var(--brand-dark);
  font-weight: 750;
}

.form-panel, .cart-row { margin-top: 16px; }
.cart-submit-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.equipment-count-grid {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  align-items: stretch;
}
.count-field {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.count-field-available {
  border-color: rgba(15, 118, 110, .28);
  background: #eef9f6;
}
.count-field-stock {
  border-color: #cfd6df;
  background: #f3f5f7;
}
.cart-row { display: grid; grid-template-columns: 1fr repeat(3, minmax(120px, 180px)) auto; gap: 12px; align-items: start; }
.cart-item-name {
  align-self: start;
  justify-self: start;
  padding-top: 4px;
  text-align: left;
}
.cart-field {
  align-self: start;
  justify-self: stretch;
}
.cart-field input {
  min-height: 46px;
}
.cart-remove {
  align-self: start;
  margin-top: 29px;
  min-height: 46px;
}
.cart-shared-term-note,
.cart-shared-term-spacer,
.reservation-edit-shared-term {
  align-self: end;
  display: grid;
  gap: 4px;
  grid-column: span 2;
  min-height: 46px;
}
.cart-shared-term-note,
.reservation-edit-shared-term {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f5f7;
  color: var(--muted);
  font-size: .88rem;
}
.cart-shared-term-note strong,
.reservation-edit-shared-term strong {
  color: var(--ink);
}
.cart-shared-term-note span,
.reservation-edit-shared-term span {
  font-weight: 700;
}
.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 26px;
  color: var(--muted);
  text-align: center;
}
.small-empty {
  min-height: auto;
  padding: 14px;
}
.block-exceptions-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.block-exceptions-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.block-exceptions-list {
  display: grid;
  gap: 10px;
}
.block-exception-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 220px 130px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.equipment-blocks-table td:nth-child(3) {
  min-width: 260px;
}
#equipment-blocks-results {
  margin-bottom: 18px;
}

.login-card { max-width: 460px; margin: 40px auto; }
.login-card form { display: grid; gap: 14px; }
.hint { color: var(--muted); font-size: .9rem; }
.hidden { display: none !important; }
.tabs {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.tab-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.tabs button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}
.tabs button.active { border-color: var(--brand); color: var(--brand-dark); background: #eef7f6; }
.admin-clock {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}
.stat { padding: 18px; }
.stat strong { display: block; font-size: 2.2rem; }
.dashboard-stats-grid .stat {
  min-height: 0;
  padding: 12px;
}
.dashboard-stats-grid .stat strong {
  font-size: 1.85rem;
  line-height: 1;
}
.dashboard-stats-grid .stat span {
  display: block;
  margin-top: 6px;
  font-size: .92rem;
  line-height: 1.18;
}
.admin-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.admin-table th, .admin-table td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.admin-table th { background: #f0f3f6; }
.admin-table th.sortable-header {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.admin-table th.sortable-header:hover,
.admin-table th.sortable-header:focus {
  background: #e6edf3;
  outline: none;
}
.admin-table th.sortable-header:focus {
  box-shadow: inset 0 0 0 2px rgba(15,118,110,.22);
}
.admin-table th.sorted-asc,
.admin-table th.sorted-desc {
  color: var(--brand-dark);
}
.count-cell {
  width: 1%;
  min-width: 108px;
  text-align: center;
  font-weight: 800;
}
.equipment-actions {
  min-width: 260px;
}
.equipment-actions .button {
  margin: 0 6px 6px 0;
}
.equipment-count-number {
  color: #344054;
}
.equipment-count-total {
  color: var(--muted);
}
.sort-indicator {
  display: inline-block;
  margin-left: 6px;
  color: var(--muted);
  font-size: .82em;
}
.hours-table {
  width: min(1180px, 100%);
  table-layout: fixed;
}
.hours-table th,
.hours-table td {
  vertical-align: middle;
}
.hours-table th:nth-child(1), .hours-table td:nth-child(1) { width: 14%; }
.hours-table th:nth-child(2), .hours-table td:nth-child(2) { width: 16%; white-space: nowrap; }
.hours-table th:nth-child(3), .hours-table td:nth-child(3) { width: 28%; }
.hours-table th:nth-child(4), .hours-table td:nth-child(4) { width: 20%; }
.hours-table th:nth-child(5), .hours-table td:nth-child(5) { width: 10%; white-space: nowrap; }
.hours-table th:nth-child(6), .hours-table td:nth-child(6) { width: 170px; text-align: right; white-space: nowrap; }
.hours-table .button {
  padding: 8px 10px;
  font-size: .9rem;
}
.drag-hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 650;
}
.category-table tbody tr {
  transition: background-color .12s ease, opacity .12s ease, transform .12s ease;
}
.category-table tbody tr.dragging {
  opacity: .58;
}
.category-table tbody tr:has(.category-drag-handle:hover) {
  background: #f8fafc;
}
.category-order-cell {
  width: 140px;
}
.category-order-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.category-table .category-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef3f6;
  color: var(--brand-dark);
  cursor: grab;
  font-weight: 900;
  user-select: none;
}
.category-table .category-drag-handle:active {
  cursor: grabbing;
}
.email-settings-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.email-toggle-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, max-content));
}
.email-template-list {
  display: grid;
  gap: 14px;
}
.email-template {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.email-template legend {
  padding: 0 6px;
  font-weight: 850;
}
.email-log-table td {
  vertical-align: top;
}
.reservations-table tr.reservation-pending td { background: #eff6ff; }
.reservations-table tr.reservation-pending td:first-child { box-shadow: inset 4px 0 0 #1d4ed8; }
.reservations-table tr.reservation-approved td { background: #f0f9ff; }
.reservations-table tr.reservation-approved td:first-child { box-shadow: inset 4px 0 0 #38bdf8; }
.reservations-table tr.reservation-borrowed td { background: #fffbeb; color: #1f2937; }
.reservations-table tr.reservation-borrowed td:first-child { box-shadow: inset 4px 0 0 #facc15; }
.reservations-table tr.reservation-unchecked td { background: #fff7ed; }
.reservations-table tr.reservation-unchecked td:first-child { box-shadow: inset 4px 0 0 #f97316; }
.reservations-table tr.reservation-overdue td { background: #fef2f2; }
.reservations-table tr.reservation-overdue td:first-child { box-shadow: inset 4px 0 0 #dc2626; }
.reservations-table tr.reservation-canceled td { background: #f3f4f6; color: #1f2937; }
.reservations-table tr.reservation-canceled td:first-child { box-shadow: inset 4px 0 0 #9ca3af; }
.reservations-table tr.reservation-returned td { background: #f0fdf4; }
.reservations-table tr.reservation-returned td:first-child { box-shadow: inset 4px 0 0 #22c55e; }
.reservations-table {
  table-layout: fixed;
  --student-note-width: 438px;
  --reservation-grid: 8px;
}
.reservations-table th,
.reservations-table td {
  padding: calc(var(--reservation-grid) * 1.5) var(--reservation-grid);
}
.reservations-table td {
  position: relative;
}
.reservations-table th:nth-child(1), .reservations-table td:nth-child(1) { width: 190px; }
.reservations-table th:nth-child(2), .reservations-table td:nth-child(2) { width: 210px; }
.reservations-table th:nth-child(3), .reservations-table td:nth-child(3) { width: 82px; }
.reservations-table th:nth-child(4), .reservations-table td:nth-child(4) { width: 102px; }
.reservations-table th:nth-child(5), .reservations-table td:nth-child(5) { width: 102px; }
.reservations-table th:nth-child(6), .reservations-table td:nth-child(6) { width: 130px; }
.reservation-date-col {
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.35;
}
.reservation-date-col strong {
  color: #344054;
}
.student-reservation-note {
  position: relative;
  z-index: 3;
  display: grid;
  gap: 4px;
  align-self: start;
  margin-top: calc(var(--reservation-grid) * 3);
  width: var(--student-note-width, 426px);
  max-width: var(--student-note-width, 426px);
  box-sizing: border-box;
  padding: var(--reservation-grid) 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.35;
}
.student-reservation-note strong {
  color: var(--muted);
  font-size: inherit;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.student-reservation-note span {
  color: #344054;
  font-weight: 700;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
@media (max-width: 760px) {
  .student-reservation-note {
    width: 100%;
    max-width: 100%;
  }
}
.reservation-editor {
  margin-top: 8px;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 650;
}
.reservation-actions-col { width: 170px; }
.reservation-note-col { width: 245px; min-width: 0; }
.reservation-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--reservation-grid);
}
.reservation-actions select {
  grid-column: 1 / -1;
  min-width: 0;
  font-size: .94rem;
}
.archived-status-note {
  grid-column: 1 / -1;
  padding: var(--reservation-grid);
  border-radius: 8px;
  background: #f1f5f9;
  color: var(--muted);
  font-weight: 700;
  font-size: .82rem;
}
.reservation-actions .button {
  min-width: 0;
  padding: var(--reservation-grid);
  font-size: .82rem;
  line-height: 1.15;
  text-align: center;
  white-space: nowrap;
}
.reservation-actions .archive-button { grid-column: 2; }
.reservation-actions .restore-button { grid-column: 1 / -1; }
.damaged-table th:last-child,
.damaged-table td:last-child {
  width: 190px;
}
.damage-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.damage-actions .button {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  font-size: .84rem;
  line-height: 1.18;
  text-align: center;
  white-space: normal;
}
.archive-danger-zone {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}
.reservation-equipment-list {
  display: grid;
  gap: 8px;
}
.reservation-equipment-chip {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  font-weight: 650;
  line-height: 1.25;
}
.equipment-quantity-nowrap {
  white-space: nowrap;
}
.reservation-summary {
  padding-left: 8px;
}
.reservation-number {
  display: block;
  width: max-content;
  margin-bottom: var(--reservation-grid);
  margin-left: -8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e7ecef;
  color: var(--brand-dark);
  font-size: .78rem;
  font-weight: 850;
}
.note-tools {
  display: grid;
  gap: 8px;
  min-width: 0;
  width: 100%;
}
.note-tools textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.note-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.note-actions .button:disabled,
.note-actions .button.note-saved {
  cursor: default;
  opacity: 1;
}
.note-actions .button:not(.note-saved):not(:disabled) {
  background: var(--brand);
  color: #fff;
}
.note-actions .button:not(.note-saved):not(:disabled):hover {
  background: var(--brand-dark);
}
.note-actions .note-saved {
  background: #e7ecef;
  color: var(--ink);
}
.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  max-width: 128px;
  padding: 5px 8px;
  border-radius: 8px;
  background: #e7ecef;
  font-size: .85rem;
  font-weight: 750;
  line-height: 1.15;
  overflow-wrap: normal;
  text-align: center;
  white-space: normal;
}
.status br,
.status-pill br {
  display: block;
}
.status.pending { background: #1d4ed8; color: #fff; }
.status.approved { background: #dbeafe; color: #1e3a8a; }
.status.borrowed { background: #fef3c7; color: #92400e; }
.status.unchecked { background: #fed7aa; color: #9a3412; }
.status.overdue { background: #dc2626; color: #fff; }
.status.canceled { background: #e5e7eb; color: #374151; }
.status.returned { background: #dcfce7; color: #166534; }
.status.unchecked,
.status.overdue {
  padding: 7px 10px;
}
.admin-form { display: grid; gap: 12px; margin: 0 0 18px; }
.admin-form .form-grid { margin-bottom: 0; }
.collapsible-form {
  gap: 12px;
}
.collapsible-form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.collapsible-form-head h3 {
  margin: 0;
}
.collapsible-form-body {
  display: grid;
  gap: 12px;
}
.collapsible-form.collapsed {
  padding-top: 14px;
  padding-bottom: 14px;
}
.collapsible-form.collapsed .collapsible-form-body {
  display: none;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(16, 24, 40, .45);
}
.modal-panel {
  width: min(980px, 100%);
  max-height: calc(100vh - 56px);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  padding: 34px;
  box-shadow: 0 24px 70px rgba(16, 24, 40, .24);
}
.modal-panel h2 {
  margin: 0 0 22px;
  font-size: clamp(32px, 4vw, 48px);
  line-height: 1.08;
}
.modal-panel .form-actions {
  justify-content: flex-end;
  margin-top: 22px;
}
.modal-panel .button {
  min-height: 52px;
  padding: 13px 22px;
  font-size: 1rem;
}
.confirm-panel {
  width: min(780px, 100%);
}
.quick-cart-form {
  display: grid;
  gap: 16px;
}
.quick-cart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.quick-cart-grid label {
  display: grid;
  gap: 8px;
  font-weight: 800;
  color: var(--muted);
}
.quick-cart-grid input,
.quick-cart-grid select {
  width: 100%;
}
.wide-modal {
  width: min(1160px, calc(100vw - 36px));
}
.block-conflicts-table {
  margin-top: 16px;
}
.block-conflicts-table td {
  min-width: 110px;
}
.block-conflict-warning {
  display: grid;
  gap: 8px;
  min-width: 220px;
  color: #9a3412;
}
.block-conflict-chip {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
}
.block-conflict-chip span {
  color: #7c2d12;
  font-size: .9rem;
}
.equipment-preview-panel {
  width: min(920px, calc(100vw - 36px));
}
.equipment-preview-title {
  margin: -8px 0 4px;
  font-size: 1.2rem;
  font-weight: 800;
}
.equipment-preview-image {
  display: block;
  width: 100%;
  max-height: 68vh;
  margin-top: 18px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}
.damage-panel {
  width: min(980px, calc(100vw - 36px));
}
.damage-description {
  max-width: 420px;
  white-space: pre-wrap;
}
.terms-panel {
  width: min(1040px, calc(100vw - 36px));
}
.terms-content {
  margin: 16px 0 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #344054;
  line-height: 1.5;
  tab-size: 4;
}
.history-panel {
  width: min(1280px, calc(100vw - 36px));
}
.history-panel h2 {
  margin: 0 0 16px;
}
.history-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  font-size: .94rem;
}
.history-table th,
.history-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.history-table th {
  background: #f0f3f6;
  font-weight: 800;
}
.history-date,
.history-time,
.history-user {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.history-date { width: 118px; }
.history-time { width: 58px; }
.history-user {
  width: 180px;
  font-weight: 750;
}
.history-action {
  width: 300px;
  white-space: nowrap;
}
.history-action.status-change {
  font-weight: 850;
}
.history-detail {
  min-width: 260px;
  overflow-wrap: anywhere;
}
.confirm-panel h2 {
  margin: 0 0 24px;
  font-size: clamp(34px, 4vw, 48px);
  line-height: 1.08;
}
.confirm-code-label {
  display: grid;
  gap: 8px;
  margin: 18px 0;
  font-weight: 750;
}
.confirm-code-label input {
  width: 100%;
}
.confirm-actions {
  justify-content: flex-end;
}
.modal-error {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fef2f2;
  color: #b91c1c;
  font-weight: 750;
}
.modal-warning {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-weight: 750;
}
.reservation-edit-items {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}
.reservation-edit-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(135px, .8fr) minmax(135px, .8fr) minmax(90px, .45fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.field-hint {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 650;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  max-width: min(620px, calc(100vw - 32px));
  background: #17202a;
  color: #fff;
  border-radius: 8px;
  padding: 12px 16px;
  transition: .2s ease;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

.settings-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}
.settings-card h3 {
  margin: 0 0 8px;
}
.settings-section {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}
.settings-section h3 {
  margin: 0;
}
.settings-subcategory {
  margin-bottom: 16px;
}
.settings-subcategory > .collapsible-form-head {
  align-items: flex-start;
}
.settings-subcategory > .collapsible-form-head .meta {
  margin: 6px 0 0;
}
.settings-subcategory > .collapsible-form-body > .admin-card {
  margin-bottom: 0;
}
.school-year-reset-panel {
  max-width: 760px;
}
.confirm-code-label {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  font-weight: 750;
  color: var(--muted);
}

@media (max-width: 1180px) {
  .item-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dashboard-stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 960px) {
  .item-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .teacher-note-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .teacher-note-form { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  main { padding: 18px; }
  .hero, .hero.active, .detail-layout { display: block; }
  .hero-side-panels { gap: 18px; }
  .hours-panel, .info-panel { margin-top: 26px; }
  .section-head { align-items: stretch; }
  .calendar-head { align-items: flex-start; flex-direction: column; }
  .input { max-width: none; }
  .dashboard-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cart-row { grid-template-columns: 1fr; }
  .reservation-edit-row { grid-template-columns: 1fr; }
  .admin-table { display: block; overflow-x: auto; }
  .tabs { flex-direction: column; }
  .admin-clock { margin-left: 0; }
}

@media (max-width: 520px) {
  .item-grid { grid-template-columns: 1fr; }
  .teacher-note-grid { grid-template-columns: 1fr; }
}
