/* dt airtwin – gemeinsames Designsystem (Markenfarben dt druckluft technik) */
:root {
  --navy: #002855;
  --navy-700: #0a3a70;
  --navy-600: #154a88;
  --navy-50: #eef3f9;
  --amber: #ffb81c;
  --amber-600: #e09e00;
  --amber-50: #fff6e0;
  --gray-900: #1c2733;
  --gray-700: #4f5b5f;
  --gray-500: #7c878e;
  --gray-300: #c9d0d6;
  --gray-200: #e3e7ec;
  --gray-100: #f1f3f6;
  --cream: #fefbf5;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: var(--gray-900);
  --muted: var(--gray-700);
  --border: var(--gray-200);
  --ok: #1f8a5b;
  --ok-bg: #e5f5ee;
  --due: #b86e00;
  --due-bg: #fff1d6;
  --warn: #c2410c;
  --warn-bg: #ffeadf;
  --fault: #c62828;
  --fault-bg: #fde7e7;
  --info: #1d5fb8;
  --info-bg: #e6effb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0, 40, 85, 0.06);
  --shadow: 0 1px 3px rgba(0, 40, 85, 0.08), 0 8px 24px rgba(0, 40, 85, 0.06);
  --shadow-lg: 0 20px 60px rgba(0, 20, 50, 0.25);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--navy-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; color: var(--navy); }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
svg.i { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.grid > *, .cols > *, .stack > * { min-width: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12px; }
.nowrap { white-space: nowrap; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: grid; gap: 16px; align-content: start; }
.stack-sm { display: grid; gap: 8px; align-content: start; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -0.02em; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--amber); color: var(--navy); display: grid; place-items: center; font-weight: 800; font-size: 15px; flex: none; }
.brand small { display: block; font-weight: 500; font-size: 11px; letter-spacing: 0.02em; opacity: 0.75; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 8px 14px; font-weight: 600; cursor: pointer; background: var(--navy); color: #fff; transition: background 0.15s, box-shadow 0.15s, transform 0.05s; text-decoration: none !important; white-space: nowrap; min-height: 38px; }
.btn:hover { background: var(--navy-700); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--surface); color: var(--navy); border-color: var(--gray-300); }
.btn.secondary:hover { background: var(--navy-50); }
.btn.accent { background: var(--amber); color: var(--navy); }
.btn.accent:hover { background: var(--amber-600); }
.btn.danger { background: var(--fault); }
.btn.ghost { background: transparent; color: var(--navy); }
.btn.ghost:hover { background: var(--navy-50); }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn.lg { padding: 12px 20px; min-height: 48px; font-size: 15px; }
.btn.block { width: 100%; }
.btn svg { width: 16px; height: 16px; flex: none; }
.icon-btn { border: 0; background: transparent; cursor: pointer; width: 36px; height: 36px; border-radius: 8px; display: inline-grid; place-items: center; color: inherit; }
.icon-btn:hover { background: rgba(0, 40, 85, 0.08); }
.icon-btn svg { width: 20px; height: 20px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { flex: 1; }
.card-body { padding: 16px 20px; }
.card.clickable { cursor: pointer; transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s; }
.card.clickable:hover { box-shadow: var(--shadow); border-color: var(--gray-300); transform: translateY(-1px); }

/* KPI */
.kpi { padding: 18px 20px; display: grid; gap: 4px; }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi .value { font-size: 28px; font-weight: 750; color: var(--navy); letter-spacing: -0.02em; line-height: 1.1; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.accent { border-left: 4px solid var(--amber); }
.kpi .value.bad { color: var(--fault); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 10px; background: var(--gray-100); color: var(--gray-700); white-space: nowrap; line-height: 20px; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.9; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.due { background: var(--due-bg); color: var(--due); }
.badge.warning { background: var(--warn-bg); color: var(--warn); }
.badge.fault { background: var(--fault-bg); color: var(--fault); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.navy { background: var(--navy); color: #fff; }
.badge.amber { background: var(--amber-50); color: #8a5a00; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ok { background: var(--ok); } .dot.due { background: var(--amber); } .dot.warning { background: var(--warn); } .dot.fault { background: var(--fault); box-shadow: 0 0 0 4px var(--fault-bg); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(198, 40, 40, 0.12); } }

/* Tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 10px 16px; border-bottom: 1px solid var(--border); background: #fafbfc; white-space: nowrap; }
table.data td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover td { background: var(--navy-50); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-title { font-weight: 600; color: var(--navy); }
.cell-sub { font-size: 12px; color: var(--muted); }

/* Forms */
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--gray-700); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); padding: 9px 12px; background: #fff; min-height: 40px; }
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { outline: none; border-color: var(--navy-600); box-shadow: 0 0 0 3px rgba(21, 74, 136, 0.18); }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--gray-500); }
.search .input { padding-left: 34px; }

/* Segmented control / choice tiles */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.choice { border: 1.5px solid var(--gray-300); border-radius: var(--radius-sm); padding: 12px; cursor: pointer; background: #fff; text-align: left; display: grid; gap: 4px; }
.choice strong { color: var(--navy); }
.choice span { font-size: 12px; color: var(--muted); }
.choice[aria-pressed='true'] { border-color: var(--navy); background: var(--navy-50); box-shadow: inset 0 0 0 1px var(--navy); }
.choice svg { width: 22px; height: 22px; color: var(--navy); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--navy); }
.tab[aria-selected='true'] { color: var(--navy); border-bottom-color: var(--amber); }
.tab .count { font-size: 11px; background: var(--gray-100); border-radius: 999px; padding: 1px 7px; margin-left: 4px; }

/* Definition list */
dl.specs { display: grid; grid-template-columns: minmax(120px, 42%) 1fr; margin: 0; }
dl.specs dt, dl.specs dd { padding: 8px 0; border-bottom: 1px solid var(--border); margin: 0; }
dl.specs dt { color: var(--muted); font-size: 13px; }
dl.specs dd { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; }
.timeline li::before { content: ''; position: absolute; left: 4px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--navy); }
.timeline li::after { content: ''; position: absolute; left: 8px; top: 18px; bottom: 0; width: 1px; background: var(--gray-300); }
.timeline li:last-child::after { display: none; }
.timeline li:last-child::before { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-50); }
.timeline .meta { font-size: 12px; color: var(--muted); }

