/* EV Challenge companion: dark shop utilitarian. Steel grey, safety amber. */

:root {
  --bg: #14161a;
  --bg-panel: #1c1f25;
  --bg-inset: #23272f;
  --line: #333842;
  --text: #e6e4de;
  --text-dim: #9aa0a8;
  --amber: #f2a71b;
  --blue: #4aa8dc;
  --green: #5cb87a;
  --red: #e06055;
  --display: "Barlow Condensed", "Arial Narrow", "Helvetica Neue", sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--body);
}
a { color: var(--blue); }

/* ---------- layout ---------- */
#app { display: flex; min-height: 100vh; }
#nav {
  width: 230px; flex: none;
  background: #101216;
  border-right: 1px solid var(--line);
  padding: 16px 0;
  display: flex; flex-direction: column; gap: 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
#main { flex: 1; min-width: 0; padding: 20px 24px 80px; max-width: 1100px; }

.brand { padding: 0 16px 10px; border-bottom: 2px solid var(--amber); }
.brand-name {
  font-family: var(--display); font-size: 26px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--amber); text-decoration: none;
}
.brand-sub { color: var(--text-dim); font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; }

.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-link {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 16px; min-height: 44px;
  color: var(--text); text-decoration: none;
  font-family: var(--display); font-size: 17px; letter-spacing: 0.03em;
  border-left: 3px solid transparent;
}
.nav-link:hover { background: var(--bg-inset); }
.nav-link.active { border-left-color: var(--amber); background: var(--bg-panel); color: var(--amber); }
.nav-code {
  font-family: var(--mono); font-size: 10px; color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 3px; padding: 1px 4px; min-width: 26px; text-align: center;
}
.nav-link.active .nav-code { color: var(--amber); border-color: var(--amber); }
.nav-actions { padding: 0 16px; display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.sync-note { color: var(--text-dim); font-size: 11px; }

/* ---------- module header ---------- */
.module-header h2 {
  font-family: var(--display); font-size: 30px; font-weight: 700;
  letter-spacing: 0.03em; text-transform: uppercase; margin: 0 0 2px;
}
.mod-code {
  color: var(--amber); font-family: var(--mono); font-size: 14px;
  border: 1px solid var(--amber); border-radius: 3px; padding: 2px 6px;
  vertical-align: middle; margin-right: 10px;
}
.status-line { color: var(--text-dim); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; }
.status-line .sep { margin: 0 8px; color: var(--line); }
.status-line strong { color: var(--text); }

/* ---------- panels ---------- */
.panel {
  background: var(--bg-panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 14px 16px; margin: 16px 0;
}
.panel-title {
  font-family: var(--display); font-size: 20px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  margin: 0 0 10px; color: var(--text);
  border-bottom: 1px solid var(--line); padding-bottom: 6px;
}

.banner { border-radius: 5px; padding: 10px 14px; margin: 12px 0; font-size: 14px; }
.banner.warn { background: rgba(242, 167, 27, 0.12); border: 1px solid var(--amber); }
.banner.info { background: rgba(74, 168, 220, 0.10); border: 1px solid rgba(74, 168, 220, 0.5); color: var(--text); }
.banner-link { margin-left: 6px; }

.theory { background: var(--bg-inset); border: 1px dashed var(--line); border-radius: 6px; margin: 14px 0; }
.theory summary {
  cursor: pointer; padding: 10px 14px; min-height: 44px; display: flex; align-items: center;
  font-family: var(--display); font-size: 16px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--amber);
}
.theory-body { padding: 0 16px 12px; color: var(--text); max-width: 75ch; }
.theory-body p { margin: 8px 0; }

/* ---------- fields ---------- */
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 14px; margin: 10px 0; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field.wide { grid-column: 1 / -1; }
.field-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.field-input { display: flex; align-items: center; gap: 6px; }
.unit { color: var(--text-dim); font-size: 12px; white-space: nowrap; }

input, select, textarea {
  background: var(--bg-inset); color: var(--text);
  border: 1px solid var(--line); border-radius: 4px;
  padding: 9px 10px; font: 14px var(--body); min-height: 40px;
  width: 100%; max-width: 100%;
}
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; flex: none; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--amber); outline-offset: -1px; border-color: var(--amber); }
.cell-num { max-width: 90px; padding: 6px 6px; min-height: 36px; }
textarea { resize: vertical; }

