/* ═══════════════════════════════════════════════════════════════
   LENS BASE — Brand DNA
   Extracted from Work Order (the 90% reference).
   Every lens <link>s to this file. Lens-specific CSS goes inline.
   Tokens imported from prototype-tokens.css (single source of truth).
   ═══════════════════════════════════════════════════════════════ */
@import url('prototype-tokens.css');

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

body {
  font-family: var(--font-sans);
  background: var(--surface-base);
  color: var(--txt);
  min-height: 100vh;
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 16px 48px;
  font-size: 14px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

svg { display: inline-block; vertical-align: middle; }

/* ═══════════════════════════════════════════════════════
   PANEL
   ═══════════════════════════════════════════════════════ */
.panel {
  width: 720px;
  border-radius: 8px; overflow: hidden;
  border-top:    1px solid var(--border-top);
  border-right:  1px solid var(--border-side);
  border-bottom: 1px solid var(--border-bottom);
  border-left:   1px solid var(--border-side);
  box-shadow: var(--shadow-panel);
  background: var(--surface);
  display: flex; flex-direction: column;
}

/* ═══════════════════════════════════════════════════════
   LENS HEADER — glass nav bar
   ═══════════════════════════════════════════════════════ */
.lens-hdr {
  height: 56px; flex-shrink: 0;
  display: flex; align-items: center; padding: 0 16px;
  border-bottom: 1px solid var(--border-sub);
  background: var(--glass-bg);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.hdr-back {
  width: 44px; height: 44px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--txt2); background: none; border: none;
  transition: background 60ms; margin-right: 8px;
}
.hdr-back:hover { background: var(--surface-hover); color: var(--txt); }
.hdr-type {
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  color: var(--txt2); flex: 1; text-transform: uppercase;
}
.hdr-actions { display: flex; align-items: center; gap: 4px; }
.hdr-btn {
  height: 44px; border-radius: 6px; padding: 0 10px;
  display: flex; align-items: center; gap: 5px;
  cursor: pointer; color: var(--txt3); font-size: 11px; font-weight: 500;
  background: none; border: none; font-family: var(--font-sans);
  transition: background 60ms;
}
.hdr-btn:hover { background: var(--surface-hover); color: var(--txt2); }
.hdr-close {
  width: 44px; height: 44px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--txt-ghost); background: none; border: none;
  transition: background 60ms;
}
.hdr-close:hover { background: var(--surface-hover); color: var(--txt2); }

/* Theme toggle — CSS-based icon swap (one canonical implementation) */
.icon-sun { display: none; }
.icon-moon { display: inline-block; }
[data-theme="light"] .icon-sun { display: inline-block; }
[data-theme="light"] .icon-moon { display: none; }

/* ═══════════════════════════════════════════════════════
   BODY — scroll container
   ═══════════════════════════════════════════════════════ */
.lens-body {
  flex: 1; overflow-y: auto; padding: 0 40px 40px;
}

/* ═══════════════════════════════════════════════════════
   IDENTITY STRIP — structured hierarchy
   ═══════════════════════════════════════════════════════ */
.identity { padding-top: 32px; padding-bottom: 28px; }

.identity-top-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}

.identity-overline {
  font-family: var(--font-mono); font-size: 12px; font-weight: 500;
  color: var(--txt3); letter-spacing: 0.04em;
}

.identity-title {
  font-size: 22px; font-weight: 600; line-height: 1.25;
  letter-spacing: -0.01em; margin-bottom: 8px;
}

.identity-context {
  font-size: 13px; font-weight: 400; color: var(--txt2);
  margin-bottom: 16px;
}

.identity-actions {
  display: flex; align-items: center; gap: 8px;
}

.crew-link {
  color: var(--mark); cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--mark-underline);
  text-underline-offset: 2px;
}
.crew-link:hover { text-decoration-color: var(--mark); }

/* Status pills */
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 6px;
  font-size: 12px; font-weight: 500;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.pill-green { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.pill-green .dot { background: var(--green); }
.pill-amber { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-border); }
.pill-amber .dot { background: var(--amber); }
.pill-neutral { background: var(--neutral-bg); color: var(--txt3); border: 1px solid var(--border-sub); }
.pill-neutral .dot { background: var(--txt3); }
.pill-red { background: var(--red-bg); color: var(--red); border: 1px solid var(--red-border); }
.pill-red .dot { background: var(--red); }

