/* CoreForge Web — Gestaltungssystem (ohne Build-Schritt). */
:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --border: #e1e4ec;
  --border-strong: #c8cedb;
  --text: #17191f;
  --text-2: #4b5263;
  --text-3: #7a8194;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --ok: #15803d; --ok-soft: #e8f7ee;
  --warn: #b45309; --warn-soft: #fff4e5;
  --bad: #b91c1c; --bad-soft: #fdecec;
  --info: #1d4ed8; --info-soft: #e8f0fe;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 12px rgba(16,24,40,.06);
  --shadow-lg: 0 16px 40px rgba(16,24,40,.18);
  --radius: 12px;
  --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sidebar-w: 236px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0f1116;
  --surface: #171a21;
  --surface-2: #1e222b;
  --border: #2a2f3a;
  --border-strong: #3a4150;
  --text: #e7e9ee;
  --text-2: #b4bac7;
  --text-3: #7e879a;
  --accent: #7c74ff;
  --accent-hover: #948dff;
  --accent-soft: #23234a;
  --ok: #4ade80; --ok-soft: #12321f;
  --warn: #fbbf24; --warn-soft: #3a2a0d;
  --bad: #f87171; --bad-soft: #3d1717;
  --info: #60a5fa; --info-soft: #14243f;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.6);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
button { font: inherit; }
button, a, input, select, textarea, [tabindex] { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--accent-soft);
  outline-offset: 2px;
  box-shadow: 0 0 0 1px var(--accent);
}
[hidden] { display: none !important; }
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Layout */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 20; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 10px 24px; border-bottom: 1px solid var(--border); background: var(--surface); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 5; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.content { padding: 24px; max-width: 1400px; width: 100%; }
#menu-toggle { display: none; }
.sidebar-scrim { display: none; appearance: none; padding: 0; }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; width: min(300px, 86vw); transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar-scrim.visible { display: block; position: fixed; inset: 0; z-index: 19; border: 0; background: rgba(15, 17, 22, .36); cursor: pointer; }
  #menu-toggle { display: inline-flex; }
  .topbar { padding: 9px 14px; }
  .content { padding: 16px 14px 32px; }
  body.sidebar-open { overflow: hidden; }
}

/* Brand & nav */
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 8px; }
.brand-lg { padding: 0 0 12px; }
.brand-mark { display: inline-flex; width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; align-items: center; justify-content: center; flex: none; box-shadow: 0 5px 12px rgba(79,70,229,.22); }
.brand-name { font-weight: 700; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--text-3); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { padding: 6px 10px; flex: 1; }
.nav-group { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); padding: 14px 8px 6px; font-weight: 600; }
.nav a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a .badge { margin-left: auto; }
.nav svg { width: 16px; height: 16px; flex: none; opacity: .85; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 12px 14px; display: grid; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.status-row { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); } .dot.info { background: var(--info); }
.foot-actions { display: flex; gap: 6px; margin-top: 4px; }
.crumbs { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; min-width: 0; }
.crumbs .sep { color: var(--text-3); font-weight: 400; }
.crumbs .muted { font-weight: 400; }

