:root {
  color-scheme: light;
  --zso-orange: #f28c00;
  --zso-orange-dark: #d97706;
  --zso-blue: #005a9c;
  --zso-blue-dark: #003b6f;
  --bg: #eef3f8;
  --fg: #172033;
  --muted: #617287;
  --card-bg: #ffffff;
  --content-bg: #ffffff;
  --surface: #f8fafc;
  --surface-hover: #e7f0fa;
  --surface-strong: #dbe8f4;
  --border: #c7d3df;
  --field-bg: #ffffff;
  --field-fg: var(--fg);
  --shadow: 0 1px 2px rgba(0,32,64,.07), 0 4px 14px rgba(0,32,64,.11);
  --accent: var(--zso-orange);
  --accent-hover: var(--zso-orange-dark);
  --accent-contrast: #172033;
  --topbar-bg: var(--zso-blue);
  --topbar-fg: #ffffff;
  --banner-bg: #064a7f;
  --banner-empty-bg: #9b5300;
  --nav-bg: #ffffff;
  --overlay-bg: rgba(0,32,64,.38);
  --primary-bg: var(--zso-blue);
  --primary-hover: var(--zso-blue-dark);
  --link: var(--zso-blue);
  --danger-bg: #fde2e2;
  --danger-fg: #7a1c1c;
  --danger-border: #e3a4a4;
  --danger-hover: #f8caca;
  --ok-bg: #defcef;
  --ok-fg: #0b5b3a;
  --header-h: 56px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1726;
  --fg: #eef5ff;
  --muted: #a9b6c6;
  --card-bg: #172235;
  --content-bg: #162236;
  --surface: #1e2c40;
  --surface-hover: #263a55;
  --surface-strong: #2e4664;
  --border: #3c5068;
  --field-bg: #101a2a;
  --field-fg: var(--fg);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 22px rgba(0,0,0,.34);
  --accent: #ff9f2e;
  --accent-hover: #f28c00;
  --accent-contrast: #111827;
  --topbar-bg: var(--zso-blue-dark);
  --banner-bg: #0a3158;
  --banner-empty-bg: #8a4b10;
  --nav-bg: #111c2c;
  --overlay-bg: rgba(0,0,0,.62);
  --primary-bg: #0072bc;
  --primary-hover: #158bd8;
  --link: #72c7ff;
  --danger-bg: #4a1f24;
  --danger-fg: #ffd7dc;
  --danger-border: #7a3038;
  --danger-hover: #61303a;
  --ok-bg: #163f32;
  --ok-fg: #c9f7e5;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--fg); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: inherit; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center;
  height: var(--header-h);
  padding: 0 .6rem;
  background: var(--topbar-bg); color: var(--topbar-fg);
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.brand {
  display: inline-flex; align-items: center;
  min-width: 0; height: calc(var(--header-h) - 14px);
  font-weight: 600; text-decoration: none; margin-left: .5rem; font-size: 1.1rem;
}
.brand-logo { display: block; max-width: min(42vw, 210px); max-height: 100%; object-fit: contain; }
.userinfo { margin-left: auto; font-size: .85rem; opacity: .9; }
.role { display: inline-block; background: var(--accent); color: var(--accent-contrast); padding: .1rem .45rem; border-radius: 3px; font-size: .75rem; margin-right: .3rem; }

.auth-form { margin: 0 0 0 .5rem; display: flex; }
.auth-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  background: rgba(255,255,255,.08);
  color: #fff; border: 0; border-radius: 50%;
  cursor: pointer; text-decoration: none;
  transition: background .15s;
}
.auth-btn:hover { background: rgba(255,255,255,.18); }
.auth-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* If there's no .userinfo content, the auth-btn still sits in the corner */
.topbar > .userinfo:empty + .auth-btn,
.topbar > .userinfo:empty + .auth-form { margin-left: auto; }

