/* Druckdienst – Designsystem
   Arbeitsfläche ruhig und papierhell, Akzent Prozess-Cyan. Die Vorschau ist das einzige laute Element. */

@font-face {
  font-family: "Geist";
  src: url("/static/fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --canvas: #F6F6F4;
  --surface: #FFFFFF;
  --paper: #FFFFFF;          /* Icons & Blätter */
  --sheet: #FFFFFF;          /* echtes Papier – auch im Dunkelmodus weiß */
  --stage: #ECECE8;
  --stage-dot: #D9D8D3;
  --ink: #24231F;
  --ink-2: #4D4C47;
  --muted: #7A7975;
  --line: #E7E6E2;
  --line-strong: #D5D4CF;
  --hover: #F1F1EE;
  --accent: #0A7CC1;
  --accent-hover: #0869A4;
  --accent-soft: #E7F2FA;
  --accent-ink: #FFFFFF;
  --ok: #2B7A4E; --ok-soft: #E8F3EC;
  --warn: #9A6200; --warn-soft: #FAF0DC;
  --err: #C2413B; --err-soft: #FBEBE9;
  --cyan: #00A3E0; --magenta: #D6247A; --yellow: #F2C200; --key: #2B2A27;
  --r-sm: 6px; --r: 9px; --r-lg: 14px;
  --shadow-pop: 0 1px 2px rgba(36, 35, 31, .06), 0 8px 28px rgba(36, 35, 31, .12);
  --shadow-sheet: 0 1px 1px rgba(30, 28, 20, .08), 0 3px 6px rgba(30, 28, 20, .06), 0 18px 40px -8px rgba(30, 28, 20, .22);
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #1B1B19; --surface: #232320; --paper: #2C2C29; --stage: #141413; --stage-dot: #2A2A27;
    --ink: #ECEBE7; --ink-2: #C9C8C3; --muted: #9B9A95; --line: #33322F; --line-strong: #44433F; --hover: #2B2B28;
    --accent: #3FA4E4; --accent-hover: #62B5EA; --accent-soft: #15324A; --accent-ink: #08121B;
    --ok: #6CCB94; --ok-soft: #173325; --warn: #E9B64F; --warn-soft: #3A2E12; --err: #F08A84; --err-soft: #3B1D1B;
    --key: #ECEBE7;
    --shadow-pop: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .5);
    --shadow-sheet: 0 2px 4px rgba(0, 0, 0, .4), 0 22px 48px -8px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

/* ------------------------------------------------------------ Basis */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--canvas); color: var(--ink);
  font: 400 15px/1.5 var(--font); font-feature-settings: "ss01", "tnum" 0;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.012em; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code { font-size: .9em; background: var(--hover); padding: 1px 5px; border-radius: 4px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ic { width: 18px; height: 18px; flex: none; }
.ic-xl { width: 26px; height: 26px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.help { font-size: 13px; color: var(--muted); margin-top: 6px; }
.help.is-error { color: var(--err); }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ Scrollbalken
   Webkit/Blink: gestaltet über ::-webkit-scrollbar. Die Standard-Eigenschaften
   (scrollbar-width/-color) nur für Firefox setzen – Chrome ignoriert sonst das Styling. */
:root { --sb-thumb: color-mix(in srgb, var(--ink) 22%, transparent); --sb-thumb-hover: color-mix(in srgb, var(--ink) 42%, transparent); }
.thumbs::-webkit-scrollbar, .panel::-webkit-scrollbar, .table-wrap::-webkit-scrollbar { width: 12px; height: 12px; }
.thumbs::-webkit-scrollbar-track, .panel::-webkit-scrollbar-track, .table-wrap::-webkit-scrollbar-track { background: transparent; }
.thumbs::-webkit-scrollbar-thumb, .panel::-webkit-scrollbar-thumb, .table-wrap::-webkit-scrollbar-thumb {
  background-color: var(--sb-thumb); border-radius: 99px;
  border: 4px solid transparent; background-clip: padding-box;   /* wirkt 4 px dünn, Greiffläche bleibt 12 px */
}
.thumbs::-webkit-scrollbar-thumb:hover, .panel::-webkit-scrollbar-thumb:hover, .table-wrap::-webkit-scrollbar-thumb:hover {
  background-color: var(--sb-thumb-hover); border-width: 3px;
}
.thumbs::-webkit-scrollbar-thumb:active, .table-wrap::-webkit-scrollbar-thumb:active { background-color: var(--accent); border-width: 3px; }
.thumbs::-webkit-scrollbar-button, .panel::-webkit-scrollbar-button, .table-wrap::-webkit-scrollbar-button { display: none; }
.thumbs::-webkit-scrollbar-track:horizontal { margin: 0 14px; }
.panel::-webkit-scrollbar-track:vertical { margin: 10px 0; }
@supports not selector(::-webkit-scrollbar) {
  .thumbs, .panel, .table-wrap { scrollbar-width: thin; scrollbar-color: var(--sb-thumb) transparent; }
}

/* ------------------------------------------------------------ Buttons & Eingaben */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--r); border: 1px solid transparent;
  font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s, opacity .15s;
}
.btn:hover { text-decoration: none; }
.btn-lg { height: 46px; padding: 0 18px; font-size: 15px; border-radius: 10px; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 6px; }
.btn-sm .ic { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { background: var(--hover); }
.btn-danger-soft { background: var(--err-soft); color: var(--err); }
.btn-danger-soft:hover { filter: brightness(.97); }
.btn-text { background: none; border: 0; padding: 2px 0; color: var(--accent); cursor: pointer; font-size: 13px; font-weight: 500; }
.btn-text:hover { text-decoration: underline; text-underline-offset: 3px; }
.btn-text.danger { color: var(--err); }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px;
  background: none; border: 0; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.btn-chip {
  white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px;
  border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 13px; font-weight: 500; cursor: pointer;
}
.btn-chip .ic { width: 15px; height: 15px; }
.btn-chip:hover { background: var(--hover); }

input[type=text], input[type=password], input[type=number], input:not([type]) {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--muted); opacity: .8; }
input:hover { border-color: var(--muted); }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[aria-invalid=true] { border-color: var(--err); box-shadow: 0 0 0 3px var(--err-soft); }
.field label { display: block; font-weight: 500; font-size: 14px; margin-bottom: 6px; }
.field input { height: 46px; font-size: 16px; border-radius: 10px; }
.stack { display: grid; gap: 18px; }

