:root {
  color-scheme: light;
  --navy-950: #07111f;
  --navy-900: #0b172a;
  --navy-850: #102039;
  --navy-800: #142742;
  --blue-700: #075fc7;
  --blue-600: #0875e1;
  --blue-500: #1688f0;
  --cyan-500: #12b9d6;
  --cyan-100: #dff8fc;
  --ink-950: #101828;
  --ink-800: #24334b;
  --ink-700: #34445c;
  --ink-600: #52627a;
  --ink-500: #697991;
  --line-strong: #ccd5e1;
  --line: #dfe5ed;
  --line-soft: #edf1f5;
  --surface: #ffffff;
  --surface-subtle: #f7f9fc;
  --workspace: #f2f5f9;
  --success: #0c8c61;
  --success-bg: #e5f7ef;
  --warning: #b35a00;
  --warning-bg: #fff2dc;
  --danger: #c7374f;
  --danger-bg: #feeaed;
  --violet: #7154ce;
  --violet-bg: #eeeafd;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 4px rgba(16, 24, 40, .04);
  --shadow-md: 0 8px 24px rgba(16, 35, 60, .08), 0 2px 8px rgba(16, 35, 60, .05);
  --shadow-lg: 0 22px 64px rgba(7, 17, 31, .2);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --sidebar-width: 270px;
  --topbar-height: 78px;
  --content-max: 1680px;
  --focus: rgba(18, 185, 214, .42);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

*, *::before, *::after { box-sizing: border-box; }

html { min-width: 320px; background: var(--workspace); }

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--ink-950);
  background: var(--workspace);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { color: inherit; font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .58; }
a { color: var(--blue-700); }
img, svg { display: block; }
h1, h2, h3, h4, p { margin-top: 0; }
h1, h2, h3, h4 { color: var(--ink-950); line-height: 1.2; }

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

::selection { color: #fff; background: var(--blue-600); }

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 12px;
  padding: 10px 14px;
  color: #fff;
  background: var(--blue-700);
  border-radius: var(--radius-sm);
  transform: translateY(-150%);
  transition: transform .15s ease;
}
.skip-link:focus { transform: translateY(0); }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100svh;
}

.app-shell.is-login { grid-template-columns: minmax(0, 1fr); }
.app-shell.is-login .sidebar,
.app-shell.is-login .topbar-primary-action,
.app-shell.is-login .profile-button,
.app-shell.is-login .logout-button,
.app-shell.is-login .mobile-menu-button { display: none; }

.login-screen {
  display: flex;
  min-height: calc(100vh - 90px);
  min-height: calc(100svh - 90px);
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(360px, 100%);
  padding: 32px;
  text-align: center;
}

.login-form .login-logo { width: 88px; margin: 0 auto 8px; }
.login-form h1 { margin: 0 0 4px; font-size: 1.3rem; }
.login-form label { text-align: left; font-weight: 600; font-size: .9rem; }
.login-form .login-error {
  margin: 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: #fdecec;
  color: #b42318;
  font-size: .9rem;
}
.login-form .login-error[hidden] { display: none; }

.sidebar {
  position: sticky;
  z-index: 40;
  top: 0;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  height: 100vh;
  height: 100svh;
  padding: 22px 18px 18px;
  color: #d9e5f4;
  background:
    radial-gradient(circle at 15% -5%, rgba(18, 185, 214, .18), transparent 34%),
    linear-gradient(180deg, var(--navy-900), var(--navy-950));
  border-right: 1px solid rgba(255, 255, 255, .06);
  overflow-y: auto;
}

.brand {
  display: block;
  align-items: center;
  min-height: 62px;
  padding: 2px 7px 17px;
}

.brand-logo {
  display: block;
  width: 160px;
  height: 58px;
  max-width: 100%;
  object-fit: contain;
  object-position: left center;
}