.btn {
  background: var(--bg-inset); color: var(--text);
  border: 1px solid var(--line); border-radius: 4px;
  padding: 10px 14px; min-height: 44px; cursor: pointer;
  font: 600 13px var(--body); letter-spacing: 0.02em;
}
.btn:hover { border-color: var(--amber); color: var(--amber); }
.btn.primary { background: var(--amber); border-color: var(--amber); color: #14161a; }
.btn.primary:hover { background: #ffbe3d; color: #14161a; }
.btn.danger:hover { border-color: var(--red); color: var(--red); }
.btn.small { padding: 6px 10px; min-height: 36px; font-size: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin: 10px 0; }
.toolbar .field { min-width: 180px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 10px 0; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th, table.data td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
table.data th {
  background: var(--bg-inset); font-family: var(--display); font-weight: 600;
  font-size: 13px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-dim);
}
table.data input, table.data select { min-height: 34px; padding: 5px 6px; font-size: 13px; }
.row-open td { background: rgba(242, 167, 27, 0.05); }
.row-active td { background: rgba(242, 167, 27, 0.08); }
.col-best { background: rgba(92, 184, 122, 0.10); }
.matrix-total td { border-top: 2px solid var(--amber); }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--text-dim); font-size: 13px; }

/* ---------- badges / stats ---------- */
.badge {
  display: inline-block; padding: 2px 7px; border-radius: 3px;
  font: 700 10px var(--body); letter-spacing: 0.06em; text-transform: uppercase;
  border: 1px solid var(--line); color: var(--text-dim); white-space: nowrap;
}
.badge.ok { border-color: var(--green); color: var(--green); }
.badge.warn { border-color: var(--amber); color: var(--amber); }
.badge.bad { border-color: var(--red); color: var(--red); }
.badge.event { border-color: var(--blue); color: var(--blue); }
.badge.src-published { border-color: var(--blue); color: var(--blue); }
.badge.src-inferred { border-color: var(--amber); color: var(--amber); }
.badge.src-self-imposed { border-color: var(--green); color: var(--green); }
.badge-btn {
  cursor: pointer; background: transparent; border: 1px solid var(--line); border-radius: 3px;
  padding: 4px 8px; font: 700 10px var(--body); letter-spacing: 0.05em; text-transform: uppercase;
  min-height: 32px;
}
.badge-btn.ok { border-color: var(--green); color: var(--green); }
.badge-btn.warn { border-color: var(--amber); color: var(--amber); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin: 12px 0; }
.stat { background: var(--bg-inset); border: 1px solid var(--line); border-radius: 5px; padding: 10px 12px; }
.stat-value { font-family: var(--display); font-size: 24px; font-weight: 700; color: var(--amber); line-height: 1.1; }
.stat-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }
.stat-sub { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

.chart-box { position: relative; margin: 12px 0; }
.chart-fallback { color: var(--text-dim); font-size: 13px; display: flex; align-items: center; }

/* ---------- checklist ---------- */
.check-cat {
  font-family: var(--display); text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--blue); margin: 14px 0 6px; font-size: 16px;
}
.check-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-bottom: 1px solid var(--line);
}
.check-state {
  flex: none; width: 64px; min-height: 36px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 4px; background: var(--bg-inset);
  font: 700 10px var(--body); letter-spacing: 0.05em; color: var(--text-dim);
}
.state-pass .check-state { border-color: var(--green); color: var(--green); }
.state-fail .check-state { border-color: var(--red); color: var(--red); }
.state-na .check-state { opacity: 0.5; }
.check-text { flex: 1; min-width: 200px; }
.state-pass .check-text { color: var(--text-dim); }
.check-notes { max-width: 200px; min-height: 34px; font-size: 12px; }
.check-box { display: none; }

