/* ==========================================================================
   OFSM Inspection Tracker — dark mission-control
   Design language: fire alarm control panel. Matte near-black steel, LED
   status lights, engraved uppercase microlabels, tabular numerals, mono
   for identifiers. Signal red is reserved for alarm semantics only.
   ========================================================================== */

:root {
  --void: #0B0D11;          /* page background */
  --panel: #12151B;         /* raised panel */
  --panel-2: #181C24;       /* nested / hover surface */
  --line: rgba(235, 240, 255, 0.07);
  --line-strong: rgba(235, 240, 255, 0.14);
  --text: #E8EBF2;
  --muted: #A9B1C3;
  --faint: #7E879B;

  --signal: #FF453A;        /* alarm red — fire, open, failed, primary action */
  --amber: #FFB340;         /* supervisory — in progress, cat C */
  --green: #30D158;         /* normal — resolved, passed */
  --blue: #5AA2FF;          /* documentation — cat A, focus */

  --signal-dim: rgba(255, 69, 58, 0.14);
  --amber-dim: rgba(255, 179, 64, 0.14);
  --green-dim: rgba(48, 209, 88, 0.14);
  --blue-dim: rgba(90, 162, 255, 0.14);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Inter, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --r: 10px;
  --r-lg: 14px;
}

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

html { background: var(--void); }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 50% -200px, rgba(255, 69, 58, 0.045), transparent 70%),
    var(--void);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- primitives ---------- */