.sidebar-context {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 18px;
  padding: 11px 12px;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .075);
  border-radius: 10px;
}
.sidebar-context > span:not(.context-dot), .sidebar-status > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.sidebar-context strong, .sidebar-status strong { color: #eef7ff; font-size: 12px; font-weight: 700; }
.sidebar-context small, .sidebar-status small { color: #8298b3; font-size: 11px; }
.context-dot, .status-indicator { flex: 0 0 auto; width: 8px; height: 8px; background: #2ad69d; border: 2px solid rgba(42, 214, 157, .18); border-radius: 50%; box-shadow: 0 0 0 3px rgba(42, 214, 157, .1); }

.primary-nav { display: flex; flex: 1; flex-direction: column; gap: 5px; }
.nav-item {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 13px;
  color: #aebfd2;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  transition: color .15s ease, background-color .15s ease, border-color .15s ease;
}
.nav-item svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item span:nth-child(2) { overflow: hidden; font-size: 14px; font-weight: 625; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { color: #f3f9ff; background: rgba(255, 255, 255, .055); }
.nav-item.is-active, .nav-item[aria-current="page"] { color: #fff; background: linear-gradient(90deg, rgba(8, 117, 225, .28), rgba(18, 185, 214, .1)); border-color: rgba(70, 194, 244, .2); box-shadow: inset 3px 0 0 var(--cyan-500); }
.nav-count { min-width: 23px; padding: 2px 7px; color: #c9f8ff; font-size: 11px; font-weight: 750; text-align: center; background: rgba(18, 185, 214, .15); border-radius: 999px; }

.sidebar-footer { margin-top: 20px; padding: 17px 6px 3px; border-top: 1px solid rgba(255, 255, 255, .08); }
.sidebar-status { display: flex; align-items: center; gap: 9px; }
.sidebar-footer p { margin: 15px 0 0 25px; color: #667d98; font-size: 10px; line-height: 1.5; }

.nav-scrim { display: none; }
.app-stage { min-width: 0; }

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  min-height: var(--topbar-height);
  padding: 12px clamp(20px, 2.6vw, 42px);
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.topbar-heading { min-width: 0; }
.topbar-heading h1 { margin: 0; font-size: 21px; font-weight: 740; letter-spacing: -.025em; }
.topbar-heading p { margin: 3px 0 0; color: var(--ink-500); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.mobile-menu-button { display: none !important; margin-right: 8px; }

.profile-button {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 5px 9px 5px 6px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 11px;
}
.profile-button:hover { background: var(--surface-subtle); border-color: var(--line-soft); }
.profile-avatar { display: grid; width: 36px; height: 36px; place-items: center; color: #fff; font-size: 12px; font-weight: 800; background: var(--navy-800); border-radius: 9px; }
.profile-copy { display: flex; flex-direction: column; min-width: 0; }
.profile-copy strong { font-size: 12px; }
.profile-copy small { color: var(--ink-500); font-size: 10px; }
.profile-button > svg { width: 15px; height: 15px; fill: none; stroke: var(--ink-500); stroke-width: 2; }

.page-content { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: clamp(24px, 2.6vw, 42px); }
.page-content:focus { outline: none; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.page-heading h2 { margin: 3px 0 6px; font-size: clamp(24px, 2.2vw, 34px); font-weight: 760; letter-spacing: -.035em; }
.page-heading p { margin: 0; color: var(--ink-600); font-size: 14px; }
.eyebrow { color: var(--blue-700); font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.page-actions, .toolbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }

.button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 9px;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.button:not(:disabled):active { transform: translateY(1px); }
.button-primary { color: #fff; background: var(--blue-600); border-color: var(--blue-600); box-shadow: 0 4px 10px rgba(8, 117, 225, .18); }
.button-primary:hover { background: var(--blue-700); border-color: var(--blue-700); }
.button-secondary { color: var(--blue-700); background: #eef6ff; border-color: #bedcff; }
.button-secondary:hover { background: #e3f1ff; border-color: #9fcaff; }
.button-neutral { color: var(--ink-800); background: #fff; border-color: var(--line-strong); box-shadow: var(--shadow-sm); }

.work-card-page {
  margin: 0;
  color: #111;
  background: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15pt;
  line-height: 1.35;
}

.work-card-sheet {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 14mm;
  background: #fff;
}

.work-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18mm;
  padding-bottom: 7mm;
  border-bottom: 2px solid #111;
}

.work-card-header h1 {
  margin: 0 0 4mm;
  color: #111;
  font-size: 24pt;
  letter-spacing: 0;
}

.work-card-header strong { font-size: 20pt; }
.work-card-header img { width: 38mm; height: auto; object-fit: contain; }

.work-card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5mm 8mm;
  padding: 7mm 0;
  border-bottom: 1.5px solid #111;
}

.work-card-meta div { display: grid; grid-template-columns: 38mm 1fr; gap: 4mm; }
.work-card-meta span { font-weight: 700; }
.work-card-meta strong { font-weight: 500; }

.work-card-section {
  padding: 6mm 0;
  border-bottom: 1px solid #111;
}

.work-card-section h2 {
  margin: 0 0 3mm;
  color: #111;
  font-size: 15pt;
  text-transform: uppercase;
  letter-spacing: 0;
}

.work-card-section p {
  min-height: 14mm;
  margin: 0;
  white-space: normal;
}

.work-card-request p { font-size: 18pt; font-weight: 700; }
.work-card-checklist { display: grid; gap: 2.5mm; margin: 0; padding: 0; list-style: none; }
.work-card-checklist li { display: grid; grid-template-columns: 8mm 1fr; gap: 3mm; align-items: start; break-inside: avoid; }
.work-card-checkbox { font-family: "Segoe UI Symbol", Arial, sans-serif; font-size: 18pt; line-height: 1; }
.work-card-empty { color: #555; }

.work-card-signoff {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7mm 10mm;
  padding-top: 8mm;
  font-weight: 700;
}

.work-card-signoff div { min-height: 12mm; }
.work-card-signoff .wide { grid-column: 1 / -1; }
.work-card-signoff span { display: block; min-height: 10mm; border-bottom: 1px solid #111; }

@page { size: A4 portrait; margin: 0; }

@media print {
  html, body.work-card-page { width: 210mm; min-height: 297mm; background: #fff; }
  .work-card-sheet { margin: 0; box-shadow: none; }
}
.button-neutral:hover { background: var(--surface-subtle); border-color: #aebdce; }
.button-ghost { color: var(--blue-700); background: transparent; }
.button-ghost:hover { background: #edf6ff; }
.button-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.button-danger:hover { background: #aa283f; }
.button-small { min-height: 36px; padding: 0 11px; font-size: 12px; }
.button-large { min-height: 50px; padding-inline: 20px; font-size: 14px; }
.button-block { width: 100%; }
.icon-button { width: 42px; min-width: 42px; padding: 0; color: var(--ink-700); background: #fff; border-color: var(--line); }
.icon-button:hover { color: var(--blue-700); background: #f5f9ff; border-color: #bad8f5; }
.icon-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.search-command-card {
  position: relative;
  padding: clamp(22px, 2.6vw, 34px);
  color: #fff;
  background:
    radial-gradient(circle at 88% 0, rgba(18, 185, 214, .24), transparent 34%),
    linear-gradient(125deg, var(--navy-900), #102b4d);
  border: 1px solid #203b5b;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.search-command-card::after { content: ""; position: absolute; right: -70px; bottom: -110px; width: 260px; height: 260px; border: 38px solid rgba(255, 255, 255, .025); border-radius: 50%; pointer-events: none; }
.search-command-copy { position: relative; z-index: 1; }
.search-command-copy h3 { margin-bottom: 3px; color: #fff; font-size: 20px; }
.search-command-copy p { margin-bottom: 17px; color: #a9bad0; font-size: 13px; }
.global-search {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 25px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 6px 7px 6px 17px;
  background: #fff;
  border: 2px solid transparent;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
}
.global-search:focus-within { border-color: var(--cyan-500); box-shadow: 0 0 0 4px rgba(18, 185, 214, .15), 0 10px 30px rgba(0, 0, 0, .18); }
.global-search > svg { width: 23px; height: 23px; fill: none; stroke: var(--ink-500); stroke-width: 2; stroke-linecap: round; }
.global-search input { min-width: 0; height: 42px; color: var(--ink-950); font-size: 15px; background: transparent; border: 0; outline: 0; }
.global-search input::placeholder { color: #8997aa; }
.global-search kbd { padding: 4px 7px; color: var(--ink-500); font: 10px/1.2 inherit; background: var(--surface-subtle); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; }

.quick-actions { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.quick-action { display: grid; grid-template-columns: 39px minmax(0, 1fr) 18px; align-items: center; gap: 10px; min-height: 68px; padding: 10px 13px; color: #e9f4ff; text-align: left; background: rgba(255, 255, 255, .065); border: 1px solid rgba(255, 255, 255, .1); border-radius: 11px; }
.quick-action:hover { background: rgba(255, 255, 255, .11); border-color: rgba(89, 202, 255, .32); }
.quick-action-icon { display: grid; width: 39px; height: 39px; place-items: center; color: #aef2ff; background: rgba(18, 185, 214, .13); border-radius: 9px; }
.quick-action-icon svg, .quick-action-arrow { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.quick-action > span:nth-child(2) { display: flex; flex-direction: column; min-width: 0; }
.quick-action strong { color: #fff; font-size: 12px; }
.quick-action small { margin-top: 2px; color: #90a6c0; font-size: 10px; }
.quick-action-arrow { width: 16px; color: #718aa5; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
.metric-card { position: relative; min-width: 0; padding: 19px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.metric-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--metric-color, var(--blue-600)); }
.metric-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--ink-600); font-size: 12px; font-weight: 700; }
.metric-icon { display: grid; flex: 0 0 34px; width: 34px; height: 34px; place-items: center; color: var(--metric-color); background: var(--metric-bg); border-radius: 9px; }
.metric-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.metric-value { display: block; margin: 8px 0 2px; font-size: 30px; font-weight: 780; letter-spacing: -.04em; }
.metric-card > small { color: var(--ink-500); font-size: 10px; }
.metric-blue { --metric-color: var(--blue-600); --metric-bg: #eaf4ff; }
.metric-cyan { --metric-color: #0789a2; --metric-bg: var(--cyan-100); }
.metric-amber { --metric-color: #bd6a0b; --metric-bg: #fff1dd; }
.metric-green { --metric-color: var(--success); --metric-bg: var(--success-bg); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, .75fr); gap: 16px; }
.dashboard-orders-card { grid-row: span 2; }
.card, .panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header, .panel-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; min-height: 72px; padding: 15px 19px; border-bottom: 1px solid var(--line-soft); }
.card-header h3, .panel-header h3 { margin: 0; font-size: 15px; font-weight: 740; }
.card-header p, .panel-header p { margin: 3px 0 0; color: var(--ink-500); font-size: 11px; }
.card-body, .panel-body { padding: 20px; }
.card-footer, .panel-footer { display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding: 14px 20px; background: var(--surface-subtle); border-top: 1px solid var(--line-soft); border-radius: 0 0 var(--radius) var(--radius); }
.live-label { display: inline-flex; align-items: center; gap: 6px; color: var(--success); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.live-label > span { width: 7px; height: 7px; background: #26c991; border-radius: 50%; box-shadow: 0 0 0 4px rgba(38, 201, 145, .12); }

.content-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.span-12 { grid-column: span 12; }.span-9 { grid-column: span 9; }.span-8 { grid-column: span 8; }.span-6 { grid-column: span 6; }.span-4 { grid-column: span 4; }.span-3 { grid-column: span 3; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 15px; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.toolbar-search { position: relative; flex: 1 1 300px; min-width: 220px; }
.toolbar-search svg { position: absolute; top: 50%; left: 13px; width: 18px; height: 18px; fill: none; stroke: var(--ink-500); stroke-width: 2; transform: translateY(-50%); pointer-events: none; }
.toolbar-search input { width: 100%; padding-left: 40px; }
.toolbar-filter { min-width: 155px; }
.toolbar-actions { margin-left: auto; }

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { padding: 11px 15px; color: var(--ink-500); font-size: 10px; font-weight: 800; letter-spacing: .045em; text-align: left; text-transform: uppercase; background: #fafbfd; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data-table td { padding: 13px 15px; color: var(--ink-700); border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:not(.table-empty-row):hover { background: #f8fbff; }
.data-table .cell-title { display: block; color: var(--ink-950); font-weight: 700; }
.data-table .cell-subtitle { display: block; margin-top: 2px; color: var(--ink-500); font-size: 10px; }
.data-table .align-right, .align-right { text-align: right; }
.data-table .table-actions { display: flex; justify-content: flex-end; gap: 5px; }
.row-menu { position: relative; }
.row-menu-trigger { font-size: 18px; line-height: 1; }
.row-menu-list { position: absolute; top: calc(100% + 4px); right: 0; z-index: 30; display: flex; flex-direction: column; min-width: 172px; padding: 5px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 28px rgba(16, 32, 56, 0.16); }
.row-menu-list[hidden] { display: none; }
.row-menu-item { padding: 8px 10px; color: var(--ink-700); font-size: 13px; text-align: left; background: none; border: 0; border-radius: 7px; cursor: pointer; }
.row-menu-item:hover { color: var(--blue-700); background: #f5f9ff; }
.row-menu-item.danger { color: var(--danger); }
.row-menu-item.danger:hover { color: #fff; background: var(--danger); }
.row-menu-separator { margin: 4px 2px; border: 0; border-top: 1px solid var(--line); }
.document-menu-trigger.row-menu-trigger { font-size: 13px; line-height: normal; }
.document-menu .row-menu-list { min-width: 200px; }
.parts-order-trigger { width: auto; min-width: 64px; padding: 0 12px; font-size: 13px; line-height: normal; }
.parts-order-list { min-width: 360px; padding: 8px; }
.esa-menu-item { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; }
.esa-menu-item strong { font-size: 13px; }
.esa-menu-item small { color: var(--ink-500); font-size: 11px; }
.parts-order-back { color: var(--ink-500); font-size: 11px; font-weight: 700; }
.supplier-cards { display: flex; gap: 9px; }
.supplier-card { display: inline-flex; flex: 1 1 0; align-items: center; justify-content: center; min-width: 0; min-height: 44px; gap: 9px; padding: 8px 12px; color: var(--ink-700); text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.supplier-card:hover { background: #f5f9ff; border-color: #bad8f5; }
.supplier-card:focus-visible { outline: 2px solid var(--blue-700); outline-offset: 2px; }
.supplier-logo { display: block; flex: 0 0 auto; max-height: 26px; width: auto; object-fit: contain; }
.supplier-logo-esa { max-height: 24px; max-width: 62px; }
.supplier-logo-derendinger { max-height: 26px; max-width: 150px; }
.supplier-card-text { min-width: 0; overflow: hidden; color: var(--ink-700); font-size: 13px; font-weight: 800; line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 420px) {
  .supplier-cards { flex-direction: column; }
  .parts-order-list { min-width: 220px; }
  .supplier-card { justify-content: flex-start; width: 100%; }
}
.derendinger-basket-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-color: #b7d5f1; background: #f7fbff; }
.derendinger-basket-status > div { display: flex; flex-direction: column; gap: 2px; }
.derendinger-basket-status strong { color: var(--ink-950); font-size: 13px; }
.derendinger-basket-status span { color: var(--ink-600); font-size: 12px; }
.derendinger-basket-preview { display: flex; flex-direction: column; gap: 14px; }
.success-line { margin: 0; color: #1c7c3b; font-size: 13px; font-weight: 800; }
.derendinger-basket-table td small { display: block; margin-top: 3px; color: var(--ink-500); font-size: 10px; }
.derendinger-times { padding: 10px 12px; background: #fafbfd; border: 1px solid var(--line-soft); border-radius: 9px; }
.derendinger-times summary { color: var(--ink-700); font-size: 12px; font-weight: 800; cursor: pointer; }
.derendinger-times pre { max-height: 260px; overflow: auto; margin: 10px 0 0; font-size: 11px; white-space: pre-wrap; }

.document-trail { padding: 14px 18px; }
.document-trail-list { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; padding: 0; list-style: none; }
.document-trail-arrow { color: var(--ink-500); font-size: 14px; }
.document-trail-item { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; text-align: left; background: var(--surface-subtle); border: 1px solid var(--line-soft); border-radius: 9px; cursor: pointer; }
.document-trail-item:hover { background: #eef6ff; border-color: #bedcff; }
.document-trail-item span { color: var(--ink-500); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.document-trail-item strong { color: var(--ink-950); font-size: 13px; font-weight: 700; }
.data-table .table-empty-row td { padding: 0; }
.row-link { color: inherit; text-decoration: none; }
.row-link:hover .cell-title { color: var(--blue-700); }

.badge, .status-badge, .type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 25px;
  padding: 3px 9px;
  color: var(--ink-700);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  background: #eef2f6;
  border: 1px solid rgba(82, 98, 122, .09);
  border-radius: 999px;
}
.status-badge::before { content: ""; width: 6px; height: 6px; background: currentColor; border-radius: 50%; }
.status-badge.status-neu, .status-badge[data-status="neu"] { color: #1766b5; background: #e9f3ff; }
.status-badge.status-termin, .status-badge[data-status="termin"] { color: var(--violet); background: var(--violet-bg); }
.status-badge.status-in-arbeit, .status-badge[data-status="in-arbeit"] { color: #087e98; background: var(--cyan-100); }
.status-badge.status-wartet-auf-teile, .status-badge[data-status="wartet-auf-teile"] { color: var(--warning); background: var(--warning-bg); }
.status-badge.status-fertig, .status-badge[data-status="fertig"] { color: var(--success); background: var(--success-bg); }
.status-badge.status-verrechnet, .status-badge[data-status="verrechnet"] { color: #4553a4; background: #e9ebfb; }
.status-badge.status-abgeholt, .status-badge[data-status="abgeholt"] { color: #5b6778; background: #eceff3; }
.status-badge.status-entwurf, .status-badge[data-status="entwurf"] { color: #725607; background: #fff4ce; }
.status-badge.status-storniert, .status-badge[data-status="storniert"] { color: var(--danger); background: var(--danger-bg); }
.status-badge.status-gesendet, .status-badge[data-status="gesendet"] { color: var(--blue-700); background: #e8f3ff; }
.status-badge.status-angenommen, .status-badge[data-status="angenommen"] { color: var(--success); background: var(--success-bg); }
.status-badge.status-abgelehnt, .status-badge[data-status="abgelehnt"] { color: var(--danger); background: var(--danger-bg); }
.status-badge.status-abgelaufen, .status-badge[data-status="abgelaufen"] { color: #5b6778; background: #eceff3; }
.badge-success { color: var(--success); background: var(--success-bg); }
.badge-warning { color: var(--warning); background: var(--warning-bg); }
.badge-danger { color: var(--danger); background: var(--danger-bg); }
.status-badge.inventory-status-ok { color: #177245; background: #e8f6ef; }
.status-badge.inventory-status-low { color: #9a6500; background: #fff4d8; }
.status-badge.inventory-status-empty { color: var(--danger); background: var(--danger-bg); }
.inventory-row.inventory-status-low td { background: #fffaf0; }
.inventory-row.inventory-status-empty td { background: #fff6f7; }
.badge-info { color: var(--blue-700); background: #e9f3ff; }

.license-plate { display: inline-flex; align-items: center; min-height: 34px; padding: 4px 11px; color: #111; font-size: 14px; font-weight: 850; letter-spacing: .045em; background: #fff; border: 2px solid #1e2938; border-radius: 5px; box-shadow: inset 0 0 0 1px #e0e4e9; white-space: nowrap; }
.vin, .mono { font-family: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: .94em; letter-spacing: .025em; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }

.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.field { display: flex; min-width: 0; flex-direction: column; gap: 6px; }
.field.span-12 { grid-column: span 12; }.field.span-8 { grid-column: span 8; }.field.span-6 { grid-column: span 6; }.field.span-4 { grid-column: span 4; }.field.span-3 { grid-column: span 3; }.field.span-2 { grid-column: span 2; }
.field label, .field-label { color: var(--ink-700); font-size: 11px; font-weight: 750; }
.field label .required { color: var(--danger); }
.field-hint { margin: 0; color: var(--ink-500); font-size: 10px; }
.field-error { margin: 0; color: var(--danger); font-size: 10px; font-weight: 650; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  color: var(--ink-950);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
input::placeholder, textarea::placeholder { color: #98a4b5; }
input:hover, select:hover, textarea:hover { border-color: #aab8c9; }
input:focus, select:focus, textarea:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(22, 136, 240, .13); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"], .is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(199, 55, 79, .1); }
textarea { min-height: 105px; resize: vertical; }
select { padding-right: 36px; background-color: #fff; }
input[type="checkbox"], input[type="radio"] { width: 18px; min-height: 18px; accent-color: var(--blue-600); }
.check-field { display: inline-flex; align-items: center; gap: 9px; min-height: 36px; color: var(--ink-700); font-size: 12px; font-weight: 600; }
.input-group { display: flex; align-items: stretch; }
.input-group > input { min-width: 0; border-radius: 8px 0 0 8px; }
.input-suffix, .input-prefix { display: grid; min-width: 48px; place-items: center; color: var(--ink-600); font-size: 11px; font-weight: 700; background: var(--surface-subtle); border: 1px solid var(--line-strong); }
.input-suffix { border-left: 0; border-radius: 0 8px 8px 0; }
.input-prefix { border-right: 0; border-radius: 8px 0 0 8px; }
.input-prefix + input { border-radius: 0 8px 8px 0; }

.segmented-control { display: inline-flex; min-height: 42px; padding: 3px; background: #edf1f5; border-radius: 9px; }
.segmented-control button, .segmented-control label { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 14px; color: var(--ink-600); font-size: 11px; font-weight: 700; background: transparent; border: 0; border-radius: 7px; }
.segmented-control .is-active, .segmented-control [aria-pressed="true"], .segmented-control input:checked + span { color: var(--ink-950); background: #fff; box-shadow: var(--shadow-sm); }
.segmented-control label { position: relative; cursor: pointer; }
.segmented-control label input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.section-divider { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; margin: 7px 0 0; }
.section-divider::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }
.section-divider strong { color: var(--ink-800); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.info-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 24px; margin: 0; }
.info-list > div { min-width: 0; }
.info-list dt { color: var(--ink-500); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.info-list dd { margin: 3px 0 0; color: var(--ink-950); font-size: 13px; font-weight: 650; overflow-wrap: anywhere; }

.entity-header { display: flex; align-items: center; gap: 16px; padding: 20px; background: linear-gradient(135deg, #fff, #f7fbff); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.entity-icon { display: grid; flex: 0 0 54px; width: 54px; height: 54px; place-items: center; color: var(--blue-700); background: #e8f4ff; border-radius: 13px; }
.entity-icon svg { width: 29px; height: 29px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.entity-title { min-width: 0; flex: 1; }
.entity-title h2 { margin: 0; font-size: 22px; }
.entity-title p { margin: 4px 0 0; color: var(--ink-600); font-size: 12px; }
.entity-identifiers { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.timeline { position: relative; margin: 0; padding: 0; list-style: none; }
.timeline::before { content: ""; position: absolute; top: 8px; bottom: 8px; left: 12px; width: 2px; background: var(--line); }
.timeline-item { position: relative; display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 12px; padding-bottom: 20px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { z-index: 1; width: 12px; height: 12px; margin: 5px 0 0 7px; background: #fff; border: 3px solid var(--blue-600); border-radius: 50%; }
.timeline-card { padding: 13px 15px; background: var(--surface-subtle); border: 1px solid var(--line-soft); border-radius: 9px; }
.timeline-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; color: var(--ink-500); font-size: 10px; }
.timeline-card h4 { margin: 5px 0 3px; font-size: 13px; }
.timeline-card p { margin: 0; color: var(--ink-600); font-size: 11px; }

.line-editor { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.line-editor-header, .line-item {
  display: grid;
  grid-template-columns: 88px minmax(210px, 2fr) 76px 90px 114px 80px 120px 42px;
  gap: 9px;
  align-items: center;
  min-width: 940px;
}
.line-editor-header { padding: 9px 12px; color: var(--ink-500); font-size: 9px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; background: #f7f9fc; border-bottom: 1px solid var(--line); }
.line-items { overflow-x: auto; }
.line-item { position: relative; padding: 11px 12px; background: #fff; border-bottom: 1px solid var(--line-soft); }
.line-item:last-child { border-bottom: 0; }
.line-item input, .line-item select { min-height: 38px; padding: 7px 8px; font-size: 11px; }
.line-item-total { color: var(--ink-950); font-size: 12px; font-weight: 750; text-align: right; font-variant-numeric: tabular-nums; }
.line-editor-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; background: #fafbfd; border-top: 1px solid var(--line); }
.line-summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); gap: 20px; padding: 18px; background: #fff; border-top: 1px solid var(--line); }
.totals-list { grid-column: 2; margin: 0; }
.totals-row { display: flex; align-items: baseline; justify-content: space-between; gap: 20px; padding: 6px 0; color: var(--ink-600); font-size: 12px; }
.totals-row dd { margin: 0; color: var(--ink-950); font-weight: 700; font-variant-numeric: tabular-nums; }
.totals-row.total { margin-top: 5px; padding-top: 12px; color: var(--ink-950); font-size: 16px; font-weight: 800; border-top: 2px solid var(--ink-950); }
.totals-row.total dd { font-size: 20px; }

.invoice-preview {
  position: relative;
  width: min(100%, 900px);
  min-height: 1120px;
  margin: 0 auto;
  padding: clamp(34px, 6vw, 72px);
  color: #182230;
  background: #fff;
  border: 1px solid #d6dce4;
  box-shadow: 0 18px 60px rgba(17, 29, 45, .12);
}
.invoice-preview.is-draft::before { content: "ENTWURF"; position: absolute; top: 42%; left: 50%; color: rgba(10, 82, 144, .055); font-size: clamp(70px, 11vw, 140px); font-weight: 900; letter-spacing: .09em; transform: translate(-50%, -50%) rotate(-28deg); pointer-events: none; }
.invoice-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 35px; padding-bottom: 34px; border-bottom: 3px solid var(--navy-900); }
.invoice-brand h2 { margin: 0; color: var(--navy-900); font-size: 28px; }
.invoice-brand p, .invoice-company p { margin: 5px 0 0; color: #526174; font-size: 11px; }
.invoice-company { text-align: right; }
.invoice-address-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 40px; margin: 44px 0; }
.invoice-address { min-height: 120px; font-size: 12px; }
.invoice-address strong { display: block; margin-bottom: 10px; color: #647083; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.invoice-meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; align-content: start; margin: 0; font-size: 11px; }
.invoice-meta dt { color: #647083; }.invoice-meta dd { margin: 0; font-weight: 700; text-align: right; }
.invoice-preview h1 { margin: 0 0 9px; font-size: 25px; }
.invoice-vehicle { display: flex; flex-wrap: wrap; gap: 18px; margin: 18px 0 26px; padding: 13px 15px; background: #f4f7fa; border-left: 3px solid var(--blue-600); }
.invoice-vehicle span { font-size: 10px; }.invoice-vehicle strong { display: block; margin-top: 2px; font-size: 11px; }
.invoice-table { width: 100%; border-collapse: collapse; font-size: 10px; }
.invoice-table th { padding: 9px 7px; color: #fff; text-align: left; background: var(--navy-900); }
.invoice-table td { padding: 10px 7px; border-bottom: 1px solid #e2e6eb; vertical-align: top; }
.invoice-table .description { width: 45%; }.invoice-table .number { text-align: right; white-space: nowrap; }
.invoice-totals { width: min(100%, 350px); margin: 24px 0 0 auto; }
.invoice-footer { position: absolute; right: clamp(34px, 6vw, 72px); bottom: 38px; left: clamp(34px, 6vw, 72px); display: flex; justify-content: space-between; padding-top: 12px; color: #758194; font-size: 8px; border-top: 1px solid #d9dee5; }

.empty-state { display: flex; min-height: 190px; flex-direction: column; align-items: center; justify-content: center; padding: 28px; color: var(--ink-500); text-align: center; }
.empty-state.compact { min-height: 150px; }
.empty-state-icon { display: grid; width: 44px; height: 44px; margin-bottom: 10px; place-items: center; color: var(--blue-700); background: #edf6ff; border-radius: 12px; }
.empty-state-icon svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.empty-state strong { color: var(--ink-800); font-size: 12px; }
.empty-state p { max-width: 360px; margin: 4px 0 13px; font-size: 10px; }
.compact-empty { min-height: 230px; }

.loading-state { display: flex; min-height: 180px; align-items: center; justify-content: center; gap: 10px; color: var(--ink-500); font-size: 12px; }
.spinner { width: 24px; height: 24px; border: 3px solid #dce5ef; border-top-color: var(--blue-600); border-radius: 50%; animation: spin .75s linear infinite; }
.skeleton { position: relative; color: transparent !important; background: #e9eef4 !important; border-color: transparent !important; border-radius: 6px; overflow: hidden; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent); transform: translateX(-100%); animation: shimmer 1.4s infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 100% { transform: translateX(100%); } }

.modal-root:empty { display: none; }
.modal-backdrop, .drawer-backdrop { position: fixed; z-index: 100; inset: 0; display: grid; padding: 20px; place-items: center; background: rgba(5, 14, 27, .62); backdrop-filter: blur(3px); }
.modal { width: min(100%, 720px); max-height: calc(100vh - 40px); max-height: calc(100svh - 40px); background: #fff; border: 1px solid rgba(255, 255, 255, .25); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-wide { width: min(100%, 1080px); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding: 19px 22px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 18px; }.modal-header p { margin: 4px 0 0; color: var(--ink-500); font-size: 11px; }
.modal-body { max-height: calc(100vh - 180px); max-height: calc(100svh - 180px); padding: 22px; overflow-y: auto; }
.modal-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 9px; padding: 14px 22px; background: var(--surface-subtle); border-top: 1px solid var(--line); }
.drawer-backdrop { justify-items: end; padding: 0; }
.drawer { width: min(92vw, 560px); height: 100%; background: #fff; box-shadow: var(--shadow-lg); overflow-y: auto; }
.drawer-header { position: sticky; z-index: 1; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; background: #fff; border-bottom: 1px solid var(--line); }
.drawer-body { padding: 20px; }

.toast-root { position: fixed; z-index: 200; right: 20px; bottom: 20px; display: flex; width: min(390px, calc(100vw - 40px)); flex-direction: column; gap: 9px; pointer-events: none; }
.toast { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: start; gap: 10px; padding: 13px 14px; color: #fff; background: var(--navy-900); border: 1px solid rgba(255, 255, 255, .12); border-radius: 11px; box-shadow: var(--shadow-lg); pointer-events: auto; }
.toast-success { border-left: 4px solid #36d39d; }.toast-warning { border-left: 4px solid #ffc35a; }.toast-error { border-left: 4px solid #ff6e82; }
.toast strong { display: block; color: #fff; font-size: 12px; }.toast p { margin: 2px 0 0; color: #b8c8da; font-size: 10px; }

.mobile-nav { display: none; }
.noscript-message { position: fixed; z-index: 300; right: 20px; bottom: 20px; left: 20px; padding: 14px 18px; color: #fff; text-align: center; background: var(--danger); border-radius: 10px; box-shadow: var(--shadow-lg); }
.print-only { display: none !important; }

.lagerzettel-sheet { display: flex; flex-direction: column; gap: 10px; padding: 6px; color: #000; }
.lagerzettel-title { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: .04em; text-align: center; }
.lagerzettel-location { padding: 8px 10px; font-size: 18px; font-weight: 800; text-align: center; background: #f2f4f7; border: 2px solid #000; border-radius: 6px; }
.lagerzettel-identity { display: flex; flex-direction: column; gap: 4px; padding: 8px 0; border-top: 2px solid #000; border-bottom: 2px solid #000; }
.lagerzettel-identity > div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.lagerzettel-identity span { color: #444; }
.lagerzettel-identity strong { font-size: 14px; font-weight: 800; }
.lagerzettel-season { font-size: 13px; font-weight: 800; text-align: center; }
.lagerzettel-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.lagerzettel-table th, .lagerzettel-table td { padding: 5px 6px; text-align: left; border: 1px solid #000; }
.lagerzettel-table th { background: #eee; font-weight: 800; }
.lagerzettel-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; margin: 0; font-size: 12px; }
.lagerzettel-meta dt { color: #444; font-weight: 700; }
.lagerzettel-meta dd { margin: 0; font-weight: 700; }
.lagerzettel-preview { padding: 10px; background: #fff; border: 1px solid var(--line-soft); border-radius: 10px; }
  .modal-dialog.modal-whatsapp { width: min(760px, calc(100vw - 32px)); }
  .modal-whatsapp .modal-body { padding: 24px; }
  .invoice-whatsapp-form { display: flex; width: 100%; flex-direction: column; gap: 20px; }
  .whatsapp-identity { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: start; width: 100%; padding: 16px; background: #f7f9fc; border: 1px solid var(--line-soft); border-radius: 10px; }
  .whatsapp-customer-field { min-width: 0; }
  .whatsapp-identity strong { display: block; margin-bottom: 6px; color: var(--ink-500); font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
  .whatsapp-customer-name { display: block; min-width: 0; color: var(--ink-950); font-size: 15px; font-weight: 750; word-break: normal; overflow-wrap: break-word; white-space: normal; }
  .whatsapp-identity .whatsapp-phone-value { display: block; color: var(--ink-950); font-size: 15px; font-weight: 750; white-space: nowrap; }
  .whatsapp-phone-input { min-width: 0; }
  .whatsapp-message-field { display: flex; width: 100%; flex-direction: column; }
  .whatsapp-message-field textarea { box-sizing: border-box; width: 100%; min-height: 220px; resize: vertical; }

  @media (max-width: 620px) {
    .whatsapp-identity { grid-template-columns: 1fr; gap: 14px; }
  }

  .modal-dialog.modal-email { width: min(760px, calc(100vw - 32px)); }
  .modal-email .modal-body { padding: 24px; }
  .invoice-email-form { display: flex; width: 100%; flex-direction: column; gap: 20px; }
  .email-identity { padding: 16px; background: #f7f9fc; border: 1px solid var(--line-soft); border-radius: 10px; }
  .email-identity strong { display: block; margin-bottom: 6px; color: var(--ink-500); font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
  .email-to-value { display: block; color: var(--ink-950); font-size: 15px; font-weight: 750; word-break: break-all; }
  .email-message-field { display: flex; width: 100%; flex-direction: column; }
  .email-message-field textarea { box-sizing: border-box; width: 100%; min-height: 220px; resize: vertical; }
  .email-attachment { margin: 0; color: var(--ink-500); font-size: 13px; }
  .button-icon { display: inline-block; margin-right: 6px; vertical-align: -3px; }

@media (max-width: 1280px) {
  :root { --sidebar-width: 244px; }
  .profile-copy { display: none; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: minmax(0, 1.3fr) minmax(290px, .7fr); }
}

@media (max-width: 1020px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-orders-card { grid-row: auto; }
  .content-grid > .span-9, .content-grid > .span-8 { grid-column: span 12; }
  .content-grid > .span-4, .content-grid > .span-3 { grid-column: span 6; }
  .quick-actions { grid-template-columns: 1fr; }
  .quick-action { min-height: 58px; }
}

@media (max-width: 820px) {
  :root { --topbar-height: 66px; }
  body { padding-bottom: 70px; }
  body.nav-open { overflow: hidden; }
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 90; inset: 0 auto 0 0; width: min(86vw, 300px); transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar, .app-shell.nav-open .sidebar { transform: translateX(0); }
  .nav-scrim { position: fixed; z-index: 80; inset: 0; width: 100%; height: 100%; padding: 0; background: rgba(3, 10, 20, .55); border: 0; opacity: 0; visibility: hidden; transition: opacity .2s ease, visibility .2s ease; }
  body.nav-open .nav-scrim, .app-shell.nav-open .nav-scrim { display: block; opacity: 1; visibility: visible; }
  .mobile-menu-button { display: inline-flex !important; }
  .topbar { padding-inline: 14px; }
  .topbar-heading h1 { font-size: 18px; }
  .topbar-heading p { display: none; }
  .topbar-primary-action span { display: none; }
  .topbar-primary-action { width: 44px; padding: 0; }
  .profile-button { display: none; }
  .page-content { padding: 22px 16px 26px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
  .mobile-nav { position: fixed; z-index: 70; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(5, 1fr); height: 70px; padding: 5px max(5px, env(safe-area-inset-right)) max(5px, env(safe-area-inset-bottom)) max(5px, env(safe-area-inset-left)); background: rgba(255, 255, 255, .97); border-top: 1px solid var(--line-strong); box-shadow: 0 -8px 25px rgba(23, 40, 65, .08); backdrop-filter: blur(12px); }
  .mobile-nav-item { display: flex; min-width: 0; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 0 2px; color: var(--ink-500); font-size: 9px; font-weight: 700; background: transparent; border: 0; border-radius: 8px; }
  .mobile-nav-item > svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .mobile-nav-item.is-active, .mobile-nav-item[aria-current="page"] { color: var(--blue-700); background: #eff7ff; }
  .mobile-nav-main { transform: translateY(-13px); }
  .mobile-nav-main > span { display: grid; width: 47px; height: 47px; place-items: center; color: #fff; background: var(--blue-600); border: 4px solid #fff; border-radius: 15px; box-shadow: 0 7px 16px rgba(8, 117, 225, .3); }
  .mobile-nav-main svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; }
  .mobile-nav-main small { color: var(--blue-700); font-size: 9px; font-weight: 800; }
  .toast-root { bottom: 86px; }
  .invoice-preview { min-height: 0; padding: 28px 24px 80px; }
}

@media (max-width: 620px) {
  .page-heading h2 { font-size: 25px; }
  .search-command-card { padding: 20px 16px; border-radius: 14px; }
  .global-search { grid-template-columns: 22px minmax(0, 1fr); padding: 7px 10px; }
  .global-search kbd { display: none; }
  .global-search .button { grid-column: 1 / -1; width: 100%; }
  .metric-grid { grid-template-columns: 1fr; gap: 10px; }
  .metric-card { padding: 15px 17px; }
  .metric-value { font-size: 26px; }
  .card-header, .panel-header { align-items: flex-start; min-height: 64px; padding: 14px 15px; }
  .card-header > .button { min-width: 40px; }
  .card-header > .button svg { margin: 0; }
  .card-body, .panel-body { padding: 16px; }
  .toolbar { align-items: stretch; }
  .toolbar-search, .toolbar-filter, .toolbar-actions, .toolbar-actions .button { width: 100%; }
  .toolbar-actions { margin-left: 0; }
  .data-table.responsive-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .data-table.responsive-table, .data-table.responsive-table tbody, .data-table.responsive-table tr, .data-table.responsive-table td { display: block; width: 100%; }
  .data-table.responsive-table tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .data-table.responsive-table td { display: grid; grid-template-columns: minmax(95px, .42fr) minmax(0, 1fr); gap: 12px; padding: 5px 0; border: 0; }
  .data-table.responsive-table td::before { content: attr(data-label); color: var(--ink-500); font-size: 9px; font-weight: 800; text-transform: uppercase; }
  .form-grid { grid-template-columns: 1fr; }
  .field.span-12, .field.span-8, .field.span-6, .field.span-4, .field.span-3, .field.span-2 { grid-column: 1; }
  .content-grid > .span-12, .content-grid > .span-9, .content-grid > .span-8, .content-grid > .span-6, .content-grid > .span-4, .content-grid > .span-3 { grid-column: span 12; }
  .info-list { grid-template-columns: 1fr; }
  .entity-header { align-items: flex-start; flex-wrap: wrap; padding: 16px; }
  .entity-identifiers { width: 100%; }
  .line-editor-toolbar { top: var(--topbar-height); }
  .line-editor-section > .line-editor-toolbar .line-editor-header { display: flex; }
  .line-items { overflow: visible; }
  .line-item { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); min-width: 0; gap: 10px; padding: 14px; }
  .line-item > * { min-width: 0; }
  .line-item .line-description { grid-column: 1 / -1; }
  .line-item .line-item-total { display: flex; grid-column: 1 / -1; align-items: center; justify-content: space-between; padding-top: 9px; border-top: 1px solid var(--line-soft); }
  .line-item .line-item-total::before { content: "Total"; color: var(--ink-500); font-size: 10px; text-transform: uppercase; }
  .line-summary { grid-template-columns: 1fr; padding: 14px; }
  .totals-list { grid-column: 1; }
  .invoice-header, .invoice-address-grid { grid-template-columns: 1fr; flex-direction: column; gap: 20px; }
  .invoice-company { text-align: left; }
  .invoice-address-grid { display: grid; margin: 28px 0; }
  .invoice-table { font-size: 9px; }
  .invoice-table th, .invoice-table td { padding-inline: 4px; }
  .invoice-table .optional-column { display: none; }
  .invoice-footer { position: static; margin-top: 50px; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: 94svh; border-radius: 18px 18px 0 0; }
  .modal-body { max-height: calc(94svh - 145px); padding: 17px; }
  .modal-footer { padding: 12px 17px; }
  .modal-footer .button { flex: 1 1 auto; }
}

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

@media print {
  @page { size: A4 portrait; margin: 12mm; }
  :root { color-scheme: light; }
  html, body { min-width: 0; padding: 0; color: #000; background: #fff; }
  .sidebar, .topbar, .mobile-nav, .nav-scrim, .toast-root, .modal-root, .no-print, .page-heading, .toolbar { display: none !important; }
  .app-shell { display: none !important; }
  .app-stage { display: block; min-height: 0; }
  .page-content { width: 100%; max-width: none; margin: 0; padding: 0; }
  #invoice-print-root { display: block !important; }
  .invoice-print-sheet { width: 100%; min-height: 0; margin: 0; padding: 0; color: #000; border: 0; box-shadow: none; }
  body.print-invoice .page-content > :not(.invoice-preview), body.print-invoice .page-content > section > :not(.invoice-preview) { display: none !important; }
  .invoice-preview { width: 100%; min-height: 0; margin: 0; padding: 0; color: #000; border: 0; box-shadow: none; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .invoice-preview.is-draft::before { color: rgba(10, 82, 144, .045); }
  .invoice-header { padding-bottom: 8mm; }
  .invoice-address-grid { margin: 10mm 0; }
  .invoice-footer { position: fixed; right: 0; bottom: 0; left: 0; }
  .invoice-table tr, .invoice-table td, .invoice-table th { break-inside: avoid; }
  .print-only { display: block !important; }
  a { color: inherit; text-decoration: none; }

  /* Lagerzettel: readable from 1-2 meters away, high contrast, no chrome. */
  #lagerzettel-print-root { position: fixed; inset: 0; padding: 10mm; background: #fff; }
  .lagerzettel-sheet { gap: 8mm; }
  .lagerzettel-title { font-size: 34pt; letter-spacing: .08em; }
  .lagerzettel-location { padding: 6mm; font-size: 30pt; border-width: 3px; border-color: #000; }
  .lagerzettel-identity { gap: 3mm; padding: 5mm 0; border-color: #000; }
  .lagerzettel-identity > div { flex-direction: column; gap: 1mm; }
  .lagerzettel-identity span { font-size: 11pt; }
  .lagerzettel-identity strong { font-size: 20pt; }
  .lagerzettel-season { font-size: 16pt; }
  .lagerzettel-table { font-size: 13pt; }
  .lagerzettel-table th, .lagerzettel-table td { padding: 4mm; border-width: 2px; border-color: #000; }
  .lagerzettel-meta { font-size: 12pt; }
}

/* --------------------------------------------------------------------------
   Markup emitted by app.js
   -------------------------------------------------------------------------- */

@media screen {
  /* Shared route headers and controls */
  .page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 20px;
  }

  .page-header > div:first-child { min-width: 0; }

  .page-header h1 {
    margin: 0;
    font-size: clamp(25px, 2.2vw, 34px);
    font-weight: 780;
    letter-spacing: -.035em;
  }

  .page-header p {
    margin: 6px 0 0;
    color: var(--ink-600);
    font-size: 13px;
  }

  .form-page-header,
  .detail-header { align-items: flex-start; }

  .back-button,
  .text-button,
  .table-link {
    padding: 0;
    color: var(--blue-700);
    font: inherit;
    font-weight: 720;
    text-align: left;
    background: transparent;
    border: 0;
  }

  .back-button {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    margin: -5px 0 5px;
    color: var(--ink-600);
    font-size: 12px;
  }

  .back-button:hover,
  .text-button:hover,
  .table-link:hover { color: var(--blue-500); text-decoration: underline; text-underline-offset: 3px; }

  .button-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 9px;
  }

  .button-quiet {
    color: var(--ink-700);
    background: transparent;
    border-color: var(--line);
  }

  .button-quiet:hover { color: var(--blue-700); background: #f3f8fd; border-color: #bcd5ec; }

  .card-subtle {
    background: var(--surface-subtle);
    border: 1px solid var(--line);
    border-radius: 10px;
  }

  .muted { color: var(--ink-500); font-size: 11px; }
  .numeric { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .full-span { grid-column: 1 / -1; }

  /* Dashboard search and quick actions */
  .dashboard-search.card {
    position: relative;
    z-index: 4;
    padding: 8px;
    border-color: #d4dde8;
    box-shadow: 0 10px 30px rgba(16, 35, 60, .1);
    overflow: visible;
  }

  .dashboard-search .global-search {
    min-height: 52px;
    padding: 3px 5px 3px 12px;
    border: 0;
    box-shadow: none;
  }

  .dashboard-search .global-search:focus-within {
    border-color: transparent;
    box-shadow: 0 0 0 3px rgba(22, 136, 240, .13);
  }

  .search-icon {
    display: grid;
    width: 26px;
    height: 26px;
    place-items: center;
    color: var(--blue-700);
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
  }

  .quick-actions {
    display: block;
    margin: 19px 0 0;
  }

  .quick-actions > .section-heading {
    margin: 0 0 11px;
    padding: 0;
    border: 0;
  }

  .section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
  }

  .section-heading h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 760;
    letter-spacing: -.02em;
  }

  .section-heading p {
    margin: 4px 0 0;
    color: var(--ink-500);
    font-size: 11px;
  }

  .quick-action-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 13px;
  }

  .quick-action.card {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    align-items: center;
    gap: 13px;
    min-height: 82px;
    padding: 14px 16px;
    color: var(--ink-700);
    text-align: left;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
  }

  .quick-action.card:hover {
    background: #fafdff;
    border-color: #a9d3f7;
    box-shadow: 0 9px 24px rgba(16, 75, 132, .1);
    transform: translateY(-1px);
  }

  .quick-action.card .quick-action-icon {
    width: 48px;
    height: 48px;
    margin: 0;
    color: var(--blue-700);
    font-size: 22px;
    font-weight: 500;
    background: linear-gradient(145deg, #e7f8fc, #e7f1ff);
    border: 1px solid #d7edf5;
    border-radius: 12px;
  }

  .quick-action.card > span:nth-child(2) { display: flex; min-width: 0; flex-direction: column; }
  .quick-action.card strong { color: var(--ink-950); font-size: 13px; font-weight: 760; }
  .quick-action.card small { margin-top: 3px; color: var(--ink-500); font-size: 10px; line-height: 1.35; }

  .metric-card.card {
    display: grid;
    grid-template-rows: auto 1fr auto;
    align-items: start;
    width: 100%;
    min-height: 134px;
    padding: 18px 20px;
    color: var(--ink-950);
    text-align: left;
    cursor: pointer;
  }

  .metric-card.card:nth-child(1) { --metric-color: var(--blue-600); --metric-bg: #eaf4ff; }
  .metric-card.card:nth-child(2) { --metric-color: #0789a2; --metric-bg: var(--cyan-100); }
  .metric-card.card:nth-child(3) { --metric-color: #7052c9; --metric-bg: #eeeafd; }
  .metric-card.card:nth-child(4) { --metric-color: var(--success); --metric-bg: var(--success-bg); }

  .metric-card.card:hover {
    border-color: color-mix(in srgb, var(--metric-color) 35%, var(--line));
    box-shadow: 0 9px 24px rgba(16, 35, 60, .09);
    transform: translateY(-1px);
  }

  .metric-label {
    color: var(--ink-600);
    font-size: 11px;
    font-weight: 760;
  }

  .metric-card.card .metric-value { align-self: center; margin: 5px 0 1px; color: var(--ink-950); }
  .metric-card.card > small { color: var(--ink-500); font-size: 10px; }

  /* Dashboard lists */
  .list-card { overflow: hidden; }

  .card-header h2 {
    margin: 0;
    color: var(--ink-950);
    font-size: 16px;
    font-weight: 750;
    letter-spacing: -.018em;
  }

  .list-card .card-header { min-height: 66px; }

  .text-button {
    min-height: 34px;
    padding: 0 9px;
    font-size: 11px;
    white-space: nowrap;
    border-radius: 7px;
  }

  .text-button:hover { background: #edf6ff; text-decoration: none; }

  .compact-list { display: flex; min-height: 76px; flex-direction: column; }

  .compact-list-item {
    display: flex;
    width: 100%;
    min-height: 65px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 11px 18px;
    color: var(--ink-700);
    text-align: left;
    background: #fff;
    border: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .compact-list-item:last-child { border-bottom: 0; }
  .compact-list-item:hover { background: #f6faff; }
  .compact-list-item > span { display: flex; min-width: 0; flex-direction: column; }
  .compact-list-item > span:first-child { flex: 1; }
  .compact-list-item strong { color: var(--ink-950); font-size: 12px; font-weight: 750; }
  .compact-list-item small { margin-top: 3px; color: var(--ink-500); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .list-item-aside {
    flex: 0 0 auto;
    align-items: flex-end;
    text-align: right;
  }

  .empty-list {
    display: grid;
    min-height: 105px;
    margin: 0;
    padding: 22px;
    place-items: center;
    color: var(--ink-500);
    font-size: 11px;
    text-align: center;
  }

  /* Global search results */
  .search-results:empty { display: none; }

  .search-results:not(:empty) {
    margin: 4px 5px 5px;
    padding: 12px;
    background: #f8fafc;
    border-top: 1px solid var(--line-soft);
    border-radius: 0 0 9px 9px;
  }

  .search-result-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }

  .search-group {
    min-width: 0;
    padding: 9px;
    background: #fff;
    border: 1px solid var(--line-soft);
    border-radius: 9px;
  }

  .search-group h3 {
    display: flex;
    justify-content: space-between;
    margin: 0 0 6px;
    padding: 2px 5px 7px;
    color: var(--ink-600);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .05em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--line-soft);
  }

  .search-group h3 span { color: var(--blue-700); }

  .search-result-item {
    display: flex;
    width: 100%;
    min-height: 46px;
    flex-direction: column;
    justify-content: center;
    padding: 7px 8px;
    color: var(--ink-800);
    text-align: left;
    background: transparent;
    border: 0;
    border-radius: 7px;
  }

  .search-result-item:hover { color: var(--blue-700); background: #edf6ff; }
  .search-result-item strong { font-size: 11px; }
  .search-result-item small { margin-top: 2px; color: var(--ink-500); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .search-hint, .search-loading, .search-error { margin: 0; padding: 9px 10px; color: var(--ink-600); font-size: 11px; }
  .search-error { color: var(--danger); background: var(--danger-bg); border-radius: 7px; }
  .search-empty { padding: 18px; text-align: center; }
  .search-empty strong { font-size: 12px; }
  .search-empty p { margin: 3px 0 0; color: var(--ink-500); font-size: 10px; }

  /* Data tables */
  .table-card { margin-bottom: 16px; overflow: hidden; }

  .table-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 11px;
    padding: 14px 16px;
    background: #fafbfd;
    border-bottom: 1px solid var(--line);
  }

  .table-search { display: block; flex: 1 1 330px; max-width: 620px; }
  .table-search input { background: #fff; }

  .toolbar-select {
    display: flex;
    min-width: 185px;
    flex-direction: column;
    gap: 5px;
    color: var(--ink-600);
    font-size: 10px;
    font-weight: 750;
  }

  .toolbar-select select { min-height: 44px; }
  .data-table td > small { display: block; margin-top: 3px; color: var(--ink-500); font-size: 9px; }
  .data-table .table-link { font-size: inherit; }
  .table-link.plate-text { display: inline-flex; }
  .table-actions .icon-button {
    width: auto;
    min-width: 76px;
    min-height: 36px;
    padding: 0 10px;
    font-size: 10px;
    font-weight: 720;
  }
  .clickable-row { cursor: pointer; }
  .clickable-row:hover { background: #f5faff !important; }
  .history-table { min-width: 860px; }
  .empty-row td { height: 130px; color: var(--ink-500); text-align: center; }

  .plate-text {
    display: inline-block;
    color: #17202d !important;
    font-size: 11px !important;
    font-weight: 850 !important;
    letter-spacing: .055em;
    line-height: 1.2;
    white-space: nowrap;
  }

  .plate-display {
    display: inline-flex;
    align-items: center;
    min-height: 39px;
    padding: 4px 12px;
    color: #101722;
    font-size: 17px !important;
    font-weight: 900 !important;
    letter-spacing: .055em;
    background: #fff;
    border: 2px solid #1c2736;
    border-radius: 5px;
    box-shadow: inset 0 0 0 1px #e0e5eb;
    white-space: nowrap;
  }

  .plate-heading {
    display: inline-flex;
    width: fit-content;
    margin-top: 2px !important;
    padding: 5px 13px;
    color: #101722;
    font-size: 22px !important;
    letter-spacing: .05em !important;
    background: #fff;
    border: 2px solid #1c2736;
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px #e0e5eb;
  }

  .count-badge {
    display: inline-grid;
    min-width: 24px;
    min-height: 24px;
    margin-left: 5px;
    padding: 2px 7px;
    place-items: center;
    color: var(--blue-700);
    font-size: 10px;
    background: #e8f3ff;
    border-radius: 999px;
    vertical-align: middle;
  }

  /* Entity details */
  .detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
  }

  .detail-card { min-height: 170px; overflow: hidden; }
  .detail-card > .preserve-lines { padding: 19px 20px 10px; }
  .detail-card > .muted { display: block; padding: 0 20px 18px; }
  .tire-storage-card-list { display: flex; flex-direction: column; gap: 10px; padding: 0 20px 18px; }
  .tire-storage-card-item { padding: 10px 0; border-top: 1px solid var(--line-soft); }
  .tire-storage-card-item:first-child { border-top: 0; padding-top: 0; }
  .tire-storage-card-item > header { margin-bottom: 6px; color: var(--ink-950); font-size: 12px; font-weight: 720; }

  .detail-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    margin: 0;
    padding: 8px 20px 17px;
  }

  .detail-list > div { min-width: 0; padding: 12px 10px 12px 0; border-bottom: 1px solid var(--line-soft); }
  .detail-list > div:nth-last-child(-n + 2) { border-bottom: 0; }
  .detail-list dt { color: var(--ink-500); font-size: 9px; font-weight: 800; letter-spacing: .045em; text-transform: uppercase; }
  .detail-list dd { margin: 3px 0 0; color: var(--ink-950); font-size: 12px; font-weight: 650; overflow-wrap: anywhere; }

  /* Reifenhotel shelf overview */
  .tire-area-overview { display: grid; gap: 16px; margin-bottom: 16px; }
  .tire-area-card { overflow: hidden; }
  .tire-area-card .card-header p { margin: 3px 0 0; color: var(--ink-500); font-size: 11px; }
  .tire-rack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
    gap: 12px;
    padding: 16px 20px 20px;
  }
  .tire-rack { min-width: 0; border: 1px solid var(--line); background: #f7f9fb; }
  .tire-rack h3 { margin: 0; padding: 9px 11px; color: var(--ink-700); font-size: 11px; border-bottom: 1px solid var(--line); }
  .tire-level {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 8px;
    min-height: 58px;
    align-content: center;
    padding: 9px 11px;
    border-bottom: 1px solid var(--line-soft);
  }
  .tire-level:last-child { border-bottom: 0; }
  .tire-level span { color: var(--ink-500); font-size: 10px; }
  .tire-level strong { color: var(--ink-950); font-size: 12px; }
  .tire-level small { grid-column: 1 / -1; font-size: 10px; font-weight: 700; }
  .tire-level-free { border-left: 3px solid var(--success); background: var(--success-bg); }
  .tire-level-free small { color: var(--success); }
  .tire-level-occupied { border-left: 3px solid var(--danger); background: var(--danger-bg); }
  .tire-level-occupied small { color: var(--danger); }
  .tire-level-inactive { border-left: 3px solid var(--ink-400); background: #eef1f4; }
  .tire-level-inactive small { color: var(--ink-500); }
  .tire-area-card .empty-state.compact { min-height: 130px; padding: 24px; }

  .tire-occupancy-card { display: grid; gap: 10px; padding: 14px 18px; margin-bottom: 16px; }
  .tire-occupancy-card > div { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; color: var(--ink-700); font-size: 13px; }
  .tire-occupancy-card strong { color: var(--ink-950); }
  .tire-occupancy-progress { width: 100%; height: 10px; accent-color: var(--success); }
  .storage-plan { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, 0.7fr) minmax(0, 1fr); gap: 18px; align-items: start; }
  .storage-plan-section { min-width: 0; }
  .storage-plan-section h2 { margin: 0 0 10px; color: var(--ink-950); font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; }
  .storage-plan-racks { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 12px; }
  .storage-rack-card { overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 18px rgba(16, 32, 56, 0.06); }
  .storage-rack-card h3 { margin: 0; padding: 8px 10px; color: var(--ink-700); font-size: 11px; background: #f7f9fb; border-bottom: 1px solid var(--line); }
  .storage-slot { display: grid; gap: 2px; width: 100%; min-height: 74px; padding: 9px 10px; text-align: left; background: #fff; border: 0; border-bottom: 1px solid var(--line-soft); cursor: pointer; }
  .storage-slot:last-child { border-bottom: 0; }
  .storage-slot strong { color: var(--ink-950); font-size: 13px; }
  .storage-slot span { color: var(--ink-700); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .storage-slot small { color: var(--ink-500); font-size: 11px; }
  .storage-slot-free { border-left: 3px solid var(--success); background: var(--success-bg); }
  .storage-slot-free:hover { background: #e6f6ef; }
  .storage-slot-occupied { border-left: 3px solid var(--blue-600); background: #f1f7fd; }
  .storage-slot-occupied:hover { background: #e7f1fb; }
  .storage-slot-inactive { border-left: 3px solid #d98731; background: #fff7ed; cursor: not-allowed; }
  .storage-slot:disabled { opacity: 0.65; cursor: not-allowed; }
  .inline-field-action { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
  .modal-wide .modal-dialog, .modal-dialog.modal-wide { width: min(1120px, calc(100vw - 32px)); }

  .preserve-lines { margin: 0; color: var(--ink-700); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }

  .identity-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    margin-bottom: 16px;
    padding: 0;
    background: var(--line-soft);
    overflow: hidden;
  }

  .identity-strip > div {
    display: flex;
    min-width: 0;
    min-height: 92px;
    flex-direction: column;
    justify-content: center;
    padding: 15px 18px;
    background: #fff;
  }

  .identity-strip > div > span,
  .selected-vehicle > div > span,
  .invoice-vehicle-strip > div > span {
    margin-bottom: 5px;
    color: var(--ink-500);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .045em;
    text-transform: uppercase;
  }

  .identity-strip > div > strong { color: var(--ink-950); font-size: 14px; }
  .order-identity { grid-template-columns: 1.05fr 1.35fr 1.6fr 1fr 1.15fr; }
  .order-notes-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .internal-note-card { background: #fffcf4; border-color: #eddca7; }

  .privacy-badge {
    display: inline-flex;
    align-items: center;
    min-height: 23px;
    padding: 3px 8px;
    color: #8a5d00;
    font-size: 9px;
    font-style: normal;
    font-weight: 800;
    background: #fff1c9;
    border: 1px solid #efd990;
    border-radius: 999px;
  }

  .status-large { min-height: 32px; padding: 5px 11px; font-size: 11px; }

  .info-banner {
    margin: 0 0 16px;
    padding: 13px 15px;
    color: #285a85;
    font-size: 11px;
    font-weight: 600;
    background: #edf6ff;
    border: 1px solid #c9e3f9;
    border-left: 4px solid var(--blue-600);
    border-radius: 9px;
  }

  .info-banner.subtle { margin: 0; color: var(--ink-600); background: #fafbfd; border-color: var(--line); border-left-width: 1px; border-radius: 0; }

  .vehicle-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding: 16px;
  }

  .vehicle-card-grid > .empty-list { grid-column: 1 / -1; }

  .vehicle-summary {
    display: flex;
    min-height: 120px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 16px;
    color: var(--ink-700);
    text-align: left;
  }

  .vehicle-summary:hover { background: #f1f8ff; border-color: #acd2f2; }
  .vehicle-summary strong:not(.plate-display) { margin-top: 10px; color: var(--ink-950); font-size: 13px; }
  .vehicle-summary small { margin-top: 3px; color: var(--ink-500); font-size: 10px; }

  /* Forms */
  .entity-form { display: flex; flex-direction: column; gap: 16px; }
  .form-section { overflow: hidden; }

  .form-section > .section-heading {
    margin: 0;
    padding: 17px 20px;
    background: #fcfdff;
    border-bottom: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .form-section > .form-grid { padding: 20px; }

  .form-field {
    display: flex;
    grid-column: span 4;
    min-width: 0;
    flex-direction: column;
    gap: 6px;
  }

  .form-field.span-wide { grid-column: span 8; }
  .form-field.span-full { grid-column: 1 / -1; }

  .form-field > span,
  .line-field > span:first-child {
    color: var(--ink-700);
    font-size: 11px;
    font-weight: 750;
  }

  .form-field > span em { margin-left: 3px; color: var(--danger); font-style: normal; }
  .form-field > span .privacy-badge { margin-left: 8px; }
  .form-field > small { color: var(--ink-500); font-size: 10px; }
  .internal-field { padding: 12px; background: #fffcf4; border: 1px solid #eddeae; border-radius: 9px; }

  .selected-vehicle {
    display: grid;
    grid-template-columns: .8fr 1.5fr 1.2fr;
    gap: 1px;
    margin: 0 20px 20px;
    background: var(--line);
    overflow: hidden;
  }

  .selected-vehicle > div { display: flex; min-width: 0; flex-direction: column; justify-content: center; padding: 12px 15px; background: #f8fbff; }
  .selected-vehicle strong { color: var(--ink-950); font-size: 11px; overflow-wrap: anywhere; }

  .sticky-form-actions {
    position: sticky;
    z-index: 15;
    bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-height: 68px;
    padding: 11px 14px;
    background: rgba(255, 255, 255, .95);
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    box-shadow: 0 12px 35px rgba(16, 35, 60, .14);
    backdrop-filter: blur(12px);
  }

  .sticky-form-actions > span:first-child { flex: 1; }

  .integration-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 22px;
    background: linear-gradient(135deg, #fff, #f1f8ff);
  }

  .integration-card h2 { margin: 4px 0; font-size: 18px; }
  .integration-card p { max-width: 680px; margin: 0; color: var(--ink-600); font-size: 11px; }

  .bexio-test-card { align-items: center; }
  .bexio-integration-copy { min-width: 0; flex: 1; }
  .bexio-test-card > .button { flex: none; white-space: nowrap; }

  .bexio-connection-status {
    display: flex;
    max-width: 680px;
    align-items: flex-start;
    gap: 10px;
    margin-top: 14px;
    padding: 11px 13px;
    color: var(--ink-700);
    background: var(--surface-subtle);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
  }

  .bexio-connection-status strong { display: block; font-size: 12px; }
  .bexio-connection-status p { margin-top: 2px; }

  .bexio-status-dot {
    width: 9px;
    height: 9px;
    flex: none;
    margin-top: 5px;
    background: var(--warning);
    border-radius: 50%;
    box-shadow: 0 0 0 4px var(--warning-bg);
  }

  .bexio-test-card.is-ready .bexio-status-dot,
  .bexio-test-card.is-checking .bexio-status-dot { background: var(--blue-600); box-shadow: 0 0 0 4px var(--cyan-100); }
  .bexio-test-card.is-connected .bexio-connection-status { background: var(--success-bg); border-color: #c2e8d9; }
  .bexio-test-card.is-connected .bexio-status-dot { background: var(--success); box-shadow: 0 0 0 4px #c2e8d9; }
  .bexio-test-card.is-error .bexio-connection-status { background: var(--danger-bg); border-color: #f1c5cc; }
  .bexio-test-card.is-error .bexio-status-dot { background: var(--danger); box-shadow: 0 0 0 4px #f1c5cc; }

  /* Editable line items */
  .line-editor-section { overflow: visible; }

  .line-editor-toolbar {
    position: sticky;
    z-index: 20;
    top: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 5px 14px rgba(23, 40, 65, .08);
  }

  .line-editor-toolbar .line-editor-header {
    display: flex;
    grid-template-columns: none;
    min-width: 0;
    padding: 15px 19px;
    color: inherit;
    font-size: inherit;
    letter-spacing: 0;
    text-transform: none;
    background: #fcfdff;
    border-bottom: 0;
  }

  .template-picker {
    display: grid;
    grid-template-columns: auto minmax(220px, 1fr) auto;
    align-items: center;
    gap: 11px;
    padding: 13px 18px;
    background: #f4f9ff;
    border-bottom: 1px solid #dcebf8;
  }

  .template-picker > label { color: var(--ink-700); font-size: 11px; font-weight: 750; }
  .template-picker select { min-height: 42px; }

  .empty-line-items { display: flex; min-height: 170px; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; color: var(--ink-500); background: #fafbfd; }
  .empty-line-items p { margin: 0; font-size: 11px; }

  .line-editor-section .line-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    background: #f4f6f9;
    overflow: visible;
  }

  .line-editor-section .line-item {
    display: block;
    min-width: 0;
    padding: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }

  .line-item-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 49px;
    padding: 8px 12px 8px 15px;
    background: #fafbfd;
    border-bottom: 1px solid var(--line-soft);
  }

  .line-item-heading > strong { font-size: 11px; }
  .line-item-actions { display: flex; align-items: center; gap: 5px; }
  .line-item-actions .icon-button { width: auto; min-width: 36px; min-height: 34px; height: 34px; padding: 0 9px; font-size: 11px; }
  .icon-button.danger { color: var(--danger); background: #fff; border-color: #f0c5cc; }
  .icon-button.danger:hover { color: #fff; background: var(--danger); border-color: var(--danger); }

  .line-item-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 12px;
    padding: 15px;
  }

  .line-field { display: flex; grid-column: span 2; min-width: 0; flex-direction: column; gap: 5px; }
  .line-field.span-description { grid-column: span 4; }
  .line-field input, .line-field select { min-height: 40px; padding: 7px 9px; font-size: 11px; }

  .input-with-suffix { position: relative; display: block; }
  .input-with-suffix input { padding-right: 42px; }
  .input-with-suffix em { position: absolute; top: 50%; right: 9px; color: var(--ink-500); font-size: 9px; font-style: normal; font-weight: 800; transform: translateY(-50%); pointer-events: none; }

  .line-editor-section .field-hint { margin: -3px 15px 12px; padding: 8px 10px; background: var(--warning-bg); border-radius: 7px; }

  .line-editor-section .line-item-total {
    display: flex;
    grid-column: auto;
    align-items: center;
    justify-content: flex-end;
    gap: 20px;
    min-width: 0;
    padding: 10px 15px;
    color: var(--ink-600);
    font-size: 10px;
    text-align: right;
    background: #fafbfd;
    border-top: 1px solid var(--line-soft);
  }

  .line-editor-section .line-item-total strong { min-width: 120px; color: var(--ink-950); font-size: 13px; }

  .totals-panel { display: flex; justify-content: flex-end; padding: 18px 20px; background: #fff; border-top: 1px solid var(--line); }
  .totals-panel dl { width: min(100%, 390px); margin: 0; }
  .totals-panel dl > div { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; padding: 5px 0; color: var(--ink-600); font-size: 11px; }
  .totals-panel dd { margin: 0; color: var(--ink-950); font-weight: 720; font-variant-numeric: tabular-nums; }
  .totals-panel .total-row { margin-top: 7px; padding-top: 12px; color: var(--ink-950); font-size: 14px; font-weight: 800; border-top: 2px solid var(--navy-900); }
  .totals-panel .total-row dd { font-size: 18px; }
  .totals-compact { padding-right: 0; }
  .invoice-lines-wrap { border-bottom: 1px solid var(--line-soft); }
  .invoice-lines .item-type-badge { display: inline-flex; padding: 3px 7px; color: var(--blue-700); font-size: 9px; font-weight: 800; background: #eaf4ff; border-radius: 999px; }
  .invoice-lines .text-line td { color: var(--ink-600); background: #fafbfd; font-style: italic; }
  .tire-storage-info-block { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; font-style: normal; background: #fff; border: 1px solid var(--line-soft); border-radius: 8px; }
  .tire-storage-info-block strong { color: var(--navy-900); font-size: 10px; letter-spacing: 0.03em; text-transform: uppercase; }
  .tire-storage-info-block span { color: var(--ink-700); font-size: 12px; }

  /* Templates */
  .template-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .template-card { display: flex; min-height: 235px; flex-direction: column; overflow: hidden; }
  .template-card-main { flex: 1; padding: 21px; }
  .template-card-main h2 { margin: 7px 0 8px; font-size: 18px; }
  .template-card-main p { margin: 0; color: var(--ink-600); font-size: 11px; }
  .template-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; background: #fafbfd; border-top: 1px solid var(--line-soft); }
  .template-card-footer > strong { font-size: 13px; font-variant-numeric: tabular-nums; }

  /* Invoices */
  .invoice-sheet { margin-bottom: 16px; padding: clamp(24px, 4vw, 48px); overflow: hidden; }

  .invoice-sheet-header,
  .invoice-preview-meta {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(250px, .7fr);
    gap: 42px;
    align-items: start;
    padding-bottom: 25px;
    border-bottom: 2px solid var(--navy-900);
  }

  .invoice-sheet-header h2,
  .invoice-preview-meta h3 { margin: 5px 0 6px; font-size: 20px; }
  .invoice-sheet-header p,
  .invoice-preview-meta p { margin: 0; color: var(--ink-600); font-size: 11px; white-space: pre-line; }
  .invoice-sheet-header dl,
  .invoice-preview-meta dl { margin: 0; }
  .invoice-sheet-header dl > div,
  .invoice-preview-meta dl > div { display: flex; justify-content: space-between; gap: 18px; padding: 5px 0; font-size: 10px; border-bottom: 1px solid var(--line-soft); }
  .invoice-sheet-header dd,
  .invoice-preview-meta dd { margin: 0; font-weight: 750; text-align: right; }

  .invoice-vehicle-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    margin: 24px 0;
    background: #dce5ee;
    border: 1px solid #dce5ee;
    border-left: 4px solid var(--blue-600);
    border-radius: 7px;
    overflow: hidden;
  }

  .invoice-vehicle-strip > div { display: flex; min-width: 0; min-height: 68px; flex-direction: column; justify-content: center; padding: 10px 13px; background: #f6f9fc; }
  .invoice-vehicle-strip strong { color: var(--ink-950); font-size: 11px; overflow-wrap: anywhere; }

  .invoice-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    padding: 20px;
    background: linear-gradient(135deg, #fff, #f3f7fb);
  }

  .invoice-actions h2 { margin: 0; font-size: 16px; }
  .invoice-actions p { margin: 4px 0 0; color: var(--ink-500); font-size: 10px; }

  .invoice-preview-meta { margin-bottom: 0; }
  .preview-warning { margin: -20px -20px 24px; padding: 11px 15px; color: #745000; font-size: 10px; font-weight: 700; text-align: center; background: #fff3cd; border-bottom: 1px solid #ecd98e; }
  .privacy-confirmation { margin: 18px 0 0; padding: 11px 13px; color: var(--success); font-size: 10px; font-weight: 650; background: var(--success-bg); border: 1px solid #c4e9da; border-radius: 8px; }

  /* Dialogs and toasts */
  body.modal-open { overflow: hidden; }

  .modal-root.is-open {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: grid;
    padding: 20px;
    place-items: center;
  }

  .modal-root .modal-backdrop { z-index: 0; padding: 0; }

  .modal-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 720px);
    max-height: calc(100vh - 40px);
    max-height: calc(100svh - 40px);
    background: #fff;
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
  }

  .modal-dialog.modal-wide { width: min(100%, 1100px); }
  .modal-close { display: grid; flex: 0 0 38px; width: 38px; height: 38px; padding: 0; place-items: center; color: var(--ink-600); font-size: 24px; line-height: 1; background: #fff; border: 1px solid var(--line); border-radius: 9px; }
  .modal-close:hover { color: var(--danger); background: var(--danger-bg); border-color: #f2c6ce; }
  .modal-dialog .modal-body { max-height: calc(100vh - 180px); max-height: calc(100svh - 180px); }
  .modal-dialog .invoice-preview { width: 100%; min-height: 0; padding: 34px; border: 0; box-shadow: none; }

  .toast-root .toast {
    display: block;
    min-height: 48px;
    padding: 14px 16px;
    color: #fff;
    font-size: 11px;
    font-weight: 650;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .2s ease, transform .2s ease;
  }

  .toast-root .toast.is-visible { opacity: 1; transform: translateY(0); }
  .error-state .empty-state-icon { color: var(--danger); background: var(--danger-bg); }

  .button:disabled,
  .button[aria-disabled="true"] {
    color: #718096;
    background: #edf1f5;
    border-color: #d7dee7;
    box-shadow: none;
    opacity: 1;
  }

  .icon-button:disabled,
  input:disabled,
  select:disabled,
  textarea:disabled {
    color: #8491a3;
    background: #f1f3f6;
    border-color: #e0e5eb;
    box-shadow: none;
    opacity: 1;
  }
}

@media screen and (max-width: 1120px) {
  .quick-action-grid { gap: 10px; }
  .quick-action.card { padding-inline: 13px; }
  .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vehicle-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .order-identity { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .order-notes-grid { grid-template-columns: 1fr; }
  .line-field { grid-column: span 3; }
  .line-field.span-description { grid-column: span 6; }
}

@media screen and (max-width: 820px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .quick-action-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .quick-action.card { grid-template-columns: 42px minmax(0, 1fr); min-height: 76px; padding: 11px; }
  .quick-action.card .quick-action-icon { width: 42px; height: 42px; }
  .search-result-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .identity-strip, .order-identity { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-field { grid-column: span 6; }
  .form-field.span-wide { grid-column: span 12; }
  .selected-vehicle { grid-template-columns: 1fr 1fr; }
  .selected-vehicle > div:last-child { grid-column: 1 / -1; }
  .invoice-sheet-header, .invoice-preview-meta { grid-template-columns: 1fr; gap: 22px; }
  .invoice-vehicle-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal-root.is-open { padding: 12px; }
  .line-item-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .line-field { grid-column: span 2; }
  .line-field.span-description { grid-column: span 4; }
}

@media screen and (max-width: 620px) {
  .page-header { align-items: stretch; flex-direction: column; gap: 13px; }
  .page-header > .button { width: 100%; }
  .detail-header .button-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .detail-header .button-row .button { width: 100%; }

  .dashboard-search.card { padding: 5px; }
  .dashboard-search .global-search { display: grid; grid-template-columns: 25px minmax(0, 1fr) auto; padding: 4px 5px 4px 10px; }
  .dashboard-search .global-search .button { grid-column: auto; width: auto; min-height: 40px; padding-inline: 12px; }
  .quick-action-grid { grid-template-columns: 1fr; }
  .quick-action.card { min-height: 70px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card.card { min-height: 120px; padding: 15px; }

  .list-card .card-header { align-items: center; }
  .compact-list-item { padding-inline: 14px; }
  .compact-list-item small { max-width: 210px; }
  .list-item-aside { max-width: 44%; }

  .table-toolbar { align-items: stretch; }
  .table-search, .toolbar-select { width: 100%; max-width: none; }
  .table-card > .table-wrap > .data-table:not(.invoice-lines) thead { display: none; }
  .table-card > .table-wrap > .data-table:not(.invoice-lines),
  .table-card > .table-wrap > .data-table:not(.invoice-lines) tbody,
  .table-card > .table-wrap > .data-table:not(.invoice-lines) tr,
  .table-card > .table-wrap > .data-table:not(.invoice-lines) td { display: block; width: 100%; }
  .table-card > .table-wrap > .data-table:not(.invoice-lines) tr { padding: 12px 15px; border-bottom: 1px solid var(--line); }
  .table-card > .table-wrap > .data-table:not(.invoice-lines) tr:last-child { border-bottom: 0; }
  .table-card > .table-wrap > .data-table:not(.invoice-lines) td { display: grid; grid-template-columns: 105px minmax(0, 1fr); gap: 10px; padding: 6px 0; border: 0; text-align: left !important; }
  .table-card > .table-wrap > .data-table:not(.invoice-lines) td::before { content: attr(data-label); color: var(--ink-500); font-size: 9px; font-weight: 800; text-transform: uppercase; }
  .table-card > .table-wrap > .data-table:not(.invoice-lines) td.table-actions { display: flex; justify-content: flex-end; }
  .table-card > .table-wrap > .data-table:not(.invoice-lines) td.table-actions::before { content: none; }
  .table-card > .table-wrap > .data-table:not(.invoice-lines) .empty-row { padding: 0; }
  .table-card > .table-wrap > .data-table:not(.invoice-lines) .empty-row td { display: grid; height: 130px; place-items: center; }
  .table-card > .table-wrap > .data-table:not(.invoice-lines) .empty-row td::before { content: none; }

  .detail-list { grid-template-columns: 1fr; }
  .detail-list > div:nth-last-child(-n + 2) { border-bottom: 1px solid var(--line-soft); }
  .detail-list > div:last-child { border-bottom: 0; }
  .identity-strip, .order-identity { grid-template-columns: 1fr; }
  .identity-strip > div { min-height: 76px; }
  .vehicle-card-grid, .template-grid { grid-template-columns: 1fr; }

  .form-section > .form-grid { padding: 16px; }
  .form-field, .form-field.span-wide, .form-field.span-full { grid-column: 1 / -1; }
  .selected-vehicle { grid-template-columns: 1fr; margin-inline: 16px; }
  .selected-vehicle > div:last-child { grid-column: auto; }
  .sticky-form-actions { bottom: 79px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sticky-form-actions .button { width: 100%; }
  .integration-card, .invoice-actions { align-items: stretch; flex-direction: column; }
  .bexio-test-card > .button { width: 100%; }

  .line-editor-toolbar .line-editor-header { align-items: stretch; flex-direction: column; }
  .line-editor-toolbar .line-editor-header .button { width: 100%; }
  .template-picker { grid-template-columns: 1fr; }
  .line-editor-section .line-item { display: block; min-width: 0; }
  .line-item-heading { align-items: flex-start; }
  .line-item-actions { flex-wrap: wrap; justify-content: flex-end; }
  .line-item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .line-field, .line-field.span-description { grid-column: span 1; }
  .line-field.span-description { grid-column: 1 / -1; }
  .line-editor-section .line-item-total { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; text-align: center; }
  .line-editor-section .line-item-total strong { min-width: 0; }
  .totals-panel { padding: 15px; }
  .invoice-lines { min-width: 760px; }

  .invoice-sheet { padding: 20px 16px; }
  .invoice-vehicle-strip { grid-template-columns: 1fr; }
  .modal-root.is-open { align-items: end; padding: 0; }
  .modal-dialog, .modal-dialog.modal-wide { width: 100%; max-height: 94svh; border-radius: 17px 17px 0 0; }
  .modal-dialog .modal-body { max-height: calc(94svh - 145px); }
  .modal-dialog .invoice-preview { padding: 22px 16px; }
  .preview-warning { margin: -8px -4px 20px; }
}

@media print {
  .page-header,
  .invoice-actions,
  .sticky-form-actions { display: none !important; }

  .invoice-sheet {
    width: 100%;
    margin: 0;
    padding: 0;
    color: #000;
    border: 0;
    box-shadow: none;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .invoice-sheet-header {
    display: grid;
    grid-template-columns: 1.3fr .7fr;
    gap: 15mm;
    padding-bottom: 7mm;
    border-bottom: 2px solid #101828;
  }

  .invoice-sheet-header dl > div,
  .invoice-preview-meta dl > div { display: flex; justify-content: space-between; gap: 10mm; }

  .invoice-vehicle-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin: 7mm 0;
    border: 1px solid #ccd5e1;
    border-left: 3px solid #0875e1;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .invoice-vehicle-strip > div { padding: 3mm; }
  .invoice-lines { min-width: 0; }
  .totals-panel { display: flex; justify-content: flex-end; padding: 6mm 0 0; }
  .totals-panel dl { width: 85mm; }
}

@media screen and (max-width: 640px) {
  html,
  body,
  #app-shell,
  .app-stage,
  .topbar,
  .page-content {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  html,
  body,
  #app-shell,
  .app-stage { overflow-x: clip; }

  .page-content { padding-inline: 16px; }

  .page-content > *,
  .dashboard-search,
  .dashboard-search .global-search,
  .quick-actions,
  .quick-action-grid,
  .metric-grid,
  .dashboard-grid,
  .list-card,
  .compact-list,
  .table-card,
  .entity-form,
  .form-section {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .dashboard-search .global-search {
    grid-template-columns: 24px minmax(0, 1fr) auto;
    overflow: hidden;
  }

  .dashboard-search .global-search input {
    width: auto;
    min-width: 0;
  }

  .dashboard-search .global-search .button {
    min-width: 0;
    padding-inline: 11px;
  }

  .metric-grid { grid-template-columns: minmax(0, 1fr); }
  .metric-card.card { width: 100%; min-width: 0; }

  .card-header > div,
  .card-header h2,
  .compact-list-item > span { min-width: 0; }

  .list-card .card-header { gap: 8px; }
  .list-card .text-button { flex: 0 0 auto; }

  #mobile-nav.mobile-nav {
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow: hidden;
  }

  #mobile-nav .mobile-nav-item {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding-inline: 0;
    overflow: hidden;
  }

  #mobile-nav .mobile-nav-item > span:not(.mobile-nav-main > span),
  #mobile-nav .mobile-nav-item > small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* --------------------------------------------------------------------------
   Werkstattkalender, Termine und bexio-Synchronisation
   -------------------------------------------------------------------------- */

:root {
  --calendar-hour-height: 68px;
  --calendar-time-width: 72px;
  --calendar-work: #1688f0;
  --calendar-pickup: #0c9b72;
  --calendar-pending: #c87510;
  --calendar-blocked: #7a62ca;
  --calendar-cancelled: #7b8797;
}

@media screen {
  .calendar-page,
  .appointments-page,
  .termine-page,
  .calendar-layout,
  .calendar-card,
  .calendar-shell,
  .calendar-container {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .calendar-card,
  .calendar-shell {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }

  .calendar-toolbar,
  .appointments-toolbar,
  .calendar-header {
    display: flex;
    min-height: 70px;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    background: #fff;
    border-bottom: 1px solid var(--line);
  }

  .calendar-toolbar-main,
  .calendar-navigation,
  .calendar-nav,
  .date-navigation {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 7px;
  }

  .calendar-toolbar-main { flex: 1 1 380px; }

  .calendar-nav-button,
  .calendar-arrow,
  .date-nav-button {
    display: grid;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    padding: 0;
    place-items: center;
    color: var(--ink-700);
    font-size: 17px;
    line-height: 1;
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
  }

  .calendar-nav-button:hover,
  .calendar-arrow:hover,
  .date-nav-button:hover { color: var(--blue-700); background: #eff7ff; border-color: #acd2f4; }

  .calendar-today-button,
  .today-button {
    min-height: 40px;
    padding: 0 13px;
    color: var(--ink-700);
    font-size: 11px;
    font-weight: 750;
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
  }

  .calendar-today-button:hover,
  .today-button:hover { color: var(--blue-700); background: #eff7ff; }

  .calendar-period,
  .calendar-range,
  .calendar-title,
  .calendar-current-date {
    min-width: 0;
    margin: 0 4px;
    color: var(--ink-950);
    font-size: clamp(15px, 1.5vw, 20px);
    font-weight: 780;
    letter-spacing: -.025em;
    white-space: nowrap;
  }

  .calendar-period small,
  .calendar-range small,
  .calendar-title small { display: block; margin-top: 2px; color: var(--ink-500); font-size: 9px; font-weight: 600; letter-spacing: 0; }

  .calendar-toolbar-actions,
  .calendar-actions,
  .appointment-actions,
  .termin-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }

  .calendar-view-switcher,
  .calendar-view-toggle,
  .view-switcher,
  .view-toggle {
    display: inline-grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(72px, auto);
    gap: 3px;
    min-height: 42px;
    padding: 3px;
    background: #edf1f5;
    border: 1px solid #e2e7ee;
    border-radius: 10px;
  }

  .calendar-view-switcher button,
  .calendar-view-toggle button,
  .view-switcher button,
  .view-toggle button {
    min-height: 34px;
    padding: 0 12px;
    color: var(--ink-600);
    font-size: 10px;
    font-weight: 750;
    background: transparent;
    border: 0;
    border-radius: 7px;
  }

  .calendar-view-switcher button:hover,
  .calendar-view-toggle button:hover,
  .view-switcher button:hover,
  .view-toggle button:hover { color: var(--ink-950); background: rgba(255, 255, 255, .58); }

  .calendar-view-switcher button.is-active,
  .calendar-view-switcher button[aria-pressed="true"],
  .calendar-view-toggle button.is-active,
  .calendar-view-toggle button[aria-pressed="true"],
  .view-switcher button.is-active,
  .view-switcher button[aria-pressed="true"],
  .view-toggle button.is-active,
  .view-toggle button[aria-pressed="true"] {
    color: var(--blue-700);
    background: #fff;
    box-shadow: var(--shadow-sm);
  }

  .calendar-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 13px;
    padding: 9px 16px;
    color: var(--ink-500);
    font-size: 9px;
    background: #fafbfd;
    border-bottom: 1px solid var(--line-soft);
  }

  .calendar-legend-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
  .calendar-legend-dot { width: 8px; height: 8px; background: var(--event-color, var(--calendar-work)); border-radius: 50%; }

  .calendar-scroll,
  .calendar-grid-scroll,
  .week-calendar-scroll,
  .day-calendar-scroll {
    width: 100%;
    min-width: 0;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
  }

  .calendar-grid,
  .week-calendar,
  .day-calendar {
    position: relative;
    min-width: 820px;
    background: #fff;
  }

  .calendar-week-grid,
  .week-grid {
    display: grid;
    grid-template-columns: var(--calendar-time-width) repeat(7, minmax(104px, 1fr));
    min-width: 820px;
  }

  .calendar-day-grid,
  .day-grid {
    display: grid;
    grid-template-columns: var(--calendar-time-width) minmax(460px, 1fr);
    min-width: 580px;
  }

  .calendar-corner,
  .calendar-time-header {
    position: sticky;
    z-index: 8;
    top: 0;
    left: 0;
    min-height: 66px;
    background: #f8fafc;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .calendar-day-header,
  .week-day-header,
  .day-column-header {
    position: sticky;
    z-index: 7;
    top: 0;
    display: flex;
    min-width: 0;
    min-height: 66px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    color: var(--ink-600);
    text-align: center;
    background: #f8fafc;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  .calendar-day-header:last-child,
  .week-day-header:last-child { border-right: 0; }
  .calendar-day-header.is-today,
  .week-day-header.is-today,
  .day-column-header.is-today { color: var(--blue-700); background: #eef7ff; }
  .calendar-day-name,
  .weekday-name { font-size: 9px; font-weight: 800; letter-spacing: .055em; text-transform: uppercase; }
  .calendar-day-number,
  .weekday-number { display: grid; width: 29px; height: 29px; margin-top: 3px; place-items: center; color: var(--ink-950); font-size: 13px; font-weight: 780; border-radius: 50%; }
  .is-today .calendar-day-number,
  .is-today .weekday-number { color: #fff; background: var(--blue-600); }

  .calendar-time-label,
  .time-label {
    position: relative;
    min-height: var(--calendar-hour-height);
    padding: 0 10px 0 4px;
    color: var(--ink-500);
    font-size: 9px;
    font-variant-numeric: tabular-nums;
    text-align: right;
    background: #fafbfd;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line-soft);
  }

  .calendar-time-label > span,
  .time-label > span { position: relative; top: -7px; padding-left: 4px; background: #fafbfd; }

  .calendar-day-column,
  .week-day-column,
  .day-column {
    position: relative;
    min-width: 0;
    background: #fff;
    border-right: 1px solid var(--line);
  }

  .calendar-day-column.is-today,
  .week-day-column.is-today,
  .day-column.is-today { background: rgba(238, 247, 255, .44); }

  .calendar-slot,
  .time-slot {
    position: relative;
    min-height: var(--calendar-hour-height);
    background-image: linear-gradient(to bottom, transparent calc(50% - .5px), var(--line-soft) calc(50% - .5px), var(--line-soft) calc(50% + .5px), transparent calc(50% + .5px));
    border-bottom: 1px solid var(--line-soft);
  }

  .calendar-slot:hover,
  .time-slot:hover { background-color: #f7fbff; }
  .calendar-slot.is-closed,
  .time-slot.is-closed,
  .calendar-day-column.is-closed { background-color: #f6f7f9; background-image: repeating-linear-gradient(135deg, transparent 0 8px, rgba(82, 98, 122, .035) 8px 16px); }

  .calendar-now-line,
  .current-time-line {
    position: absolute;
    z-index: 6;
    right: 0;
    left: 0;
    height: 2px;
    background: #ef465c;
    pointer-events: none;
  }

  .calendar-now-line::before,
  .current-time-line::before { content: ""; position: absolute; top: 50%; left: -4px; width: 8px; height: 8px; background: #ef465c; border-radius: 50%; transform: translateY(-50%); }

  .calendar-event,
  .appointment-event,
  .termin-event {
    --event-color: var(--calendar-work);
    position: absolute;
    z-index: 3;
    top: var(--event-top, 0);
    right: 4px;
    left: 4px;
    display: flex;
    min-height: 34px;
    height: var(--event-height, auto);
    flex-direction: column;
    align-items: flex-start;
    padding: 6px 7px 6px 9px;
    color: #14334e;
    text-align: left;
    background: color-mix(in srgb, var(--event-color) 13%, white);
    border: 1px solid color-mix(in srgb, var(--event-color) 34%, white);
    border-left: 4px solid var(--event-color);
    border-radius: 7px;
    box-shadow: 0 2px 5px rgba(16, 35, 60, .08);
    overflow: hidden;
  }

  button.calendar-event,
  button.appointment-event,
  button.termin-event { width: auto; cursor: pointer; }

  .calendar-event:hover,
  .appointment-event:hover,
  .termin-event:hover { z-index: 5; border-color: var(--event-color); box-shadow: 0 7px 18px rgba(16, 35, 60, .16); }
  .calendar-event strong,
  .appointment-event strong,
  .termin-event strong { max-width: 100%; color: inherit; font-size: 10px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .calendar-event small,
  .appointment-event small,
  .termin-event small { max-width: 100%; margin-top: 1px; color: color-mix(in srgb, var(--event-color) 63%, #24334b); font-size: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .calendar-event[data-status="geplant"],
  .calendar-event.status-geplant,
  .appointment-event[data-status="geplant"],
  .termin-event.status-geplant { --event-color: var(--calendar-work); }
  .calendar-event[data-status="bestaetigt"],
  .calendar-event[data-status="bestätigt"],
  .calendar-event.status-bestaetigt,
  .appointment-event.status-confirmed,
  .termin-event.status-bestaetigt { --event-color: var(--calendar-pickup); }
  .calendar-event[data-status="wartend"],
  .calendar-event.status-wartend,
  .appointment-event.status-pending,
  .termin-event.status-wartend { --event-color: var(--calendar-pending); }
  .calendar-event[data-status="blockiert"],
  .calendar-event.status-blockiert,
  .appointment-event.status-blocked,
  .termin-event.status-blockiert { --event-color: var(--calendar-blocked); }
  .calendar-event[data-status="abgesagt"],
  .calendar-event.status-abgesagt,
  .appointment-event.status-cancelled,
  .termin-event.status-abgesagt { --event-color: var(--calendar-cancelled); opacity: .72; text-decoration: line-through; }
  .calendar-event.is-dragging,
  .appointment-event.is-dragging { z-index: 20; opacity: .86; box-shadow: 0 12px 28px rgba(16, 35, 60, .24); }

  .calendar-all-day,
  .all-day-row {
    display: grid;
    grid-template-columns: var(--calendar-time-width) minmax(0, 1fr);
    min-height: 46px;
    background: #fbfcfe;
    border-bottom: 1px solid var(--line);
  }

  .calendar-all-day-label,
  .all-day-label { display: flex; align-items: center; justify-content: flex-end; padding: 8px 10px; color: var(--ink-500); font-size: 8px; font-weight: 800; text-transform: uppercase; border-right: 1px solid var(--line); }
  .calendar-all-day-events,
  .all-day-events { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding: 6px; }
  .all-day-event { display: inline-flex; max-width: 100%; min-height: 27px; align-items: center; padding: 3px 8px; color: var(--blue-700); font-size: 9px; font-weight: 750; background: #e8f3ff; border: 1px solid #c4e0f8; border-radius: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Month view */
  .calendar-month,
  .month-calendar,
  .calendar-month-grid,
  .month-grid { min-width: 760px; }

  .calendar-month-grid,
  .month-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(100px, 1fr));
    background: var(--line);
    gap: 1px;
  }

  .month-weekday,
  .calendar-month-weekday {
    min-height: 38px;
    padding: 12px 10px 8px;
    color: var(--ink-500);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .055em;
    text-align: center;
    text-transform: uppercase;
    background: #f8fafc;
  }

  .calendar-month-day,
  .month-day {
    position: relative;
    min-width: 0;
    min-height: 128px;
    padding: 8px;
    color: var(--ink-700);
    background: #fff;
  }

  .calendar-month-day:hover,
  .month-day:hover { background: #f8fbff; }
  .calendar-month-day.is-outside,
  .month-day.is-outside { color: #a6b0be; background: #f8f9fb; }
  .calendar-month-day.is-today,
  .month-day.is-today { background: #eff7ff; box-shadow: inset 0 0 0 2px #b9ddfa; }
  .month-day-number,
  .calendar-month-day-number { display: grid; width: 27px; height: 27px; margin: 0 0 5px auto; place-items: center; font-size: 11px; font-weight: 780; border-radius: 50%; }
  .is-today > .month-day-number,
  .is-today > .calendar-month-day-number { color: #fff; background: var(--blue-600); }
  .month-day-events,
  .calendar-month-events { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
  .month-event,
  .calendar-month-event { --event-color: var(--calendar-work); display: flex; min-width: 0; min-height: 24px; align-items: center; gap: 5px; padding: 3px 6px; color: var(--ink-800); font-size: 8px; font-weight: 700; text-align: left; background: color-mix(in srgb, var(--event-color) 11%, white); border: 0; border-left: 3px solid var(--event-color); border-radius: 4px; overflow: hidden; }
  .month-event:hover,
  .calendar-month-event:hover { background: color-mix(in srgb, var(--event-color) 19%, white); }
  .month-event-time { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 850; }
  .month-event-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .month-more,
  .calendar-month-more { display: inline-flex; min-height: 23px; align-items: center; padding: 2px 6px; color: var(--blue-700); font-size: 8px; font-weight: 800; background: transparent; border: 0; border-radius: 5px; }
  .month-more:hover,
  .calendar-month-more:hover { background: #e8f3ff; }

  /* Agenda and today's dashboard appointments */
  .today-appointments,
  .todays-appointments,
  .appointments-today,
  .dashboard-appointments { min-width: 0; overflow: hidden; }

  .appointment-list,
  .today-appointment-list,
  .agenda-list { display: flex; min-width: 0; flex-direction: column; }

  .appointment-list-item,
  .today-appointment,
  .agenda-item {
    --event-color: var(--calendar-work);
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    align-items: center;
    gap: 13px;
    min-height: 68px;
    padding: 10px 16px;
    color: var(--ink-700);
    text-align: left;
    background: #fff;
    border: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .appointment-list-item:last-child,
  .today-appointment:last-child,
  .agenda-item:last-child { border-bottom: 0; }
  .appointment-list-item:hover,
  .today-appointment:hover,
  .agenda-item:hover { background: #f7fbff; }
  .appointment-time,
  .agenda-time { color: var(--event-color); font-size: 12px; font-weight: 820; font-variant-numeric: tabular-nums; }
  .appointment-main,
  .agenda-main { display: flex; min-width: 0; flex-direction: column; }
  .appointment-main strong,
  .agenda-main strong { color: var(--ink-950); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .appointment-main small,
  .agenda-main small { margin-top: 3px; color: var(--ink-500); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .appointment-aside,
  .agenda-aside { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; color: var(--ink-500); font-size: 9px; text-align: right; }

  .appointment-status,
  .termin-status,
  .sync-status {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    color: var(--ink-700);
    font-size: 9px;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
    background: #edf1f5;
    border: 1px solid rgba(82, 98, 122, .1);
    border-radius: 999px;
  }

  .appointment-status::before,
  .termin-status::before,
  .sync-status::before { content: ""; flex: 0 0 6px; width: 6px; height: 6px; background: currentColor; border-radius: 50%; }
  .appointment-status.status-geplant,
  .termin-status.status-geplant { color: var(--blue-700); background: #e8f3ff; }
  .appointment-status.status-bestaetigt,
  .appointment-status.status-bestätigt,
  .termin-status.status-bestaetigt { color: var(--success); background: var(--success-bg); }
  .appointment-status.status-wartend,
  .termin-status.status-wartend { color: var(--warning); background: var(--warning-bg); }
  .appointment-status.status-abgesagt,
  .termin-status.status-abgesagt { color: var(--calendar-cancelled); background: #edf0f3; }

  .agenda-date-heading {
    position: sticky;
    z-index: 3;
    top: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 42px;
    padding: 8px 16px;
    color: var(--ink-700);
    font-size: 10px;
    font-weight: 800;
    background: rgba(248, 250, 252, .96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(8px);
  }

  /* Appointment detail and form */
  .appointment-detail,
  .termin-detail { display: flex; min-width: 0; flex-direction: column; gap: 16px; }

  .appointment-identity,
  .termin-identity,
  .appointment-summary {
    display: grid;
    grid-template-columns: 1.1fr 1.4fr 1fr 1fr;
    gap: 1px;
    padding: 0;
    background: var(--line-soft);
    overflow: hidden;
  }

  .appointment-identity > div,
  .termin-identity > div,
  .appointment-summary > div { display: flex; min-width: 0; min-height: 86px; flex-direction: column; justify-content: center; padding: 14px 17px; background: #fff; }
  .appointment-identity span,
  .termin-identity span,
  .appointment-summary span { margin-bottom: 4px; color: var(--ink-500); font-size: 9px; font-weight: 800; letter-spacing: .045em; text-transform: uppercase; }
  .appointment-identity strong,
  .termin-identity strong,
  .appointment-summary strong { color: var(--ink-950); font-size: 13px; overflow-wrap: anywhere; }

  .appointment-detail-grid,
  .termin-detail-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr); gap: 16px; }
  .appointment-detail-card,
  .termin-detail-card { min-width: 0; overflow: hidden; }
  .appointment-detail-card .card-body,
  .termin-detail-card .card-body { min-height: 150px; }

  .appointment-meta,
  .termin-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; margin: 0; }
  .appointment-meta > div,
  .termin-meta > div { padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
  .appointment-meta dt,
  .termin-meta dt { color: var(--ink-500); font-size: 9px; font-weight: 800; text-transform: uppercase; }
  .appointment-meta dd,
  .termin-meta dd { margin: 3px 0 0; color: var(--ink-950); font-size: 12px; font-weight: 650; }

  .appointment-form,
  .termin-form { display: flex; min-width: 0; flex-direction: column; gap: 16px; }
  .appointment-form-grid,
  .termin-form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; padding: 20px; }
  .appointment-form-grid .form-field,
  .termin-form-grid .form-field { grid-column: span 4; }
  .appointment-form-grid .span-wide,
  .termin-form-grid .span-wide { grid-column: span 8; }
  .appointment-form-grid .span-full,
  .termin-form-grid .span-full { grid-column: 1 / -1; }

  .appointment-duration,
  .duration-inputs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 8px; }
  .duration-separator { display: grid; min-height: 44px; place-items: center; color: var(--ink-500); font-size: 11px; }

  .calendar-resource-list,
  .resource-picker { display: flex; flex-wrap: wrap; gap: 8px; }
  .calendar-resource,
  .resource-chip { display: inline-flex; min-height: 34px; align-items: center; gap: 7px; padding: 5px 10px; color: var(--ink-700); font-size: 10px; font-weight: 700; background: #f5f7fa; border: 1px solid var(--line); border-radius: 999px; }
  .calendar-resource.is-selected,
  .resource-chip.is-selected { color: var(--blue-700); background: #e8f3ff; border-color: #b9daf5; }
  .resource-color { width: 8px; height: 8px; background: var(--resource-color, var(--calendar-work)); border-radius: 50%; }

  /* Timeline drag/resize interactions and mechanic utilization */
  .calendar-time-column { position: relative; }
  .calendar-event-handle {
    position: absolute;
    right: 6px;
    bottom: 0;
    left: 6px;
    height: 6px;
    cursor: ns-resize;
    border-radius: 0 0 4px 4px;
  }
  .calendar-event-handle:hover,
  .calendar-event:hover .calendar-event-handle { background: color-mix(in srgb, var(--event-color) 45%, white); }

  .calendar-drag-selection {
    position: absolute;
    z-index: 4;
    right: 4px;
    left: 4px;
    display: flex;
    align-items: flex-end;
    padding: 4px 7px;
    color: var(--blue-700);
    font-size: 9px;
    font-weight: 800;
    background: rgba(22, 136, 240, .16);
    border: 1px dashed var(--blue-600);
    border-radius: 7px;
    pointer-events: none;
  }

  .calendar-month-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(100px, 1fr));
    background: var(--line);
    gap: 1px;
  }

  .mechanic-utilization-summary { padding: 10px 16px; }
  .mechanic-utilization-summary ul { display: flex; flex-wrap: wrap; gap: 10px 20px; margin: 0; padding: 0; list-style: none; }
  .mechanic-utilization-summary li { color: var(--ink-700); font-size: 11px; font-weight: 700; }
  .mechanic-utilization-summary li.is-overbooked { color: var(--danger); }

  .checkbox-field { flex-direction: row !important; align-items: center; gap: 8px; }
  .checkbox-field input[type="checkbox"] { width: 16px; height: 16px; }


  /* bexio synchronization state */
  .bexio-sync-card,
  .bexio-status-card,
  .sync-card {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 20px;
    background: linear-gradient(135deg, #fff, #f3f8fd);
    border: 1px solid var(--line);
    border-radius: var(--radius);
  }

  .bexio-sync-card h3,
  .bexio-status-card h3,
  .sync-card h3 { margin: 0; font-size: 14px; }
  .bexio-sync-card p,
  .bexio-status-card p,
  .sync-card p { margin: 4px 0 0; color: var(--ink-500); font-size: 10px; }
  .bexio-sync-actions,
  .sync-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

  .sync-status.status-idle,
  .sync-status.status-not-synced,
  .sync-status.status-ausstehend { color: var(--ink-600); background: #edf1f5; }
  .sync-status.status-pending,
  .sync-status.status-syncing,
  .sync-status.status-wird-synchronisiert { color: var(--blue-700); background: #e8f3ff; }
  .sync-status.status-success,
  .sync-status.status-synced,
  .sync-status.status-synchronisiert { color: var(--success); background: var(--success-bg); }
  .sync-status.status-warning,
  .sync-status.status-partial { color: var(--warning); background: var(--warning-bg); }
  .sync-status.status-error,
  .sync-status.status-failed,
  .sync-status.status-fehler { color: var(--danger); background: var(--danger-bg); }
  .sync-status.status-syncing::before,
  .sync-status.status-wird-synchronisiert::before { background: transparent; border: 2px solid currentColor; border-top-color: transparent; animation: spin .75s linear infinite; }

  .bexio-warning,
  .sync-warning,
  .sync-error-banner {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
    margin: 0 0 16px;
    padding: 12px 14px;
    color: #765000;
    background: #fff7df;
    border: 1px solid #efd99b;
    border-left: 4px solid #d99118;
    border-radius: 9px;
  }

  .sync-error-banner { color: #912b3d; background: var(--danger-bg); border-color: #f0bdc6; border-left-color: var(--danger); }
  .bexio-warning-icon,
  .sync-warning-icon { display: grid; width: 34px; height: 34px; place-items: center; font-size: 16px; font-weight: 850; background: rgba(255, 255, 255, .58); border-radius: 9px; }
  .bexio-warning strong,
  .sync-warning strong,
  .sync-error-banner strong { display: block; font-size: 11px; }
  .bexio-warning p,
  .sync-warning p,
  .sync-error-banner p { margin: 2px 0 0; color: inherit; font-size: 9px; opacity: .84; }

  .bexio-sync-dialog,
  .sync-dialog-content { display: flex; min-width: 0; flex-direction: column; gap: 16px; }
  .sync-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
  .sync-summary-item { padding: 13px; text-align: center; background: var(--surface-subtle); border: 1px solid var(--line-soft); border-radius: 9px; }
  .sync-summary-item strong { display: block; font-size: 20px; }
  .sync-summary-item span { color: var(--ink-500); font-size: 9px; }
  .sync-log { max-height: 260px; margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); border-radius: 9px; overflow-y: auto; }
  .sync-log-item { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; gap: 10px; padding: 9px 11px; color: var(--ink-700); font-size: 9px; border-bottom: 1px solid var(--line-soft); }
  .sync-log-item:last-child { border-bottom: 0; }
  .sync-log-time { color: var(--ink-500); font-variant-numeric: tabular-nums; }

  .calendar-empty,
  .appointments-empty { display: flex; min-height: 340px; flex-direction: column; align-items: center; justify-content: center; padding: 32px; color: var(--ink-500); text-align: center; background: #fff; }
  .calendar-empty h3,
  .appointments-empty h3 { margin: 10px 0 4px; font-size: 14px; }
  .calendar-empty p,
  .appointments-empty p { max-width: 390px; margin: 0 0 14px; font-size: 10px; }
}

@media screen and (max-width: 1020px) {
  .appointment-detail-grid,
  .termin-detail-grid { grid-template-columns: 1fr; }
  .appointment-identity,
  .termin-identity,
  .appointment-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calendar-toolbar-actions,
  .calendar-actions { flex: 1 1 100%; justify-content: space-between; }
  .appointment-form-grid .form-field,
  .termin-form-grid .form-field { grid-column: span 6; }
  .appointment-form-grid .span-wide,
  .termin-form-grid .span-wide { grid-column: span 12; }
}

@media screen and (max-width: 640px) {
  .calendar-page,
  .appointments-page,
  .termine-page,
  .calendar-layout,
  .calendar-card,
  .calendar-shell,
  .calendar-container,
  .calendar-toolbar,
  .calendar-header,
  .calendar-scroll,
  .calendar-grid-scroll,
  .today-appointments,
  .appointments-today,
  .dashboard-appointments {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .calendar-toolbar,
  .appointments-toolbar,
  .calendar-header { align-items: stretch; padding: 11px; }
  .calendar-toolbar-main,
  .calendar-navigation,
  .calendar-nav,
  .date-navigation { flex: 1 1 100%; }
  .calendar-toolbar-main { flex-wrap: wrap; }
  .calendar-period,
  .calendar-range,
  .calendar-title,
  .calendar-current-date { flex: 1; margin-inline: 2px; font-size: 15px; text-align: center; }
  .calendar-today-button,
  .today-button { order: 5; flex: 1 1 100%; }
  .calendar-toolbar-actions,
  .calendar-actions { display: grid; grid-template-columns: 1fr; width: 100%; }
  .calendar-toolbar-actions > .button,
  .calendar-actions > .button { width: 100%; }
  .calendar-view-switcher,
  .calendar-view-toggle,
  .view-switcher,
  .view-toggle { width: 100%; grid-auto-columns: minmax(0, 1fr); }
  .calendar-view-switcher button,
  .calendar-view-toggle button,
  .view-switcher button,
  .view-toggle button { min-width: 0; padding-inline: 7px; }
  .calendar-legend { gap: 8px 12px; padding-inline: 11px; }

  .calendar-grid,
  .week-calendar,
  .calendar-week-grid,
  .week-grid { min-width: 780px; }
  .calendar-day-grid,
  .day-grid { min-width: 460px; grid-template-columns: 58px minmax(390px, 1fr); }
  .calendar-month,
  .month-calendar,
  .calendar-month-grid,
  .month-grid { min-width: 700px; }
  .calendar-month-day,
  .month-day { min-height: 105px; padding: 5px; }
  .month-weekday,
  .calendar-month-weekday { min-height: 34px; padding: 10px 5px 7px; }

  .appointment-list-item,
  .today-appointment,
  .agenda-item { grid-template-columns: 54px minmax(0, 1fr); gap: 10px; padding: 10px 12px; }
  .appointment-aside,
  .agenda-aside { grid-column: 2; align-items: flex-start; text-align: left; }
  .appointment-time,
  .agenda-time { align-self: start; padding-top: 2px; }

  .appointment-identity,
  .termin-identity,
  .appointment-summary { grid-template-columns: 1fr; }
  .appointment-identity > div,
  .termin-identity > div,
  .appointment-summary > div { min-height: 72px; }
  .appointment-detail-grid,
  .termin-detail-grid { grid-template-columns: minmax(0, 1fr); }
  .appointment-meta,
  .termin-meta { grid-template-columns: 1fr; }
  .appointment-form-grid,
  .termin-form-grid { grid-template-columns: 1fr; padding: 16px; }
  .appointment-form-grid .form-field,
  .termin-form-grid .form-field,
  .appointment-form-grid .span-wide,
  .termin-form-grid .span-wide,
  .appointment-form-grid .span-full,
  .termin-form-grid .span-full { grid-column: 1; }
  .appointment-duration,
  .duration-inputs { grid-template-columns: 1fr; }
  .duration-separator { min-height: 18px; }

  .appointment-actions,
  .termin-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .appointment-actions .button,
  .termin-actions .button { width: 100%; min-width: 0; }

  .bexio-sync-card,
  .bexio-status-card,
  .sync-card { align-items: stretch; flex-direction: column; padding: 16px; }
  .bexio-sync-actions,
  .sync-actions { display: grid; grid-template-columns: 1fr; }
  .bexio-sync-actions .button,
  .sync-actions .button { width: 100%; }
  .bexio-warning,
  .sync-warning,
  .sync-error-banner { grid-template-columns: 32px minmax(0, 1fr); }
  .bexio-warning > .button,
  .sync-warning > .button,
  .sync-error-banner > .button { grid-column: 1 / -1; width: 100%; }
  .sync-summary { grid-template-columns: 1fr; }
  .sync-log-item { grid-template-columns: 64px minmax(0, 1fr); }
  .sync-log-item > :last-child { grid-column: 2; }
}

@media print {
  .calendar-toolbar,
  .appointments-toolbar,
  .calendar-actions,
  .appointment-actions,
  .bexio-sync-card,
  .bexio-status-card,
  .bexio-warning,
  .sync-warning { display: none !important; }

  .calendar-card,
  .calendar-shell { border: 0; box-shadow: none; }
  .calendar-scroll,
  .calendar-grid-scroll { overflow: visible; }
  .calendar-week-grid,
  .week-grid { min-width: 0; grid-template-columns: 14mm repeat(7, 1fr); }
  .calendar-event,
  .appointment-event,
  .termin-event,
  .month-event,
  .calendar-month-event { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* Exact calendar markup emitted by the application. */
@media screen {
  .quick-action-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .appointment-toolbar {
    display: grid;
    grid-template-columns: auto auto minmax(320px, 1fr);
    align-items: end;
    gap: 14px;
    margin-bottom: 16px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
  }

  .appointment-navigation {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 6px;
  }

  .appointment-navigation .icon-button { width: 40px; min-width: 40px; min-height: 40px; height: 40px; }
  .appointment-navigation .button { min-height: 40px; }

  .appointment-date-picker { display: block; min-width: 140px; }
  .appointment-date-picker input { min-height: 40px; padding: 7px 9px; font-size: 11px; }

  .appointment-view-switch {
    display: inline-grid;
    grid-template-columns: repeat(3, minmax(62px, 1fr));
    gap: 3px;
    min-height: 42px;
    padding: 3px;
    background: #edf1f5;
    border: 1px solid #e1e7ee;
    border-radius: 10px;
  }

  .appointment-view-switch .button {
    min-height: 34px;
    padding-inline: 10px;
    font-size: 10px;
    border: 0;
    border-radius: 7px;
    box-shadow: none;
  }

  .appointment-view-switch .button-primary { color: var(--blue-700); background: #fff; box-shadow: var(--shadow-sm); }
  .appointment-view-switch .button-quiet:hover { background: rgba(255, 255, 255, .65); }

  .appointment-filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(150px, 1fr));
    gap: 10px;
    justify-self: stretch;
  }

  .appointment-filters > label { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
  .appointment-filters > label > span { color: var(--ink-600); font-size: 9px; font-weight: 800; text-transform: uppercase; }
  .appointment-filters select { min-height: 40px; padding-block: 7px; font-size: 11px; }

  .appointment-calendar {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-bottom: 16px;
    border-color: var(--line);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-gutter: stable;
  }

  .appointment-day-view { min-width: 0; }

  .appointment-day-view > header {
    display: flex;
    min-height: 64px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 18px;
    background: linear-gradient(135deg, #f8fbff, #eef6ff);
    border-bottom: 1px solid var(--line);
  }

  .appointment-day-view > header span { color: var(--blue-700); font-size: 10px; font-weight: 850; letter-spacing: .055em; text-transform: uppercase; }
  .appointment-day-view > header strong { color: var(--ink-950); font-size: 18px; }

  .appointment-day-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    min-height: 220px;
    align-content: start;
    padding: 16px;
  }

  .appointment-week-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(130px, 1fr));
    min-width: 910px;
    background: var(--line);
    gap: 1px;
  }

  .appointment-day-column {
    min-width: 0;
    min-height: 330px;
    background: #fff;
  }

  .appointment-day-column.is-today { background: #f3f9ff; }

  .appointment-day-column > header {
    display: flex;
    min-height: 62px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    color: var(--ink-600);
    text-align: center;
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
  }

  .appointment-day-column.is-today > header { color: var(--blue-700); background: #eaf5ff; }
  .appointment-day-column > header span { font-size: 9px; font-weight: 850; letter-spacing: .055em; text-transform: uppercase; }
  .appointment-day-column > header strong { margin-top: 3px; color: var(--ink-950); font-size: 12px; }
  .appointment-day-column.is-today > header strong { color: #fff; padding: 3px 8px; background: var(--blue-600); border-radius: 999px; }
  .appointment-day-column > div { display: flex; min-height: 267px; flex-direction: column; gap: 6px; padding: 7px; }

  .appointment-calendar-card {
    --appointment-color: var(--calendar-work);
    display: flex;
    width: 100%;
    min-width: 0;
    min-height: 70px;
    flex-direction: column;
    align-items: flex-start;
    padding: 8px 8px 8px 10px;
    color: #173852;
    text-align: left;
    background: color-mix(in srgb, var(--appointment-color) 12%, white);
    border: 1px solid color-mix(in srgb, var(--appointment-color) 30%, white);
    border-left: 4px solid var(--appointment-color);
    border-radius: 7px;
    box-shadow: 0 2px 5px rgba(16, 35, 60, .06);
  }

  .appointment-calendar-card:hover { border-color: var(--appointment-color); box-shadow: 0 7px 17px rgba(16, 35, 60, .13); transform: translateY(-1px); }
  .appointment-calendar-card > span { color: var(--appointment-color); font-size: 9px; font-weight: 850; font-variant-numeric: tabular-nums; }
  .appointment-calendar-card > strong { display: block; width: 100%; margin-top: 3px; color: var(--ink-950); font-size: 10px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .appointment-calendar-card > small { display: block; width: 100%; margin-top: 2px; color: var(--ink-500); font-size: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .appointment-calendar-card.status-geplant,
  .appointment-month-item.status-geplant { --appointment-color: var(--calendar-work); }
  .appointment-calendar-card.status-bestatigt,
  .appointment-calendar-card.status-bestaetigt,
  .appointment-month-item.status-bestatigt,
  .appointment-month-item.status-bestaetigt { --appointment-color: #0a956c; }
  .appointment-calendar-card.status-fahrzeug-eingetroffen,
  .appointment-month-item.status-fahrzeug-eingetroffen { --appointment-color: #6757c5; }
  .appointment-calendar-card.status-in-arbeit,
  .appointment-month-item.status-in-arbeit { --appointment-color: #078ca5; }
  .appointment-calendar-card.status-fertig,
  .appointment-month-item.status-fertig { --appointment-color: var(--success); }
  .appointment-calendar-card.status-abgeholt,
  .appointment-month-item.status-abgeholt { --appointment-color: #52627a; }
  .appointment-calendar-card.status-abgesagt,
  .appointment-month-item.status-abgesagt { --appointment-color: var(--calendar-cancelled); opacity: .68; text-decoration: line-through; }

  .appointment-calendar-empty {
    display: grid;
    min-height: 72px;
    padding: 12px;
    place-items: center;
    color: var(--ink-500);
    font-size: 9px;
    text-align: center;
    border: 1px dashed #d9e1ea;
    border-radius: 7px;
  }

  .appointment-day-list > .appointment-calendar-empty { grid-column: 1 / -1; min-height: 180px; }
  .appointment-day-column .appointment-calendar-empty { min-height: 70px; border: 0; }

  .appointment-month-weekdays,
  .appointment-month-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(106px, 1fr));
    min-width: 760px;
    gap: 1px;
    background: var(--line);
  }

  .appointment-month-weekdays > span {
    min-height: 38px;
    padding: 11px 8px 8px;
    color: var(--ink-500);
    font-size: 9px;
    font-weight: 850;
    letter-spacing: .06em;
    text-align: center;
    text-transform: uppercase;
    background: #f8fafc;
  }

  .appointment-month-day {
    min-width: 0;
    min-height: 126px;
    padding: 7px;
    background: #fff;
  }

  .appointment-month-day.is-outside { background: #f7f8fa; opacity: .64; }
  .appointment-month-day.is-today { background: #eff7ff; box-shadow: inset 0 0 0 2px #b9defb; }
  .appointment-month-day > button:first-child { display: grid; width: 28px; height: 28px; margin: 0 0 5px auto; padding: 0; place-items: center; color: var(--ink-700); font-size: 11px; font-weight: 820; background: transparent; border: 0; border-radius: 50%; }
  .appointment-month-day > button:first-child:hover { color: var(--blue-700); background: #e2f1ff; }
  .appointment-month-day.is-today > button:first-child { color: #fff; background: var(--blue-600); }
  .appointment-month-day > div { display: flex; min-width: 0; flex-direction: column; gap: 4px; }

  .appointment-month-item {
    --appointment-color: var(--calendar-work);
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 24px;
    padding: 4px 5px 4px 7px;
    color: var(--ink-800);
    font-size: 8px;
    font-weight: 680;
    text-align: left;
    background: color-mix(in srgb, var(--appointment-color) 11%, white);
    border: 0;
    border-left: 3px solid var(--appointment-color);
    border-radius: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .appointment-month-item:hover { background: color-mix(in srgb, var(--appointment-color) 20%, white); }
  .appointment-month-item > span { color: var(--appointment-color); font-weight: 850; font-variant-numeric: tabular-nums; }

  .appointment-more { min-height: 24px; padding: 2px 5px; color: var(--blue-700); font-size: 8px; font-weight: 800; text-align: left; background: transparent; border: 0; border-radius: 4px; }
  .appointment-more:hover { background: #e4f2ff; }

  .appointment-agenda { margin-bottom: 16px; overflow: hidden; }
  .appointment-agenda-item { display: grid; grid-template-columns: 94px minmax(0, 1fr) auto; }
  .appointment-agenda-date { align-items: flex-start; }
  .appointment-agenda-date strong { color: var(--blue-700); font-variant-numeric: tabular-nums; }

  .appointment-list-item { grid-template-columns: 68px minmax(0, 1fr) auto; }
  .appointment-list-item .appointment-time { align-items: flex-start; }
  .appointment-list-item .appointment-time strong { color: var(--blue-700); font-size: 12px; font-variant-numeric: tabular-nums; }
  .appointment-list-item .appointment-time small { color: var(--ink-500); }
  .appointment-list-item .appointment-work {
    display: block;
    margin-top: 4px;
    color: var(--blue-700);
    font-size: 9px;
    font-weight: 720;
  }

  .appointment-vehicle-section { margin-bottom: 16px; overflow: hidden; }

  .appointment-identity { grid-template-columns: .9fr .9fr 1.1fr 1.25fr .9fr; }
  .appointment-identity > div { min-height: 90px; }
  .appointment-identity .appointment-status,
  .appointment-identity .plate-display { align-self: flex-start; }

  .appointment-order-warning {
    color: #785000;
    background: var(--warning-bg);
    border-color: #edd49a;
    border-left-color: #d58a15;
  }

  .status-badge.status-geplant { color: var(--blue-700); background: #e8f3ff; }
  .status-badge.status-bestatigt,
  .status-badge.status-bestaetigt { color: var(--success); background: var(--success-bg); }
  .status-badge.status-fahrzeug-eingetroffen { color: #6757c5; background: #efedff; }
  .status-badge.status-abgesagt { color: #637083; background: #edf0f3; }

  .bexio-panel {
    position: relative;
    margin-top: 16px;
    border-color: #cfe0ef;
    overflow: hidden;
  }

  .bexio-panel::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: linear-gradient(180deg, var(--cyan-500), var(--blue-600));
  }

  .integration-badge {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    color: var(--ink-600);
    font-size: 9px;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
    background: #edf1f5;
    border: 1px solid var(--line);
    border-radius: 999px;
  }

  .integration-badge::before { content: ""; width: 6px; height: 6px; background: currentColor; border-radius: 50%; }
  .integration-badge.is-local { color: #77600c; background: #fff5cf; border-color: #f0dfa4; }
  .integration-badge.is-synced { color: var(--success); background: var(--success-bg); border-color: #c2e8d9; }
  .integration-badge.is-modified { color: #a15c00; background: #fff0da; border-color: #f2d7ab; }
  .integration-badge.is-error { color: var(--danger); background: var(--danger-bg); border-color: #f2c2bd; }

  .integration-reference {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    padding: 7px 12px;
    color: var(--success);
    font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 10px;
    font-weight: 750;
    background: var(--success-bg);
    border: 1px solid #c2e8d9;
    border-radius: 8px;
  }

  .bexio-panel .bexio-warning {
    display: block;
    margin: 9px 0 0;
    padding: 8px 10px;
    color: #8a5900;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.4;
    background: var(--warning-bg);
    border: 1px solid #edd498;
    border-left: 3px solid #d78a13;
    border-radius: 7px;
  }

  .bexio-actions { align-items: center; }
  .bexio-actions .integration-reference {
    min-height: 0;
    padding: 0;
    color: var(--ink-500);
    font-family: inherit;
    font-size: 9px;
    font-weight: 650;
    background: transparent;
    border: 0;
    border-radius: 0;
  }
}

@media screen and (max-width: 1180px) {
  .quick-action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .appointment-toolbar { grid-template-columns: 1fr auto; }
  .appointment-filters { grid-column: 1 / -1; }
  .appointment-identity { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media screen and (max-width: 820px) {
  .appointment-toolbar { grid-template-columns: 1fr; align-items: stretch; }
  .appointment-navigation { justify-content: flex-start; }
  .appointment-date-picker { flex: 1; }
  .appointment-date-picker input { width: 100%; }
  .appointment-view-switch { width: 100%; }
  .appointment-filters { grid-column: auto; }
  .appointment-day-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .appointment-identity { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media screen and (max-width: 640px) {
  .quick-action-grid { grid-template-columns: minmax(0, 1fr); }
  .appointment-toolbar,
  .appointment-calendar,
  .appointment-agenda,
  .appointment-day-view,
  .appointment-day-list {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .appointment-toolbar { gap: 11px; padding: 11px; }
  .appointment-navigation { display: grid; grid-template-columns: auto 40px 40px minmax(0, 1fr); }
  .appointment-navigation .button { padding-inline: 11px; }
  .appointment-date-picker { min-width: 0; }
  .appointment-filters { grid-template-columns: 1fr; }
  .appointment-view-switch { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .appointment-day-view > header { padding-inline: 14px; }
  .appointment-day-list { grid-template-columns: minmax(0, 1fr); padding: 11px; }
  .appointment-calendar-card { min-height: 66px; }
  .appointment-week-grid { min-width: 760px; grid-template-columns: repeat(7, minmax(108px, 1fr)); }
  .appointment-day-column { min-height: 285px; }
  .appointment-day-column > div { min-height: 222px; padding: 5px; }
  .appointment-month-weekdays,
  .appointment-month-grid { min-width: 700px; grid-template-columns: repeat(7, minmax(98px, 1fr)); }
  .appointment-month-day { min-height: 105px; padding: 5px; }
  .appointment-agenda-item,
  .appointment-list-item { grid-template-columns: 74px minmax(0, 1fr); gap: 9px; }
  .appointment-agenda-item .list-item-aside,
  .appointment-list-item .list-item-aside { grid-column: 2; align-items: flex-start; max-width: 100%; text-align: left; }
  .appointment-identity { grid-template-columns: minmax(0, 1fr); }
  .appointment-identity > div { min-height: 72px; }
  .form-section > .section-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
  .detail-header .button-row > .button:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .bexio-actions { align-items: stretch; flex-direction: column; width: 100%; }
  .bexio-actions .button { width: 100%; }
  .bexio-actions .integration-reference { text-align: center; }
}

@media print {
  .appointment-toolbar,
  .appointment-agenda { display: none !important; }
  .appointment-calendar { border: 0; box-shadow: none; overflow: visible; }
  .appointment-week-grid { min-width: 0; grid-template-columns: repeat(7, 1fr); }
  .appointment-calendar-card,
  .appointment-month-item { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
