  @font-face {
    font-family: "Open Sans";
    src: url("assets/open-sans.woff2") format("woff2");
    font-weight: 300 800;
    font-style: normal;
    font-display: swap;
  }

  :root {
    color-scheme: light;
    /* Pexon Design Tokens (Brain-Sync/corporate-identity) */
    --navy: #131B2D; --navy-900: #0B1220; --navy-700: #1A2540; --navy-600: #213355; --navy-500: #2C4471;
    --teal: #3DDBCA; --teal-700: #1FA897; --teal-600: #2BC2B0; --teal-400: #6DE5D7; --teal-100: #E3FAF6;
    --shadow-md: 0 6px 16px rgba(19,27,45,0.10), 0 2px 4px rgba(19,27,45,0.06);
    --shadow-lg: 0 18px 40px rgba(19,27,45,0.18), 0 6px 12px rgba(19,27,45,0.08);
    --glow: 0 0 0 3px rgba(61,219,202,0.25);
    --ease: cubic-bezier(0.2, 0, 0, 1); --fast: 120ms; --base: 200ms;

    --page: #F8F9FB; --surface: #FFFFFF;
    --ink: #131B2D; --ink-2: #3F4858; --muted: #6B7588;
    --grid: #E2E5EA; --baseline: #C8CDD6; --ring: rgba(19,27,45,0.10);
    --accent: #1FA897;
    --btn-primary: #131B2D; --btn-primary-hover: #213355; --btn-primary-ink: #ffffff;
    --done-bg: #E3FAF6; --done-ink: #0E7A6C;
    --cell-free: #F2F4F7; --cell-free-ink: #6B7588;
    --cell-part: #FAF0CF; --cell-part-ink: #7A5C10;
    --cell-full: #E3FAF6; --cell-full-ink: #0E7A6C;
    --cell-over: #F9DFDD; --cell-over-ink: #B03A34;
    --hatch: rgba(19,27,45,0.10);
    --danger: #C9403D;
    --badge-ro: #E7EDF8; --badge-ro-ink: #2C4471;
    --badge-de: #F2F4F7; --badge-de-ink: #3F4858;
    --st-active: #E7EDF8;      --st-active-ink: #2C4471;
    --st-signed: #E3FAF6;      --st-signed-ink: #0E7A6C;
    --st-notsigned: #FBE8D9;   --st-notsigned-ink: #9C5220;
    --st-verh: #EAE8F7;        --st-verh-ink: #5348A8;
    --st-delayed: #FAF0CF;     --st-delayed-ink: #7A5C10;
    --st-completed: #F2F4F7;   --st-completed-ink: #6B7588;
    --warn-bg: #FBE9DE; --warn-ink: #7C2D12;
    --amber: #E8A13C;
  }
  @media (prefers-color-scheme: dark) {
    :root {
      /* Dark Mode auf Navy-Basis — der Pexon-Signature-Look */
      color-scheme: dark;
      --page: #0B1220; --surface: #131B2D;
      --ink: #FFFFFF; --ink-2: #C8CDD6; --muted: #7E8AA0;
      --grid: rgba(255,255,255,0.10); --baseline: rgba(255,255,255,0.22); --ring: rgba(255,255,255,0.12);
      --accent: #3DDBCA;
      --btn-primary: #2BC2B0; --btn-primary-hover: #3DDBCA; --btn-primary-ink: #0B1220;
      --done-bg: #0F332E; --done-ink: #6DE5D7;
      --shadow-md: 0 6px 16px rgba(0,0,0,0.35), 0 2px 4px rgba(0,0,0,0.25);
      --shadow-lg: 0 18px 40px rgba(0,0,0,0.5), 0 6px 12px rgba(0,0,0,0.3);
      --cell-free: #182238; --cell-free-ink: #6B7588;
      --cell-part: #33290F; --cell-part-ink: #E3B341;
      --cell-full: #0F332E; --cell-full-ink: #6DE5D7;
      --cell-over: #3E2126; --cell-over-ink: #F08A8A;
      --hatch: rgba(255,255,255,0.10);
      --danger: #E66E6B;
      --badge-ro: #1C2B4A; --badge-ro-ink: #8FA9DB;
      --badge-de: #222B3E; --badge-de-ink: #C8CDD6;
      --st-active: #1C2B4A;    --st-active-ink: #8FA9DB;
      --st-signed: #0F332E;    --st-signed-ink: #6DE5D7;
      --st-notsigned: #3A2717; --st-notsigned-ink: #E8A06A;
      --st-verh: #292347;      --st-verh-ink: #A79BE8;
      --st-delayed: #33290F;   --st-delayed-ink: #E3B341;
      --st-completed: #222B3E; --st-completed-ink: #8A94A8;
      --warn-bg: #3A2519; --warn-ink: #F0B18F;
      --amber: #E3B341;
    }
  }
  * { box-sizing: border-box; }
  body {
    margin: 0; background: var(--page); color: var(--ink);
    font: 14px/1.45 "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
  }
  header {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 10px 20px; background: var(--navy);
    border-bottom: 1px solid rgba(255,255,255,0.12); position: sticky; top: 0; z-index: 30;
  }
  .logo { height: 26px; display: block; }
  header h1 {
    font-size: 13px; font-weight: 600; margin: 0 16px 0 0; color: rgba(255,255,255,0.72);
    padding-left: 14px; border-left: 1px solid rgba(255,255,255,0.2); align-self: center;
  }
  .tabs { display: flex; gap: 2px; align-self: flex-end; margin-bottom: -10px; }
  .tabs button {
    border: none; background: none; color: rgba(255,255,255,0.72);
    padding: 6px 13px 11px; cursor: pointer; font: inherit; font-size: 14px;
    border-bottom: 2px solid transparent; border-radius: 0;
    transition: color var(--fast) var(--ease);
  }
  .tabs button:hover { color: #fff; }
  .tabs button.on { color: #fff; font-weight: 600; border-bottom-color: var(--teal); }
  .spacer { flex: 1; }
  header .sub { color: rgba(255,255,255,0.72); }
  header .btn {
    background: transparent; border-color: rgba(255,255,255,0.25); color: rgba(255,255,255,0.85);
  }
  header .btn:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.45); color: #fff; }
  .btn {
    border: 1px solid var(--grid); background: var(--surface); color: var(--ink-2);
    padding: 6px 14px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 13px;
    transition: background var(--fast) var(--ease), color var(--fast) var(--ease), border-color var(--fast) var(--ease);
  }
  .btn:hover { border-color: var(--baseline); color: var(--ink); }
  .btn:active { transform: scale(0.98); }
  .btn.primary { background: var(--btn-primary); border-color: var(--btn-primary); color: var(--btn-primary-ink); }
  .btn.primary:hover { background: var(--btn-primary-hover); border-color: var(--btn-primary-hover); color: var(--btn-primary-ink); }
  .btn.danger-armed { background: var(--danger); border-color: var(--danger); color: #fff; }
  .btn.done { background: var(--done-bg); color: var(--done-ink); border-color: transparent; }

  #warnings { margin: 14px 20px 0; display: flex; flex-direction: column; gap: 6px; }
  .warn {
    background: var(--warn-bg); color: var(--warn-ink);
    border-radius: 8px; padding: 8px 12px; font-size: 13px;
  }
  .warn b { font-weight: 600; }

  section { padding: 14px 20px 40px; }
  .boardbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
  .boardbar label { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; cursor: pointer; }
  .legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
  .legend span { display: inline-flex; align-items: center; gap: 5px; }
  .chipbox { width: 16px; height: 12px; border-radius: 3px; border: 1px solid var(--ring); display: inline-block; }
  .hatched { background-image: repeating-linear-gradient(45deg, transparent 0 3px, var(--hatch) 3px 5px); }

  .scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--grid); border-radius: 10px; }
  table.board { border-collapse: separate; border-spacing: 0; font-size: 11px; width: 100%; }
  table.board th, table.board td { border-bottom: 1px solid var(--grid); border-right: 1px solid var(--grid); padding: 0; }
  table.board thead th {
    position: sticky; top: 0; background: var(--surface); z-index: 10;
    font-weight: 500; color: var(--muted); padding: 5px 3px; text-align: center; min-width: 42px;
    vertical-align: bottom;
  }
  table.board thead th .kw { font-weight: 600; color: var(--ink-2); display: block; }
  table.board thead th.today { color: var(--accent); }
  table.board thead th.today .kw { color: var(--accent); }
  th.namecol, td.namecol {
    position: sticky; left: 0; background: var(--surface); z-index: 5;
    min-width: 190px; max-width: 190px; text-align: left; padding: 4px 8px; font-size: 13px;
  }
  th.freecol, td.freecol {
    position: sticky; left: 190px; background: var(--surface); z-index: 5;
    min-width: 64px; max-width: 64px; text-align: center; font-size: 11px; color: var(--ink-2);
    padding: 4px; border-right: 2px solid var(--baseline) !important;
  }
  thead th.namecol, thead th.freecol { z-index: 15; }
  tr.grouprow td {
    background: var(--page); color: var(--muted); font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em; padding: 4px 8px;
    position: sticky; left: 0;
  }
  .cname { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
  .cname .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .loc {
    font-size: 10px; font-weight: 600; border-radius: 4px; padding: 1px 5px; cursor: pointer;
    background: var(--badge-de); color: var(--badge-de-ink); border: none; font-family: inherit;
  }
  .loc.RO { background: var(--badge-ro); color: var(--badge-ro-ink); }
  td.cell {
    min-width: 42px; height: 30px; text-align: center; font-variant-numeric: tabular-nums;
    color: var(--ink-2); cursor: default;
  }
  td.cell.lvl-free { background: var(--cell-free); color: var(--cell-free-ink); }
  td.cell.lvl-low { background: var(--cell-free); color: var(--cell-free-ink); font-weight: 600; }
  td.cell.lvl-part { background: var(--cell-part); color: var(--cell-part-ink); }
  td.cell.lvl-full { background: var(--cell-full); color: var(--cell-full-ink); font-weight: 600; }
  td.cell.lvl-over { background: var(--cell-over); color: var(--cell-over-ink); font-weight: 700; }
  td.cell.soft { background-image: repeating-linear-gradient(45deg, transparent 0 3px, var(--hatch) 3px 5px); }
  td.cell.past { opacity: 0.5; }
  td.cell.today, th.today { box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent); }
  td.cell.monthstart, th.monthstart { border-left: 2px solid var(--baseline); }
  .caret { display: inline-block; width: 13px; color: var(--muted); font-size: 9px; }
  td.namecol.expandable { cursor: pointer; }
  td.namecol.expandable:hover .nm { color: var(--accent); }
  tr.subrow td { background: var(--page); }
  tr.subrow td.cell { height: 24px; font-size: 10px; color: var(--muted); }
  td.subname {
    cursor: pointer; font-size: 11px !important; color: var(--ink-2);
    padding-left: 22px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    background: var(--page) !important;
  }
  td.subname:hover { color: var(--accent); }
  tr.subrow td.freecol { background: var(--page) !important; }

  #tooltip {
    position: fixed; z-index: 100; display: none; max-width: 340px;
    background: var(--surface); color: var(--ink); border: 1px solid var(--baseline);
    border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    pointer-events: none;
  }
  #tooltip .tt-head { font-weight: 600; margin-bottom: 4px; }
  #tooltip .tt-row { display: flex; justify-content: space-between; gap: 12px; }
  #tooltip .tt-kind { color: var(--muted); }

  /* Projektliste */
  table.plist { border-collapse: collapse; width: 100%; background: var(--surface); border: 1px solid var(--grid); border-radius: 10px; font-size: 13px; }
  table.plist th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--baseline); }
  table.plist td { padding: 7px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
  table.plist th.num { text-align: right; }
  #customerTable td { vertical-align: middle; }
  table.plist tr:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }
  .stbadge { border: none; font: inherit; font-size: 12px; border-radius: 6px; padding: 2px 8px; cursor: pointer; }
  select.stbadge {
    -webkit-appearance: none; appearance: none; padding-right: 18px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23898781'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 6px center;
  }
  .pname { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .st-Active { background: var(--st-active); color: var(--st-active-ink); }
  .st-Signed { background: var(--st-signed); color: var(--st-signed-ink); }
  .st-NotSigned, .st-Angebot { background: var(--st-notsigned); color: var(--st-notsigned-ink); }
  .st-Verhandlung { background: var(--st-verh); color: var(--st-verh-ink); }
  .st-Delayed { background: var(--st-delayed); color: var(--st-delayed-ink); }
  .st-Completed, .st-Canceled { background: var(--st-completed); color: var(--st-completed-ink); }
  tr.pgroup td {
    background: var(--page); padding: 8px 10px; border-bottom: 1px solid var(--baseline);
    font-size: 12px; color: var(--ink-2); font-weight: 600;
  }
  .achip {
    display: inline-block; margin: 1px 3px 1px 0; padding: 2px 8px; border-radius: 6px;
    background: var(--page); border: 1px solid var(--grid); cursor: pointer; font-size: 12px; color: var(--ink-2);
  }
  .achip:hover { border-color: var(--accent); color: var(--ink); }
  .achip.open { border-style: dashed; color: var(--st-notsigned-ink); }
  .achip .pct { font-weight: 600; }
  .stackbar { display: flex; gap: 2px; width: 100%; max-width: 420px; height: 10px; border-radius: 4px; background: var(--grid); overflow: hidden; margin: 3px 0 5px; }
  .stackbar span { height: 100%; }
  .ubullet { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
  .meter { display: inline-block; width: 64px; height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; vertical-align: middle; margin-right: 6px; }
  .meter.big { width: 160px; height: 8px; }
  .meter .fill { display: block; height: 100%; background: var(--accent); }
  .meter .fill.hi { background: var(--amber); }
  .meter .fill.over { background: var(--danger); }
  .flt { font: inherit; font-size: 13px; color: var(--ink); background: var(--surface); border: 1px solid var(--grid); border-radius: 6px; padding: 6px 10px; }
  .flt:focus-visible, dialog input:focus-visible, dialog select:focus-visible, dialog textarea:focus-visible {
    outline: none; border-color: var(--teal-600); box-shadow: var(--glow);
  }
  #fltSearch { min-width: 220px; }
  .sumbar { margin-top: 8px; font-size: 13px; color: var(--ink-2); text-align: right; padding-right: 10px; }
  .sumbar b { color: var(--ink); font-size: 14px; }
  .rolechip {
    display: inline-block; margin-right: 4px; padding: 1px 8px; border-radius: 5px; font-size: 11px;
    cursor: pointer; border: 1px solid var(--grid); color: var(--muted); background: none; font-family: inherit;
  }
  .rolechip.on { background: var(--st-active); color: var(--st-active-ink); border-color: transparent; font-weight: 600; }
  .namelink { cursor: pointer; }
  .namelink:hover { color: var(--accent); }
  .inactive-row td { opacity: 0.45; }
  .iconbtn { border: none; background: none; cursor: pointer; font-size: 14px; color: var(--muted); padding: 2px 4px; }
  .iconbtn:hover { color: var(--ink); }
  .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .sub { color: var(--muted); font-size: 12px; }

  dialog {
    border: 1px solid var(--grid); border-radius: 16px; background: var(--surface); color: var(--ink);
    padding: 18px 20px; min-width: 380px; max-width: 92vw; box-shadow: var(--shadow-lg);
  }
  dialog::backdrop { background: rgba(11,18,32,0.45); }
  dialog h3 { margin: 0 0 12px; font-size: 15px; }
  dialog .frow { display: flex; gap: 10px; margin-bottom: 10px; }
  dialog .frow > label { flex: 1; display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--ink-2); }
  dialog input, dialog select, dialog textarea {
    font: inherit; font-size: 13px; color: var(--ink); background: var(--page);
    border: 1px solid var(--grid); border-radius: 6px; padding: 6px 8px; width: 100%;
  }
  dialog .dfoot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
  dialog .dfoot .left { margin-right: auto; }
  #newConsultRow { display: none; }
  /* Feste Größe, damit die Blätter-Pfeile beim Durchschalten nicht springen; Inhalt scrollt intern.
     display nur im [open]-Zustand setzen — sonst hebelt es das native Verstecken des <dialog> aus */
  #dlgDetail {
    width: 580px; max-width: 92vw; height: min(660px, 86vh);
    overflow: visible; position: relative;
  }
  #dlgDetail[open] { display: flex; flex-direction: column; }
  #dlgDetail #detBody { flex: 1 1 auto; overflow-y: auto; min-height: 0; margin-right: -10px; padding-right: 10px; }
  .navArrow {
    position: absolute; top: 50%; transform: translateY(-50%); left: -58px;
    width: 44px; height: 44px; border-radius: 50%; font-size: 22px; line-height: 1;
    background: var(--surface); color: var(--ink-2); border: 1px solid var(--baseline); cursor: pointer;
  }
  .navArrow.right { left: auto; right: -58px; }
  .navArrow.closeX {
    top: -18px; right: -18px; left: auto; transform: none;
    width: 36px; height: 36px; font-size: 15px;
  }
  .detEditTop { position: absolute; top: 16px; right: 20px; }
  #dlgDetail h3 { padding-right: 110px; }
  .navArrow:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
  .navArrow:disabled { opacity: 0.25; cursor: default; }
  .det-grid { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; font-size: 13px; margin-bottom: 12px; }
  .det-grid .k { color: var(--muted); }
  .det-asg { border-top: 1px solid var(--grid); padding-top: 10px; font-size: 13px; }
  .det-asg .row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
  .det-asg .row .who { font-weight: 600; }
  .det-asg .row .meta { color: var(--ink-2); }
  #dlgDetail a { color: var(--accent); }
  tr.prow td { cursor: pointer; }