/* Hamburger */
.hamburger { background: none; border: 0; padding: .5rem; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.hamburger span { display: block; width: 22px; height: 2px; background: #fff; border-radius: 2px; transition: transform .2s, opacity .2s; }
.hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* WK context banner (only shown when logged in) */
.wk-banner {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem .8rem;
  background: var(--banner-bg); color: var(--topbar-fg);
  font-size: .85rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.wk-banner label { font-weight: 500; opacity: .85; }
.wk-banner select {
  background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.25);
  border-radius: 3px; padding: .2rem .4rem; font-size: .85rem; max-width: 100%;
}
.wk-banner select option { color: var(--field-fg); background: var(--field-bg); }
.wk-banner--empty { background: var(--banner-empty-bg); }
.wk-banner--empty a { color: #fff; text-decoration: underline; margin-left: auto; }

/* Sync info under header */
.sync-info { padding: .3rem .8rem; font-size: .75rem; color: var(--muted); text-align: center; min-height: 1.4em; }

/* Side nav */
.sidenav {
  position: fixed; top: 0; left: 0; bottom: 0; width: 280px;
  background: var(--nav-bg); box-shadow: var(--shadow);
  transform: translateX(-100%); transition: transform .25s ease;
  z-index: 40; padding: calc(var(--header-h) + .8rem) 1rem 1rem;
  overflow-y: auto;
}
.sidenav[aria-hidden="false"] { transform: translateX(0); }
.sidenav ul { list-style: none; padding: 0; margin: 0; }
.sidenav .nav-root > li { margin-bottom: .25rem; }
.sidenav a { text-decoration: none; color: var(--fg); display: block; padding: .5rem .6rem; border-radius: 6px; }
.sidenav a:hover { background: var(--surface-hover); }
.sidenav ul ul { margin-left: 1rem; border-left: 2px solid var(--surface-hover); padding-left: .3rem; }
.nav-theme { margin-top: 1rem; padding: 1rem .6rem 0; border-top: 1px solid var(--border); }
.nav-theme label { display: block; margin-bottom: .35rem; color: var(--muted); font-size: .85rem; font-weight: 700; }
.nav-theme select {
  width: 100%; font: inherit; padding: .5rem .55rem;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--field-bg); color: var(--field-fg);
}

.overlay {
  position: fixed; inset: 0; background: var(--overlay-bg); z-index: 35;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.overlay.show { opacity: 1; pointer-events: auto; }

/* Main */
.main { padding: .6rem; max-width: 1100px; margin: 0 auto; }

/* Kachel grid: 3 per row mobile, 4 tablet, 6 desktop */
.home-page { width: 100%; }
.home-header { margin: 0; }
.home-add-button {
  position: fixed;
  left: max(1rem, env(safe-area-inset-left));
  bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 4.75rem);
  z-index: 51;
  text-decoration: none;
}
.kacheln {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .7rem;
}
@media (min-width: 600px) { .kacheln { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 960px) { .kacheln { grid-template-columns: repeat(6, 1fr); } }

.kachel {
  display: flex; align-items: center; justify-content: center; text-align: center;
  aspect-ratio: 1 / 1;
  background: var(--card-bg);
  border-radius: 14px;
  text-decoration: none;
  color: var(--fg);
  font-weight: 600;
  font-size: .95rem;
  padding: .5rem;
  position: relative;
  border-top: 6px solid var(--c, var(--accent));
  box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease;
}
.kachel:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(0,0,0,.08), 0 8px 20px rgba(0,0,0,.12); }
.kachel:active { transform: translateY(0); }
.k-title { line-height: 1.15; word-break: break-word; }

/* Content pages */
.content { background: var(--content-bg); padding: 1rem 1.2rem; border-radius: 10px; box-shadow: var(--shadow); margin-top: .4rem; }
.content.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.content h1 { margin-top: 0; }
.content-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; }
.content-header h1 { margin-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }
.action-button {
  display: inline-flex; align-items: center; gap: .6rem;
  min-height: 2.75rem; padding: .45rem .75rem .45rem .5rem;
  border-radius: 999px; background: var(--primary-bg); color: #fff;
  font-weight: 700; text-decoration: none;
  box-shadow: var(--shadow);
}
.action-button:hover { background: var(--primary-hover); }
.action-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--accent); color: var(--accent-contrast); font-size: 1.25rem; line-height: 1;
}
.action-copy { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.05; }
.action-copy small { margin-top: .15rem; font-weight: 500; opacity: .82; }
.is-offline [data-online-only] { pointer-events: none; opacity: .45; filter: grayscale(1); }
.offline-hint { display: none; margin: 0 0 1rem; color: var(--muted); font-size: .9rem; }
.is-offline .offline-hint { display: block; }
.dashboard-section { margin-top: 1.2rem; }
.content .back { color: var(--muted); text-decoration: none; }
.content .back:hover { text-decoration: underline; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: .4rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

.listing { list-style: none; padding: 0; }
.listing li { margin: .15rem 0; }
.listing a { display: block; padding: .55rem .7rem; border-radius: 6px; text-decoration: none; color: var(--fg); background: var(--surface); }
.listing a:hover { background: var(--surface-hover); }
.listing .ic { display: inline-block; width: 1.4em; }
.listing-row { display: flex; align-items: center; gap: .45rem; }
.listing-row > a { flex: 1 1 auto; min-width: 0; }
.listing-actions { position: relative; flex: 0 0 auto; display: flex; align-items: center; }
.entry-actions-toggle { min-width: 2.25rem; line-height: 1; }
.entry-actions-menu {
  position: absolute;
  right: 0;
  top: calc(100% + .25rem);
  z-index: 30;
  min-width: 11rem;
  padding: .3rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
}
.entry-action-item {
  display: block;
  width: 100%;
  padding: .5rem .65rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.entry-action-item:hover { background: var(--surface-hover); }
.entry-action-item.danger { color: var(--danger-fg); }
.entry-action-item.danger:hover { background: var(--danger-bg); }
.secondary-button.compact,
.danger-button.compact { padding: .38rem .55rem; min-height: auto; font-size: .84rem; }
.danger-button { font: inherit; font-weight: 600; border: 1px solid var(--danger-border); border-radius: 6px; background: var(--danger-bg); color: var(--danger-fg); cursor: pointer; }
.danger-button:hover { background: var(--danger-hover); }



/* Global role-aware search */
.global-search {
  position: fixed;
  left: max(1rem, env(safe-area-inset-left));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 50;
}
.global-search-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  border: 0;
  border-radius: 50%;
  background: var(--primary-bg);
  color: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.global-search-toggle:hover { background: var(--primary-hover); }
.global-search-toggle svg { width: 1.45rem; height: 1.45rem; }
.global-search-panel[hidden] { display: none !important; }
.global-search-panel {
  position: absolute;
  left: 0;
  bottom: 4.25rem;
  width: min(420px, calc(100vw - 2rem));
  max-height: min(560px, calc(100vh - 7rem));
  display: flex;
  flex-direction: column;
  gap: .6rem;
  padding: .85rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--content-bg);
  color: var(--fg);
  box-shadow: var(--shadow);
}
.global-search-form input {
  width: 100%;
  font: inherit;
  padding: .7rem .8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--field-bg);
  color: var(--field-fg);
}
.global-search-status {
  min-height: 1.2rem;
  font-size: .86rem;
}
.global-search-results {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  overflow: auto;
  padding-right: .1rem;
}
.global-search-result {
  display: block;
  padding: .6rem .65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--fg);
  text-decoration: none;
}
.global-search-result:hover {
  border-color: var(--primary-bg);
  background: var(--surface-hover);
}
.global-search-result-title {
  display: block;
  font-weight: 700;
  color: var(--link);
}
.global-search-result-meta {
  display: block;
  margin-top: .1rem;
  font-size: .8rem;
  color: var(--muted);
}
.global-search-result p {
  margin: .35rem 0 0;
  color: var(--fg);
  font-size: .88rem;
  line-height: 1.35;
}
.global-search-empty { margin: .2rem 0; color: var(--muted); }
@media (max-width: 520px) {
  .global-search {
    left: max(.8rem, env(safe-area-inset-left));
    bottom: max(.8rem, env(safe-area-inset-bottom));
  }
  .global-search-panel {
    left: -.2rem;
    width: calc(100vw - 1.2rem);
  }
}


/* Quiz builder and scoring */
.quiz-builder-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.quiz-title-field input {
  margin-top: .25rem;
}
.quiz-questions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.quiz-question {
  padding: .9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.quiz-question-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .7rem;
}
.quiz-question-head h2 {
  margin: 0;
  font-size: 1.05rem;
}
.quiz-question .field {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  font-weight: 700;
  margin-bottom: .7rem;
}
.builder-field-options {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem .9rem;
  margin: .35rem 0 .7rem;
}
.builder-field-options .checkbox {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin: 0;
  font-weight: 600;
}
.quiz-question input,
.quiz-question select,
.quiz-question textarea,
.quiz-title-field input {
  font: inherit;
  padding: .55rem .65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--field-bg);
  color: var(--field-fg);
}
.quiz-question input[type="checkbox"],
.quiz-question input[type="radio"],
.genform input[type="checkbox"] {
  width: auto;
  padding: 0;
  border: 0;
  background: transparent;
}
.quiz-answers {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  margin-bottom: .5rem;
}
.quiz-answer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: .5rem;
  align-items: center;
}
.quiz-correct-marker {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .85rem;
  color: var(--muted);
}
.quiz-builder-submit {
  justify-content: flex-start;
}
.quiz-image-preview img,
.markdown-image-item img,
.form-field-image {
  display: block;
  max-width: min(100%, 420px);
  max-height: 240px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  margin: .35rem 0 .5rem;
}
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.quiz-score {
  display: inline-block;
  padding: .45rem .65rem;
  border-radius: 8px;
  background: var(--surface-hover);
  font-weight: 700;
}
.quiz-result.is-correct {
  border-color: #36a269;
  background: var(--ok-bg);
}
.quiz-result.is-wrong {
  border-color: var(--danger-border);
  background: var(--danger-bg);
}
.quiz-correct-answer {
  margin-top: .25rem;
  font-size: .9rem;
  color: var(--muted);
}
@media (max-width: 640px) {
  .quiz-answer {
    grid-template-columns: 1fr;
  }
  .quiz-correct-marker {
    order: 2;
  }
}

