* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
:root {
  /* macOS Dark Mode System Colors */
  --bg: #000000;
  --surface: rgba(28, 28, 30, 0.75);
  --surface-solid: #1C1C1E;
  --border: rgba(255, 255, 255, 0.1);
  --border2: rgba(255, 255, 255, 0.15);
  --yellow: #FFD60A;
  --orange: #FF9F0A;
  --blue: #0A84FF;
  --green: #32D74B;
  --red: #FF453A;
  --lilac: #BF5AF2;
  --cyan: #64D2FF;
  --white: #FFFFFF;
  --muted: #8E8E93;
  --muted2: #636366;
  
  /* macOS System Fonts */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "JetBrains Mono", monospace;
}
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #121417;
  color: var(--white);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: -webkit-fill-available;
  position: relative;
  overflow: hidden;
  border-radius: 0;
  background: linear-gradient(180deg, #121417 0%, #070b12 100%);
}

/* --- VEREINHEITLICHTER GLAS-EFFEKT (macOS) --- */
.glass-panel {
  background: var(--surface);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}

/* --- TOPBAR --- */
.topbar {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 0.5px solid var(--border);
  z-index: 50;
  flex-shrink: 0;
}
.topbar__left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar__mark {
  width: 24px;
  height: 24px;
  background: #0A327D;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: .65rem;
  font-weight: 700;
  color: #FFFFFF;
  font-family: var(--mono);
}
.topbar__name {
  font-weight: 600;
  font-size: .85rem;
  letter-spacing: .01em;
}
.topbar__right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.live-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border: 0.5px solid rgba(50, 215, 75, 0.3);
  border-radius: 20px;
  background: rgba(50, 215, 75, 0.1);
  font-family: var(--mono);
  font-size: .55rem;
  font-weight: 500;
  color: var(--green);
}
.live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  animation: blink 1.8s ease-in-out infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: .2; }
}
.clock {
  font-family: var(--mono);
  font-size: .75rem;
  color: var(--muted);
}

/* --- SCREENS --- */
.screen-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.screen.active {
  display: flex;
}