.eyebrow {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.mono { font-family: var(--mono); font-size: 12.5px; }

/* LED — the signature element. A small status lamp. */
.led {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--faint);
  flex: none;
}
.led-red    { background: var(--signal); box-shadow: 0 0 8px rgba(255,69,58,.7); }
.led-amber  { background: var(--amber);  box-shadow: 0 0 8px rgba(255,179,64,.6); }
.led-green  { background: var(--green);  box-shadow: 0 0 8px rgba(48,209,88,.6); }
.led-blue   { background: var(--blue);   box-shadow: 0 0 8px rgba(90,162,255,.6); }
.led-off    { background: #2A2F3A; box-shadow: none; }

.led-pulse { animation: led-pulse 3s ease-in-out infinite; }
@keyframes led-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* status / category chips: LED + engraved label */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.chip .led { width: 6px; height: 6px; }

/* ---------- buttons & inputs ---------- */

.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:hover { background: #1E232D; border-color: rgba(235,240,255,.22); }
.btn:active { transform: translateY(1px); }

.btn-signal {
  background: var(--signal);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.btn-signal:hover { background: #FF5A50; border-color: transparent; }

.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--muted); }
.btn-ghost:hover { color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .45; cursor: default; pointer-events: none; }

.btn-danger-confirm { background: var(--signal-dim); border-color: rgba(255,69,58,.4); color: #FF8A82; }

input, select, textarea {
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: #0E1116;
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: 8px 11px;
  width: 100%;
  transition: border-color .15s ease;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: rgba(235,240,255,.22); }
textarea { resize: vertical; min-height: 60px; }
select { appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239AA2B4' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
}

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 1px;
}

.field-label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 5px 1px;
}

.error-text { color: #FF8A82; font-size: 13px; min-height: 20px; margin: 8px 0 4px; }

/* ---------- login ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 380px;
  max-width: 100%;
  padding: 36px 32px 30px;
  position: relative;
}
.login-led { position: absolute; top: 26px; right: 26px; }
.login-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin: 10px 0 6px; }
.login-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 24px; }
.login-card .field-label { margin-top: 4px; }
.login-card input { margin-bottom: 2px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(11, 13, 17, 0.75);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.topbar-meta { font-family: var(--mono); font-size: 11.5px; color: var(--faint); margin-right: 6px; }

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

main { max-width: 1240px; margin: 0 auto; padding: 22px 28px 40px; }

.tablist {
  display: inline-flex;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 3px;
  margin-bottom: 22px;
}
.tab {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  padding: 7px 16px;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line-strong); }
.tab-upload { color: #FF8A82; }
.tab-upload.active { color: #FF8A82; background: var(--signal-dim); box-shadow: inset 0 0 0 1px rgba(255,69,58,.35); }

.view { display: none; }
.view.active { display: block; }

/* staggered panel rise on view entry */
.view.active > * { animation: rise .45s cubic-bezier(.2,.7,.3,1) both; }
.view.active > *:nth-child(2) { animation-delay: .04s; }
.view.active > *:nth-child(3) { animation-delay: .08s; }
.view.active > *:nth-child(4) { animation-delay: .12s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- dashboard: annunciator strip ---------- */

.annunciator {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.readout {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px 14px;
  position: relative;
  overflow: hidden;
}
.readout-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 8px;
}
.readout-value {
  font-size: 40px;
  font-weight: 200;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.readout-sub { font-size: 11.5px; color: var(--faint); margin-top: 4px; font-variant-numeric: tabular-nums; }
.readout-trace {
  position: absolute;
  left: 0; bottom: 0;
  height: 2px;
  background: var(--signal);
  opacity: .8;
  transition: width 1s cubic-bezier(.2,.7,.3,1);
}
.readout-trace.trace-green { background: var(--green); }
.readout-trace.trace-amber { background: var(--amber); }

/* chart grid */
.chart-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 10px;
  margin-bottom: 10px;
}
.chart-grid-2 { grid-template-columns: 2fr 3fr; margin-bottom: 0; }

.chart-panel { padding: 18px 20px 14px; }
.chart-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.chart-title .eyebrow { color: var(--muted); }
.chart-title .mono { color: var(--faint); font-size: 11px; }

.chart-panel svg { display: block; width: 100%; height: auto; }
.chart-panel text { font-family: var(--font); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- tables ---------- */

.table-panel { overflow: hidden; }
.table-tools {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.table-tools input[type="search"] { max-width: 240px; }
.table-tools select { width: auto; min-width: 120px; }
.table-tools .spacer { flex: 1; }
.result-count { font-family: var(--mono); font-size: 11.5px; color: var(--faint); white-space: nowrap; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--faint);
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: rgba(255,255,255,0.015);
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  color: var(--text);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: rgba(255,255,255,0.025); }
tbody tr.row-click { cursor: pointer; }
td.mono, th.num { font-variant-numeric: tabular-nums; }
td .dim { color: var(--muted); }
.cell-main { font-weight: 500; }
.cell-sub { color: var(--muted); font-size: 12px; margin-top: 1px; }
.nowrap { white-space: nowrap; }

.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--faint);
  font-size: 13.5px;
}

/* ---------- upload wizard ---------- */

.upload-wrap { max-width: 860px; }

.stage-rail {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 16px;
}
.stage {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}
.stage.current { color: var(--text); }
.stage.done { color: var(--green); }
.stage-sep { flex: none; width: 26px; height: 1px; background: var(--line-strong); }

.dropzone {
  display: block;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--panel);
  padding: 56px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover, .dropzone.dragover { border-color: rgba(255,69,58,.55); background: #14171e; }
.dropzone-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.dropzone-sub { color: var(--faint); font-size: 12.5px; }
.dropzone input[type="file"] { display: none; }

.upload-options {
  display: flex;
  gap: 10px;
  align-items: end;
  margin: 14px 0 0;
  flex-wrap: wrap;
}
.upload-options > div { min-width: 200px; }

.progress-panel { padding: 26px 26px 22px; }
.progress-headline { font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.progress-sub { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.progress-track {
  height: 4px;
  background: #1A1E27;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 16px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--signal), #FF7A45);
  border-radius: 2px;
  transition: width .35s ease;
}

.review-header-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px 14px;
  padding: 18px;
}
.review-header-grid .wide { grid-column: span 2; }
.review-table input, .review-table select, .review-table textarea {
  font-size: 12.5px;
  padding: 5px 8px;
  border-radius: 7px;
  background: transparent;
  border-color: transparent;
}
.review-table input:hover, .review-table select:hover, .review-table textarea:hover { border-color: var(--line-strong); background: #0E1116; }
.review-table input:focus, .review-table select:focus, .review-table textarea:focus { border-color: var(--blue); background: #0E1116; }
.review-table textarea { min-height: 42px; }
.review-table td { padding: 7px 8px; }

.commit-bar {
  display: flex;
  align-items: end;
  gap: 12px;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.commit-bar .grow { flex: 1; min-width: 220px; }
.commit-bar .btn { flex: none; }

.success-panel { padding: 40px; text-align: center; }
.success-panel .led { width: 12px; height: 12px; margin-bottom: 14px; }
.success-title { font-size: 19px; font-weight: 700; margin-bottom: 6px; }
.success-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 22px; }

.upload-error {
  background: var(--signal-dim);
  border: 1px solid rgba(255,69,58,.35);
  border-radius: var(--r);
  color: #FFB3AD;
  font-size: 13px;
  padding: 12px 14px;
  margin-top: 14px;
}

/* ---------- modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 6, 9, 0.7);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 20px 20px;
  overflow-y: auto;
  animation: fade .18s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 720px;
  max-width: 100%;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  animation: rise .3s cubic-bezier(.2,.7,.3,1) both;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px 0;
}
.modal-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.modal-kicker { margin-bottom: 4px; }
.modal-close {
  font: inherit; color: var(--faint);
  background: transparent; border: 0; cursor: pointer;
  font-size: 20px; line-height: 1; padding: 2px 6px; border-radius: 6px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px 22px 22px; }

.detail-block {
  background: #0E1116;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 13px 15px;
  margin-bottom: 16px;
  font-size: 13px;
}
.detail-block .mono { color: var(--muted); }
.detail-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; }

.edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}
.edit-grid .wide { grid-column: span 2; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}
.save-note { color: var(--green); font-size: 12.5px; align-self: center; margin-right: auto; }

/* ---------- footer ---------- */

.footpanel {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 28px 28px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11.5px;
  color: var(--faint);
  font-family: var(--mono);
}

/* ---------- responsive ---------- */

@media (max-width: 980px) {
  .annunciator { grid-template-columns: repeat(2, 1fr); }
  .chart-grid, .chart-grid-2 { grid-template-columns: 1fr; }
  .review-header-grid { grid-template-columns: 1fr 1fr; }
  .topbar-inner, main, .footpanel { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 560px) {
  .annunciator { grid-template-columns: 1fr; }
  .review-header-grid { grid-template-columns: 1fr; }
  .edit-grid { grid-template-columns: 1fr; }
  .edit-grid .wide { grid-column: span 1; }
  .topbar-inner { flex-direction: column; align-items: flex-start; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