/* Content admin actions */
.content-page-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  margin-bottom: .6rem;
}
.content-actions { position: relative; flex: 0 0 auto; }
.content-add-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.4rem; height: 2.4rem; border-radius: 50%;
  border: 1px solid var(--border); background: var(--primary-bg); color: #fff;
  cursor: pointer; box-shadow: var(--shadow);
}
.content-add-button:hover { background: var(--primary-hover); }
.content-actions-menu {
  position: absolute; right: 0; top: calc(100% + .35rem); z-index: 20;
  min-width: 210px; padding: .35rem; border-radius: 8px;
  background: var(--content-bg); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.content-actions-menu a,
.content-actions-menu button {
  display: block; width: 100%; padding: .55rem .65rem; border: 0; border-radius: 6px;
  background: transparent; color: var(--fg); text-align: left; text-decoration: none;
  font: inherit; cursor: pointer;
}
.content-actions-menu a:hover,
.content-actions-menu button:hover { background: var(--surface-hover); }
.content-import-dialog {
  width: min(520px, calc(100vw - 2rem)); padding: 0; border: 0; border-radius: 12px;
  background: var(--content-bg); color: var(--fg); box-shadow: var(--shadow);
}
.content-import-dialog::backdrop { background: rgba(0, 32, 64, .45); }
.content-import-card { display: flex; flex-direction: column; gap: .8rem; padding: 1rem; position: relative; }
.content-import-card h2 { margin: 0; }
.content-import-card label { display: flex; flex-direction: column; gap: .25rem; font-weight: 700; }
.content-import-card input[type="text"],
.content-import-card input[type="url"],
.content-import-card input:not([type]) {
  font: inherit; padding: .55rem .65rem; border: 1px solid var(--border);
  border-radius: 6px; background: var(--field-bg); color: var(--field-fg);
}
.dialog-close {
  position: absolute; top: .55rem; right: .55rem;
  width: 2rem; height: 2rem; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--fg); cursor: pointer; font-size: 1.3rem;
}
[data-content-import-file-area][hidden],
[data-content-import-file-name][hidden],
[data-content-link-url-field][hidden] { display: none !important; }
.content-dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem;
  min-height: 130px; padding: 1rem; border: 2px dashed var(--border); border-radius: 10px;
  background: var(--surface); text-align: center; cursor: pointer;
}
.content-dropzone:hover,
.content-dropzone.is-dragging { border-color: var(--primary-bg); background: var(--surface-hover); }
.dialog-actions { display: flex; justify-content: flex-end; gap: .6rem; }
.dialog-actions button[type="submit"] {
  font: inherit; font-weight: 600; padding: .55rem .85rem;
  background: var(--accent); color: var(--accent-contrast); border: 0; border-radius: 6px; cursor: pointer;
}


/* Generic form builder */
.form-builder-fields { flex: 1 1 100%; }
.form-builder-fields .content-header { margin-bottom: .7rem; }
.form-builder-field {
  padding: .85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  margin-bottom: .8rem;
}
.form-builder-field h3 { margin: 0; font-size: 1rem; }
.form-builder-field .checkbox { margin: .55rem 0; }
.form-builder-field .builder-field-options .checkbox { margin: 0; }
.form-builder-options {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  margin-bottom: .5rem;
}
.form-builder-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .5rem;
  align-items: center;
}
@media (max-width: 640px) {
  .form-builder-option { grid-template-columns: 1fr; }
}

