:root {
    /* LOEWE Brand */
    --green: #018137;
    --green-d: #016a2d;
    --green-l: #e8f4ed;
    --black: #1a1d1a;
    --orange: #ee7501;      /* LOEWE Refractory Service */
    --orange-r: #eb6009;
    --hot: #ffb347;

    /* Fortschrittsbalken – LOEWE-Grün (Vorgabe 2026-07-15, vormals Orange/„flüssiges Metall") */
    --fill-d: #016a2d;      /* dunkel (Kanalanfang) */
    --fill:   #018137;      /* LOEWE-Grün */
    --fill-l: #33b96e;      /* hell (Kanalende) */

    --bg: #eef1f3;
    --surface: #ffffff;
    --surface-2: #f7f9fa;
    --border: #e2e7ea;
    --border-2: #d3dade;
    --text: #1f2622;
    --muted: #6b7680;
    --muted-2: #9aa4ac;
    --trough: #171c22;
    --shadow: 0 6px 22px rgba(20,35,25,.08);
    --shadow-lg: 0 18px 44px rgba(20,35,25,.16);
    --radius: 16px;
    font-family: "Myriad Pro", "Myriad", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; }
  body {
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
  }

  .demo-flag {
    position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
    z-index: 60; background: #fff5ec; color: var(--orange-r);
    border: 1px solid #f6cba0; border-radius: 999px;
    padding: 5px 14px; font-size: 12px; font-weight: 600; letter-spacing: .2px;
    box-shadow: var(--shadow);
  }

  /* ---------- Login ---------- */
  #login {
    position: fixed; inset: 0; z-index: 40;
    display: grid; place-items: center;
    background:
      radial-gradient(1000px 520px at 50% -5%, #ffffff 0%, #e9eef1 60%),
      var(--bg);
    transition: opacity .5s ease, visibility .5s ease;
  }
  #login.hidden { opacity: 0; visibility: hidden; }
  .login-card {
    width: 380px; max-width: calc(100vw - 40px);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 20px; box-shadow: var(--shadow-lg);
    padding: 36px 34px 26px; text-align: center;
  }
  .login-logo { height: 46px; margin: 0 auto 20px; display: block; }
  .login-title { font-size: 18px; font-weight: 700; margin: 0; }
  .login-sub { color: var(--muted); font-size: 13px; margin: 4px 0 26px; }
  .field { text-align: left; margin-bottom: 14px; }
  .field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
  .field input {
    width: 100%; padding: 11px 13px; border-radius: 10px;
    border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text);
    font-size: 14px; outline: none; transition: border-color .15s;
  }
  .field input:focus { border-color: var(--green); background: #fff; }
  .btn {
    width: 100%; padding: 12px; border: none; border-radius: 10px; cursor: pointer;
    background: var(--green); color: #fff;
    font-size: 15px; font-weight: 700; letter-spacing: .2px; margin-top: 6px;
    transition: background .15s, transform .1s;
  }
  .btn:hover { background: var(--green-d); }
  .btn:active { transform: translateY(1px); }
  .divider { display: flex; align-items: center; gap: 10px; color: var(--muted-2); font-size: 11px; margin: 18px 0; }
  .divider::before, .divider::after { content: ""; height: 1px; background: var(--border); flex: 1; }
  .btn-sso {
    width: 100%; padding: 11px; border-radius: 10px; cursor: pointer;
    background: #fff; color: var(--text); border: 1px solid var(--border-2);
    font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 9px;
    transition: border-color .15s;
  }
  .btn-sso:hover { border-color: var(--muted); }
  .ms-logo { width: 15px; height: 15px; display: grid; grid-template-columns: 1fr 1fr; gap: 1px; }
  .ms-logo i { display: block; }
  .ms-logo i:nth-child(1){background:#f25022}.ms-logo i:nth-child(2){background:#7fba00}
  .ms-logo i:nth-child(3){background:#00a4ef}.ms-logo i:nth-child(4){background:#ffb900}
  .login-foot { color: var(--muted-2); font-size: 11px; margin-top: 22px; }

  /* ---------- App shell ---------- */
  #app { min-height: 100%; display: flex; flex-direction: column; opacity: 0; transition: opacity .6s ease .1s; }
  #app.show { opacity: 1; }
  header.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 16px;
    padding: 12px 26px; background: rgba(255,255,255,.9); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
  }
  .topbar-logo { height: 30px; display: block; }
  .topbar-tag {
    font-size: 12px; color: var(--muted); border-left: 1px solid var(--border-2);
    padding-left: 14px; margin-left: 2px; font-weight: 600; letter-spacing: .3px;
  }
  .spacer { flex: 1; }
  .tenant {
    display: flex; align-items: center; gap: 9px; padding: 6px 13px 6px 8px;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; font-size: 13px;
  }
  .tenant .logo {
    width: 26px; height: 26px; border-radius: 6px; background: #38424c;
    display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff;
  }
  .tenant .muted { color: var(--muted); }
  .avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--green);
    display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff;
  }

  main { width: 100%; max-width: 1200px; margin: 0 auto; padding: 30px 26px 50px; }
  .page-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 4px; }
  .page-head h1 { font-size: 25px; margin: 0; font-weight: 700; }
  .page-head .crumb { color: var(--muted); font-size: 13px; }
  .page-sub { color: var(--muted); font-size: 14px; margin: 0 0 26px; max-width: 720px; }

  /* ---------- KPI row ---------- */
  .kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 34px; }
  .kpi {
    background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px;
    box-shadow: var(--shadow); position: relative; overflow: hidden;
  }
  .kpi::before { content:""; position:absolute; left:0; top:0; bottom:0; width:4px; background: var(--green); }
  .kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
  .kpi .value { font-size: 30px; font-weight: 700; margin-top: 8px; line-height: 1; color: var(--black); }
  .kpi .value small { font-size: 15px; color: var(--muted); font-weight: 600; }
  .kpi .trend { font-size: 12px; color: var(--green); margin-top: 8px; font-weight: 600; }
  .kpi .trend.n { color: var(--muted); }

  /* ---------- Section ---------- */
  .section-head { display: flex; align-items: center; gap: 12px; margin: 8px 0 18px; flex-wrap: wrap; }
  .section-head h2 { font-size: 17px; margin: 0; font-weight: 700; }
  .pill { font-size: 11px; color: var(--green-d); background: var(--green-l);
          border: 1px solid #bfe2cd; padding: 3px 10px; border-radius: 999px; font-weight: 600; }
  .shift-pill { font-size: 12px; color: var(--muted); background: var(--surface);
          border: 1px solid var(--border); padding: 4px 11px; border-radius: 999px; }

  /* ---------- Tile grid ---------- */
  .tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
  .tile {
    background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
    box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease, border-color .15s;
  }
  .tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-2); }
  .tile-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
  .tile-title { font-weight: 700; font-size: 15px; color: var(--black); }
  .tile-title small { display: block; color: var(--muted); font-size: 11px; font-weight: 500; margin-top: 2px; }
  .status { font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px; }
  .status.arbeit { color: var(--orange-r); background: #fdf0e4; border: 1px solid #f7cfa8; }
  .status.fertig { color: var(--green-d); background: var(--green-l); border: 1px solid #bfe2cd; }
  .status.start  { color: var(--muted); background: var(--surface-2); border: 1px solid var(--border-2); }

  .runner-wrap { position: relative; margin: 6px 0 14px; }
  .runner { width: 100%; height: 84px; display: block; }
  .tile-foot { display: flex; align-items: flex-end; justify-content: space-between; }
  .pct { font-size: 30px; font-weight: 800; line-height: 1; color: var(--black); }
  .pct span { font-size: 15px; color: var(--muted); font-weight: 600; }
  .hours { text-align: right; font-size: 12px; color: var(--muted); }
  .hours b { color: var(--text); font-weight: 700; }

  .tile.ghost {
    border-style: dashed; background: transparent; box-shadow: none;
    display: grid; place-items: center; color: var(--muted-2); text-align: center; min-height: 210px;
  }
  .tile.ghost .plus { font-size: 30px; margin-bottom: 8px; color: var(--green); }
  .tile.ghost:hover { transform: none; box-shadow: none; border-color: var(--muted-2); }

  /* ETA line */
  .eta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin: -2px 0 12px; }
  .eta b { color: var(--text); font-weight: 700; }
  .eta.done { color: var(--green-d); font-weight: 600; }
  /* "war fertig, ist wieder da": bewusst Orange, nicht Gruen - es ist kein
     Erfolgszustand, sondern ein Hinweis. Das Objekt ist erneut in Arbeit. */
  .eta.wieder { color: var(--orange-r); font-weight: 600; }

  /* ---------- Pruefstand (vorlaeufig / teilweise / geprueft) ----------
     Bewusst KEIN Haken und KEIN Gruen: beides ist in dieser Oberflaeche schon
     belegt ("Objekt abgeschlossen", Statuspille, Balken). Stattdessen ein
     kleines Textschild in derselben Sprache wie die uebrigen Pillen. */
  /* Prueffschild sitzt in der Fusszeile rechts, auf Hoehe der Prozentzahl */
  .tile-foot .pruef { align-self: flex-end; margin-bottom: 3px; }
  .pruef {
    font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
    white-space: nowrap; letter-spacing: .2px;
  }
  .pruef.vorlaeufig { color: #8a5a12; background: #fff8ec; border: 1px solid #f5d9a8; }
  .pruef.teilweise  { color: #8a5a12; background: #fff8ec; border: 1px solid #f5d9a8; }

  /* Legende ueber dem Raster – erklaert die Schilder an den Kacheln */
  .legende {
    display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
    font-size: 11px; color: var(--muted); margin: -6px 0 16px;
  }
  .leg-sep { color: var(--border-2); margin: 0 4px; }
  .leg-ohne {
    font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
    color: var(--muted-2); background: var(--surface-2); border: 1px dashed var(--border-2);
  }
  .leg-schluss { color: var(--muted-2); margin-left: 4px; }

  /* Ausgeschriebener Hinweis in der Detailansicht */
  .pruef-block {
    font-size: 12px; line-height: 1.5; border-radius: 10px;
    padding: 11px 13px; margin: 16px 0 4px;
  }
  .pruef-block b { display: inline-block; margin-bottom: 2px; }
  .pruef-block.offen { background: #fff8ec; border: 1px solid #f5d9a8; color: #7a4f10; }
  .pruef-block.teil  { background: #fff8ec; border: 1px solid #f5d9a8; color: #7a4f10; }
  .pruef-block.ok    { background: var(--green-l); border: 1px solid #bfe2cd; color: var(--green-d); }

  /* Ungepruefte Schicht im Verlauf: gedaempfter Punkt statt gruenem */
  .tl-item.offen::before { background: var(--muted-2); box-shadow: 0 0 0 2px #e9edf0; }
  .tl-offen {
    font-size: 10px; color: #8a5a12; background: #fff8ec;
    border: 1px solid #f5d9a8; padding: 1px 7px; border-radius: 999px;
  }

  /* Detail modal */
  .modal-overlay {
    position: fixed; inset: 0; z-index: 50; background: rgba(18,28,22,.48);
    backdrop-filter: blur(3px); display: none; align-items: flex-start; justify-content: center;
    padding: 5vh 16px; overflow: auto;
  }
  .modal-overlay.open { display: flex; }
  .modal {
    width: 580px; max-width: 100%; background: var(--surface); border-radius: 18px;
    box-shadow: var(--shadow-lg); border: 1px solid var(--border); position: relative; padding: 26px 28px 30px;
  }
  .modal-x {
    position: absolute; top: 16px; right: 18px; width: 32px; height: 32px; border: none; border-radius: 8px;
    background: var(--surface-2); color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1;
  }
  .modal-x:hover { background: #eceff1; color: var(--text); }
  .modal h3 { margin: 0; font-size: 21px; color: var(--black); }
  .modal .sub { color: var(--muted); font-size: 13px; margin: 3px 0 16px; }
  .stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 16px 0 4px; }
  .stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
  .stat .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }
  .stat .v { font-size: 18px; font-weight: 700; color: var(--black); margin-top: 5px; }
  .hist-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin: 24px 0 14px; }
  .timeline { position: relative; margin: 0; padding: 0 0 0 22px; list-style: none; }
  .timeline::before { content: ""; position: absolute; left: 6px; top: 5px; bottom: 5px; width: 2px; background: var(--border-2); }
  .tl-item { position: relative; padding: 0 0 18px; }
  .tl-item::before {
    content: ""; position: absolute; left: -22px; top: 3px; width: 10px; height: 10px; border-radius: 50%;
    background: var(--green); border: 2px solid var(--surface); box-shadow: 0 0 0 2px var(--green-l);
  }
  .tl-item:last-child { padding-bottom: 0; }
  .tl-top { display: flex; align-items: baseline; gap: 10px; }
  .tl-date { font-weight: 700; font-size: 14px; color: var(--black); }
  .tl-shift { font-size: 11px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); padding: 1px 8px; border-radius: 999px; }
  .tl-hrs { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--green-d); }
  .tl-task { font-size: 13px; color: var(--text); margin-top: 4px; }
  .tl-crew { font-size: 12px; color: var(--muted-2); margin-top: 2px; }

  footer.foot { color: var(--muted-2); font-size: 12px; text-align: center; padding: 22px; border-top: 1px solid var(--border); }
  footer.foot b { color: var(--green); }

  /* ---------- Self-Service: Rollenumschalter (nur Demo) ---------- */
  .role-switch { display: flex; gap: 2px; padding: 3px; background: var(--surface-2);
                 border: 1px solid var(--border); border-radius: 999px; }
  .role-btn {
    border: none; background: transparent; color: var(--muted); font-family: inherit;
    font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 999px; cursor: pointer;
  }
  .role-btn.active { background: var(--green); color: #fff; }

  /* ---------- Self-Service: Werkzeugleiste ---------- */
  .dash-bar { display: flex; align-items: center; gap: 10px; margin: 0 0 24px; flex-wrap: wrap; }
  .bar-l { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .btn-edit {
    border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
    font-family: inherit; font-size: 13px; font-weight: 600;
    padding: 8px 14px; border-radius: 9px; cursor: pointer;
    transition: border-color .15s, background .15s;
  }
  .btn-edit:hover { border-color: var(--muted); }
  .btn-edit.primary { background: var(--green); border-color: var(--green); color: #fff; }
  .btn-edit.primary:hover { background: var(--green-d); }
  .btn-edit.ghost-btn { background: transparent; border-style: dashed; color: var(--muted); }
  .hint { font-size: 12px; color: var(--muted-2); }

  /* ---------- Self-Service: Kachel-Instanz (Panel) ---------- */
  .panel { margin-bottom: 34px; }
  .panel.editing {
    border: 1px dashed var(--border-2); border-radius: var(--radius);
    padding: 14px 16px 18px; background: rgba(255,255,255,.5);
  }
  .panel-tools { display: flex; gap: 6px; margin-left: auto; }
  .tool {
    width: 30px; height: 30px; border: 1px solid var(--border-2); background: var(--surface);
    color: var(--muted); border-radius: 8px; cursor: pointer; font-size: 12px; line-height: 1; font-family: inherit;
  }
  .tool:hover { border-color: var(--muted); color: var(--text); }
  .tool.del:hover { border-color: #e2a09a; color: #c0392b; background: #fdf1f0; }
  .tool:disabled { opacity: .3; cursor: default; }
  .tool:disabled:hover { border-color: var(--border-2); color: var(--muted); }

  /* ---------- Self-Service: Kachel-Katalog ---------- */
  .cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
  .cat-card {
    border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface-2);
    cursor: pointer; transition: border-color .15s, transform .1s;
  }
  .cat-card:hover { border-color: var(--green); transform: translateY(-2px); }
  .cat-card .n { font-weight: 700; font-size: 14px; color: var(--black); }
  .cat-card .d { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
  .cat-card.locked { cursor: not-allowed; opacity: .5; background: transparent; border-style: dashed; }
  .cat-card.locked:hover { border-color: var(--border); transform: none; }
  .tag-free, .tag-lock { float: right; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
  .tag-free { color: var(--green-d); background: var(--green-l); border: 1px solid #bfe2cd; }
  .tag-lock { color: var(--muted); background: var(--surface-2); border: 1px solid var(--border-2); }
  .note {
    font-size: 12px; color: var(--muted); line-height: 1.5;
    background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--green);
    border-radius: 8px; padding: 10px 12px; margin-top: 18px;
  }

  /* ---------- Self-Service: Konfigurations-Formular ---------- */
  .cfg-row { margin-bottom: 13px; }
  .cfg-row label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 5px; }
  .cfg-row select, .cfg-row input {
    width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border-2);
    background: var(--surface-2); color: var(--text); font-size: 14px; font-family: inherit; outline: none;
  }
  .cfg-row select:focus, .cfg-row input:focus { border-color: var(--green); background: #fff; }
  .cfg-row select:disabled { color: var(--muted); cursor: not-allowed; }
  .cfg-actions { display: flex; gap: 10px; margin-top: 20px; }
  .cfg-actions .btn-edit { flex: 1; text-align: center; }

  /* ---------- Toast ---------- */
  .toast {
    position: fixed; bottom: 26px; left: 50%; z-index: 70; pointer-events: none;
    transform: translateX(-50%) translateY(20px); opacity: 0;
    background: var(--black); color: #fff; font-size: 13px; font-weight: 600;
    padding: 11px 20px; border-radius: 999px; box-shadow: var(--shadow-lg);
    transition: opacity .25s ease, transform .25s ease;
  }
  .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

  @media (max-width: 720px) {
    .kpis { grid-template-columns: repeat(2, 1fr); }
    .topbar-tag { display: none; }
    .cat-grid { grid-template-columns: 1fr; }
    .role-switch { display: none; }
  }

  /* ---------- Kennzahl-Kachel mit Saeulendiagramm ----------
     Eine Serie, also EINE Farbe und keine Legende - der Titel sagt, was
     geplottet ist. Werte nicht an jeder Saeule, nur am Hoechststand und an der
     laufenden Periode; den Rest tragen Achse und Tooltip. */
  .kennzahl-flaeche { display: block; }
  .tile.kennzahl { padding: 18px 20px 14px; }
  .kennzahl-kopf { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
  .kennzahl-zahl {
    font-size: 34px; font-weight: 800; line-height: 1; color: var(--black);
  }
  .kennzahl-label { font-size: 12px; color: var(--muted); margin-top: 5px; }
  .pill.intern {
    color: var(--muted); background: var(--surface-2);
    border: 1px dashed var(--border-2); font-weight: 700;
  }

  .diagramm { display: flex; gap: 10px; margin-top: 18px; max-width: 560px; }
  .diagramm-achse {
    display: flex; flex-direction: column; justify-content: space-between;
    font-size: 10px; color: var(--muted-2); height: 112px;
    font-variant-numeric: tabular-nums; text-align: right; min-width: 14px;
  }
  .diagramm-flaeche {
    flex: 1; display: flex; align-items: flex-end; gap: 2px;   /* 2px Surface-Gap */
    border-bottom: 1px solid var(--border);                     /* Achse, hairline */
  }
  .saeule { flex: 1; display: flex; flex-direction: column; align-items: center; }
  .saeule-wert {
    font-size: 11px; font-weight: 700; color: var(--text);
    height: 15px; font-variant-numeric: tabular-nums;
  }
  .saeule-bahn {
    width: 100%; max-width: 24px;      /* Mark-Spec: Saeule nie breiter als 24px */
    height: 96px; display: flex; align-items: flex-end;
  }
  .saeule-fuell {
    width: 100%; background: var(--fill);
    border-radius: 4px 4px 0 0;        /* gerundetes Datenende, eckig an der Basis */
    transition: height .3s ease;
  }
  /* Eine Null zeigt NICHTS. Ein min-height wuerde aus 0 einen sichtbaren Balken
     machen - das Diagramm wuerde den Wert falsch darstellen. Die Luecke IST die
     Aussage ("in dieser Woche wurde nichts fertig"). */
  .saeule-fuell.leer { height: 0 !important; }
  .saeule-label {
    font-size: 10px; color: var(--muted-2); margin-top: 6px;
    white-space: nowrap;
  }