/* Buttons & badges */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 500; line-height: 1.2; white-space: nowrap; transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { color: var(--bad); border-color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-ok { color: var(--ok); border-color: var(--ok); }
.btn-ok:hover { background: var(--ok-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 34px; padding: 4px 9px; font-size: 12.5px; }
.btn-icon { min-width: 40px; padding: 4px 8px; font-size: 16px; }
.btn-block { width: 100%; }
.badge { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); line-height: 1.5; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip { display: inline-flex; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; font-family: var(--mono); }

/* Cards & grids */
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 700px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-body { padding: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.card-head .spacer { margin-left: auto; }
.card-head .badge { font-weight: 600; }
.metric { padding: 16px; }
.metric .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.metric .label { color: var(--text-2); margin-top: 4px; font-weight: 500; }
.metric .hint { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.metric.clickable { cursor: pointer; text-align: left; color: var(--text); }
.metric.clickable:hover { border-color: var(--accent); box-shadow: 0 6px 18px rgba(79,70,229,.12); transform: translateY(-1px); }
.card-button { display: block; width: 100%; appearance: none; font: inherit; color: inherit; text-align: left; }
.section-title { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); font-weight: 700; margin: 22px 0 10px; }
.section-title:first-child { margin-top: 0; }
.page-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.banner { display: flex; gap: 12px; align-items: center; padding: 13px 16px; border-radius: var(--radius); border: 1px solid; margin-bottom: 16px; }
.banner.bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.banner.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.banner.info { background: var(--info-soft); border-color: var(--info); color: var(--info); }
.banner .actions { margin-left: auto; display: flex; gap: 8px; }
.empty { padding: 28px 16px; text-align: center; color: var(--text-3); }
.empty strong { display: block; color: var(--text-2); margin-bottom: 4px; }
.split { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }

/* Tables & lists */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table tr.clickable:focus-visible td { background: var(--accent-soft); }
.table td.actions { text-align: right; white-space: nowrap; }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; align-items: flex-start; padding: 11px 16px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: var(--surface-2); }
.list-button { border: 0; border-bottom: 1px solid var(--border); background: transparent; }
.list-button:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; }
.list-item .meta { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.time { color: var(--text-3); font-size: 12.5px; white-space: nowrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; min-height: 40px; padding: 8px 12px; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; white-space: nowrap; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { min-height: 38px; padding: 6px 9px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
pre.log { background: #0b0d12; color: #d6dbe6; padding: 12px 14px; border-radius: 8px; max-height: 420px; overflow: auto; margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 12.5px; line-height: 1.5; }
pre.log.small { max-height: 220px; }
pre.json { background: var(--surface-2); padding: 12px; border-radius: 8px; overflow: auto; max-height: 480px; margin: 0; }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 14px; overflow-x: auto; }
@media (max-width: 1000px) { .kanban { grid-template-columns: repeat(2, minmax(220px,1fr)); } }
.kcol { background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 120px; }
.kcol-head { display: flex; align-items: center; gap: 8px; font-weight: 600; padding: 2px 4px 10px; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; box-shadow: var(--shadow); }
.kcard:hover { border-color: var(--accent); }
.kcard .title { font-weight: 600; font-size: 13.5px; }
.kcard .meta { color: var(--text-3); font-size: 12px; margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }

/* Stepper */
.stepper { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.step { text-align: center; padding: 10px 6px 8px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); position: relative; }
.step .n { width: 26px; height: 26px; border-radius: 50%; margin: 0 auto 6px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12.5px; background: var(--surface); border: 2px solid var(--border-strong); color: var(--text-2); }
.step .l { font-size: 12.5px; font-weight: 600; }
.step .c { font-size: 11.5px; color: var(--text-3); }
.step.reached .n { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.current { border-color: var(--accent); background: var(--accent-soft); }
.step.current .n { background: var(--accent); border-color: var(--accent); color: #fff; }
.step.notMeasured { opacity: .55; border-style: dashed; }
.stepper.mini { gap: 3px; }
.stepper.mini .step { padding: 4px 2px; }
.stepper.mini .n { width: 18px; height: 18px; font-size: 10px; margin-bottom: 0; }
.stepper.mini .l, .stepper.mini .c { display: none; }
@media (max-width: 800px) { .stepper { grid-template-columns: repeat(4, 1fr); } }

/* Prerequisites */
.prereq { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; font-size: 13px; }
.prereq .mark { width: 18px; height: 18px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.prereq.satisfied .mark { background: var(--ok-soft); color: var(--ok); }
.prereq.missing .mark { background: var(--bad-soft); color: var(--bad); }
.prereq.notMeasured .mark { background: var(--surface-2); color: var(--text-3); }

/* Forms */
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field input, .field select, .field textarea { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); width: 100%; font: inherit; }
.field input:not([type="checkbox"]), .field select { min-height: 40px; }
.field input[type="checkbox"] { accent-color: var(--accent); }
.field textarea { min-height: 80px; resize: vertical; }
.field .help { font-size: 12px; color: var(--text-3); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.preview { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 8px 10px; border-radius: 8px; color: var(--text-2); overflow-wrap: anywhere; }

/* Modal, drawer, toasts */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10,12,18,.54); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; width: min(680px, 100%); box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.modal.wide { width: min(980px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 15px; }
.modal-head .btn-icon { margin-left: auto; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--border); }
.drawer { position: fixed; right: 0; top: 0; height: 100vh; width: min(440px, 100vw); background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 40; display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.drawer-head .btn-icon { margin-left: auto; }
.drawer-body { overflow-y: auto; flex: 1; }
.cmd { padding: 11px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.cmd:last-child { border-bottom: 0; }
.cmd:hover { background: var(--surface-2); }
.cmd .line { display: flex; gap: 8px; align-items: center; }
.cmd code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmd .meta { color: var(--text-3); font-size: 12px; margin-top: 3px; }
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; max-width: 90vw; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.loading-state { display: grid; gap: 14px; }
.loading-state .skeleton-title { width: min(280px, 60%); height: 24px; }
.loading-state .skeleton-wide { width: 100%; height: 120px; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 700px) {
  .page-head .actions { width: 100%; margin-left: 0; }
  .page-head .actions .btn { flex: 1 1 auto; }
  .banner { align-items: flex-start; flex-wrap: wrap; }
  .banner .actions { width: 100%; margin-left: 0; }
  .field-row { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 12px; }
  .modal { border-radius: 12px; }
  .modal-body { padding: 16px; }
  .modal-foot { padding: 12px 16px; flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Login */
.login { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; width: min(420px, 100%); box-shadow: var(--shadow-lg); }
.login-error { color: var(--bad); background: var(--bad-soft); padding: 8px 10px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }

/* Swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px; }
.swatch i { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border-strong); display: inline-block; }
.svg-preview { background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0/16px 16px; border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow: auto; max-height: 560px; }
.svg-preview svg { max-width: 100%; height: auto; }
.output-row { display: flex; gap: 8px; align-items: center; }
kbd { font-family: var(--mono); background: var(--surface-2); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font-size: 11.5px; }