/* Markdown editor */
.markdown-editor-form { max-width: none; }
.markdown-toolbar { display: flex; flex-wrap: wrap; gap: .4rem; flex: 1 1 100%; }
.markdown-toolbar button {
  font: inherit; font-weight: 600; padding: .4rem .65rem; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface-hover); color: var(--primary-bg); cursor: pointer;
}
.markdown-image-import { flex: 1 1 100%; padding: .85rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.markdown-image-import h2 { margin: 0 0 .35rem; font-size: 1rem; }
.markdown-image-options { display: grid; grid-template-columns: minmax(0, 1fr) 8rem 12rem; gap: .6rem; margin: .75rem 0; align-items: end; }
.markdown-image-options label { display: flex; flex-direction: column; gap: .25rem; font-weight: 700; font-size: .9rem; }
.markdown-image-options input, .markdown-image-options select { font: inherit; padding: .45rem .55rem; border: 1px solid var(--border); border-radius: 6px; background: var(--field-bg); color: var(--field-fg); }
.markdown-image-list { display: flex; flex-direction: column; gap: .5rem; margin-top: .6rem; }
.markdown-image-item { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: .6rem; align-items: center; }
.markdown-image-item img { width: 72px; height: 52px; margin: 0; object-fit: contain; }
.markdown-image-meta { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.markdown-image-meta strong, .markdown-image-meta span { overflow-wrap: anywhere; }
.markdown-image-meta span { color: var(--muted); font-size: .85rem; }
@media (max-width: 780px) { .markdown-image-options { grid-template-columns: 1fr; } .markdown-image-item { grid-template-columns: 56px minmax(0, 1fr); } .markdown-image-item button { grid-column: 2; justify-self: start; } }
.markdown-editor-grid {
  flex: 1 1 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: .8rem; align-items: stretch;
}
.markdown-input-field { grid-column: 1; }
.markdown-editor-grid textarea {
  grid-column: 1; width: 100%; min-height: 420px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.markdown-preview {
  grid-column: 2; grid-row: 1 / span 2; min-height: 420px; padding: .75rem;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
  overflow: auto;
}
@media (max-width: 780px) {
  .markdown-editor-grid { grid-template-columns: 1fr; }
  .markdown-preview { grid-column: 1; grid-row: auto; min-height: 220px; }
}

.markdown-editor-shell {
  flex: 1 1 100%;
  width: 100%;
  min-width: 0;
}
.markdown-editor-shell .EasyMDEContainer {
  width: 100%;
}
.markdown-editor-shell .editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  border-color: var(--border);
  border-radius: 10px 10px 0 0;
  background: var(--surface-hover);
  opacity: 1;
}
.markdown-editor-shell .editor-toolbar::before,
.markdown-editor-shell .editor-toolbar::after {
  display: none;
}
.markdown-editor-shell .editor-toolbar button,
.markdown-editor-shell .editor-toolbar .easymde-dropdown {
  min-width: auto;
  height: auto;
  padding: .35rem .55rem;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--fg);
  background: transparent;
  font: inherit;
  font-size: .9rem;
  line-height: 1.2;
}
.markdown-editor-shell .editor-toolbar button:hover,
.markdown-editor-shell .editor-toolbar button.active,
.markdown-editor-shell .editor-toolbar button:focus-visible {
  border-color: var(--border);
  background: var(--surface);
  color: var(--primary-bg);
}
.markdown-editor-shell .editor-toolbar i.separator {
  border-left-color: var(--border);
  border-right: 0;
  height: 1.75rem;
  margin: 0 .15rem;
}
.markdown-editor-shell .CodeMirror {
  min-height: 460px;
  border-color: var(--border);
  border-radius: 0 0 10px 10px;
  background: var(--surface);
  color: var(--fg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.markdown-editor-shell .CodeMirror-cursor {
  border-left-color: var(--fg);
}
.markdown-editor-shell .CodeMirror-gutters {
  border-right-color: var(--border);
  background: var(--surface-hover);
}
.markdown-editor-shell .CodeMirror-linenumber,
.markdown-editor-shell .CodeMirror-placeholder {
  color: var(--muted);
}
.markdown-editor-shell .editor-preview,
.markdown-editor-shell .editor-preview-side {
  background: var(--surface);
  color: var(--fg);
}
.markdown-editor-shell .editor-preview-side {
  border-color: var(--border);
}
.markdown-editor-shell .editor-statusbar {
  color: var(--muted);
}
.markdown-editor-shell .CodeMirror-selected,
.markdown-editor-shell .CodeMirror-focused .CodeMirror-selected {
  background: var(--surface-hover);
}
.markdown-editor-shell .cm-s-easymde .cm-tag,
.markdown-editor-shell .cm-s-default .cm-tag { color: var(--link); }
.markdown-editor-shell .cm-s-easymde .cm-attribute,
.markdown-editor-shell .cm-s-default .cm-attribute { color: #7c3aed; }
.markdown-editor-shell .cm-s-easymde .cm-string,
.markdown-editor-shell .cm-s-default .cm-string { color: #9a3412; }
.markdown-editor-shell .cm-s-easymde .cm-bracket,
.markdown-editor-shell .cm-s-default .cm-bracket { color: var(--muted); }
.markdown-editor-shell .cm-s-easymde .cm-link,
.markdown-editor-shell .cm-s-easymde .cm-url,
.markdown-editor-shell .cm-s-default .cm-link { color: var(--link); }
html[data-theme="dark"] .markdown-editor-shell .cm-s-easymde .cm-attribute,
html[data-theme="dark"] .markdown-editor-shell .cm-s-default .cm-attribute { color: #f0abfc; }
html[data-theme="dark"] .markdown-editor-shell .cm-s-easymde .cm-string,
html[data-theme="dark"] .markdown-editor-shell .cm-s-default .cm-string { color: #fdba74; }
.markdown-editor-fallback textarea[data-markdown-editor] {
  width: 100%;
  min-height: 420px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (max-width: 780px) {
  .markdown-editor-shell .CodeMirror { min-height: 360px; }
  .markdown-editor-shell .editor-toolbar button { padding: .3rem .45rem; font-size: .84rem; }
}

/* Prose (rendered markdown) */
.prose { line-height: 1.55; }
.prose img { max-width: 100%; height: auto; border-radius: 6px; }
.prose table { border-collapse: collapse; margin: .8rem 0; }
.prose th, .prose td { border: 1px solid var(--border); padding: .35rem .6rem; }
.prose code { background: var(--surface-hover); padding: .1rem .35rem; border-radius: 3px; }

/* Forms */
.loginform { display: flex; flex-direction: column; gap: .8rem; max-width: 420px; }
.genform { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .8rem; max-width: 560px; }
.genform.wide { max-width: 900px; }
/* Each form element is a row by default; width hints let two share a line. */
.genform .form-el { flex: 1 1 100%; }
.genform .form-el > * { width: 100%; }
.genform .form-el.w-half { flex: 1 1 calc(50% - .4rem); }
.genform .form-el.w-third { flex: 1 1 calc(33.333% - .54rem); }
.genform .form-el.w-quarter { flex: 1 1 calc(25% - .6rem); }
.genform > button { flex: 1 1 100%; }
.loginform label, .genform .field { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; font-size: .9rem; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; }
.day-row { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.muted { color: var(--muted); }
.section-title-with-info { display: flex; align-items: center; gap: .45rem; }
.info-popover {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 1.15rem; height: 1.15rem; border-radius: 50%; background: var(--surface-hover); color: var(--primary-bg);
  font-size: .8rem; font-weight: 700; cursor: help; border: 1px solid var(--border);
}
.info-bubble {
  position: absolute; left: 50%; bottom: calc(100% + .45rem); transform: translateX(-50%);
  width: max-content; max-width: 220px; padding: .45rem .55rem; border-radius: 6px;
  background: var(--primary-bg); color: #fff; font-size: .8rem; font-weight: 500;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .12s ease;
}
.info-popover:hover .info-bubble, .info-popover:focus .info-bubble { opacity: 1; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.loginform input, .genform input:not([type=radio]), .genform select, .genform textarea {
  font: inherit; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: 6px; background: var(--field-bg); color: var(--field-fg);
}
.genform .field { font-size: .92rem; }
/* Compact field: label left, a small input pinned to the right. The label
   keeps the input on the same row and wraps onto two lines if it is long. */
.genform .field--compact { flex-direction: row; align-items: center; justify-content: space-between; gap: .75rem; }
.genform .field--compact > label { flex: 1 1 auto; min-width: 0; }
.genform .field--compact > input:not([type=radio]),
.genform .field--compact > select {
  flex: 0 0 auto; width: auto; max-width: 60%;
}
.genform .field--compact > input[type=number] { width: 6rem; }
.genform .field--compact > input[type=date],
.genform .field--compact > input[type=time] { width: auto; }
.genform label.radio { font-weight: 400; display: inline-flex; gap: .35rem; margin-right: 1rem; }
.genform button, .loginform button { font: inherit; font-weight: 600; padding: .6rem 1rem; background: var(--accent); color: var(--accent-contrast); border: 0; border-radius: 6px; cursor: pointer; }
.genform button:hover, .loginform button:hover { background: var(--accent-hover); }

/* Form display elements (section banner, text block, signature line) */
.form-heading {
  --banner-c: var(--surface-strong);
  background: var(--banner-c); color: var(--fg);
  font-weight: 700; font-size: .95rem;
  padding: .45rem .7rem; border-radius: 6px;
  margin: .4rem 0 .1rem;
}
.form-paragraph { margin: .2rem 0; color: var(--fg); font-size: .92rem; }
.form-image-block { margin: .35rem 0 .7rem; }
.form-image-block figcaption { margin-top: .25rem; color: var(--muted); font-size: .84rem; }
.field-check { font-weight: 400; }
.genform label.checkbox { display: inline-flex; align-items: flex-start; gap: .45rem; font-weight: 400; }
.form-signature { display: flex; flex-direction: column; gap: .15rem; margin: .6rem 0 .2rem; }
.form-signature .sig-line { display: block; border-bottom: 1px solid var(--fg); height: 1.6rem; max-width: 320px; }
.form-signature .sig-label { font-size: .8rem; color: var(--muted); }

/* Submission detail (ordered, printable checklist) */
.sub-elements { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .55rem; margin: .6rem 0 1rem; }
.sub-el { flex: 1 1 100%; }
.sub-el.w-half { flex: 1 1 calc(50% - .28rem); }
.sub-el.w-third { flex: 1 1 calc(33.333% - .37rem); }
.sub-el.w-quarter { flex: 1 1 calc(25% - .42rem); }
.sub-field { display: flex; flex-direction: column; gap: .1rem; padding: .3rem .55rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.sub-field--compact { flex-direction: row; align-items: baseline; justify-content: space-between; gap: .75rem; }
.sub-label { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.sub-field--compact .sub-label { text-transform: none; letter-spacing: 0; font-size: .9rem; }
.sub-value { font-size: 1.02rem; font-weight: 600; color: var(--fg); }
.sub-field--compact .sub-value { text-align: right; flex: 0 0 auto; }
.sub-value:empty::after { content: "—"; color: var(--muted); font-weight: 400; }
.sub-write { border-bottom: 1px solid var(--fg); height: 1.6rem; max-width: 360px; }
.sub-write--block { border: 1px solid var(--border); border-radius: 6px; height: 4.5rem; max-width: none; }
.sub-check { display: flex; align-items: flex-start; gap: .5rem; font-size: .95rem; }
.sub-check .box { font-size: 1.15rem; line-height: 1; }

.err { background: var(--danger-bg); color: var(--danger-fg); padding: .5rem .7rem; border-radius: 6px; }
.ok { background: var(--ok-bg); color: var(--ok-fg); padding: .5rem .7rem; border-radius: 6px; }

.tablewrap { overflow-x: auto; }
.results { border-collapse: collapse; width: 100%; font-size: .9rem; }
.results th, .results td { border: 1px solid var(--border); padding: .4rem .55rem; text-align: left; }
.results a { color: var(--link); font-weight: 700; text-decoration: none; }
.results a:hover { text-decoration: underline; }
.results thead { background: var(--surface-hover); }

.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .55rem 1rem;
  flex-wrap: wrap;
  margin: .55rem 0 .75rem;
}
.results-meta {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .9rem;
}
.results-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .55rem;
  flex-wrap: wrap;
  margin-left: auto;
}
.results-filter {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin: 0;
  font-weight: 700;
  font-size: .9rem;
}
.results-filter input {
  width: min(14rem, 42vw);
  font: inherit;
  padding: .45rem .55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--field-bg);
  color: var(--field-fg);
}
.table-sort-button {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.table-sort-button:hover {
  color: var(--link);
}
.sort-indicator {
  min-width: .8rem;
  color: var(--link);
  font-size: .75rem;
}
.results tr[hidden] {
  display: none !important;
}
.quiz-summary { padding-left: 1.1rem; }


.secondary-button {
  font: inherit; font-weight: 600; padding: .55rem .85rem;
  background: var(--surface-hover); color: var(--primary-bg); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer;
}
.secondary-button:hover:not(:disabled) { background: var(--surface-strong); }
.secondary-button:disabled { opacity: .45; cursor: not-allowed; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; min-width: 2.45rem; padding: .55rem; }
.icon-button svg { display: block; width: 1.1rem; height: 1.1rem; }
.result-print-actions { display: flex; align-items: center; gap: .55rem; margin: 0; }
@media (max-width: 640px) {
  .results-toolbar { align-items: stretch; }
  .results-controls { width: 100%; justify-content: flex-start; margin-left: 0; }
  .results-filter { flex: 1 1 100%; }
  .results-filter input { flex: 1; width: auto; min-width: 0; }
}
.select-col { width: 2.3rem; text-align: center; }
.select-col input { width: 1rem; height: 1rem; }
#print-bundle { display: none; }


.print-logo-wrap { display: none; }

/* Print: strip app chrome so a submission detail prints as a clean sheet. */
@media print {
  .topbar, .wk-banner, .sync-info, .sidenav, .overlay, .no-print,
  .crumbs, .content .back { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; max-width: none; }
  .content { box-shadow: none; border-radius: 0; padding: 0; margin: 0; }
  .content-header.print-title-row {
    --print-logo-min-width: 48mm;
    --print-logo-max-width: 62mm;
    --print-logo-min-height: 12mm;
    --print-logo-max-height: 15mm;
    position: relative;
    display: block;
    padding-right: calc(var(--print-logo-max-width) + 4mm);
    min-height: 0;
    margin-bottom: .25rem;
  }
  .print-title-row h1 { margin-right: 0; }
  .print-logo-wrap {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    justify-content: flex-end;
    align-items: flex-start;
    width: clamp(var(--print-logo-min-width), 22vw, var(--print-logo-max-width));
    height: clamp(var(--print-logo-min-height), 6vw, var(--print-logo-max-height));
    margin: 0;
  }
  .print-logo { display: block; width: 100%; height: 100%; object-fit: contain; }
  .sub-detail > .muted { margin-top: 0; }
  .form-heading { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a[href] { color: inherit; text-decoration: none; }
  /* Keep multi-column elements together on one page where possible. */
  .sub-el, .form-signature, .sub-check { break-inside: avoid; }

  body.print-detail-bundle > :not(#print-bundle) { display: none !important; }
  body.print-detail-bundle #print-bundle { display: block !important; }
  .print-page { break-after: page; page-break-after: always; }
  .print-page:last-child { break-after: auto; page-break-after: auto; }
}


.row-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.secondary-button.compact, .danger-button.compact { padding: .35rem .55rem; font-size: .85rem; }
.danger-button, .danger-submit {
  font: inherit; font-weight: 600; padding: .55rem .85rem;
  background: var(--danger-bg); color: var(--danger-fg); border: 1px solid var(--danger-border);
  border-radius: 6px; cursor: pointer; text-decoration: none;
}
.danger-button:hover, .danger-submit:hover { background: var(--danger-hover); }

/* ===================== Appell ===================== */
.btn {
  display: inline-block; font: inherit; font-weight: 600; padding: .5rem .85rem;
  background: var(--surface-strong); color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-hover); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.btn-small { padding: .3rem .55rem; font-size: .85rem; }
.btn.icon-button { display: inline-flex; align-items: center; justify-content: center; min-width: 2.35rem; padding: .4rem; }

.appell-controls { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: .6rem; }
.appell-controls .list-select select { padding: .35rem; }
.appell-controls .list-name { font-weight: 700; }
.view-toggle { margin-left: auto; display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.view-toggle button { font: inherit; border: 0; background: var(--surface); color: var(--fg); padding: .4rem .8rem; cursor: pointer; }
.view-toggle button.active { background: var(--accent); color: var(--accent-contrast); }

.appell-filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.appell-filters select, .appell-filters input { padding: .35rem .4rem; border: 1px solid var(--border); border-radius: 6px; background: var(--field-bg, var(--surface)); color: var(--fg); }
.appell-count { margin-bottom: .4rem; font-size: .85rem; }
.offline-banner { background: var(--danger-bg); color: var(--danger-fg); padding: .4rem .6rem; border-radius: 6px; margin-bottom: .5rem; }

/* status colours */
.st-neutral { --st: var(--surface-strong); }
.st-anwesend { --st: #2e9e4f; }
.st-abwesend { --st: #d6443a; }
.st-krank { --st: #e8862e; }

/* matrix */
.matrix-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.appell-matrix { border-collapse: separate; border-spacing: 2px; }
.appell-matrix th, .appell-matrix td { padding: 0; }
.appell-matrix thead th { font-size: .72rem; font-weight: 600; text-align: center; color: var(--muted); padding: .15rem .25rem; white-space: nowrap; }
.appell-matrix thead th span { display: block; font-weight: 700; color: var(--fg); }
.appell-matrix .rowhead { position: sticky; left: 0; z-index: 2; background: var(--bg); text-align: left; padding: .25rem .5rem .25rem 0; min-width: 9.5rem; }
.appell-matrix .rowhead .p-name { display: block; font-weight: 600; cursor: pointer; }
.appell-matrix .rowhead .p-meta { display: block; font-size: .72rem; color: var(--muted); }
.appell-matrix tbody td { width: 2rem; height: 2rem; text-align: center; }
.appell-matrix .cell { background: var(--st); border-radius: 5px; cursor: pointer; position: relative; }
.appell-matrix .cell-empty { background: repeating-linear-gradient(45deg, transparent, transparent 3px, var(--surface) 3px, var(--surface) 6px); border-radius: 5px; }
.appell-matrix .note-dot { position: absolute; top: -2px; right: -1px; font-size: .6rem; }
/* current day highlighted + enlarged for easier tapping */
.appell-matrix .is-today { outline: 2px solid var(--accent); outline-offset: -1px; }
.appell-matrix thead th.is-today { color: var(--accent); font-size: .82rem; }
.appell-matrix tbody td.is-today { width: 2.7rem; height: 2.7rem; }
.appell-matrix td.is-today .note-dot { font-size: .72rem; }

/* day view */
.day-head { margin: .3rem 0 .6rem; font-size: 1.05rem; }
.day-list { display: flex; flex-direction: column; gap: .4rem; }
.day-row { display: flex; align-items: center; gap: .5rem; padding: .4rem; border: 1px solid var(--border); border-left: 6px solid var(--st); border-radius: 8px; background: var(--surface); }
.day-status { width: 2.6rem; height: 2.6rem; flex: none; border: 0; border-radius: 8px; background: var(--st); color: #fff; font-size: 1.3rem; font-weight: 700; cursor: pointer; }
.st-neutral .day-status { color: var(--fg); }
.day-person { flex: 1 1 auto; min-width: 0; }
.day-person .p-name { font-weight: 600; display: block; cursor: pointer; }
.day-person .p-meta { font-size: .78rem; color: var(--muted); display: block; }
.note-input { flex: 1 1 8rem; min-width: 6rem; padding: .35rem .4rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--fg); }
.mobile-btn, .mobile-num { flex: none; }
.mobile-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: .3rem .45rem; cursor: pointer; font-size: 1rem; }
.mobile-num { font-size: .85rem; white-space: nowrap; }

/* tags */
.tag-chips { display: inline-flex; flex-wrap: wrap; gap: .2rem; margin-top: .15rem; }
.tag-chip { display: inline-flex; align-items: center; gap: .2rem; background: var(--surface-strong); border-radius: 10px; padding: .05rem .45rem; font-size: .72rem; }
.tag-chip button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: .9rem; line-height: 1; padding: 0; }

/* modal */
.appell-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem; }
.appell-modal { background: var(--card-bg); color: var(--fg); border-radius: 12px; padding: 1.2rem; max-width: 30rem; width: 100%; max-height: 90vh; overflow: auto; position: relative; }
.appell-modal h2 { margin: 0 0 .2rem; }
.modal-close { position: absolute; top: .5rem; right: .6rem; border: 0; background: none; font-size: 1.6rem; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-contact { font-size: .9rem; }
.modal-tags { margin: .8rem 0; }
.modal-tags label { font-weight: 600; display: block; margin-bottom: .3rem; }
.modal-tags [data-tag-list] { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .4rem; }
.modal-tags form { display: flex; gap: .3rem; }
.modal-tags input { flex: 1; padding: .35rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--fg); }
.modal-days { display: flex; flex-direction: column; gap: .35rem; }
.modal-day { display: flex; align-items: center; gap: .5rem; border-left: 5px solid var(--st); padding-left: .4rem; }
.modal-day span { width: 4rem; font-size: .85rem; }
.modal-day .day-status { width: 2rem; height: 2rem; font-size: 1rem; }

/* review/import */
.diff-summary { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 1rem; }
.diff-changed { font-size: .85rem; color: var(--muted); }
.appell-table { border-collapse: collapse; width: 100%; font-size: .85rem; }
.appell-table th, .appell-table td { border: 1px solid var(--border); padding: .25rem .5rem; text-align: left; }
.review-actions { display: flex; gap: .6rem; margin-top: 1rem; }
.appell-import fieldset { border: 1px solid var(--border); border-radius: 8px; margin-bottom: .8rem; }
.appell-import label { display: block; margin: .3rem 0; }
.appell-import .file-pick { margin: .6rem 0; }

.appell-toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%) translateY(2rem); background: var(--fg); color: var(--bg); padding: .6rem 1rem; border-radius: 8px; opacity: 0; transition: all .2s; z-index: 60; pointer-events: none; }
.appell-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Appell: print sheet (current list + filters applied) */
.appell-print-head { display: none; }
@media print {
  .appell-page .appell-controls, .appell-page .appell-filters,
  .appell-page .appell-count, .appell-page .view-toggle,
  .appell-page .content-header a, .appell-page .offline-banner { display: none !important; }
  .appell-page { box-shadow: none; }
  .appell-print-head { display: block; margin-bottom: 4mm; }
  .appell-print-head h2 { margin: 0 0 1mm; font-size: 14pt; }
  .appell-print-head .print-meta { font-size: 9pt; color: #000; }
  .appell-print-head .print-legend { font-size: 8pt; color: #333; margin-top: 1mm; }

  .matrix-wrap { overflow: visible !important; }
  .appell-matrix { border-collapse: collapse; border-spacing: 0; width: 100%; font-size: 8pt; }
  .appell-matrix th, .appell-matrix td { border: 1px solid #555; }
  .appell-matrix thead th { color: #000; padding: 1mm; }
  .appell-matrix thead th span { color: #000; }
  .appell-matrix .rowhead { position: static; background: #fff; min-width: 0; padding: 1mm 2mm 1mm 0; }
  .appell-matrix .rowhead .p-name { color: #000; }
  .appell-matrix .rowhead .p-meta { color: #333; }
  .appell-matrix tbody td { width: 7mm; height: 6mm; text-align: center; vertical-align: middle;
    -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .appell-matrix .cell { border-radius: 0; }
  .appell-matrix .cell-empty { background: #fff; border: 1px solid #ddd; }
  .appell-matrix .note-dot { display: none; }
  .appell-matrix .is-today { outline: none; }
  .appell-matrix thead th.is-today { font-weight: 700; text-decoration: underline; }
  /* glyphs so status is legible even on a black/white printer */
  .appell-matrix td.cell::after { font-size: 8pt; font-weight: 700; }
  .appell-matrix td.cell.st-anwesend::after { content: "✓"; }
  .appell-matrix td.cell.st-abwesend::after { content: "✗"; }
  .appell-matrix td.cell.st-krank::after { content: "K"; }
  .appell-matrix tbody tr { break-inside: avoid; }
  .tag-chips { display: none; }
}

/* ===== Transportzentrale ============================================== */
.transport-page .content-header { display: flex; align-items: center; gap: 1rem; }
.tz-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin: .6rem 0 1rem; }
.tz-date { display: inline-flex; align-items: center; gap: .3rem; }
.tz-date button { border: 1px solid var(--border); background: var(--surface); color: var(--fg); border-radius: 6px; cursor: pointer; padding: .3rem .55rem; font: inherit; }
.tz-date input[type="date"] { font: inherit; padding: .3rem .4rem; border: 1px solid var(--border); border-radius: 6px; background: var(--field-bg); color: var(--fg); }
.tz-weekday { color: var(--muted); font-size: .9rem; }
.tz-veh select, .tz-add-form select, .tz-add-form input, .tz-f input, .tz-f select, .tz-f textarea,
.tz-trailer-row input, .tz-trailer-row select { font: inherit; padding: .35rem .45rem; border: 1px solid var(--border); border-radius: 6px; background: var(--field-bg); color: var(--fg); }

.tz-away { background: var(--ok-bg); color: var(--ok-fg); border-radius: 8px; padding: .45rem .7rem; margin-bottom: .7rem; font-size: .9rem; }
.tz-away-chip { display: inline-block; margin: .15rem .35rem .15rem 0; background: var(--card-bg); border: 1px solid var(--border); border-radius: 20px; padding: .15rem .6rem; }
.tz-away-chip button { font: inherit; font-size: .8rem; margin-left: .3rem; border: 0; background: none; color: var(--link); cursor: pointer; text-decoration: underline; }
.tz-away-chip.is-released { opacity: .7; }
.tz-rel-info { font-size: .78rem; color: var(--muted); margin-left: .3rem; }
.tz-trailer-row .tz-rel-info { flex-basis: 100%; }
.tz-trailer-row .tz-rel-info button { font: inherit; font-size: .78rem; border: 0; background: none; color: var(--link); cursor: pointer; text-decoration: underline; }

.tz-bestellungen { margin-bottom: 1rem; }
.tz-bestellungen > summary { cursor: pointer; font-weight: 600; margin-bottom: .4rem; }
.tz-best-card { display: flex; align-items: center; gap: .7rem; padding: .5rem .7rem; border: 1px solid var(--border); border-radius: 8px; margin: .3rem 0; background: var(--card-bg); }
.tz-best-main { display: flex; flex-direction: column; gap: .1rem; flex: 1; min-width: 0; }
.tz-best-main .muted { font-size: .85rem; }
.tz-best-desc { font-size: .85rem; }

/* timeline */
.tz-timeline { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--card-bg); }
/* Cross-WK read-only sections shown below the active WK on the same time axis. */
.tz-cross { margin-top: 1.25rem; }
.tz-cross-divider { display: flex; align-items: center; gap: .6rem; margin: .5rem 0 .75rem; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
.tz-cross-divider::before, .tz-cross-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.tz-cross-sec { margin-bottom: 1rem; }
.tz-cross-head { font-weight: 600; color: var(--muted); margin: .25rem 0 .35rem; }
.tz-bar--ro { cursor: default; }
.tz-ruler-row, .tz-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--border); width: max-content; min-width: 100%; }
.tz-row:last-child { border-bottom: 0; }
.tz-row-label { flex: 0 0 8.5rem; width: 8.5rem; padding: .4rem .5rem; box-sizing: border-box; border-right: 1px solid var(--border); position: sticky; left: 0; background: var(--card-bg); z-index: 2; }
.tz-res-name { display: block; font-weight: 600; font-size: .9rem; }
.tz-res-sub { display: block; color: var(--muted); font-size: .75rem; }
.tz-ruler { position: relative; height: 1.6rem; }
.tz-track { position: relative; min-height: 2.5rem; }
.tz-tick { position: absolute; top: 0; font-size: .7rem; color: var(--muted); border-left: 1px solid var(--border); padding-left: 2px; height: 100%; }
.tz-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); z-index: 3; }
.tz-row.is-unavail { background: repeating-linear-gradient(45deg, transparent, transparent 6px, rgba(128,128,128,.12) 6px, rgba(128,128,128,.12) 12px); }
.tz-tag { font-size: .7rem; border-radius: 4px; padding: 0 .3rem; }
.tz-tag--off { background: var(--danger-bg); color: var(--danger-fg); }

/* plan bar (always shown, blue) + thin "ist" line underneath + grey park block */
.tz-bar { position: absolute; height: 1.4rem; border-radius: 5px; padding: 0 .35rem; box-sizing: border-box; cursor: pointer; overflow: hidden; color: #fff; display: flex; align-items: center; box-shadow: var(--shadow); z-index: 2; }
.tz-bar.is-overdue { outline: 2px solid #ff7b6b; }
.tz-bar-label { font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tz-ist { position: absolute; height: .45rem; border-radius: 3px; cursor: pointer; z-index: 2; }
.tz-grey { position: absolute; top: 2px; bottom: 2px; background: repeating-linear-gradient(45deg, rgba(120,120,120,.30), rgba(120,120,120,.30) 7px, rgba(120,120,120,.15) 7px, rgba(120,120,120,.15) 14px); border: 1px solid rgba(120,120,120,.5); border-radius: 4px; z-index: 1; display: flex; align-items: center; overflow: hidden; }
.tz-grey span { font-size: .72rem; color: var(--fg); opacity: .8; padding: 0 .3rem; white-space: nowrap; }

.ph-geplant { background: #2563a8; }
.ph-laufend { background: #d9822b; }
.ph-abgeschlossen { background: #2e8b57; }
.ph-overdue { background: #c0392b; }

.tz-legend { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .5rem; font-size: .8rem; }
.tz-chip { color: #fff; border-radius: 4px; padding: .05rem .45rem; }
.tz-ist-chip { display: inline-block; width: 1.4rem; height: .4rem; border-radius: 3px; vertical-align: middle; }
.tz-grey-chip { display: inline-block; width: 1.4rem; height: .8rem; border-radius: 3px; vertical-align: middle; background: repeating-linear-gradient(45deg, rgba(120,120,120,.30), rgba(120,120,120,.30) 5px, rgba(120,120,120,.12) 5px, rgba(120,120,120,.12) 10px); border: 1px solid rgba(120,120,120,.5); }

/* order list (driver) */
.tz-order-list { display: flex; flex-direction: column; gap: .4rem; }
.tz-order-card { display: flex; gap: .7rem; align-items: stretch; border: 1px solid var(--border); border-left-width: 5px; border-radius: 8px; padding: .5rem .7rem; background: var(--card-bg); cursor: pointer; }
.tz-order-card.ph-geplant { border-left-color: #2563a8; }
.tz-order-card.ph-laufend { border-left-color: #d9822b; }
.tz-order-card.ph-abgeschlossen { border-left-color: #2e8b57; }
.tz-order-card.ph-overdue { border-left-color: #c0392b; }
.tz-oc-time { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 3.2rem; }
.tz-oc-time span { display: block; font-weight: 400; color: var(--muted); font-size: .85rem; }
.tz-oc-main { display: flex; flex-direction: column; gap: .1rem; }
.tz-oc-status { font-size: .8rem; color: var(--muted); }

/* modals */
.tz-modal { max-width: 38rem; }
.tz-form { display: flex; flex-direction: column; gap: .6rem; margin-top: .6rem; }
.tz-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.tz-f { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; }
.tz-f span { color: var(--muted); }
.tz-f textarea { font: inherit; }
.tz-check, .tz-stay { display: flex; align-items: center; gap: .4rem; font-size: .9rem; }
.tz-trailer-row { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; padding: .35rem; border: 1px solid var(--border); border-radius: 6px; margin: .25rem 0; }
.tz-trailer-row [data-tname] { flex: 1 1 8rem; }
.tz-trailer-row [data-trm] { border: 0; background: none; color: var(--danger-fg); font-size: 1.2rem; cursor: pointer; }
.tz-actions { display: flex; gap: .6rem; margin-top: .4rem; }
.btn-danger { background: var(--danger-bg); color: var(--danger-fg); border-color: var(--danger-border); }

.tz-driver { background: var(--surface); border-radius: 8px; padding: .6rem; margin: .5rem 0; display: flex; flex-direction: column; gap: .4rem; }
.tz-driver-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.tz-driver .is-done { background: var(--ok-bg); color: var(--ok-fg); border-color: var(--ok-fg); }
.tz-driver [data-dcomment], .tz-driver input[type="time"], .tz-driver-id input { font: inherit; padding: .35rem .45rem; border: 1px solid var(--border); border-radius: 6px; background: var(--field-bg); color: var(--fg); }
.tz-driver-row { align-items: center; }
.tz-driver-row .btn { min-width: 8rem; }
.tz-driver-id { display: flex; gap: .4rem; }
.tz-driver-id input { flex: 1; }

/* print-only blocks (Auftrag + Dispo-Übersicht) */
.tz-print-head { display: none; }
.tz-print-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; border-bottom: 2px solid #000; margin-bottom: .4rem; padding-bottom: .2rem; }
.tz-print-title h2 { margin: 0; }
.tz-print-wk { font-weight: 600; }
.tz-print-logo { max-height: 15mm; max-width: 60mm; object-fit: contain; }
.tz-print-table { width: 100%; border-collapse: collapse; }
.tz-print-table th { text-align: left; width: 11rem; vertical-align: top; padding: .15rem .4rem .15rem 0; color: #333; }
.tz-print-table td { padding: .15rem 0; }

@media print {
  /* Order detail: print only the clean summary, not the form/inputs. */
  body.tz-print-order .main, body.tz-print-order .global-search { display: none !important; }
  body.tz-print-order .appell-modal-overlay { position: static; background: none; display: block; padding: 0; z-index: auto; }
  body.tz-print-order .appell-modal { box-shadow: none; max-width: none; max-height: none; overflow: visible; padding: 0; }
  body.tz-print-order .appell-modal > *:not(.tz-print-head) { display: none !important; }
  body.tz-print-order .tz-print-head { display: block !important; }

  /* Dispo overview: show a WK header and scale the timeline to fit the page. */
  body.tz-print-overview [data-print-head] { display: block !important; margin-bottom: .5rem; }
  body.tz-print-overview .tz-timeline { overflow: visible !important; transform: scale(var(--tz-print-scale, 1)); transform-origin: top left; }
  body.tz-print-overview .tz-row-label { position: static !important; }
  body.tz-print-overview .tz-bar, body.tz-print-overview .tz-ist, body.tz-print-overview .tz-grey { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

.tz-fleet-row { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; padding: .35rem 0; border-bottom: 1px solid var(--border); }
.tz-fleet-name { flex: 1 1 9rem; }
.tz-fleet-name em { color: var(--muted); font-size: .8rem; }
.tz-fleet-un { color: var(--danger-fg); font-size: .75rem; flex-basis: 100%; }
.tz-fleet-row [data-del-res] { border: 0; background: none; color: var(--danger-fg); font-size: 1.2rem; cursor: pointer; }
.tz-add-form { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 1rem; }

@media (max-width: 560px) {
  .tz-grid2 { grid-template-columns: 1fr; }
  .tz-row-label { flex-basis: 6rem; width: 6rem; }
}