/* Key-value detail lines */
.detail-lines { margin-bottom: 24px; }
.detail-line {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--txt2);
  min-height: 32px;
}
.detail-label {
  font-size: 11px; font-weight: 500; color: var(--txt3);
  text-transform: uppercase; letter-spacing: 0.04em;
  min-width: 80px;
}
.detail-val { font-size: 13px; color: var(--txt); }
.mono { font-family: var(--font-mono); }
.mono-val { font-family: var(--font-mono); font-size: 13px; color: var(--txt); }

/* Description (WO + Shopping List keep this) */
.desc-block { margin-bottom: 24px; }
.desc-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--txt3); margin-bottom: 6px;
}
.desc-text {
  font-size: 14px; font-weight: 400; color: var(--txt2);
  line-height: 1.65; max-width: 600px;
}

/* ═══════════════════════════════════════════════════════
   SPLIT BUTTON — active state (default)
   ═══════════════════════════════════════════════════════ */
.split-wrap { position: relative; flex-shrink: 0; }
.split-btn { display: flex; border-radius: 8px; overflow: hidden; }
.split-main {
  padding: 0 16px; height: 44px;
  background: var(--teal-bg); color: var(--mark);
  font-size: 13px; font-weight: 500; border: none;
  font-family: var(--font-sans); cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: background 60ms;
}
.split-main:hover { background: var(--mark-hover); }
.split-main svg { width: 14px; height: 14px; flex-shrink: 0; }
.split-toggle {
  width: 44px; height: 44px;
  background: var(--teal-bg); color: var(--mark);
  border: none; border-left: 1px solid var(--mark-thumb);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-sans); transition: background 60ms;
}
.split-toggle:hover { background: var(--mark-hover); }

/* Split button — disabled state (e.g. WO incomplete checklist) */
.split-main.disabled {
  background: var(--split-bg); color: var(--txt-ghost);
  cursor: default;
}
.split-main.disabled:hover { background: var(--split-bg); }
.split-toggle.disabled {
  background: var(--split-bg); color: var(--txt-ghost);
  border-left-color: var(--border-chrome);
}
.split-toggle.disabled:hover { background: var(--split-bg-hover); }

/* Tooltip — shown on disabled split hover */
.split-tooltip {
  display: none; position: absolute; top: 42px; right: 0;
  background: var(--surface-el); color: var(--txt2);
  font-size: 11px; padding: 6px 10px; border-radius: 6px;
  white-space: nowrap; border: 1px solid var(--border-sub);
  box-shadow: var(--shadow-tip);
  pointer-events: none; z-index: 20;
}
.split-wrap:hover .split-tooltip { display: block; }

/* Dropdown */
.dropdown {
  display: none; position: absolute; top: 50px; right: 0;
  background: var(--surface-el); border-radius: 8px;
  border: 1px solid var(--border-chrome);
  box-shadow: var(--shadow-drop);
  min-width: 200px; padding: 4px; z-index: 30;
}
.dropdown.open { display: block; }
.dd-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 6px;
  font-size: 13px; font-weight: 400; color: var(--txt);
  cursor: pointer; width: 100%; border: none;
  background: none; font-family: var(--font-sans); text-align: left;
  transition: background 60ms; min-height: 44px;
}
.dd-item:hover { background: var(--surface-hover); }
.dd-item svg { width: 14px; height: 14px; color: var(--txt3); flex-shrink: 0; }
.dd-item.danger { color: var(--red); }
.dd-item.danger svg { color: var(--red); }
.dd-sep { height: 1px; background: var(--border-sub); margin: 4px 8px; }

/* ═══════════════════════════════════════════════════════
   SECTION SYSTEM — ruled line + 14px/600 heading
   ═══════════════════════════════════════════════════════ */
.section {
  border-top: 1px solid var(--border-sub);
  padding-top: 24px;
  margin-top: 32px;
}
.section:first-child { margin-top: 24px; }