/* --- SCREEN 1: SCHEMA (MAP) --- */
.zone-carousel {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  overflow: visible;
  border-bottom: 0.5px solid var(--border);
  scrollbar-width: none;
}
.zone-carousel::-webkit-scrollbar { display: none; }
.zone-btn {
  flex: 1 1 118px;
  padding: 6px 10px;
  border-radius: 14px;
  font-size: .65rem;
  font-weight: 500;
  cursor: pointer;
  border: 0.5px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  white-space: nowrap;
  text-align: center;
  transition: all .2s;
}
.zone-btn.on {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.canvas-scroll-wrapper {
  flex: 1;
  overflow: hidden;
  position: relative;
  -webkit-overflow-scrolling: touch;
}
.canvas-inner-wrap {
  width: 100%;
  min-width: 0;
  height: 100%;
  position: relative;
}
canvas {
  position: absolute;
  inset: 0;
  display: block;
}
.canvas-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.scroll-hint {
  display: none;
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  border: 0.5px solid var(--border2);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: .6rem;
  color: var(--white);
  pointer-events: none;
  font-weight: 500;
  animation: fadeOut 4s forwards;
  z-index: 10;
  white-space: nowrap;
}
@keyframes fadeOut {
  0% { opacity: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}

.tip {
  position: absolute;
  border: 0.5px solid var(--border2);
  border-radius: 12px;
  padding: 12px 14px;
  min-width: 200px;
  display: none;
  z-index: 30;
  pointer-events: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.tip.show { display: block; }
.tip__name { font-weight: 600; font-size: .8rem; margin-bottom: 8px; }
.tip__row {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  padding: 5px 0;
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
  font-size: .65rem;
}
.tip__row:last-child { border-bottom: none; }
.tip__lbl { color: var(--muted); }

.alert-stack {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 40;
  pointer-events: none;
  max-width: 200px;
}
.alert {
  border: 0.5px solid var(--border2);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .65rem;
  animation: slideIn .4s cubic-bezier(0.25, 0.8, 0.25, 1);
  border-left: 4px solid;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
@keyframes slideIn {
  from { transform: translateY(15px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.alert-green { border-left-color: var(--green); }
.alert-yellow { border-left-color: var(--yellow); }
.alert__title { font-weight: 600; margin-bottom: 3px; font-size: .7rem; }
.alert__body { color: var(--muted); line-height: 1.3; }

/* --- SCREEN 2: ANALYTICS --- */
.scroll-screen {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pb {
  background: var(--surface-solid);
  border: 0.5px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}
.pb__title {
  font-size: .6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.kpi {
  background: rgba(255,255,255,0.03);
  border: 0.5px solid rgba(255,255,255,0.05);
  border-radius: 10px;
  padding: 12px;
}
.kpi__val {
  font-size: 1.25rem;
  font-weight: 700;
  font-family: var(--mono);
  line-height: 1;
}
.kpi__label {
  font-size: .6rem;
  color: var(--muted);
  margin-top: 6px;
  font-weight: 500;
}
.bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 54px;
  padding-top: 4px;
}
.bar {
  flex: 1;
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height .4s ease;
}
.ring-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
}
.ring {
  position: relative;
  width: 54px;
  height: 54px;
  flex-shrink: 0;
}
.ring svg { transform: rotate(-90deg); }
.ring__val {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  font-family: var(--mono);
}
.ring-rows { flex: 1; }
.ring-row {
  display: flex;
  justify-content: space-between;
  font-size: .65rem;
  padding: 4px 0;
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
}
.ring-row:last-child { border-bottom: none; }
.ring-row span:first-child { color: var(--muted); }
.ring-row span:last-child { font-family: var(--mono); }

.prog { margin-bottom: 10px; }
.prog:last-child { margin-bottom: 0; }
.prog__head {
  display: flex;
  justify-content: space-between;
  font-size: .65rem;
  margin-bottom: 4px;
}
.prog__name { color: var(--muted); }
.prog__val { font-family: var(--mono); color: var(--white); font-weight: 500; }
.prog__bg { height: 6px; background: rgba(255,255,255,.08); border-radius: 3px; overflow: hidden; }
.prog__fill { height: 100%; border-radius: 3px; transition: width .8s ease; }
.prog__fill--spring { width: 68%; background: var(--yellow); }
.prog__fill--public { width: 91%; background: var(--green); }
.prog__fill--leather { width: 34%; background: var(--orange); }
.prog__fill--mto { width: 12%; background: var(--blue); }

.dash-color-green { color: var(--green); }
.dash-color-yellow { color: var(--yellow); }
.dash-color-blue { color: var(--blue); }
.dash-color-white { color: var(--white); }
.dash-bg-green { background: var(--green); }
.dash-bg-yellow { background: var(--yellow); }
.dash-bg-red { background: var(--red); }
.pb--fill { flex: 1; }
.scroll-screen--flush { padding-top: 0; }

/* --- SCREEN 3: MACHINES --- */
.mach-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mach-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .65rem;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  border: 0.5px solid rgba(255,255,255,0.05);
}
.mach-status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.mach-id { font-family: var(--mono); color: var(--muted2); min-width: 38px; }
.mach-name { flex: 1; color: var(--white); font-weight: 500;}
.mach-spd { font-family: var(--mono); font-size: .6rem; }

.log-feed {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}
.log-entry {
  display: flex;
  gap: 8px;
  font-size: .65rem;
  padding: 6px 0;
  border-bottom: 0.5px solid rgba(255,255,255,0.08);
}
.log-entry:last-child { border-bottom: none; }
.log-time { font-family: var(--mono); color: var(--muted2); flex-shrink: 0; }
.log-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.log-msg { color: rgba(255,255,255,.8); line-height: 1.3; }

/* --- SCREEN 4: CLIENT/ORDERS --- */
.order-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  overflow: visible;
  border-bottom: 0.5px solid var(--border);
  scrollbar-width: none;
}
.order-selector::-webkit-scrollbar { display: none; }
.order-btn {
  flex: 1 1 140px;
  padding: 6px 14px;
  border-radius: 14px;
  font-size: .65rem;
  font-weight: 500;
  border: 0.5px solid var(--border);
  background: rgba(255,255,255,0.05);
  color: var(--muted);
  white-space: nowrap;
  text-align: center;
  transition: all .2s;
}
.order-btn.on {
  background: rgba(10, 132, 255, 0.15);
  color: var(--blue);
  border-color: rgba(10, 132, 255, 0.3);
}
.cv-hero {
  padding: 16px;
  background: linear-gradient(145deg, #1C1C1E, #000000);
  border-bottom: 0.5px solid var(--border);
}
.cv-tag {
  font-weight: 600;
  font-size: .55rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--blue);
  margin-bottom: 6px;
}
.cv-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 4px; }
.cv-meta { font-size: .65rem; color: var(--muted); margin-bottom: 14px; }
.cv-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.cv-stat {
  background: rgba(255,255,255,0.05);
  border: 0.5px solid rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
}
.cv-stat__val { font-family: var(--mono); font-size: 1rem; font-weight: 700; color: var(--white); }
.cv-stat__lbl { font-size: .55rem; color: var(--muted); margin-top: 2px; font-weight: 500;}

.timeline {
  padding: 6px 0;
}
.tl-title {
  font-size: .6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 12px;
}
.tl-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  padding-bottom: 12px;
  position: relative;
}
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: '';
  position: absolute;
  left: 11px;
  top: 14px;
  bottom: 0;
  width: 1px;
  background: var(--border2);
}
.tl-item:last-child::before { display: none; }
.tl-dot-wrap { display: flex; justify-content: center; padding-top: 3px; z-index: 1; }
.tl-dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--surface-solid); }
.tl-step { font-size: .7rem; font-weight: 500; }
.tl-meta { font-size: .6rem; color: var(--muted); margin-top: 2px; }
.tl-badge {
  display: inline-block;
  font-size: .55rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
  margin-left: 6px;
  vertical-align: middle;
}

