:root{
  --bg:#07121d;
  --panel:#0b1c2d;
  --panel2:#0d2338;
  --text:#e7fbff;
  --muted:#9fd8e6;
  --line:#1b4164;
  --line2:#2a6a9a;
  --accent:#4dd6ff;
  --accent2:#bff6ff;
  --danger:#ff5c7a;
  --shadow: 0 12px 30px rgba(0,0,0,.35);
  --sidebar-w: 320px;
}
*{box-sizing:border-box}
html{ height:100%; overflow-x: hidden; }
body{
  margin:0;
  min-height:100%;
  background: radial-gradient(1200px 700px at 20% 0%, #0b2740, var(--bg));
  color:var(--text);
  font-family: ui-sans-serif, system-ui, Segoe UI, Roboto, Helvetica, Arial;
  overflow-x: hidden;
}

.topbar{
  position:sticky; top:0; z-index:10;
  display:flex; align-items:center; justify-content:space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(7,18,29,.92);
  border-bottom:1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand{ min-width: 0; flex: 1 1 200px; }
.brand__title{ font-weight:800; letter-spacing:.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand__subtitle{ font-size: 12px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.topbar__actions{ display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

.layout{
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 16px;
  padding: 16px;
  min-width: 0;
  max-width: 100%;
}
.sidebar{ display: flex; flex-direction: column; gap: 14px; min-width: 0; max-width: 100%; }
.content{ min-width: 0; max-width: 100%; overflow-x: hidden; }

.card{
  background: linear-gradient(180deg, rgba(13,35,56,.72), rgba(11,28,45,.72));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card__title{
  font-weight:800;
  letter-spacing:.06em;
  margin-bottom:10px;
}
.hint{color:var(--muted); font-size:12px; line-height:1.4; margin-top:8px}
.bullets{margin:10px 0 0 18px; padding:0; color:var(--muted)}
.bullets li{margin:8px 0}

.field{display:flex; flex-direction:column; gap:6px; margin-top:10px}
.field__label{font-size:12px; color:var(--muted); letter-spacing:.05em}
.input{
  width: 100%;
  max-width: 100%;
  border-radius: 10px;
  padding: 10px 10px;
  border: 1px solid var(--line2);
  background: rgba(0,0,0,.15);
  color: var(--text);
  outline: none;
}
.input:focus{border-color: var(--accent); box-shadow: 0 0 0 3px rgba(77,214,255,.18)}
select.input{ min-width: 0; }
/* Hoher Kontrast für Dokument-/Bauplan-Auswahl */
.input--docSelect{
  background: var(--panel2);
  color: var(--accent2);
  border-color: var(--accent);
  font-weight: 600;
  padding: 10px 12px;
}
.input--docSelect:focus{ background: #0f2842; color: #fff; }
.input--docSelect option{
  background: #0a1628;
  color: #e7fbff;
  font-weight: 500;
  padding: 8px 10px;
}
.input--docSelect option:checked,
.input--docSelect option:hover{ background: var(--line2); color: var(--accent2); }
.input--docSelect option[value=""]{ color: var(--muted); }
.row{ display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; min-width: 0; }
.spacer{flex:1}
.pill{
  border:1px solid var(--line2);
  border-radius:999px;
  padding:6px 10px;
  color:var(--muted);
  background: rgba(0,0,0,.12);
  font-size:12px;
  letter-spacing:.04em;
}

.btn{
  border-radius:10px;
  padding:10px 12px;
  border:1px solid rgba(77,214,255,.35);
  background: rgba(77,214,255,.12);
  color:var(--text);
  cursor:pointer;
  font-weight:700;
  letter-spacing:.03em;
}
.btn:hover{border-color: rgba(77,214,255,.8); background: rgba(77,214,255,.18)}
.btn:active{transform: translateY(1px)}
.btn--ghost{
  background: rgba(0,0,0,.12);
  border-color: var(--line2);
}
.btn--ghost:hover{border-color: var(--accent)}
.btn--small{padding:7px 10px; font-size:12px}
.btn--danger{border-color: rgba(255,92,122,.55); background: rgba(255,92,122,.12)}
.btn--danger:hover{border-color: rgba(255,92,122,.85); background: rgba(255,92,122,.16)}

.filebtn{position:relative; overflow:hidden}
.filebtn input[type=file]{
  position:absolute; inset:0;
  opacity:0; cursor:pointer;
}

.tabs{
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0,0,0,.12);
  margin-bottom: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  min-height: 44px;
  align-items: center;
}
.tabs::-webkit-scrollbar { height: 6px; }
.tabs::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 3px; }
.tab{
  flex-shrink: 0;
  border-radius: 999px;
  padding: 8px 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  letter-spacing: .05em;
  font-size: 13px;
  white-space: nowrap;
}
.tab.is-active{
  border-color: rgba(77,214,255,.45);
  background: rgba(77,214,255,.12);
  color: var(--text);
}

.panel{display:none}
.panel.is-active{display:block}

.grid2{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  min-width: 0;
}
.toolbar{ display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; min-width: 0; }

.list{ display: flex; flex-direction: column; gap: 10px; }
.item{
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(0,0,0,.10);
  min-width: 0;
}
.item__top{
  display: flex;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.item__top > div:first-child{ min-width: 0; flex: 1 1 180px; }
.item__title{ font-weight: 800; letter-spacing: .04em; word-break: break-word; overflow-wrap: break-word; }
.item__meta{ color: var(--muted); font-size: 12px; margin-top: 4px; word-break: break-word; }
.item__actions{ margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; flex-shrink: 0; align-items: center; }
.tag{ display: inline-block; font-size: 11px; color: var(--muted); border: 1px solid var(--line2); border-radius: 999px; padding: 4px 8px; margin-right: 6px; margin-bottom: 4px; }

.tableWrap{ overflow: auto; border-radius: 12px; border: 1px solid var(--line); -webkit-overflow-scrolling: touch; max-width: 100%; }
.table{ width: 100%; border-collapse: collapse; min-width: 640px; background: rgba(0,0,0,.10); }
.table th,.table td{ padding: 10px 8px; border-bottom: 1px solid rgba(27,65,100,.7); text-align: left; word-break: break-word; }
.table th{ font-size: 12px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; background: rgba(0,0,0,.12); }
.table tr:hover td{ background: rgba(77,214,255,.06); }
.num{ text-align: right; }

.ops{display:flex; flex-direction:column; gap:10px}
.op{
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px;
  background: rgba(0,0,0,.10);
}
.op__title{font-weight:900; letter-spacing:.04em}
.op__sub{color:var(--muted); font-size:12px; margin-top:4px}
.op__grid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 10px; }
.kpi{border:1px solid var(--line2); border-radius:10px; padding:8px 10px; background: rgba(0,0,0,.08)}
.kpi__label{color:var(--muted); font-size:11px; letter-spacing:.08em; text-transform:uppercase}
.kpi__value{font-weight:900; margin-top:4px}

.prozessIntro{
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 16px 0;
}
.prozessFlow{
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.prozessStage{
  border: 1px solid var(--line2);
  border-radius: 12px;
  padding: 14px 16px;
  background: rgba(0,0,0,.12);
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 14px;
  align-items: start;
  min-width: 0;
}
.prozessStage__desc{ overflow-wrap: break-word; word-break: break-word; }
.prozessStage__num{
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(77,214,255,.18);
  border: 1px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 14px;
  color: var(--accent2);
  flex-shrink: 0;
}
.prozessStage__title{ font-weight: 800; letter-spacing: .04em; margin-bottom: 4px; }
.prozessStage__desc{ color: var(--muted); font-size: 13px; line-height: 1.45; }
.prozessStage__atoms{ margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.prozessStage__atoms .tag{ font-size: 11px; }
.prozessArrow{
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 0;
}
.prozessArrow::after{ content: "↓"; display: block; font-size: 18px; }

.docHead{ font-size: 1rem; font-weight: 800; letter-spacing: .04em; margin: 1.25rem 0 0.5rem 0; color: var(--accent2); }
.docP{ color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0.5rem 0; }
.docList{ color: var(--muted); font-size: 14px; line-height: 1.55; margin: 0.5rem 0 1rem 1.5rem; padding: 0; }
.docList li{ margin: 0.4rem 0; }

.viewToolbar{ display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.viewToolbar__label{ font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.viewBtn{ transition: border-color .15s, background .15s; }
.viewBtn.is-active{ border-color: var(--accent); background: rgba(77,214,255,.2); color: var(--accent2); }

.calcGrid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-bottom: 12px; }
.calcOut{ min-height: 2rem; margin-top: 8px; color: var(--muted); font-size: 14px; }
.docCard{ margin-top: 14px; }

.blueprintFrame{
  margin-top:12px;
  border:1px solid var(--line);
  border-radius:14px;
  overflow:hidden;
  background: rgba(0,0,0,.12);
  min-height: 520px;
}
.blueprintDesc{ margin-top: 16px; }
.blueprintDesc__grid{ display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 12px; }
@media (min-width: 700px){ .blueprintDesc__grid{ grid-template-columns: repeat(2, 1fr); } }
.blueprintDesc__view{ padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(0,0,0,.06); }
.blueprintDesc__view.is-active{ border-color: var(--accent); background: rgba(77,214,255,.08); }
.blueprintImgWrap{
  width: 100%;
  min-height: 520px;
  max-height: 75vh;
  overflow: auto;
  padding: 10px;
}
.blueprintImg,
.blueprintSvg{
  width: 100%;
  height: auto;
  max-width: 100%;
  display: block;
  border-radius: 10px;
  border: 1px solid rgba(27,65,100,.7);
  background: rgba(0,0,0,.08);
}
.blueprintPlaceholder{
  color: var(--muted);
  padding: 2rem;
  text-align: center;
  font-size: 14px;
}

/* Fabrikplanung: P&ID + Leitstand */
.pidWrap{ margin-top: 12px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #0a1628; min-height: 380px; }
.pidWrap--ref{ min-height: 0; padding: 10px; }
.pidRefImg{ display: block; max-width: 100%; height: auto; border-radius: 10px; }
.pidDiagram{ width: 100%; min-height: 360px; padding: 12px; overflow: auto; }
.pidDiagram svg{ display: block; width: 100%; height: auto; max-width: 100%; }
.pidDiagram .pid-equip{ stroke: #4dd6ff; stroke-width: 1.5; fill: rgba(0,0,0,.2); }
.pidDiagram .pid-pipe{ stroke: #5eb8e6; stroke-width: 2; fill: none; }
.pidDiagram .pid-pipe-hot{ stroke: #e68a4d; }
.pidDiagram .pid-pipe-cold{ stroke: #4dd6ff; }
.pidDiagram .pid-text{ fill: #d8fbff; font-size: 11px; font-family: system-ui, sans-serif; }
.pidDiagram .pid-tag{ fill: #7adfff; font-weight: 700; font-size: 10px; }
.pidDiagram .pid-value{ fill: #bff6ff; font-size: 10px; }
.dashboardStrip{ display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; }
.dashboardPanel{ flex: 1 1 160px; min-width: 140px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(0,0,0,.15); }
.dashboardPanel__title{ font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
.dashboardPanel__row{ display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; }
.led{ display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.led--green{ background: #2ecc71; box-shadow: 0 0 8px #2ecc71; }
.led--orange{ background: #f39c12; box-shadow: 0 0 8px #f39c12; }
.led--red{ background: #e74c3c; box-shadow: 0 0 8px #e74c3c; }
.led.off{ background: #333; box-shadow: none; opacity: .6; }
.btn--success{ background: #27ae60; color: #fff; border-color: #27ae60; }
.btn--danger{ background: #c0392b; color: #fff; border-color: #c0392b; }
.zoneGrid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 12px; }
.zoneCard{ padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(0,0,0,.1); }
.zoneCard__name{ font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.zoneCard__desc{ font-size: 12px; color: var(--muted); }

dialog::backdrop{background: rgba(0,0,0,.65)}
dialog{
  border: 1px solid var(--line2);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(13,35,56,.96), rgba(11,28,45,.96));
  color: var(--text);
  box-shadow: var(--shadow);
  width: min(740px, calc(100vw - 24px));
  max-width: 100%;
  max-height: 90vh;
  margin: auto;
  display: flex;
  flex-direction: column;
}
.dlg{ padding: 0; margin: 0; display: flex; flex-direction: column; min-height: 0; max-height: 100%; }
.dlg__title{ padding: 14px 14px 0 14px; font-weight: 900; letter-spacing: .06em; flex-shrink: 0; }
.dlg__body{ padding: 14px; overflow: auto; flex: 1 1 auto; min-height: 0; }
.dlg__actions{ display: flex; justify-content: flex-end; gap: 10px; padding: 0 14px 14px 14px; flex-shrink: 0; }

.formGrid{ display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-width: 0; }
.formGrid .field{ margin: 0; min-width: 0; }
.formGrid .field--full{ grid-column: 1 / -1; }
.input--textarea{ min-height: 4em; resize: vertical; max-width: 100%; }
.hr{ height: 1px; background: rgba(27,65,100,.8); margin: 10px 0; }

.emptyState{
  color: var(--muted);
  font-size: 13px;
  padding: 20px 14px;
  text-align: center;
  border: 1px dashed var(--line2);
  border-radius: 12px;
  background: rgba(0,0,0,.08);
}

/* Testumgebung */
.testSimGrid{ display: flex; flex-direction: column; gap: 6px; }
.testSimRow{ display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.testSimRow span{ color: var(--muted); }
.testFaultGrid{ display: flex; flex-wrap: wrap; gap: 12px 16px; }
.testFaultLabel{ display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.testFaultLabel input{ margin: 0; }
.table td.fail{ color: var(--danger); font-weight: 600; }
/* Production readiness */
.table td.pass{ color: #7dffb1; font-weight: 700; }
.table td.warn{ color: #ffd27a; font-weight: 700; }

/* Dokumentation-Viewer */
.docViewer{
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0,0,0,.12);
  max-height: 70vh;
  overflow: auto;
  font-size: 14px;
  line-height: 1.55;
}
.docViewer:empty::before{ content: "Dokument auswählen."; color: var(--muted); }
.docViewer h1{ font-size: 1.35rem; margin: 0 0 0.75rem; border-bottom: 1px solid var(--line2); padding-bottom: 6px; }
.docViewer h2{ font-size: 1.15rem; margin: 1.25rem 0 0.5rem; }
.docViewer h3{ font-size: 1rem; margin: 1rem 0 0.4rem; }
.docViewer p{ margin: 0.5rem 0; }
.docViewer ul{ margin: 0.5rem 0; padding-left: 1.5rem; }
.docViewer li{ margin: 0.25rem 0; }
.docViewer table{ width: 100%; border-collapse: collapse; margin: 0.75rem 0; font-size: 13px; }
.docViewer th,.docViewer td{ border: 1px solid var(--line2); padding: 8px 10px; text-align: left; }
.docViewer th{ background: rgba(0,0,0,.2); color: var(--muted); }
.docViewer pre,.docViewer code{ background: rgba(0,0,0,.25); padding: 2px 6px; border-radius: 4px; font-family: ui-monospace, monospace; font-size: 12px; overflow-x: auto; }
.docViewer pre{ padding: 12px; display: block; white-space: pre-wrap; margin: 0.5rem 0; }
.docViewer hr{ border: none; border-top: 1px solid var(--line2); margin: 1rem 0; }
.docPdfWrap{ width: 100%; min-height: 72vh; border: 1px solid var(--line2); border-radius: 10px; overflow: hidden; background: rgba(0,0,0,.22); }
.docPdfFrame{ width: 100%; min-height: 72vh; border: 0; background: #fff; }

@media (max-width: 900px){
  .layout{ grid-template-columns: 1fr; padding: 12px; }
  .sidebar{ max-width: 100%; }
  .grid2{ grid-template-columns: 1fr; }
  .table{ min-width: 560px; }
  .formGrid{ grid-template-columns: 1fr; }
  .op__grid{ grid-template-columns: 1fr 1fr; }
  dialog{ width: calc(100vw - 16px); max-height: 85vh; }
}

@media (max-width: 600px){
  .topbar{ padding: 10px 12px; }
  .brand__title{ font-size: 15px; }
  .tabs{ padding: 6px 8px; min-height: 40px; }
  .tab{ padding: 6px 10px; font-size: 12px; }
  .layout{ padding: 10px; }
  .card{ padding: 12px; }
  .item__top > div:first-child{ flex-basis: 100%; }
  .item__actions{ margin-left: 0; margin-top: 8px; }
  .table{ min-width: 480px; }
  .table th,.table td{ padding: 8px 6px; font-size: 13px; }
  .op__grid{ grid-template-columns: 1fr; }
  :root{ --sidebar-w: 100%; }
}

@media print {
  .topbar__actions,
  .sidebar,
  .tabs,
  .toolbar .btn,
  .item__actions,
  .filebtn,
  .hint { display: none !important; }
  .layout { grid-template-columns: 1fr; padding: 0; }
  .content { max-width: 100%; }
  .panel { display: block !important; break-inside: avoid; }
  .panel + .panel { margin-top: 1.5rem; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #333; }
  body { background: #fff; color: #111; }
  .topbar { background: #f5f5f5; border-color: #ccc; }
  .brand__title { color: #111; }
  .brand__subtitle { color: #444; }
}
