/* maintenance-dashboard.html — readable primary maintenance hub */

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #1c2330;
  --border: #30363d;
  --text: #f0f3f8;
  --dim: #9aa5b5;
  --green: #3ecf8e;
  --yellow: #f0c040;
  --orange: #f07d2e;
  --red: #f07070;
  --cyan: #58c4ff;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: "SF Mono", "Fira Code", Consolas, monospace;
  --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  min-height: 100vh;
}

code { font-family: var(--mono); font-size: 0.88em; color: var(--cyan); }

/* Top bar */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; }
.topbar .sub { font-size: 0.9rem; color: var(--dim); margin-top: 4px; }
.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 40px) 56px;
}

/* KPI row */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi-lbl { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--dim); margin-bottom: 6px; }
.kpi-val { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.kpi-val.warn { color: var(--yellow); }
.kpi-val.info { color: var(--cyan); }
.kpi-val.crit { color: var(--red); }
.kpi-val.good { color: var(--green); }
.kpi-sub { font-size: 0.85rem; color: var(--dim); margin-top: 6px; }

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}
.panel-primary { border-color: rgba(88, 196, 255, 0.35); }
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}
.panel-head h2 { font-size: 1.1rem; font-weight: 700; }
.panel-note { font-size: 0.9rem; color: var(--dim); width: 100%; margin-top: 2px; }
.panel-foot { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }

/* Garage list */
.garage-list { display: flex; flex-direction: column; gap: 12px; }
.garage-item {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
}
.garage-item.pri-high { border-left: 3px solid var(--red); }
.garage-item.pri-med { border-left: 3px solid var(--yellow); }
.garage-item.done { opacity: 0.65; }
.garage-item.done .garage-lbl { text-decoration: line-through; color: var(--dim); }
.garage-check { display: flex; align-items: flex-start; gap: 10px; flex-shrink: 0; padding-top: 2px; }
.garage-check input { width: 20px; height: 20px; accent-color: var(--cyan); cursor: pointer; }
.garage-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(88, 196, 255, 0.12);
  color: var(--cyan);
  font-size: 0.85rem;
  font-weight: 700;
}
.garage-lbl { font-size: 1rem; font-weight: 600; margin-bottom: 6px; }
.garage-detail { font-size: 0.92rem; color: var(--dim); line-height: 1.6; }

/* Alerts */
.alert { padding: 14px 16px; border-radius: 8px; margin-bottom: 10px; font-size: 0.95rem; line-height: 1.6; }
.alert:last-child { margin-bottom: 0; }
.alert strong { display: block; margin-bottom: 6px; font-size: 1rem; }
.alert p { color: #d4dae4; margin: 0; }
.alert-crit { background: rgba(240, 112, 112, 0.1); border: 1px solid rgba(240, 112, 112, 0.35); }
.alert-crit strong { color: var(--red); }
.alert-warn { background: rgba(240, 192, 64, 0.08); border: 1px solid rgba(240, 192, 64, 0.3); }
.alert-warn strong { color: var(--yellow); }

/* Systems grid */
.sys-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.sys-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.sys-card h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--cyan); margin-bottom: 10px; }
.sys-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(48, 54, 61, 0.6);
  font-size: 0.92rem;
}
.sys-row:last-child { border-bottom: none; }
.sys-row span:first-child { color: var(--dim); }
.editable {
  cursor: text;
  border-bottom: 1px dashed var(--border);
  min-width: 4em;
  text-align: right;
  color: var(--text);
}
.editable:focus { outline: none; border-color: var(--cyan); color: var(--cyan); }

/* Tyre table */
.tyre-table, .log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.tyre-table th, .log-table th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--dim);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.tyre-table td, .log-table td {
  padding: 10px;
  border-bottom: 1px solid rgba(48, 54, 61, 0.5);
  vertical-align: top;
}
.tyre-table tr:last-child td, .log-table tr:last-child td { border-bottom: none; }
.tyre-age-crit { color: var(--red); font-weight: 600; }
.tyre-age-warn { color: var(--yellow); }

.empty { text-align: center; color: var(--dim); padding: 20px; font-size: 0.95rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: 0.15s;
}
.btn-sm { padding: 7px 14px; font-size: 0.88rem; }
.btn-primary { background: var(--cyan); color: #041018; }
.btn-primary:hover { background: #7dd4ff; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--cyan); color: var(--cyan); }
.btn-nct { background: rgba(240, 192, 64, 0.15); border: 1px solid rgba(240, 192, 64, 0.45); color: var(--yellow); }
.btn-nct:hover { background: rgba(240, 192, 64, 0.25); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
}
.btn-icon:hover { border-color: var(--cyan); color: var(--cyan); }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.lightbox[hidden] { display: none; }
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
}
.lightbox-panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: min(720px, 100%);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}
.lightbox-sm { width: min(440px, 100%); }
.lightbox-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px 12px;
  border-bottom: 1px solid var(--border);
}
.lightbox-head h2 { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.lightbox-sub { font-size: 0.9rem; color: var(--dim); margin-top: 4px; }
.lightbox-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
}
.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill { height: 100%; background: var(--cyan); border-radius: 4px; transition: width 0.3s; }
.lightbox-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 22px;
  font-size: 0.95rem;
  color: var(--text);
}
.lightbox-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border);
}
.lightbox-form { padding: 16px 22px; display: flex; flex-direction: column; gap: 14px; }
.lightbox-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; color: var(--dim); }
.lightbox-form input,
.lightbox-form select,
.lightbox-form textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
}
.lightbox-form input:focus,
.lightbox-form select:focus,
.lightbox-form textarea:focus { outline: none; border-color: var(--cyan); }
#modal-body { color: #d8dee8; line-height: 1.65; white-space: pre-wrap; }

/* NCT checklist inside lightbox */
.nct-cat { margin-bottom: 18px; }
.nct-cat-lbl {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--cyan);
  margin-bottom: 8px;
  font-weight: 600;
}
.nct-row {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(48, 54, 61, 0.5);
  cursor: pointer;
}
.nct-row.done { opacity: 0.7; }
.nct-row.done .nct-lbl { text-decoration: line-through; color: var(--dim); }
.nct-row input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--cyan); flex-shrink: 0; }
.nct-lbl { font-weight: 600; font-size: 0.95rem; }
.nct-detail { font-size: 0.88rem; color: var(--dim); margin-top: 4px; line-height: 1.5; }

@media (max-width: 720px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .sys-grid { grid-template-columns: 1fr; }
  html { font-size: 15px; }
}