/* ------------------------------------------------------------ App-Leiste */
.app-bar {
  position: sticky; top: 0; z-index: 20; height: 56px;
  display: flex; align-items: center; gap: 20px; padding: 0 20px;
  background: color-mix(in srgb, var(--canvas) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 600; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.logo { width: 24px; height: 24px; color: var(--ink); }
.brand-tag { font-weight: 500; color: var(--muted); padding-left: 9px; border-left: 1px solid var(--line-strong); }
.app-bar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 11px 0 9px;
  border-radius: 99px; font-size: 13px; font-weight: 500;
}
.pill .pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.user-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
.avatar {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: var(--canvas); font-size: 12px; font-weight: 600;
}
.user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs { display: flex; gap: 2px; }
.tabs a { padding: 6px 11px; border-radius: 7px; color: var(--ink-2); font-weight: 500; font-size: 14px; }
.tabs a:hover { background: var(--hover); text-decoration: none; }
.tabs a[aria-current=page] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }

/* ------------------------------------------------------------ Arbeitsbereich */
.workspace {
  max-width: 1280px; margin: 0 auto; padding: 20px;
  display: grid; grid-template-columns: minmax(0, 1fr) 392px; gap: 20px; align-items: start;
}

/* --- Bühne / Vorschau */
.stage {
  position: relative; min-height: 0; height: min(calc(100vh - 96px), 820px); min-height: 520px;
  border-radius: var(--r-lg); background-color: var(--stage);
  background-image: radial-gradient(var(--stage-dot) 1px, transparent 1.2px);
  background-size: 18px 18px; background-position: 9px 9px;
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--line);
  transition: box-shadow .15s;
}
.stage.dragging { box-shadow: inset 0 0 0 2px var(--accent); }

