* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'IBM Plex Sans', sans-serif;
  background: #F7F5F1;
  color: #1A1D1B;
}

a { color: inherit; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #123832;
  display: flex;
  flex-direction: column;
  padding: 28px 0;
}

.sidebar-brand {
  padding: 0 24px 28px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand span {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 19px;
  font-weight: 600;
  color: #FFFFFF;
  letter-spacing: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
}

.sidebar-nav-bottom {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
  margin-top: auto;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 24px 0 24px;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.sidebar-footer-label {
  font-size: 12px;
  color: #9FC2B8;
}

.sidebar-footer-name {
  font-size: 13px;
  color: #FFFFFF;
  font-weight: 500;
  margin-top: 2px;
}

.main-column {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 72px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  border-bottom: 1px solid #E4DFD3;
  background: #FFFFFF;
}

.school-switch {
  font-size: 14px;
  font-weight: 500;
  color: #1A1D1B;
  border: 1px solid #E4DFD3;
  padding: 8px 14px;
  border-radius: 8px;
  background: #FBFAF7;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: #E4DFD3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
}

.content {
  flex-grow: 1;
  padding: 32px 40px 48px 40px;
}

h1.page-title {
  margin: 0;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 25px;
  font-weight: 600;
  color: #1A1D1B;
  letter-spacing: 0;
}

.page-subtitle {
  margin: 6px 0 0 0;
  font-size: 14px;
  color: #6B6659;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-family: 'IBM Plex Sans', sans-serif;
  text-decoration: none;
}

.btn-primary {
  background: #1B5E52;
  color: #FFFFFF;
}

.btn-secondary {
  background: #FFFFFF;
  color: #1A1D1B;
  border: 1px solid #E4DFD3;
}

.card {
  background: #FFFFFF;
  border: 1px solid #E4DFD3;
  border-radius: 12px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-tile {
  background: #FFFFFF;
  border: 1px solid #E4DFD3;
  border-radius: 12px;
  padding: 16px 20px;
}

.stat-label {
  font-size: 12px;
  color: #6B6659;
  font-weight: 500;
}

.stat-value {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 25px;
  font-weight: 600;
  color: #1A1D1B;
  margin-top: 2px;
}

.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.search-input {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid #E4DFD3;
  font-size: 13px;
  font-family: 'IBM Plex Sans', sans-serif;
  background: #FFFFFF;
  min-width: 240px;
}

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid #E4DFD3;
  background: #FFFFFF;
  color: #6B6659;
  text-decoration: none;
}

.chip.active {
  border-color: #1B5E52;
  background: #1B5E52;
  color: #FFFFFF;
}

/* Risk-level filter chips use the same pastel palette as the risk badges,
   so a level is recognisable by colour before you even read the label.
   The active chip for a level fills with that level's badge-text colour
   (mirroring how the neutral "All" chip fills dark green when active)
   rather than switching to the app's default green. */
.chip-low { background: #E4F3EA; color: #2F7D5A; border-color: #E4F3EA; }
.chip-medium { background: #FBEBD0; color: #B7791F; border-color: #FBEBD0; }
.chip-high { background: #FBE7D6; color: #C2600F; border-color: #FBE7D6; }
.chip-extreme { background: #FBE0DD; color: #C0392B; border-color: #FBE0DD; }

.chip-low.active { background: #2F7D5A; color: #FFFFFF; border-color: #2F7D5A; }
.chip-medium.active { background: #B7791F; color: #FFFFFF; border-color: #B7791F; }
.chip-high.active { background: #C2600F; color: #FFFFFF; border-color: #C2600F; }
.chip-extreme.active { background: #C0392B; color: #FFFFFF; border-color: #C0392B; }

/* Equipment status filter chips, same pastel-palette treatment as the risk
   chips above. */
.chip-operational { background: #E4F3EA; color: #2F7D5A; border-color: #E4F3EA; }
.chip-needs-repair { background: #FBEBD0; color: #B7791F; border-color: #FBEBD0; }
.chip-out-of-service { background: #FBE0DD; color: #C0392B; border-color: #FBE0DD; }

.chip-operational.active { background: #2F7D5A; color: #FFFFFF; border-color: #2F7D5A; }
.chip-needs-repair.active { background: #B7791F; color: #FFFFFF; border-color: #B7791F; }
.chip-out-of-service.active { background: #C0392B; color: #FFFFFF; border-color: #C0392B; }

.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid #E4DFD3;
  overflow-x: auto;
}

.admin-tab {
  display: inline-block;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #6B6659;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}

.admin-tab:hover {
  color: #1A1D1B;
}

.admin-tab.active {
  color: #1B5E52;
  border-bottom-color: #1B5E52;
}

/* Same look as .admin-tabs, but for switching between panels on the same
   page (e.g. Log an inspection / Log maintenance on the equipment detail
   page) instead of navigating to a different URL. */
.section-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid #E4DFD3;
}

.section-tab {
  display: inline-block;
  padding: 8px 4px;
  margin-right: 20px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  color: #6B6659;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  white-space: nowrap;
}

.section-tab:hover {
  color: #1A1D1B;
}

.section-tab.active {
  color: #1B5E52;
  border-bottom-color: #1B5E52;
}

/* Log an inspection/maintenance checklist: bold category headings, regular-
   weight criterion text, and a tick/cross/N-A control per item (green for
   pass, red for fail) instead of a plain checkbox. */
.criteria-category-header {
  font-size: 13px;
  font-weight: 700;
  color: #1A1D1B;
  background: #F3F0E8;
  padding: 8px 12px;
  border-radius: 6px;
  margin: 16px 0 6px;
}

.criteria-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 4px;
  border-bottom: 1px solid #E4DFD3;
}

.criteria-row-label {
  font-size: 13px;
  font-weight: 400;
  color: #1A1D1B;
  flex: 1;
}

.criteria-status-group {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.criteria-status-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border-radius: 15px;
  border: 1.5px solid #E4DFD3;
  background: #FFFFFF;
  color: #B0AA9A;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  line-height: 1;
}

.criteria-status-btn:hover {
  border-color: #6B6659;
  color: #1A1D1B;
}

.criteria-status-btn.status-yes.active {
  background: #2F7D5A;
  border-color: #2F7D5A;
  color: #FFFFFF;
}

.criteria-status-btn.status-no.active {
  background: #C0392B;
  border-color: #C0392B;
  color: #FFFFFF;
}

.criteria-status-btn.status-na.active {
  background: #6B6659;
  border-color: #6B6659;
  color: #FFFFFF;
}

.log-status-icon {
  display: inline-block;
  font-weight: 700;
}

.log-status-icon.log-status-yes {
  color: #2F7D5A;
}

.log-status-icon.log-status-no {
  color: #C0392B;
}

.log-status-icon.log-status-na {
  color: #6B6659;
}

table {
  border-collapse: collapse;
  width: 100%;
}

th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  color: #6B6659;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #FBFAF7;
  border-bottom: 1px solid #E4DFD3;
}

td {
  padding: 11px 16px;
  font-size: 13px;
  color: #1A1D1B;
  border-bottom: 1px solid #F0EDE5;
}

tr:last-child td {
  border-bottom: none;
}

tr.row-link:hover {
  background: #FBFAF7;
  cursor: pointer;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-low { background: #E4F3EA; color: #2F7D5A; }
.badge-medium { background: #FBEBD0; color: #B7791F; }
.badge-high { background: #FBE7D6; color: #C2600F; }
.badge-extreme { background: #FBE0DD; color: #C0392B; }

.badge-draft { background: #F0EDE5; color: #6B6659; }
.badge-pending { background: #FBEBD0; color: #B7791F; }
.badge-approved { background: #E4F3EA; color: #2F7D5A; }
.badge-changes { background: #FBE0DD; color: #C0392B; }

.badge-operational { background: #E4F3EA; color: #2F7D5A; }
.badge-needs-repair { background: #FBEBD0; color: #B7791F; }
.badge-out-of-service { background: #FBE0DD; color: #C0392B; }

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: #6B6659;
  font-size: 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: start;
}

.detail-section {
  margin-bottom: 14px;
  background: #FFFFFF;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 1px 2px rgba(26, 29, 27, 0.06);
}

.detail-label {
  font-size: 11px;
  font-weight: 600;
  color: #6B6659;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.detail-value {
  font-size: 14px;
  color: #1A1D1B;
  line-height: 1.5;
  white-space: pre-line;
}

.form-card {
  background: #FFFFFF;
  border: 1px solid #E4DFD3;
  border-radius: 12px;
  padding: 28px;
  max-width: 640px;
}

.form-row {
  margin-bottom: 18px;
}

.form-row label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #1A1D1B;
  margin-bottom: 6px;
}

.form-row input[type="text"],
.form-row select,
.form-row textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #E4DFD3;
  font-size: 14px;
  font-family: 'IBM Plex Sans', sans-serif;
  background: #FFFFFF;
}

.form-row textarea {
  min-height: 90px;
  resize: vertical;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row label {
  margin: 0;
  font-weight: 500;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.note-box {
  padding: 12px;
  background: #FBFAF7;
  border: 1px solid #E4DFD3;
  border-radius: 8px;
  font-size: 12px;
  color: #6B6659;
  margin-bottom: 20px;
}

.back-link {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: #1B5E52;
  text-decoration: none;
  margin-bottom: 16px;
}

.form-section-title {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: #1A1D1B;
  margin: 32px 0 4px 0;
  padding-top: 20px;
  border-top: 1px solid #E4DFD3;
}

.form-card .form-section-title:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.form-section-hint {
  font-size: 12px;
  color: #6B6659;
  margin: 0 0 16px 0;
}

.tool-picker {
  border: 1px solid #E4DFD3;
  border-radius: 8px;
  overflow: hidden;
}

.tool-picker-search {
  padding: 10px;
  border-bottom: 1px solid #E4DFD3;
  background: #FBFAF7;
}

.tool-picker-search input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #E4DFD3;
  font-size: 13px;
  font-family: 'IBM Plex Sans', sans-serif;
}

.tool-picker-list {
  max-height: 400px;
  overflow-y: auto;
  padding: 4px 0;
}

.tool-picker-group {
  border-bottom: 1px solid #E4DFD3;
}

.tool-picker-group:last-child {
  border-bottom: none;
}

.tool-picker-group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  color: #6B6659;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.tool-picker-group-label::-webkit-details-marker {
  display: none;
}

.tool-picker-group-label::before {
  content: '▸';
  display: inline-block;
  font-size: 10px;
  color: #A8A296;
  transition: transform 0.15s ease;
}

.tool-picker-group[open] > .tool-picker-group-label::before {
  transform: rotate(90deg);
}

.tool-picker-group-count {
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: #A8A296;
}

.tool-picker-group-items {
  padding-bottom: 4px;
}

.tool-picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  font-size: 13px;
}

.tool-picker-item:hover {
  background: #FBFAF7;
}

.tool-picker-item input {
  flex-shrink: 0;
}

.tool-picker-item label {
  flex-grow: 1;
  margin: 0;
  font-weight: 400;
  cursor: pointer;
}

/* ---------- Change history (collapsible tree) ---------- */

.change-log {
  border: 1px solid #E4DFD3;
  border-radius: 8px;
  overflow: hidden;
}

.change-log-entry {
  border-bottom: 1px solid #E4DFD3;
}

.change-log-entry:last-child {
  border-bottom: none;
}

.change-log-summary {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px 12px 30px;
  position: relative;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.change-log-summary::-webkit-details-marker {
  display: none;
}

.change-log-summary::before {
  content: '▸';
  position: absolute;
  left: 12px;
  top: 13px;
  font-size: 13px;
  font-weight: 700;
  color: #6B6659;
  transition: transform 0.15s ease;
}

.change-log-entry[open] > .change-log-summary::before {
  transform: rotate(90deg);
}

.change-log-datetime {
  font-size: 13px;
  font-weight: 600;
  color: #1A1D1B;
}

.change-log-brief {
  font-size: 13px;
  color: #6B6659;
}

.change-log-detail {
  padding: 0 14px 14px 30px;
  font-size: 13px;
  color: #1A1D1B;
  line-height: 1.5;
  white-space: pre-line;
}

/* Equipment Inspection/Maintenance history reuses .change-log above --
   these two are the only additions it needed: a failed-check brief line
   stands out the same red as the tick/cross icons, and a note attached to
   a check (or a return-to-service note) reads as a positive, resolved
   comment rather than plain body text. */
.change-log-brief.log-brief-fail {
  color: #C0392B;
  font-weight: 600;
}

.log-note-positive {
  color: #2F7D5A;
  font-style: italic;
  margin-top: 8px;
}

.tool-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #E4DFD3;
  background: #FBFAF7;
  text-decoration: none;
  color: #1A1D1B;
}

.monitoring-row {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 0;
  border-bottom: 1px solid #F0EDE5;
  font-size: 13px;
}

.monitoring-row:last-of-type {
  border-bottom: none;
}

.monitoring-row .monitoring-question {
  flex-grow: 1;
}

.monitoring-row label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  font-weight: 400;
  font-size: 13px;
}

.signature-pad-wrap {
  margin: 6px 0 0;
}

.signature-pad {
  display: block;
  width: 100%;
  height: 150px;
  border: 1px solid #E0DDD3;
  border-radius: 8px;
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}

.signature-pad-actions {
  display: flex;
  justify-content: flex-end;
  margin: 6px 0 14px;
}

.signature-image {
  display: block;
  max-width: 280px;
  border: 1px solid #E0DDD3;
  border-radius: 6px;
  background: #fff;
  padding: 6px;
}

/* ---------- Bottom navigation (mobile) ---------- */

.bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  align-items: center;
  justify-content: space-around;
  background: #123832;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px)) 4px;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.bottom-nav a svg {
  width: 20px;
  height: 20px;
}

/* ---------- Responsive tables ---------- */
/* Tables scroll horizontally on narrow screens instead of squashing columns. */

.card:has(> table) {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.card:has(> table) table {
  min-width: 560px;
}

/* ---------- Mobile layout ---------- */

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .bottom-nav {
    display: flex;
  }

  .topbar {
    height: 56px;
    padding: 0 16px;
  }

  .school-switch {
    font-size: 12px;
    padding: 6px 10px;
  }

  .content {
    padding: 20px 16px calc(80px + env(safe-area-inset-bottom, 0px)) 16px;
  }

  h1.page-title {
    font-size: 22px;
  }

  .page-header {
    align-items: flex-start;
  }

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

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid > .card {
    order: -1;
  }

  .form-card {
    padding: 18px;
  }

  .form-actions {
    flex-wrap: wrap;
  }

  .form-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .filter-row form {
    width: 100%;
  }

  .search-input {
    min-width: 0;
    width: 100%;
  }

  .monitoring-row {
    flex-wrap: wrap;
    row-gap: 8px;
  }
}

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