:root {
  --lp-orange: #ff4f17;
  --lp-charcoal: #171a1f;
  --lp-green: #1f8a45;
  --lp-canvas: #f3f5f7;
  --lp-line: #dce1e7;
}

body {
  background: var(--lp-canvas);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (min-width: 1200px) {
  body.minimal-app-ui .global-nav {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 100;
    display: flex;
    width: 186px;
    height: 100vh;
    padding: 28px 18px;
    flex-direction: column;
    align-items: stretch;
    gap: 7px;
    border: 0;
    background: linear-gradient(180deg, #171a1f 0%, #111318 100%);
    box-shadow: 12px 0 34px rgba(16, 24, 40, .12);
  }

  body.minimal-app-ui .global-nav::before {
    content: "GIGAMACH\A OS";
    white-space: pre;
    margin: 0 4px 28px;
    color: #fff;
    font-size: 22px;
    font-weight: 900;
    line-height: 1.05;
    letter-spacing: .5px;
  }

  body.minimal-app-ui .global-nav a {
    padding: 11px 12px;
    color: #d0d5dd;
    border-radius: 10px;
    font-size: 13px;
  }

  body.minimal-app-ui .global-nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
  body.minimal-app-ui .global-nav a[aria-current="page"] { color: #fff; background: var(--lp-orange); }

  body.minimal-app-ui .page {
    width: calc(100% - 186px);
    max-width: none;
    margin: 0 0 0 186px;
  }
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 76px;
  padding: 14px 22px;
  border-bottom-color: var(--lp-line);
  box-shadow: 0 1px 0 rgba(16, 24, 40, .02);
}

.app-title h1 { color: #111318; font-size: 27px; letter-spacing: -.5px; }
.app-title p { color: #77808d; }
.button-link, button { border-radius: 10px; }
button.primary { border-color: var(--lp-charcoal); background: var(--lp-charcoal); }
button.success, [data-generate-plan] { color: #fff; border-color: var(--lp-orange); background: var(--lp-orange); }

.safety-banner {
  border: 1px solid #fed7aa;
  border-left: 5px solid var(--lp-orange);
  border-radius: 12px;
  color: #7c2d12;
  background: #fff7ed;
}

.workspace {
  grid-template-columns: minmax(480px, 570px) minmax(720px, 1fr);
  gap: 18px;
  padding: 18px 20px 34px;
}

.editor {
  max-height: none;
  overflow: visible;
}

.source-panel, details, .editor-actions {
  border-color: var(--lp-line);
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(16, 24, 40, .045);
}

details > summary { padding: 15px 16px; color: #25282d; font-size: 15px; }
details[open] > summary { color: var(--lp-orange); }
.section-body { padding: 16px; }

input, select, textarea {
  border-color: #d3d9e1;
  border-radius: 9px;
  background: #fbfcfd;
}

input:focus, select:focus, textarea:focus {
  outline-color: rgba(255, 79, 23, .25);
  border-color: var(--lp-orange);
  background: #fff;
}

.engineering-panel {
  display: grid;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--lp-line);
  border-radius: 12px;
  background: #f8fafc;
}

.engineering-panel h3 {
  margin: 0;
  color: #24272c;
  font-size: 14px;
}

.engineering-panel p, .field-help {
  margin: 0;
  color: #707986;
  font-size: 11px;
  line-height: 1.45;
}

.geometry-figure {
  border-color: var(--lp-line);
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.55);
}

.geometry-figure svg { max-height: 440px; }
.geometry-figure .diagram-title { fill: #20242a; }
.geometry-figure .diagram-angle, .geometry-figure .diagram-accent { stroke: var(--lp-orange); fill: var(--lp-orange); }

.hirarc-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.hirarc-stat {
  min-height: 72px;
  padding: 10px;
  border: 1px solid var(--lp-line);
  border-radius: 10px;
  background: #fff;
}

.hirarc-stat span { display: block; color: #717a87; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.hirarc-stat strong { display: block; margin-top: 7px; font-size: 18px; }
.hirarc-stat[data-level="high"] strong { color: #b42318; }
.hirarc-stat[data-level="medium"] strong { color: #b45309; }
.hirarc-stat[data-level="low"] strong { color: #18743c; }

.hirarc-list { display: grid; gap: 6px; }
.hirarc-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--lp-line);
  border-radius: 9px;
  background: #fff;
  font-size: 11px;
}

.risk-dot { width: 9px; height: 9px; border-radius: 50%; background: #16a34a; }
.risk-dot.medium { background: #f59e0b; }
.risk-dot.high { background: #dc2626; }
.risk-score { color: #667085; font-weight: 800; }

.doc-risk-high { color: #991b1b; background: #fee2e2; font-weight: 800; }
.doc-risk-medium { color: #92400e; background: #fef3c7; font-weight: 800; }
.doc-risk-low { color: #166534; background: #dcfce7; font-weight: 800; }
.doc-engineering-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2mm; }
.doc-engineering-grid .geometry-figure { break-inside: avoid; }
.draft-watermark {
  margin: 3mm 0;
  padding: 2.5mm;
  border: 1px solid #ef4444;
  color: #991b1b;
  background: #fef2f2;
  text-align: center;
  font-size: 11pt;
  font-weight: 900;
  letter-spacing: .8px;
}

@media screen {
  .preview-shell { overflow-x: hidden; }
  .paper { width: min(210mm, 100%); }
}

@media (min-width: 1200px) and (max-width: 1599px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .editor { max-height: none; overflow: visible; }
  .preview-shell { position: static; overflow-x: auto; }
}

.certificate-upload-panel { border-left: 4px solid var(--lp-orange); }
.certificate-upload-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.document-register-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.document-register-toolbar strong,
.document-register-toolbar span { display: block; }
.document-register-toolbar span { margin-top: 3px; color: #707986; font-size: 11px; }
.document-register { display: grid; gap: 8px; }
.document-record {
  display: grid;
  grid-template-columns: auto 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--lp-line);
  border-radius: 11px;
  background: #fff;
}
.document-record > input { width: 18px; min-height: 18px; margin: 0; }
.document-record-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  color: var(--lp-orange);
  background: #fff0ea;
  font-size: 10px;
  font-weight: 900;
}
.document-record-main { min-width: 0; }
.document-record-main strong,
.document-record-main span { display: block; }
.document-record-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.document-record-main span { margin-top: 3px; color: #707986; font-size: 10px; line-height: 1.35; }
.document-record-actions { display: flex; gap: 6px; }
.document-record-actions button { min-height: 34px; padding: 6px 9px; font-size: 10px; }
.document-record-actions button[data-delete-lifting-document] { color: #b42318; }
.document-record[data-expiry="expired"] { border-color: #fda29b; background: #fff5f4; }
.document-record[data-expiry="expiring"] { border-color: #f7ce76; background: #fffbeb; }
.document-pack-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2mm;
  margin-bottom: 3mm;
}
.document-pack-stat { padding: 2mm; border: 1px solid #aeb8c5; background: #f7f8fa; }
.document-pack-stat span { display: block; color: #667085; font-size: 7pt; text-transform: uppercase; }
.document-pack-stat strong { display: block; margin-top: 1mm; font-size: 11pt; }
.document-pack-index td:first-child { width: 10mm; text-align: center; }
.document-annex-page {
  min-height: 262mm;
  break-before: page;
  page-break-before: always;
  break-inside: avoid;
  page-break-inside: avoid;
  display: flex;
  flex-direction: column;
}
.document-annex-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4mm;
  align-items: start;
  padding-bottom: 2mm;
  border-bottom: 1.5px solid #20242a;
}
.document-annex-header h3 { margin: 0; color: #20242a; font-size: 12pt; }
.document-annex-header p { margin: 1mm 0 0; color: #667085; font-size: 8pt; }
.document-annex-number { color: var(--lp-orange); font-size: 11pt; font-weight: 900; }
.document-annex-image {
  display: grid;
  place-items: center;
  flex: 1;
  min-height: 220mm;
  margin-top: 3mm;
  border: 1px solid #d0d5dd;
  background: #f8fafc;
}
.document-annex-image img { display: block; max-width: 100%; max-height: 220mm; object-fit: contain; }
.document-annex-footer { margin-top: 2mm; color: #667085; font-size: 7pt; }

@media (max-width: 767px) {
  .app-title h1 { font-size: 21px; }
  .engineering-panel { padding: 11px; }
  .hirarc-summary { grid-template-columns: 1fr; }
  .hirarc-item { grid-template-columns: auto minmax(0, 1fr); }
  .hirarc-item .risk-score { grid-column: 2; }
  .doc-engineering-grid { grid-template-columns: 1fr; }
  .document-record { grid-template-columns: auto 38px minmax(0, 1fr); }
  .document-record-actions { grid-column: 2 / -1; }
  .document-pack-summary { grid-template-columns: 1fr; }
}

@media print {
  .page { width: auto; margin: 0; }
}