.dropzone {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; cursor: pointer; padding: 24px; text-align: center;
}
.drop-sheet {
  width: 150px; height: 212px; margin-bottom: 18px; border-radius: 3px;
  display: grid; place-items: center; color: var(--muted);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border: 1.5px dashed var(--line-strong);
  transition: transform .25s cubic-bezier(.2, .7, .2, 1), border-color .2s, color .2s;
}
.dropzone:hover .drop-sheet, .stage.dragging .drop-sheet { border-color: var(--accent); color: var(--accent); transform: translateY(-4px); }
.dropzone:has(input:focus-visible) .drop-sheet { outline: 2px solid var(--accent); outline-offset: 4px; }
.drop-title { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.drop-sub { color: var(--muted); font-size: 14px; }
.linkish { color: var(--accent); font-weight: 500; }

.preview { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.file-bar {
  display: flex; align-items: center; gap: 10px; margin: 12px 12px 0; padding: 8px 8px 8px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
}
.file-ic { color: var(--accent); }
.file-info { min-width: 0; flex: 1; }
.file-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.viewport {
  flex: 1; min-height: 0; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  perspective: 1800px;
}
.sheet-stack { position: relative; transition: width .35s cubic-bezier(.2, .7, .2, 1), height .35s cubic-bezier(.2, .7, .2, 1); }
.stack-shadow {
  position: absolute; inset: 0; background: var(--sheet); border-radius: 2px;
  box-shadow: 0 1px 2px rgba(30, 28, 20, .12); opacity: 0; transition: opacity .2s, transform .25s;
}
.sheet-stack[data-copies="2"] .s1, .sheet-stack[data-copies="3"] .s1 { opacity: 1; transform: translate(7px, 7px); }
.sheet-stack[data-copies="3"] .s2 { opacity: 1; transform: translate(14px, 14px); }
.sheet {
  position: absolute; inset: 0; transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.3, .7, .2, 1);
}
.sheet.duplex { cursor: pointer; }
.sheet.flipped { transform: rotateY(180deg); }
.sheet.axis-x.flipped { transform: rotateX(180deg); }
.face {
  position: absolute; inset: 0; background: var(--sheet); border-radius: 2px;
  display: grid; place-items: center; box-shadow: var(--shadow-sheet);
  backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden;
}
.face.back { transform: rotateY(180deg); }
.sheet.axis-x .face.back { transform: rotateX(180deg); }
.sheet:not(.duplex) .face.back { display: none; }
.face canvas { display: block; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); transition: filter .35s; }
.face-empty { display: none; color: #A3A29C; font-size: 13px; }
.face.is-empty canvas { display: none; }
.face.is-empty .face-empty { display: block; }
.stage.mono canvas { filter: grayscale(1) contrast(1.02); }
.copies-badge {
  position: absolute; top: -12px; right: -14px; z-index: 2;
  padding: 3px 9px; border-radius: 99px; background: var(--ink); color: var(--canvas);
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; box-shadow: var(--shadow-pop);
}
.paper-label {
  position: absolute; bottom: 10px; left: 0; right: 0; text-align: center;
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
}

.sheet-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 12px 8px; }
.nav-center { display: flex; align-items: center; gap: 12px; }
.nav-text { white-space: nowrap; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.thumbs-head {
  display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px 0;
  border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 70%, transparent);
  font-size: 13px; font-weight: 600;
}
.thumbs-hint { font-weight: 400; color: var(--muted); }
.thumbs {
  display: flex; gap: 10px; overflow-x: auto; padding: 10px 14px 14px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);

}
.thumbs { cursor: grab; user-select: none; -webkit-user-select: none; }
.thumbs.grabbing { cursor: grabbing; }
.thumbs.grabbing .thumb-view { pointer-events: none; }
.thumb { flex: none; position: relative; display: grid; justify-items: center; gap: 4px; }
.thumb-view { padding: 0; border: 0; background: none; cursor: inherit; border-radius: 3px; }
.thumb canvas {
  display: block; height: 92px; min-width: 64px; background: var(--sheet); border-radius: 2px;
  box-shadow: 0 0 0 1px var(--line-strong), 0 2px 5px rgba(30, 28, 20, .08);
  transition: box-shadow .15s, opacity .15s, filter .35s;
  -webkit-user-drag: none;
}
.thumb:not(.ready) canvas { width: 65px; }
.thumb-view:hover canvas { box-shadow: 0 0 0 1px var(--muted), 0 4px 10px rgba(30, 28, 20, .12); }
.thumb.current canvas { box-shadow: 0 0 0 2px var(--accent), 0 2px 6px rgba(30, 28, 20, .1); }
.thumb.off canvas { opacity: .35; }
.thumb-check {
  position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; padding: 0;
  display: grid; place-items: center; border-radius: 50%; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); border: 1.5px solid var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18); transition: background-color .12s, border-color .12s, transform .12s;
}
.thumb-check .ic { width: 13px; height: 13px; stroke-width: 2.6; }
.thumb-check[aria-pressed=false] { background: rgba(255, 255, 255, .92); border-color: #A9A8A2; color: transparent; }
.thumb-check:hover { transform: scale(1.08); }
.thumb-num { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.thumb.current .thumb-num { color: var(--accent); font-weight: 600; }

/* --- Einstellungs-Panel */
.panel {
  position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 2px 18px 0; display: flex; flex-direction: column;
}
.group { border: 0; margin: 0; padding: 13px 0 14px; min-width: 0; border-bottom: 1px solid var(--line); }
.group:has(+ .print-bar) { border-bottom: 0; }
.group.two-col { display: grid; grid-template-columns: 1fr 132px; gap: 14px; }
.sub { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { float: left; width: 100%; padding: 0; margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
legend ~ * { clear: both; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 99px;
  border: 1px solid var(--line-strong); font-size: 13px; font-weight: 500; color: var(--ink-2);
  cursor: pointer; transition: background-color .15s, border-color .15s, color .15s;
}
.chip span:hover { background: var(--hover); }
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--canvas); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.tile {
  position: relative; display: grid; justify-items: center; align-content: center; gap: 2px;
  padding: 10px 8px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface);
  cursor: pointer; text-align: center; transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.tile input { position: absolute; opacity: 0; pointer-events: none; }
.tile:hover { background: var(--hover); }
.tile:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.tile:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile:has(input:disabled) { opacity: .4; cursor: not-allowed; background: var(--surface); }
.tile-title { font-size: 14px; font-weight: 600; }
.tile-sub { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1.3; }
.tile:has(input:checked) .tile-title { color: var(--accent); }

.formats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.format-tile { padding: 9px 6px 8px; }
.paper-glyph {
  height: 34px; display: flex; align-items: flex-end; justify-content: center; margin-bottom: 5px;
}
.paper-glyph::before {
  content: ""; display: block; background: var(--paper); border: 1.5px solid var(--ink-2); border-radius: 2px;
  background-image: linear-gradient(var(--line-strong), var(--line-strong)), linear-gradient(var(--line-strong), var(--line-strong)), linear-gradient(var(--line-strong), var(--line-strong));
  background-size: 60% 1.5px, 60% 1.5px, 38% 1.5px; background-repeat: no-repeat;
  background-position: 50% 26%, 50% 42%, 32% 58%;
  transition: border-color .15s;
}
.paper-glyph.fmt-A5::before { width: 16px; height: 23px; }
.paper-glyph.fmt-A4::before { width: 20px; height: 28px; }
.paper-glyph.fmt-A3::before { width: 24px; height: 34px; }
.paper-glyph.fmt-A3 { transform: none; }
.paper-glyph.fmt-Letter::before { width: 30px; height: 39px; }
.tile:has(input:checked) .paper-glyph::before { border-color: var(--accent); }

.segmented { display: grid; gap: 8px; }
.segmented.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.segmented.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row-tile {
  /* Symbol und Beschriftung links bündig – in jeder Kachel an derselben Position. */
  --icw: 34px;
  grid-template-columns: var(--icw) minmax(0, 1fr); justify-items: start; align-items: center;
  gap: 10px; padding: 9px 14px; min-width: 0; text-align: left;
}
.row-tile > .tile-title { line-height: 1.25; }
.row-tile:has(.scale-ic) { --icw: 22px; }
.swatch { display: inline-flex; align-items: center; }
.swatch i { width: 14px; height: 14px; border-radius: 50%; display: block; margin-left: -5px; box-shadow: 0 0 0 1.5px var(--surface); }
.swatch i:first-child { margin-left: 0; }
.swatch.mono i:nth-child(1) { background: #2B2A27; }
.swatch.mono i:nth-child(2) { background: #8C8B86; }
.swatch.mono i:nth-child(3) { background: #D3D2CD; }
.swatch.cmy i:nth-child(1) { background: var(--cyan); }
.swatch.cmy i:nth-child(2) { background: var(--magenta); }
.swatch.cmy i:nth-child(3) { background: var(--yellow); }
.tile:has(input:checked) .swatch i { box-shadow: 0 0 0 1.5px var(--accent-soft); }
.orient-tile { padding: 10px 4px 9px; }
.orient-glyph { position: relative; height: 30px; width: 40px; display: grid; place-items: center; margin-bottom: 5px; }
.orient-glyph i { display: block; background: var(--paper); border: 1.5px solid var(--ink-2); border-radius: 2px; }
.orient-glyph.portrait i { width: 19px; height: 26px; }
.orient-glyph.landscape i { width: 30px; height: 21px; }
.orient-glyph.auto i { position: absolute; }
.orient-glyph.auto i:first-child { width: 17px; height: 23px; left: 6px; top: 1px; }
.orient-glyph.auto i:last-child { width: 24px; height: 17px; right: 3px; bottom: 1px; }
.tile:has(input:checked) .orient-glyph i { border-color: var(--accent); }
.scale-ic { width: 22px; height: 22px; color: var(--ink-2); flex: none; }
.tile:has(input:checked) .scale-ic { color: var(--accent); }
#scale-info.is-warn { color: var(--warn); }
.mode-ic { width: 34px; height: 27px; color: var(--ink-2); flex: none; }
.tile:has(input:checked) .mode-ic { color: var(--accent); }
.tile-text { display: grid; text-align: left; line-height: 1.25; }
.duplex-tile { align-content: start; padding: 9px 6px 8px; }
.duplex-ic { width: 36px; height: 29px; color: var(--ink-2); margin-bottom: 3px; }
.tile:has(input:checked) .duplex-ic { color: var(--accent); }

.range-field { position: relative; }
.range-field input { padding-right: 52px; font-variant-numeric: tabular-nums; }
.range-field .btn-text { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
.stepper {
  display: grid; grid-template-columns: 36px 1fr 36px; height: 40px;
  border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; background: var(--surface);
}
.stepper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stepper .step { border: 0; background: none; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.stepper .step:hover { background: var(--hover); color: var(--ink); }
.stepper .step .ic { width: 16px; height: 16px; }
.stepper input {
  height: 100%; border: 0; border-radius: 0; text-align: center; padding: 0; font-weight: 600;
  font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; box-shadow: none !important;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.print-bar {
  position: sticky; bottom: 0; margin: auto -18px 0; padding: 14px 18px 18px; display: grid; gap: 10px;
  background: var(--surface); border-top: 1px solid var(--line);
}
.summary { display: grid; gap: 2px; }
.sum-main { font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.sum-sub { font-size: 13px; color: var(--muted); }
.btn-print { width: 100%; }
.btn-print.busy { cursor: progress; }
.upload-progress { height: 4px; border-radius: 99px; background: var(--hover); overflow: hidden; }
.upload-progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }

/* ------------------------------------------------------------ Aufträge */
.jobs-section { max-width: 1280px; margin: 8px auto 64px; padding: 0 20px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.jobs { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.jobs-empty { padding: 28px 20px; color: var(--muted); text-align: center; font-size: 14px; }
.job { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 16px; }
.job + .job { border-top: 1px solid var(--line); }
.job.changed { animation: job-flash 1.6s ease-out; }
@keyframes job-flash { from { background: var(--accent-soft); } to { background: transparent; } }
.job-glyph {
  justify-self: center; width: 24px; height: 32px; border-radius: 2px; background: var(--paper);
  border: 1.5px solid var(--line-strong); display: grid; align-content: start; gap: 3px; padding: 6px 4px;
}
.job-glyph.fmt-A3 { width: 26px; height: 36px; }
.job-glyph.fmt-A5 { width: 20px; height: 28px; }
.job-glyph span { height: 2px; border-radius: 1px; background: var(--line-strong); }
.job-glyph span:last-child { width: 60%; }
.job-glyph.color span:nth-child(1) { background: var(--cyan); }
.job-glyph.color span:nth-child(2) { background: var(--magenta); }
.job-glyph.color span:nth-child(3) { background: var(--yellow); }
.job-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-meta { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.job-error { font-size: 13px; color: var(--err); margin-top: 2px; }
.job-side { display: flex; align-items: center; gap: 14px; }
.job-time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; }
.job[data-status=done] .job-title, .job[data-status=cancelled] .job-title, .job[data-status=expired] .job-title { color: var(--ink-2); }

.status {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 99px;
  font-size: 12.5px; font-weight: 500; white-space: nowrap; background: var(--hover); color: var(--ink-2);
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.s-queued { background: var(--accent-soft); color: var(--accent); }
.status.s-printing { background: var(--warn-soft); color: var(--warn); }
.status.s-printing::before { animation: blink 1.2s ease-in-out infinite; }
.status.s-done { background: var(--ok-soft); color: var(--ok); }
.status.s-error { background: var(--err-soft); color: var(--err); }
.status.s-cancelled::before, .status.s-expired::before { background: var(--muted); }
@keyframes blink { 50% { opacity: .25; } }

/* ------------------------------------------------------------ Toasts */
.toasts {
  position: fixed; z-index: 50; right: 20px; bottom: 20px; display: grid; gap: 8px;
  width: min(380px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow-pop);
  font-size: 14px; cursor: pointer; animation: toast-in .28s cubic-bezier(.2, .8, .2, 1);
}
.toast .ic { margin-top: 1px; }
.toast.ok .ic { color: var(--ok); }
.toast.error .ic { color: var(--err); }
.toast.leaving { animation: toast-out .2s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ------------------------------------------------------------ Anmeldung */
body.auth { min-height: 100vh; }
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-wrap.single { grid-template-columns: 1fr; place-items: center; padding: 24px; }
.auth-art {
  background-color: var(--stage);
  background-image: radial-gradient(var(--stage-dot) 1px, transparent 1.2px);
  background-size: 18px 18px; display: grid; place-items: center; overflow: hidden;
  border-right: 1px solid var(--line);
}
.sheet-fan { position: relative; width: 340px; height: 420px; }
.fan-sheet {
  position: absolute; background: var(--sheet); border-radius: 2px; box-shadow: var(--shadow-sheet);
  display: grid; align-content: start; gap: 9px; padding: 9% 10%;
}
.fan-sheet span { height: 6px; border-radius: 3px; background: #E4E3DE; }
.fan-sheet span.short { width: 55%; }
.fan-sheet span.accent { background: var(--cyan); width: 70%; }
.fan-sheet.a3 { width: 250px; height: 354px; left: 10px; top: 20px; transform: rotate(-7deg); }
.fan-sheet.a3 span:first-child { height: 34%; height: 110px; background: linear-gradient(135deg, #CFE8F5, #F6D5E5 55%, #FBEFC0); }
.fan-sheet.a4 { width: 177px; height: 250px; left: 120px; top: 110px; transform: rotate(4deg); }
.fan-sheet.a4.gray span:first-child { height: 64px; background: linear-gradient(135deg, #D8D7D2, #B9B8B3); }
.fan-sheet.a5 { width: 125px; height: 177px; left: 40px; top: 230px; transform: rotate(-2deg); }
.auth-card { width: 100%; max-width: 400px; margin: auto; padding: 40px 24px; display: grid; gap: 10px; }
.auth-wrap.single .auth-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 32px 28px;
}
.brand-row { display: flex; align-items: center; gap: 9px; font-weight: 600; margin-bottom: 26px; }
.auth-card h1 { margin-bottom: 18px; font-size: 30px; letter-spacing: -0.025em; line-height: 1.15; }
.lede { color: var(--muted); font-size: 16px; margin-bottom: 18px; }
.auth-card .btn-lg { width: 100%; margin-top: 4px; }

/* ------------------------------------------------------------ Admin */
.admin-main { max-width: 1280px; margin: 0 auto; padding: 20px 20px 64px; display: grid; gap: 16px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }
.admin-grid.even { grid-template-columns: 1fr 1fr; }
.panel-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; min-width: 0; }
.panel-card > h2 { margin-bottom: 14px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head .btn { margin-left: auto; }
.count { font-size: 12.5px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--hover); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.empty-note { color: var(--muted); font-size: 14px; padding: 6px 0; }

.agent-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.agent-head h1 { font-size: 19px; }
.agent-dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 6px; flex: none; }
.agent-card.is-online .agent-dot { background: var(--ok); box-shadow: 0 0 0 5px var(--ok-soft); }
.agent-card.is-offline .agent-dot { background: var(--warn); box-shadow: 0 0 0 5px var(--warn-soft); }
.agent-msg { margin-top: 14px; font-size: 13px; color: var(--ink-2); padding: 8px 10px; border-radius: 8px; background: var(--hover); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px 20px; margin: 0; }
.facts dt { font-size: 12.5px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 500; font-size: 14px; overflow-wrap: anywhere; }

.cartridges { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.cartridge { margin: 0; display: grid; justify-items: center; gap: 6px; }
.cartridge svg { width: 34px; height: 90px; }
.cart-shell { fill: var(--hover); stroke: var(--line-strong); stroke-width: 1.5; }
.cartridge figcaption { display: grid; justify-items: center; font-size: 12px; color: var(--muted); line-height: 1.3; }
.cartridge strong { color: var(--ink); font-size: 13px; font-variant-numeric: tabular-nums; }
.cartridge.low strong { color: var(--err); }

.metrics {
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
}
.metric { padding: 16px 20px; display: grid; gap: 2px; }
.metric + .metric { border-left: 1px solid var(--line); }
.metric-value { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.metric-label { font-size: 13px; color: var(--muted); }
.metric.has-errors .metric-value { color: var(--err); }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bars li { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 12px; align-items: center; font-size: 13.5px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { width: 100%; height: 10px; display: block; }
.bar-track { fill: var(--hover); }
.bar-fill { fill: var(--ink-2); }
.bar-fill-color { fill: var(--accent); }
.bar-value { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 500; }

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--hover) 60%, transparent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.table .actions { text-align: right; white-space: nowrap; }
.cell-main { font-weight: 500; }
.cell-sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.cell-error { color: var(--err); max-width: 300px; }
.cell-file { max-width: 280px; overflow-wrap: anywhere; }
.tag {
  display: inline-flex; align-items: center; height: 21px; padding: 0 7px; margin: 1px 2px 1px 0;
  border-radius: 5px; border: 1px solid var(--line-strong); font-size: 12px; font-weight: 500; color: var(--ink-2);
}
.tag-warn { border-color: transparent; color: var(--warn); background: var(--warn-soft); margin-left: 6px; }
.printer-state { font-size: 13px; color: var(--ink-2); display: flex; align-items: center; flex-wrap: wrap; gap: 4px 0; }
.tag-color { border-color: transparent; color: var(--accent); background: var(--accent-soft); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input { width: 260px; height: 36px; }
.push-right { margin-left: auto; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; font-size: 13px; }

/* ------------------------------------------------------------ Responsiv */
@media (max-width: 1060px) {
  .workspace { grid-template-columns: minmax(0, 1fr) 360px; }
  .admin-grid, .admin-grid.even { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .metric:nth-child(4) { border-left: 0; }
  .metric:nth-child(n+4) { border-top: 1px solid var(--line); }
}
@media (max-width: 860px) {
  .workspace { grid-template-columns: 1fr; padding: 12px 12px 0; gap: 12px; }
  .stage { height: auto; min-height: 0; }
  .dropzone { padding: 32px 16px 36px; }
  .drop-sheet { width: 104px; height: 147px; margin-bottom: 12px; }
  .viewport { height: 56vh; min-height: 340px; flex: none; }
  .panel { position: static; max-height: none; overflow: visible; padding: 2px 16px 0; border-radius: var(--r-lg); }
  .print-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; margin: 0;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-top: 1px solid var(--line); box-shadow: 0 -6px 24px rgba(0, 0, 0, .06);
    grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 12px;
  }
  body.app { padding-bottom: 84px; }
  .sum-main { font-size: 14px; }
  .sum-sub { font-size: 12.5px; }
  .btn-print { height: 44px; }
  .upload-progress { grid-column: 1 / -1; order: -1; }
  .btn-print { width: auto; }
  .jobs-section { padding: 0 12px; margin-top: 20px; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-art { height: 200px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sheet-fan { zoom: .44; }
  .auth-card { padding: 28px 20px 40px; }
  .auth-card h1 { font-size: 26px; }
  .brand-row { margin-bottom: 16px; }
  .toasts { left: 16px; right: 16px; bottom: 88px; width: auto; }
}
@media (max-width: 520px) {
  .app-bar { padding: 0 12px; gap: 10px; }
  .user-name, .brand-tag { display: none; }
  .brand span { display: none; }
  .pill { padding: 0 10px 0 8px; }
  .thumbs-hint { display: none; }
  .nav-center { gap: 8px; }
  .nav-text { font-size: 12.5px; }
  .group.two-col { grid-template-columns: 1fr 120px; }
  .job { grid-template-columns: 26px minmax(0, 1fr); padding: 12px; gap: 10px; }
  .job-side { grid-column: 2; justify-content: flex-start; gap: 10px; }
  .job-time { text-align: left; min-width: 0; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { border-left: 0 !important; border-top: 1px solid var(--line); }
  .metric:nth-child(-n+2) { border-top: 0; }
  .metric:nth-child(even) { border-left: 1px solid var(--line) !important; }
  .bars li { grid-template-columns: 80px minmax(0, 1fr) auto; }
  .toolbar input { width: 100%; }
  .push-right { margin-left: 0; }
  .tabs a { padding: 6px 8px; }
}

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