.sec-hdr {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; user-select: none;
  padding-bottom: 12px;
  min-height: 44px;
}
.sec-hdr:hover .sec-title { color: var(--txt2); }
.sec-icon { width: 16px; height: 16px; color: var(--txt3); flex-shrink: 0; }
.sec-title {
  font-size: 14px; font-weight: 600; color: var(--txt3);
  text-transform: uppercase; letter-spacing: 0.06em;
  transition: color 120ms; flex: 1;
}
.sec-action {
  font-size: 13px; font-weight: 500; color: var(--mark);
  cursor: pointer; background: none; border: none; font-family: var(--font-sans);
  padding: 4px 8px; border-radius: 4px; transition: background 60ms;
}
.sec-action:hover { background: var(--teal-bg); }
.sec-count {
  font-size: 11px; color: var(--txt-ghost); font-family: var(--font-mono);
}
.sec-chevron {
  width: 16px; height: 16px; color: var(--txt-ghost);
  transition: transform 200ms ease; flex-shrink: 0;
}
.section.collapsed .sec-chevron { transform: rotate(-90deg); }

.sec-body {
  overflow: hidden;
  transition: max-height 300ms ease, opacity 250ms ease;
}
.section.collapsed .sec-body {
  max-height: 0 !important; opacity: 0;
}

/* ═══════════════════════════════════════════════════════
   DOCUMENT ROWS
   ═══════════════════════════════════════════════════════ */
.doc-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 6px;
  cursor: pointer; transition: background 60ms; min-height: 44px;
}
.doc-row:hover { background: var(--surface-hover); }
.doc-icon {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--teal-bg);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.doc-icon svg { width: 14px; height: 14px; color: var(--mark); }
.doc-info { flex: 1; }
.doc-name { font-size: 13px; font-weight: 500; color: var(--txt); }
.doc-name .doc-code { font-family: var(--font-mono); font-size: 12px; }
.doc-name .doc-sop-action { color: var(--mark); font-weight: 500; }
.doc-meta { font-size: 11px; color: var(--txt3); margin-top: 1px; }
.doc-meta .doc-date { font-family: var(--font-mono); font-size: 10px; }
.doc-meta .doc-size { font-family: var(--font-mono); font-size: 10px; }
.doc-chevron { color: var(--txt-ghost); }

/* ═══════════════════════════════════════════════════════
   NOTES
   ═══════════════════════════════════════════════════════ */