.notifs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
.notif {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: .65rem;
  border: 0.5px solid;
}
.notif-green { background: rgba(50,215,75,0.05); border-color: rgba(50,215,75,0.2); }
.notif-yellow { background: rgba(255,214,10,0.05); border-color: rgba(255,214,10,0.2); }
.notif__icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.notif-green .notif__icon { background: var(--green); }
.notif-yellow .notif__icon { background: var(--yellow); }
.notif__time { font-family: var(--mono); color: var(--muted); font-size: .55rem; margin-top: 4px; }

/* --- STATUS BAR --- */
.statusbar {
  height: 28px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-top: 0.5px solid var(--border);
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: 0.01em;
  color: var(--muted);
  overflow: hidden;
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
}
.statusbar-scroll {
  display: flex;
  align-items: center;
  animation: scrollText 40s linear infinite;
  /* keep rendering on the CPU so the text stays crisp instead of being
     rasterized to a GPU texture and bilinearly interpolated each frame */
}
@keyframes scrollText {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.sb-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 22px;
  font-weight: 500;
}
.sb-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* --- BOTTOM NAV --- */
.bottom-nav {
  height: 60px;
  border-top: 0.5px solid var(--border);
  display: flex;
  z-index: 50;
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: .65rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all .2s;
}
.bottom-nav-item.active {
  color: var(--blue);
}
.bottom-nav-item svg {
  width: 20px;
  height: 20px;
  transition: transform .2s;
}
.bottom-nav-item.active svg {
  transform: translateY(-2px);
}