/* ---------- config sticker cards ---------- */
.config-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.config-card.sticker {
  background: var(--bg-inset);
  border: 2px solid var(--line); border-radius: 8px; padding: 12px;
  position: relative;
}
.config-card.sticker.active { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.config-card.sticker.active::after {
  content: "TECH OK"; position: absolute; top: 8px; right: 10px;
  font: 700 10px var(--display); letter-spacing: 0.15em; color: var(--amber);
  border: 2px solid var(--amber); border-radius: 4px; padding: 2px 6px;
  transform: rotate(-6deg); opacity: 0.9;
}
.sticker-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; padding-right: 70px; }
.sticker-name { font-family: var(--display); font-size: 19px; font-weight: 700; text-transform: uppercase; }
.sticker-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.mini-field { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.mini-field > span { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.mini-field.wide { margin: 6px 0; }

/* ---------- sessions / tasks ---------- */
.session-card { border: 1px solid var(--line); border-radius: 6px; padding: 12px; margin: 12px 0; background: var(--bg-inset); }
.session-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.session-head input, .session-head select { width: auto; flex: 1 1 130px; }
.task-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.task-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.task-row .task-title { flex: 2 1 200px; }
.task-row select, .task-row input[type="date"] { width: auto; flex: 1 1 120px; }
.task-row.done .task-title { text-decoration: line-through; color: var(--text-dim); }
.phase summary {
  cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 8px;
  font-family: var(--display); font-size: 17px; letter-spacing: 0.04em; text-transform: uppercase;
}

/* ---------- decisions ---------- */
.decision-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.decision-title { font-family: var(--display); font-size: 19px; font-weight: 700; }
.weight { margin-top: 4px; }
table.matrix input.cell-num { max-width: 70px; }

/* ---------- geometry viewer ---------- */
.viewer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; margin-top: 10px; }
.svg-box { background: var(--bg-inset); border: 1px solid var(--line); border-radius: 6px; padding: 6px; }
.linkage-svg { width: 100%; height: auto; display: block; }
.travel-slider { padding: 0; min-height: 44px; accent-color: var(--amber); }

/* ---------- misc ---------- */
.glossary dt { font-weight: 700; color: var(--amber); margin-top: 10px; }
.glossary dd { margin: 2px 0 0 0; color: var(--text); max-width: 80ch; }
.plain-list { padding-left: 20px; }
.plain-list li { margin: 4px 0; }
.edit-grid { display: flex; flex-direction: column; gap: 8px; }
.print-only { display: none; }
.plan-detail summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--blue); }

/* ---------- responsive ---------- */
@media (max-width: 800px) {
  #app { flex-direction: column; }
  #nav {
    width: 100%; height: auto; position: static; border-right: 0;
    border-bottom: 1px solid var(--line); padding: 10px 0;
  }
  .nav-list { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .nav-list li { flex: none; }
  .nav-link { border-left: 0; border-bottom: 3px solid transparent; padding: 10px 12px; }
  .nav-link.active { border-bottom-color: var(--amber); }
  .nav-actions { flex-direction: row; align-items: center; margin-top: 6px; }
  .sync-note { display: none; }
  #main { padding: 14px 12px 60px; }
  .module-header h2 { font-size: 24px; }
  .check-notes { max-width: 120px; }
}

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

/* ---------- print ---------- */
@media print {
  body { background: #fff; color: #000; font-size: 12px; }
  #nav, .toolbar, .no-print, .theory, .banner, .chart-box { display: none !important; }
  .panel { border: none; background: #fff; padding: 0; margin: 8px 0; }
  .panel-title, .module-header h2, .check-cat { color: #000; }
  .status-line { color: #333; }
  table.data th, table.data td { border-color: #999; color: #000; }
  table.data th { background: #eee; }
  a { color: #000; text-decoration: none; }

  /* checklist print mode: show only the checklist */
  body.printing-checklist #main > *:not(.print-target) { display: none; }
  body.printing-checklist .module-header { display: none; }
  body.printing-checklist .print-only { display: block; }
  body.printing-checklist .check-box { display: inline; font-family: var(--mono); }
  body.printing-checklist .check-item { padding: 3px 0; border-bottom: 1px solid #ccc; page-break-inside: avoid; }
  body.printing-checklist .check-text, body.printing-checklist .check-cat { color: #000; }
  body.printing-checklist .print-head h2 { margin: 0 0 4px; }

  /* setup sheet print mode: show only the appended sheet */
  body.printing-sheet #app { display: none; }
  .setup-sheet { display: block; color: #000; }
  .setup-sheet h2 { font-family: var(--display); text-transform: uppercase; }
  .setup-sheet table { border-collapse: collapse; width: 100%; }
  .setup-sheet th, .setup-sheet td { border: 1px solid #999; padding: 6px 10px; text-align: left; font-size: 14px; }
}
.setup-sheet { display: none; }