.note {
  padding: 14px 0;
  border-bottom: 1px solid var(--border-faint);
}
.note:last-child { border-bottom: none; }
.note-meta {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.note-author { font-size: 13px; font-weight: 500; color: var(--txt); }
.note-time { font-family: var(--font-mono); font-size: 11px; color: var(--txt3); }
.note-body {
  font-size: 14px; font-weight: 400; color: var(--txt2); line-height: 1.6;
}
.note-body.clamped {
  display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
}
.note-more {
  font-size: 12px; font-weight: 500; color: var(--mark);
  cursor: pointer; background: none; border: none;
  font-family: var(--font-sans); padding: 0; margin-top: 4px;
}
.note-more:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════
   AUDIT TRAIL — dot timeline
   ═══════════════════════════════════════════════════════ */
.audit-event {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 0; min-height: 40px;
  position: relative;
}
.audit-event:not(:last-child)::after {
  content: ''; position: absolute;
  left: 5px; top: 28px; bottom: -2px; width: 1px;
  background: var(--border-sub);
}
.audit-dot {
  width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0;
  margin-top: 3px; border: 2px solid var(--mark);
  background: var(--surface);
}
.audit-info { flex: 1; }
.audit-action {
  font-size: 13px; font-weight: 400; color: var(--txt);
  line-height: 1.45;
}
.audit-action .crew { font-weight: 500; }
.audit-time {
  font-family: var(--font-mono); font-size: 10px; color: var(--txt3);
  margin-top: 2px;
}

/* ═══════════════════════════════════════════════════════
   ATTACHMENTS
   ═══════════════════════════════════════════════════════ */
.attach-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; min-height: 44px;
  cursor: pointer; border-radius: 6px;
  transition: background 60ms;
}
.attach-row:hover { background: var(--surface-hover); margin: 0 -8px; padding: 10px 8px; }
.attach-thumb {
  width: 40px; height: 40px; border-radius: 6px;
  flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.attach-thumb.img {
  background: linear-gradient(135deg, var(--surface-base) 0%, var(--surface-el) 50%, var(--surface-base) 100%);
}
.attach-thumb.img::after {
  content: ''; display: block; width: 20px; height: 14px;
  border-radius: 2px; background: var(--mark-thumb);
}
.attach-thumb.doc {
  background: var(--surface-el);
}
.attach-thumb.doc svg { width: 18px; height: 18px; color: var(--txt3); }
.attach-info { flex: 1; min-width: 0; }
.attach-name { font-size: 13px; font-weight: 500; color: var(--txt); }
.attach-caption {
  font-size: 11px; color: var(--txt3); margin-top: 1px;
  font-style: italic; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.attach-size {
  font-family: var(--font-mono); font-size: 11px; color: var(--txt-ghost);
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════
   PARTS (inline in sections)
   ═══════════════════════════════════════════════════════ */
.part-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; min-height: 44px;
  border-bottom: 1px solid var(--border-faint);
}
.part-row:last-child { border-bottom: none; }
.part-name {
  font-size: 13px; font-weight: 500; flex: 1;
  color: var(--mark); cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--mark-underline);
  text-underline-offset: 2px;
}
.part-name:hover { text-decoration-color: var(--mark); }
.part-name .part-id { font-family: var(--font-mono); font-size: 12px; }
.part-qty {
  font-family: var(--font-mono); font-size: 12px;
  font-weight: 500; color: var(--txt2);
}
.part-stock {
  font-family: var(--font-mono); font-size: 11px; color: var(--txt3);
}

/* ═══════════════════════════════════════════════════════
   CHECKLIST
   ═══════════════════════════════════════════════════════ */
.progress-bar {
  height: 3px; width: 100%; border-radius: 2px;
  background: var(--split-bg); overflow: hidden;
  margin-bottom: 12px;
}
.progress-bar .fill {
  height: 100%; border-radius: 2px; background: var(--mark);
}

.check-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0; min-height: 44px;
}
.check-item.done { opacity: 0.5; }
.check-box {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  margin-top: 2px; display: flex; align-items: center; justify-content: center;
}
.check-box.checked { background: var(--green); }
.check-box.checked svg { width: 11px; height: 11px; color: var(--on-status); }
.check-box.pending {
  background: none; border: 1.5px solid var(--txt3); cursor: pointer;
}
.check-box.pending:hover { border-color: var(--mark); }
.check-text { flex: 1; }
.check-desc {
  font-size: 13px; font-weight: 400; color: var(--txt); line-height: 1.45;
}
.check-item.done .check-desc { text-decoration: line-through; color: var(--txt3); }
.check-meta {
  font-size: 11px; color: var(--txt3); margin-top: 2px;
  display: flex; align-items: center; gap: 8px;
}
.check-meta .ts { font-family: var(--font-mono); font-size: 10px; }
.check-step {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  color: var(--txt3); min-width: 18px; text-align: right;
  margin-top: 2px; flex-shrink: 0;
}
.check-photo {
  display: inline-flex; align-items: center; gap: 3px;
  color: var(--txt3); font-size: 10px;
}
.check-photo svg { width: 11px; height: 11px; }
.check-undo {
  font-size: 11px; font-weight: 500; color: var(--mark);
  cursor: pointer; background: none; border: none; font-family: var(--font-sans);
  padding: 0;
}
.check-undo:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════
   HISTORY — prior service periods
   ═══════════════════════════════════════════════════════ */
.period {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-faint);
}
.period:last-child { border-bottom: none; }
.period-hdr {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; min-height: 36px;
}
.period-year {
  font-family: var(--font-mono); font-size: 13px;
  font-weight: 600; color: var(--txt);
}
.period-label { font-size: 12px; color: var(--txt2); }
.period-tag {
  font-size: 9px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; padding: 2px 6px; border-radius: 3px;
  margin-left: auto;
}
.period-tag.active { color: var(--amber); background: var(--amber-bg); }
.period-tag.closed { color: var(--txt3); background: var(--neutral-bg); }
.period-summary {
  font-size: 12px; color: var(--txt3); margin-top: 4px;
}
.period-summary .ps-mono { font-family: var(--font-mono); font-size: 11px; }

