:root {
  --bg: #f4f5f7; --surface: #ffffff; --ink: #1c2430; --ink2: #4a5563; --muted: #64707d;
  --line: #dde1e6; --line2: #b9c0c8; --side: #ffffff; --side-ink: #1c2430; --accent: #0f766e; --accent-ink: #fff; --accent-soft: #e0f2ef; --accent-dark: #0b5f59;
  --good: #0ca30c; --warn: #fab219; --serious: #ec835a; --crit: #b42318;
  --open: #7d8fa3; --run: #0f766e; --done: #9fb8a0;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
h1, h2, h3, h4 { margin: 0; text-wrap: balance; }
button, input, select, textarea { font: inherit; color: inherit; }
.mono, pre, code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* Layout */
.layout { display: grid; grid-template-columns: 268px 1fr; height: 100vh; }
.side { background: var(--side); color: var(--side-ink); overflow-y: auto; border-right: 1px solid var(--line); padding: 14px 10px 24px; }
.brand { color: var(--accent); font-weight: 800; font-size: 17px; padding: 4px 10px 14px; letter-spacing: .02em; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.navgroup { margin-top: 14px; }
.navgroup > div { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 4px 10px; }
.side a, .side span.lbl { display: block; white-space: nowrap; padding: 7px 10px; border-radius: 6px; color: inherit; text-decoration: none; }
.side span.lbl { color: var(--muted); }
.side a:hover { background: #eef2f6; }
.side a.on { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.side .i1 { padding-left: 24px; } .side .i2 { padding-left: 38px; }
.side .i1::before, .side .i2::before { content: "└ "; opacity: .5; }
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 22px; background: var(--surface); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 19px; flex: 1; }
.top .who { color: var(--ink2); text-align: right; line-height: 1.2; }
.top .who small { color: var(--muted); display: block; }
#page { padding: 20px 22px 40px; overflow: auto; flex: 1; }
.intro { color: var(--ink2); max-width: 75ch; margin: 0 0 14px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .sp { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.tiles { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; min-width: 150px; }
.tile b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.tile span { color: var(--ink2); font-size: 12px; }

/* Controls */
.btn { border: 1px solid var(--line2); background: var(--surface); border-radius: 6px; padding: 7px 13px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink2); } .btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--crit); }
.btn.sm { padding: 3px 9px; font-size: 13px; }
.btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.icon { border: 0; background: none; cursor: pointer; color: var(--ink2); padding: 2px 6px; border-radius: 4px; }
.icon:hover { background: var(--line); }
input, select, textarea { border: 1px solid var(--line2); border-radius: 6px; padding: 6px 9px; background: #fff; max-width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.seg { display: inline-flex; } .seg .btn { border-radius: 0; margin-left: -1px; }
.seg .btn:first-child { border-radius: 6px 0 0 6px; margin: 0; } .seg .btn:last-child { border-radius: 0 6px 6px 0; }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tbl th { text-align: left; font-size: 12px; color: var(--ink2); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line2); background: #fafbfc; white-space: nowrap; }
.tbl td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th.num { text-align: right; }
.tbl td.act { white-space: nowrap; text-align: right; }
.tbl tr.sum td { background: #fafbfc; font-weight: 600; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.chip { display: inline-block; background: #e8ecf0; border-radius: 99px; padding: 1px 9px; font-size: 12px; margin: 1px 2px 1px 0; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 99px; padding: 1px 9px; font-size: 12px; font-weight: 600; border: 1px solid var(--line2); white-space: nowrap; }
.badge.good { border-color: var(--good); color: #006300; } .badge.crit { border-color: var(--crit); color: #b42318; }
.badge.warn { border-color: #c98a00; color: #7a5300; } .badge.run { border-color: var(--run); color: var(--run); }
.meter { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; min-width: 70px; margin-top: 4px; }
.meter i { display: block; height: 100%; background: var(--run); }

/* Forms / modal */
#modal-root:empty { display: none; }
.overlay { position: fixed; inset: 0; background: rgba(20, 24, 26, .45); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow: auto; z-index: 50; }
.modal { background: var(--surface); border-radius: 10px; width: 560px; max-width: 100%; box-shadow: 0 12px 40px rgba(0, 0, 0, .25); }
.modal.wide { width: 1080px; }
.modal header { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal header h3 { flex: 1; font-size: 16px; }
.modal .mbody { padding: 16px 18px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.modal-err { color: #b42318; margin-right: auto; align-self: center; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.fld { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fld > span { font-size: 12px; color: var(--ink2); font-weight: 600; }
.fld small, .hint { color: var(--muted); font-size: 12px; margin: 0; }
.full { grid-column: 1 / -1; }
.fsec { grid-column: 1 / -1; font-size: 13px; border-bottom: 1px solid var(--line); padding: 8px 0 4px; }
.chk { display: flex; gap: 7px; align-items: center; }
.rowsf { overflow-x: auto; }
.rowsf table { border-collapse: collapse; margin-bottom: 6px; }
.rowsf th { font-size: 11px; color: var(--ink2); text-align: left; padding: 2px 4px; white-space: nowrap; }
.rowsf td { padding: 2px 3px; } .rowsf input, .rowsf select { padding: 4px 6px; width: 100%; }
.rowsf > span { font-size: 12px; color: var(--ink2); font-weight: 600; display: block; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.checks h5 { grid-column: 1 / -1; margin: 8px 0 0; font-size: 12px; color: var(--ink2); }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 6px; }
#toast div { background: #1c2430; color: #fff; padding: 9px 16px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); }
#toast div.err { background: #b42318; }
#tip { position: fixed; z-index: 60; pointer-events: none; background: #1c2430; color: #fff; padding: 8px 11px; border-radius: 7px; font-size: 12.5px; max-width: 320px; display: none; line-height: 1.5; }
#tip b { font-size: 13px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 340px; }
.login h1 { font-size: 22px; margin-bottom: 2px; color: var(--accent); font-weight: 800; }
.login p { color: var(--ink2); margin: 0 0 14px; }
.login input { width: 100%; font-size: 20px; padding: 9px 12px; margin-bottom: 10px; letter-spacing: .08em; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 12px; }
.keypad button { font-size: 22px; padding: 13px 0; border-radius: 8px; border: 1px solid var(--line2); background: #fff; cursor: pointer; }
.keypad button:active { background: var(--line); }
.login .btn.primary { width: 100%; font-size: 17px; padding: 12px; }
.termnote { background: #e0f2ef; border-radius: 6px; padding: 8px 10px; margin-bottom: 12px; font-size: 13px; }
.errline { color: #b42318; min-height: 20px; margin-bottom: 6px; }

/* Terminal */
.tbar { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.status { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.status .state { font-size: 20px; font-weight: 700; }
.status .state small { display: block; font-weight: 400; font-size: 13px; color: var(--ink2); }
.big { font-size: 17px; padding: 14px 22px; border-radius: 9px; }
.opcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 12px; margin-bottom: 20px; }
.opcard { background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--open); border-radius: var(--radius); padding: 13px 15px; }
.opcard.gestartet { border-left-color: var(--run); } .opcard.wait { opacity: .7; }
.opcard h3 { font-size: 16px; } .opcard .sub { color: var(--ink2); margin-bottom: 8px; }
.opcard dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0 0 10px; }
.opcard dt { color: var(--muted); } .opcard dd { margin: 0; }
.opcard .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.opcard .acts .btn { flex: 1; font-size: 15px; padding: 12px 10px; }
.ohgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 20px; }
.ohgrid button { text-align: left; padding: 16px; border-radius: 9px; border: 1px solid var(--line2); background: var(--surface); cursor: pointer; font-size: 16px; font-weight: 600; }
.ohgrid button small { display: block; font-weight: 400; color: var(--muted); }
.ohgrid button:hover { border-color: var(--accent); }
.running { background: var(--accent-soft); border: 1px solid var(--run); border-radius: var(--radius); padding: 12px 16px; display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
h2.sec { font-size: 15px; margin: 18px 0 8px; }

/* Gantt */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink2); margin-bottom: 8px; align-items: center; }
.legend i { display: inline-block; width: 22px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; }
.gantt { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 290px); position: relative; }
.g-inner { position: relative; }
.g-head { display: flex; position: sticky; top: 0; z-index: 4; background: #fafbfc; border-bottom: 1px solid var(--line2); }
.g-corner { position: sticky; left: 0; z-index: 5; background: #fafbfc; flex: none; border-right: 1px solid var(--line2); }
.g-day { flex: none; font-size: 12px; color: var(--ink2); padding: 5px 6px; border-left: 1px solid var(--line); white-space: nowrap; overflow: hidden; }
.g-day.we { color: var(--muted); }
.g-row { display: flex; border-bottom: 1px solid var(--line); height: 38px; }
.g-label { position: sticky; left: 0; z-index: 3; flex: none; background: var(--surface); border-right: 1px solid var(--line2); padding: 3px 10px; line-height: 1.25; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.g-label small { display: block; color: var(--muted); font-size: 11px; }
.g-track { position: relative; flex: none; }
.g-we { position: absolute; top: 0; bottom: 0; background: rgba(120, 120, 100, .08); pointer-events: none; }
.g-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--crit); z-index: 2; pointer-events: none; }
.bar { position: absolute; top: 6px; height: 26px; border-radius: 4px; color: #fff; font-size: 11.5px; line-height: 26px; padding: 0 5px; overflow: hidden; white-space: nowrap; cursor: pointer; box-shadow: 0 0 0 1px var(--surface); background: var(--open); }
.bar.gestartet { background: var(--run); } .bar.fertig { background: var(--done); color: #1c2430; }
.bar.late { box-shadow: 0 0 0 1px var(--surface), inset 0 0 0 2px var(--crit); }
.bar:hover { filter: brightness(1.12); }
.due { position: absolute; top: 9px; width: 0; height: 0; border: 7px solid transparent; border-bottom-color: var(--ink); border-top: 0; margin-left: -7px; z-index: 1; }
.due.late { border-bottom-color: var(--crit); }
.result { background: #eef6ee; border: 1px solid #9fc79f; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; }
.slider { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink2); }
.slider input { width: 90px; padding: 0; }

/* Kalender (Urlaub / Schicht / Qualimatrix) */
.cal { border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); }
.cal th, .cal td { border: 1px solid var(--line); text-align: center; padding: 0; height: 30px; min-width: 27px; font-size: 12px; }
.cal th { background: #fafbfc; color: var(--ink2); font-weight: 600; padding: 3px 2px; }
.cal .name { text-align: left; padding: 3px 10px; white-space: nowrap; position: sticky; left: 0; background: var(--surface); min-width: 170px; font-size: 13px; }
.cal .name small { color: var(--muted); }
.cal .we { background: #eef2f6; } .cal td.today, .cal th.today { background-color: #e0f2ef; }
.cal .grp td { background: #fafbfc; text-align: left; padding: 3px 10px; font-weight: 600; color: var(--ink2); }
.ab { display: block; height: 100%; line-height: 30px; font-weight: 700; color: #fff; }
.ab.ok { background: var(--good); } .ab.req { background: repeating-linear-gradient(45deg, #fab219, #fab219 5px, #fcd27a 5px, #fcd27a 10px); color: #0b0b0b; }
.ab.oth { background: #6b6fb8; } .ab.no { background: none; color: var(--crit); text-decoration: line-through; }
.calwrap { overflow: auto; margin-bottom: 18px; }
.sh { cursor: default; min-width: 108px !important; padding: 4px 6px !important; height: 44px !important; line-height: 1.25; }
.sh.edit { cursor: pointer; } .sh.edit:hover { background: #e0f2ef; }
.sh b { display: inline-block; border-radius: 4px; padding: 0 7px; color: #fff; background: var(--open); }
.sh b.F { background: #2563eb; } .sh b.S { background: #b5651f; } .sh b.N { background: #3c3f6b; } .sh b.T { background: #2f8a6b; } .sh b.X { background: #a7a89f; }
.sh small { display: block; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.sh.absent { background: repeating-linear-gradient(45deg, #f6f7f9, #f6f7f9 6px, #dde1e6 6px, #dde1e6 12px); }
.cal tr.me .name { font-weight: 700; }
.q { cursor: default; font-weight: 700; } .q.edit { cursor: pointer; }
.q1 { background: #e0f2ef; } .q2 { background: #a7d9d2; } .q3 { background: #3f9d94; color: #fff; } .q4 { background: #0f766e; color: #fff; }
.cal th.vert { height: 130px; vertical-align: bottom; padding-bottom: 6px; }
.cal th.vert span { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }

.rule { margin-bottom: 10px; } .rule h3 { font-size: 14px; display: flex; gap: 8px; align-items: center; }
.rule pre { background: #f6f7f9; border-radius: 6px; padding: 9px 11px; margin: 8px 0; white-space: pre-wrap; }
.rule.off { opacity: .55; }
.lg td, .lg th { padding: 4px 8px 4px 0; vertical-align: top; text-align: left; font-size: 13px; } .lg code { background: #f6f7f9; padding: 1px 5px; border-radius: 4px; }
.lg td:first-child { width: 44%; }
.lg { border-collapse: collapse; margin-bottom: 10px; width: 100%; table-layout: fixed; }
.card h3 { font-size: 15px; margin-bottom: 8px; } .card h4 { font-size: 13px; margin: 12px 0 4px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; height: auto; } .side { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
  .navgroup { margin: 0; } .main { height: auto; } .grid2 { grid-template-columns: 1fr; } .form { grid-template-columns: 1fr; }
}