@media (max-width: 720px) {
  .topbar { height: 46px; padding-inline: 10px; }
  .topbar__name { font-size: .78rem; }
  .clock { display: none; }
  .zone-carousel { gap: 6px; padding: 8px; }
  .zone-btn { flex-basis: calc(33.333% - 6px); padding: 6px 7px; font-size: .58rem; }
  .canvas-inner-wrap { min-height: 230px; }
  .alert-stack { right: 8px; bottom: 8px; max-width: min(210px, calc(100% - 16px)); }
  .alert { padding: 8px 10px; }
  .cv-stats { grid-template-columns: repeat(2, 1fr); }
  .order-selector { gap: 6px; padding: 8px; }
  .order-btn { flex-basis: calc(33.333% - 6px); padding-inline: 8px; font-size: .58rem; }
  .bottom-nav { height: 56px; }
  .bottom-nav-item { font-size: .58rem; }
  .statusbar { height: 24px; font-size: .58rem; }
}

@media (max-width: 440px) {
  .topbar__mark { width: 22px; height: 22px; }
  .topbar__name { max-width: 112px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .live-pill { padding-inline: 7px; }
  .zone-btn,
  .order-btn { flex-basis: calc(50% - 6px); }
  .scroll-screen { padding: 10px; gap: 10px; }
  .pb { padding: 12px; border-radius: 12px; }
  .kpi-grid { gap: 6px; }
  .kpi { padding: 10px; }
  .kpi__val { font-size: 1.08rem; }
  .cv-title { font-size: .98rem; }
  .bottom-nav-item svg { width: 18px; height: 18px; }
}

@media (max-width: 520px) {
  html,
  body,
  .app-shell {
    min-height: 100dvh;
    height: 100dvh;
  }
  .app-shell {
    border-radius: 0;
  }
  .topbar {
    height: 42px;
    padding-inline: 9px;
  }
  .topbar__left {
    min-width: 0;
  }
  .topbar__name {
    max-width: 132px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar__right {
    gap: 6px;
  }
  .live-pill {
    font-size: .5rem;
    padding: 3px 7px;
  }
  .screen-container,
  .screen,
  .scroll-screen {
    min-height: 0;
  }
  .zone-carousel {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 7px 8px;
    gap: 6px;
    scrollbar-width: none;
  }
  .zone-btn {
    flex: 0 0 auto;
    min-width: max-content;
    padding: 6px 10px;
    font-size: .58rem;
  }
  .canvas-scroll-wrapper {
    min-height: 0;
  }
  .scroll-screen {
    padding: 8px;
    gap: 8px;
  }
  .pb {
    padding: 10px;
    border-radius: 12px;
  }
  .pb__title {
    margin-bottom: 9px;
    font-size: .68rem;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .kpi {
    min-width: 0;
    padding: 9px;
  }
  .kpi__val {
    font-size: 1rem;
  }
  .kpi__label {
    font-size: .54rem;
    line-height: 1.2;
  }
  .bars {
    height: 86px;
  }
  .ring-wrap {
    gap: 10px;
  }
  .mach-card {
    padding: 9px 10px;
  }
  .mach-name {
    font-size: .72rem;
  }
  .mach-task {
    font-size: .58rem;
  }
  .order-selector {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 7px 8px;
    gap: 6px;
    scrollbar-width: none;
  }
  .order-btn {
    flex: 0 0 auto;
    min-width: max-content;
    padding: 6px 10px;
    font-size: .56rem;
  }
  .cv-hero {
    padding: 14px;
    border-radius: 14px;
  }
  .cv-title {
    font-size: .95rem;
    line-height: 1.15;
  }
  .cv-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  .cv-stat {
    min-width: 0;
    padding: 8px;
  }
  .statusbar {
    display: none;
  }
  .bottom-nav {
    height: 54px;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav-item {
    gap: 3px;
    font-size: .52rem;
  }
  .bottom-nav-item svg {
    width: 17px;
    height: 17px;
  }
}