/* ═══════════════════════════════════════════════════════
   ENTITY ICON (used in cross-reference rows)
   ═══════════════════════════════════════════════════════ */
.entity-icon {
  width: 28px; height: 28px; border-radius: 6px;
  background: var(--teal-bg);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.entity-icon svg { width: 14px; height: 14px; color: var(--mark); }

/* ═══════════════════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════════════════ */
.empty-state {
  padding: 20px 0;
  font-size: 13px; font-weight: 400; color: var(--txt3);
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════
   OCR BANNER
   ═══════════════════════════════════════════════════════ */
.ocr-banner {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 500; color: var(--txt3);
  padding: 6px 10px; border-radius: 4px;
  background: var(--neutral-bg);
  margin-bottom: 14px;
}
.ocr-banner svg { width: 12px; height: 12px; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════
   DOCUMENT PREVIEW AREA (Document + Handover lenses)
   ═══════════════════════════════════════════════════════ */
.preview-area {
  background: var(--surface-el);
  border: 1px solid var(--border-sub);
  border-radius: 8px;
  min-height: 400px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  padding: 48px 32px;
  position: relative;
}
.preview-badge {
  position: absolute; top: 12px; left: 12px;
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--txt3);
  background: var(--neutral-bg);
  padding: 4px 10px; border-radius: 4px;
  border: 1px solid var(--border-faint);
}
.preview-badge svg { width: 12px; height: 12px; color: var(--txt3); }
.preview-actions {
  display: flex; align-items: center; gap: 16px; margin-top: 12px;
}
.preview-link {
  font-size: 13px; font-weight: 500; color: var(--mark);
  cursor: pointer; text-decoration: underline;
  text-decoration-color: var(--mark-underline);
  text-underline-offset: 2px;
  background: none; border: none; font-family: var(--font-sans);
}
.preview-link:hover { text-decoration-color: var(--mark); }

/* ═══════════════════════════════════════════════════════
   PRINT BUTTON (Certificate, Document lenses)
   ═══════════════════════════════════════════════════════ */
.print-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 0 14px; height: 44px; border-radius: 8px;
  background: var(--teal-bg); color: var(--mark);
  font-size: 13px; font-weight: 500; border: none;
  font-family: var(--font-sans); cursor: pointer;
  transition: background 60ms;
}
.print-btn:hover { background: var(--mark-hover); }
.print-btn svg { width: 14px; height: 14px; }

/* ═══════════════════════════════════════════════════════
   SCROLL REVEAL
   ═══════════════════════════════════════════════════════ */
.reveal {
  opacity: 0; transform: translateY(10px);
  transition: opacity 350ms ease, transform 350ms ease;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ═══════════════════════════════════════════════════════
   KEY-VALUE ROWS (Coverage Details etc.)
   ═══════════════════════════════════════════════════════ */
.kv-row {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 13px; color: var(--txt2);
  min-height: 36px; padding: 4px 0;
}
.kv-label {
  font-size: 11px; font-weight: 500; color: var(--txt3);
  text-transform: uppercase; letter-spacing: 0.04em;
  min-width: 120px; padding-top: 2px;
}
.kv-value { flex: 1; color: var(--txt); font-size: 13px; }
.kv-value .sub { color: var(--txt2); }

/* ═══════════════════════════════════════════════════════
   EQUIP LINK (used in many lenses)
   ═══════════════════════════════════════════════════════ */
.equip-link {
  color: var(--mark); cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--mark-underline);
  text-underline-offset: 2px;
}
.equip-link:hover { text-decoration-color: var(--mark); }

/* ═══════════════════════════════════════════════════════
   REPORT FOOTER
   ═══════════════════════════════════════════════════════ */
.report-footer {
  padding: 24px 0 8px;
  text-align: center;
  font-size: 11px; color: var(--txt-ghost);
  border-top: 1px solid var(--border-faint);
  margin-top: 32px;
}
