/* GIM-DE Server – Oberfläche. Alle Farben/Abstände als Variablen, damit die
   Beta.4-Vorlage zentral übernommen werden kann. */
:root {
  --brand: #063a78;
  --brand-dark: #042a57;
  --brand-light: #e6eef8;
  --accent: #1f6fc5;
  --bg: #eef0f3;
  --sheet: #ffffff;
  --grid: #d6dbe2;
  --grid-strong: #b9c1cc;
  --head: #f2f4f7;
  --row-alt: #fafbfc;
  --row-hover: #eef4fb;
  --row-sel: #d9e7f7;
  --text: #1d2733;
  --muted: #5d6b7a;
  --ok: #1e7a46;
  --warn: #b26a00;
  --bad: #b3261e;
  --radius: 4px;
  --font: "Segoe UI", "Calibri", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Consolas", "Cascadia Mono", ui-monospace, monospace;
  font-size: 13px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; color: var(--muted); }
.hidden { display: none !important; }
.ico { width: 16px; height: 16px; flex: none; }
.tile .t-head .ico { width: 20px; height: 20px; }

/* ---------- Rahmen ---------- */
.shell { display: grid; grid-template-rows: auto auto 1fr auto; height: 100vh; }
.titlebar { background: var(--brand); color: #fff; display: flex; align-items: center; gap: 16px; padding: 0 14px; height: 44px; }
.titlebar .logo { font-weight: 700; font-size: 17px; letter-spacing: .3px; display: flex; align-items: center; gap: 9px; }
.titlebar .logo .mark { width: 24px; height: 24px; border-radius: 4px; background: #fff; color: var(--brand); display: grid; place-items: center; font-size: 12px; font-weight: 800; }
.titlebar .site { color: #b9d3f0; font-size: 12px; }
.titlebar .spacer { flex: 1; }
.titlebar .who { font-size: 12px; text-align: right; line-height: 1.25; }
.titlebar .who small { display: block; color: #b9d3f0; }
.titlebar button { background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff; border-radius: var(--radius); padding: 4px 10px; cursor: pointer; }
.titlebar button:hover { background: rgba(255,255,255,.12); }

.ribbon { background: var(--sheet); border-bottom: 1px solid var(--grid-strong); display: flex; align-items: stretch; padding: 0 8px; overflow-x: auto; }
.ribbon a { display: flex; align-items: center; gap: 7px; padding: 9px 14px 8px; color: var(--text); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 500; }
.ribbon a:hover { background: var(--row-hover); }
.ribbon a.active { border-bottom-color: var(--brand); color: var(--brand); font-weight: 600; }
.ribbon a .count { background: var(--brand-light); color: var(--brand); border-radius: 9px; padding: 0 7px; font-size: 11px; font-weight: 600; }
.ribbon a.active .count { background: var(--brand); color: #fff; }
.ribbon .ico { width: 16px; height: 16px; flex: none; }

.main { overflow: auto; padding: 14px; min-height: 0; }
.statusbar { background: #e3e7ec; border-top: 1px solid var(--grid-strong); display: flex; gap: 0; font-size: 12px; color: var(--muted); height: 24px; align-items: stretch; }
.statusbar > span { padding: 0 12px; display: flex; align-items: center; border-right: 1px solid var(--grid); white-space: nowrap; }
.statusbar .grow { flex: 1; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; background: var(--grid-strong); }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.busy { background: var(--warn); }

/* ---------- Arbeitsblatt ---------- */
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 10px; }
.page-head h1 { font-size: 19px; margin: 0; font-weight: 600; color: var(--brand-dark); }
.page-head .sub { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.page-head .spacer { flex: 1; }

.sheet { background: var(--sheet); border: 1px solid var(--grid-strong); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(16,24,40,.05); }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px; border-bottom: 1px solid var(--grid); background: var(--head); border-radius: var(--radius) var(--radius) 0 0; }
.toolbar .spacer { flex: 1; }
.toolbar .info { color: var(--muted); font-size: 12px; }

.btn { border: 1px solid var(--grid-strong); background: #fff; border-radius: var(--radius); padding: 5px 11px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; line-height: 18px; }
.btn:hover { background: var(--row-hover); border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--bad); border-color: #e2b4b0; }
.btn.small { padding: 2px 8px; font-size: 12px; }
.btn .ico { width: 15px; height: 15px; }

input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  border: 1px solid var(--grid-strong); border-radius: var(--radius); padding: 5px 8px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .ribbon a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; min-height: 70px; width: 100%; }
label.field { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
label.field > input, label.field > select, label.field > textarea { color: var(--text); font-size: 13px; }

/* Tabelle wie ein Excel-Blatt */
.gridwrap { overflow: auto; max-height: calc(100vh - 230px); }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; }
table.grid th, table.grid td { border-right: 1px solid var(--grid); border-bottom: 1px solid var(--grid); padding: 5px 8px; text-align: left; vertical-align: top; }
table.grid th { position: sticky; top: 0; background: var(--head); font-weight: 600; color: #334; z-index: 1; white-space: nowrap; }
table.grid tr.filters th { top: 29px; background: #f8f9fb; padding: 3px 4px; font-weight: 400; }
table.grid tr.filters input { width: 100%; padding: 2px 5px; font-size: 12px; }
table.grid td.rn, table.grid th.rn { width: 38px; text-align: right; color: #8692a0; background: var(--head); font-size: 11px; }
table.grid tbody tr:nth-child(even) td:not(.rn) { background: var(--row-alt); }
table.grid tbody tr { cursor: pointer; }
table.grid tbody tr:hover td:not(.rn) { background: var(--row-hover); }
table.grid tbody tr.sel td:not(.rn) { background: var(--row-sel); }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.mono { font-family: var(--mono); font-size: 12px; }
table.grid td.wrap { white-space: normal; min-width: 200px; }
table.grid td { overflow-wrap: break-word; }
table.grid td.nowrap { white-space: nowrap; }
table.grid th.sortable { cursor: pointer; }
table.grid th .arrow { color: var(--accent); margin-left: 4px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.badge { display: inline-block; border-radius: 3px; padding: 1px 7px; font-size: 11.5px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.st-8  { background: #fff1e0; color: #8a4b00; border-color: #f3d2a6; }
.st-9  { background: #e5effc; color: #0d4a8f; border-color: #b9d1f0; }
.st-10 { background: #f0e9fb; color: #5b2e98; border-color: #d6c4f1; }
.st-11 { background: #fde7e6; color: #9b1c14; border-color: #f2bdb9; }
.st-12 { background: #e5f4ea; color: #1b6b3c; border-color: #b8e0c6; }
.st-13 { background: #e1f3f4; color: #0f6168; border-color: #b4dfe2; }
.st-none { background: #eef0f3; color: #5d6b7a; border-color: #d6dbe2; }

/* Liste + Detail nebeneinander */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 12px; align-items: start; }
.split.closed { grid-template-columns: minmax(0, 1fr); }
.detail { position: sticky; top: 0; max-height: calc(100vh - 130px); overflow: auto; }
.detail .dhead { padding: 10px 12px; border-bottom: 1px solid var(--grid); background: var(--head); display: flex; align-items: center; gap: 8px; }
.detail .dhead h2 { font-size: 14px; margin: 0; flex: 1; }
.detail .dbody { padding: 12px; display: grid; gap: 12px; }
dl.kv { display: grid; grid-template-columns: 140px 1fr; margin: 0; border-top: 1px solid var(--grid); }
dl.kv dt, dl.kv dd { margin: 0; padding: 5px 6px; border-bottom: 1px solid var(--grid); }
dl.kv dt { color: var(--muted); background: var(--head); font-size: 12px; }
dl.kv dd { white-space: pre-wrap; word-break: break-word; }
.section-title { font-size: 12px; font-weight: 700; color: var(--brand-dark); text-transform: uppercase; letter-spacing: .4px; margin: 4px 0 -4px; }
.actions { display: grid; gap: 8px; border: 1px solid var(--grid); border-radius: var(--radius); padding: 10px; background: #fbfcfd; }
.actions .row { display: flex; gap: 8px; flex-wrap: wrap; }

table.grid.mini { font-size: 12px; }
table.grid.mini th { position: static; }
table.grid.mini tbody tr { cursor: default; }
.radios.col { flex-direction: column; gap: 6px; }
.pad > .sheet, .pad > .cols2 + .sheet { margin-top: 12px; }
.pad > .msg + .cols2 { margin-top: 10px; }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Startseite */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tile { background: var(--sheet); border: 1px solid var(--grid-strong); border-radius: var(--radius); padding: 14px; display: grid; gap: 6px; text-decoration: none; color: inherit; border-top: 4px solid var(--brand); }
.tile:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(6,58,120,.12); }
.tile .t-head { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--brand-dark); }
.tile .t-num { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tile .t-sub { color: var(--muted); font-size: 12px; }
.tile.prod { border-top-color: #1f6fc5; } .tile.qual { border-top-color: #7a4cc2; } .tile.wo { border-top-color: #b26a00; } .tile.stock { border-top-color: #1e7a46; } .tile.admin { border-top-color: #5d6b7a; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.panel { padding: 12px 14px; display: grid; gap: 8px; align-content: start; }
.panel h3 { margin: 0; font-size: 13px; color: var(--brand-dark); }

/* Dialog */
.overlay { position: fixed; inset: 0; background: rgba(15,25,40,.45); display: grid; place-items: center; z-index: 20; padding: 16px; }
.dialog { background: #fff; border-radius: 6px; width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.dialog .dh { background: var(--brand); color: #fff; padding: 10px 14px; font-weight: 600; display: flex; align-items: center; border-radius: 6px 6px 0 0; }
.dialog .dh .spacer { flex: 1; }
.dialog .dh button { background: transparent; border: 0; color: #fff; font-size: 18px; cursor: pointer; line-height: 1; }
.dialog .db { padding: 14px; display: grid; gap: 12px; }
.dialog .df { padding: 10px 14px; border-top: 1px solid var(--grid); display: flex; justify-content: flex-end; gap: 8px; background: var(--head); border-radius: 0 0 6px 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.picklist { border: 1px solid var(--grid-strong); border-radius: var(--radius); max-height: 190px; overflow: auto; }
.picklist div { padding: 5px 8px; border-bottom: 1px solid var(--grid); cursor: pointer; }
.picklist div:hover, .picklist div.on { background: var(--row-sel); }
.picklist small { color: var(--muted); display: block; }
.radios { display: flex; gap: 14px; flex-wrap: wrap; }
.radios label { display: flex; align-items: center; gap: 5px; color: var(--text); font-size: 13px; }

.msg { padding: 8px 10px; border-radius: var(--radius); border: 1px solid; font-size: 12.5px; }
.msg.err { background: #fdeceb; border-color: #f0b9b5; color: #8c1d16; }
.msg.ok { background: #e7f5ec; border-color: #b6dfc4; color: #155c32; }
.msg.info { background: #eaf2fb; border-color: #bfd5ef; color: #0d3f75; }
.toast { position: fixed; right: 16px; bottom: 36px; z-index: 30; max-width: 420px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }

/* Anmeldung */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(180deg, var(--brand) 0 38%, var(--bg) 38%); padding: 16px; }
.login .card { width: min(380px, 100%); background: #fff; border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.18); overflow: hidden; }
.login .card .top { padding: 18px 20px; border-bottom: 1px solid var(--grid); }
.login .card .top b { font-size: 20px; color: var(--brand); }
.login .card .top div { color: var(--muted); font-size: 12px; margin-top: 2px; }
.login form { padding: 18px 20px; display: grid; gap: 12px; }

.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--grid); padding: 0 8px; background: var(--head); }
.subtabs button { border: 0; background: transparent; padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; }
.subtabs button.on { border-bottom-color: var(--brand); color: var(--brand); font-weight: 600; }
.pad { padding: 12px; }
.hint { color: var(--muted); font-size: 12px; }
code.json { display: block; white-space: pre; font-family: var(--mono); font-size: 12px; }

/* ---------- Tablet und Smartphone ---------- */
@media (max-width: 1280px) {
  .ribbon a .lbl { display: none; }
  .ribbon a.active .lbl { display: inline; }
  .ribbon a { padding: 9px 11px 8px; }
}
@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .detail { position: fixed; inset: 44px 0 24px auto; width: min(480px, 100vw); max-height: none; z-index: 15; border-radius: 0; box-shadow: -8px 0 24px rgba(0,0,0,.18); }
  .cols2 { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  :root { font-size: 14px; }
  .titlebar .site, .titlebar .who small { display: none; }
  .ribbon a { padding: 10px 10px 9px; }
  .ribbon a .lbl { display: none; }
  .ribbon a.active .lbl { display: inline; }
  .main { padding: 8px; }
  .grid2 { grid-template-columns: 1fr; }
  .page-head { flex-wrap: wrap; align-items: center; }
  .page-head > div:first-child { flex-basis: 100%; }
  .page-head .spacer { display: none; }
  table.grid .hide-sm { display: none; }
  table.grid td.wrap { min-width: 170px; }
  .gridwrap { max-height: none; }
  .statusbar .hide-sm { display: none; }
  dl.kv { grid-template-columns: 110px 1fr; }
}
/* 0.1.1-r2: vorbeugende Instandhaltung */
.due-overdue { background: #fde7e6; color: #9b1c14; border-color: #f2bdb9; }
.due-due { background: #fff1e0; color: #8a4b00; border-color: #f3d2a6; }
.due-open { background: #e5f4ea; color: #1b6b3c; border-color: #b8e0c6; }
.tile.prev { border-top-color: #0f6168; }
.tile .t-split { display: flex; gap: 10px; font-size: 12px; }
.checklist { display: grid; gap: 6px; }
.checklist .cp { border: 1px solid var(--grid); border-radius: 3px; padding: 6px 8px; display: grid; gap: 4px; }
.checklist .cp .cp-head { display: flex; gap: 8px; align-items: baseline; }
.checklist .cp .cp-head b { flex: 1; font-weight: 600; }
.checklist .cp .cp-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.checklist .cp .cp-row input[type=text] { flex: 1 1 160px; min-width: 0; }
.checklist .cp.bad { border-color: #f2bdb9; background: #fff8f7; }
.actions input[type=search] { width: 100%; }
/* 0.1.2: Instanz, Konto */
.titlebar .instance { background: #f59e0b; color: #1f2937; font-weight: 700; font-size: 11.5px; padding: 2px 8px; border-radius: 3px; letter-spacing: .04em; }
.titlebar .instance.sim { background: #fde68a; }
.titlebar button.who { background: transparent; border: 0; color: inherit; text-align: right; cursor: pointer; font: inherit; display: grid; }
.secret { font-size: 18px; letter-spacing: .08em; padding: 6px 0; }
.mono.small { font-size: 11px; word-break: break-all; }

/* 0.1.3 – geführte Wartung (nur Preventive-Bearbeitung) */
.btn.big { padding: 10px 18px; font-size: 15px; }
.pm-list { margin: 0; padding-left: 22px; display: grid; gap: 4px; }
.pm-list li { display: flex; gap: 8px; align-items: center; }
.pm-list .pm-t { flex: 1; }
.badge.pm-open { background: #eef1f5; color: #445; border: 1px dashed #99a; }
.badge.pm-ok { background: #e5f4e4; color: #1d5e1d; }
.badge.pm-bad { background: #fbe3e3; color: #8a1414; }
.badge.pm-na, .badge.pm-np { background: #eceff3; color: #334; }
.dialog.pm { width: min(760px, 100%); display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.dialog.pm .pm-body { padding: 14px; overflow: auto; display: grid; gap: 12px; }
.dialog.pm .df .spacer { flex: 1; }
.pm-progress { display: flex; gap: 10px; align-items: center; color: #556; font-size: 13px; }
.pm-title { margin: 0; font-size: 18px; }
.pm-instr { white-space: pre-wrap; line-height: 1.45; background: var(--head); border-left: 3px solid var(--brand); padding: 8px 10px; }
.pm-detail .pm-instr { display: block; margin-top: 4px; }
.pm-meta { font-size: 13px; color: #334; }
.pm-results { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.pm-results .pm-res { min-height: 72px; font-size: 22px; }
.pm-results.small .pm-res { min-height: 40px; font-size: 14px; font-weight: 500; }
.pm-special { margin: 8px 0; } .pm-special summary { cursor: pointer; color: var(--muted, #555); font-size: 13px; }
.pm-res { min-height: 56px; font-size: 17px; font-weight: 600; border: 2px solid var(--grid); border-radius: 6px; background: #fff; cursor: pointer; }
.pm-res.on.ok { background: #2e7d32; border-color: #2e7d32; color: #fff; }
.pm-res.on.bad { background: #c62828; border-color: #c62828; color: #fff; }
.pm-res.on.na, .pm-res.on.np { background: #546e7a; border-color: #546e7a; color: #fff; }
.pm-jump { display: flex; flex-wrap: wrap; gap: 4px; }
.pm-dot { min-width: 30px; height: 30px; border-radius: 15px; border: 1px solid var(--grid); background: #fff; cursor: pointer; font-size: 12px; }
.pm-dot.r2 { background: #e5f4e4; } .pm-dot.r1 { background: #fbe3e3; } .pm-dot.r0, .pm-dot.r3 { background: #eceff3; }
.pm-dot.open { border-style: dashed; }
.pm-dot.cur { outline: 2px solid var(--brand); }
label.check { display: flex; gap: 8px; align-items: flex-start; }
@media (max-width: 640px) {
  .overlay .dialog.pm { width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .pm-results { grid-template-columns: repeat(2, 1fr); }
}

/* 0.1.4: Logbuch, Schichtbuch, KPI – gleiche Farben und Dichte wie die übrigen Module */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--row-hover); }
.rec { border-left: 3px solid var(--accent); padding: 4px 8px; margin: 6px 0; }
.src { margin: 8px 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin: 6px 0 10px; }
.kpi { text-align: left; border: 1px solid var(--grid-strong); border-left: 4px solid var(--grid-strong); border-radius: var(--radius); background: var(--sheet); padding: 8px 10px; cursor: pointer; font: inherit; color: inherit; }
.kpi:hover { background: var(--row-hover); }
.kpi.good { border-left-color: var(--ok); } .kpi.bad { border-left-color: var(--bad); }
.kpi .k-t { font-size: 12px; color: var(--muted); } .kpi .k-v { font-size: 22px; font-weight: 700; color: var(--brand); } .kpi .k-s { font-size: 11px; color: var(--muted); }
.chart { width: 100%; max-width: 640px; height: auto; } .chart text { font-size: 9px; fill: var(--muted); }
.chart .b0, .legend .b0 { fill: var(--brand); background: var(--brand); } .chart .b1, .legend .b1 { fill: #7fa7d6; background: #7fa7d6; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); } .legend i { display: inline-block; width: 10px; height: 10px; margin-right: 4px; }
.basis { font-size: 12px; color: var(--muted); margin: 6px 0 0 16px; padding: 0; }
.print-head { display: none; }
textarea.mono { font-family: Consolas, monospace; width: 100%; }
@media print {
  .ribbon, .statusbar, .toolbar, .noprint, .page-head button, .btn { display: none !important; }
  .print-head { display: block; } .sheet { box-shadow: none; break-inside: avoid; } body { background: #fff; }
}
.guided .stepno { display: inline-block; width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: #fff; text-align: center; font-size: 12px; line-height: 20px; margin-right: 6px; }
.guided textarea { width: 100%; }
.single-actions { margin-top: 10px; } .single-actions > summary { cursor: pointer; color: var(--brand); font-weight: 600; padding: 6px 0; }
.steps-status div { padding: 2px 0; }
@media (max-width: 640px) {
  .dialog { width: 100vw; max-width: 100vw; }
  table.grid.mini { display: block; overflow-x: auto; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