/* List items */
.list { display: grid; }
.list-item { display: flex; gap: 12px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { background: var(--navy-50); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--navy-50); color: var(--navy); flex: none; }
.item-icon svg { width: 20px; height: 20px; }
.item-icon.amber { background: var(--amber-50); color: #8a5a00; }
.item-icon.fault { background: var(--fault-bg); color: var(--fault); }
.item-icon.ok { background: var(--ok-bg); color: var(--ok); }

/* Empty */
.empty { padding: 32px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 36px; height: 36px; color: var(--gray-300); margin-bottom: 8px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 20, 45, 0.5); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade 0.15s; backdrop-filter: blur(2px); }
.modal { background: #fff; border-radius: 16px; width: min(640px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: rise 0.2s; }
.modal.wide { width: min(880px, 100%); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { flex: 1; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--border); background: #fafbfc; border-radius: 0 0 16px 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(0.98); } }

/* Toast */
.toasts { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 200; }
.toast { background: var(--navy); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center; animation: rise 0.2s; max-width: 380px; }
.toast svg { width: 18px; height: 18px; color: var(--amber); flex: none; }

/* Progress bar */
.bar { height: 8px; border-radius: 999px; background: var(--gray-100); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--navy); border-radius: 999px; }
.bar.amber > span { background: var(--amber); }
.bar.fault > span { background: var(--fault); }

/* QR */
.qr-box { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px; display: inline-grid; place-items: center; }
.qr-box img { width: 140px; height: 140px; display: block; }

@media (max-width: 640px) {
  .card-pad, .card-body { padding: 14px; }
  .card-head { padding: 14px; }
  .kpi .value { font-size: 22px; }
  .list-item { padding: 12px 14px; }
  table.data th, table.data td { padding: 10px 12px; }
  .toasts { left: 16px; right: 16px; bottom: 16px; }
}

/* Digitaler Zwilling */
.twin { position: relative; width: 100%; height: 100%; min-height: 320px; overflow: hidden; background: radial-gradient(ellipse at 50% 30%, #ffffff 0%, #e6ebf1 70%, #d7dee6 100%); border-radius: var(--radius); }
.twin canvas { display: block; touch-action: none; cursor: grab; }
.twin-labels { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.twin-label { position: absolute; left: 0; top: 0; pointer-events: auto; display: flex; gap: 6px; align-items: center; background: rgba(255, 255, 255, 0.94); border: 1px solid var(--gray-200); border-radius: 8px; padding: 3px 8px 3px 6px; font-size: 11px; line-height: 1.2; box-shadow: 0 2px 8px rgba(0, 30, 60, 0.12); cursor: pointer; white-space: nowrap; text-align: left; color: var(--gray-900); transition: background 0.15s, box-shadow 0.15s; }
.twin-label strong { display: block; color: var(--navy); font-size: 11.5px; }
.twin-label small { display: block; color: var(--muted); font-size: 10px; }
.twin-label .dot { width: 8px; height: 8px; }
.twin-label:hover { box-shadow: 0 4px 14px rgba(0, 30, 60, 0.2); }
.twin-label.selected { background: var(--navy); border-color: var(--navy); }
.twin-label.selected strong { color: #fff; }
.twin-label.selected small { color: rgba(255, 255, 255, 0.7); }
.twin-label::after { content: ''; position: absolute; left: 50%; bottom: -5px; width: 8px; height: 8px; background: inherit; border-right: 1px solid var(--gray-200); border-bottom: 1px solid var(--gray-200); transform: translateX(-50%) rotate(45deg); }
.twin-label.selected::after { border-color: var(--navy); }
.twin-toolbar { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; z-index: 5; flex-wrap: wrap; }
.twin-toolbar .btn { box-shadow: var(--shadow-sm); }
.twin-legend { position: absolute; bottom: 12px; left: 12px; display: flex; gap: 12px; background: rgba(255, 255, 255, 0.9); border-radius: 8px; padding: 6px 10px; font-size: 11px; color: var(--muted); z-index: 5; flex-wrap: wrap; }
.twin-legend span { display: inline-flex; gap: 5px; align-items: center; }
.twin-legend .dot { width: 8px; height: 8px; }
.twin-legend .dot.fault { animation: none; box-shadow: none; }
.twin-hint { position: absolute; bottom: 12px; right: 12px; font-size: 11px; color: var(--muted); background: rgba(255, 255, 255, 0.85); padding: 4px 8px; border-radius: 6px; z-index: 5; }
@media (max-width: 640px) { .twin-hint { display: none; } }
