:root {
  --ink: #17211c;
  --muted: #5e6a63;
  --line: #e3ddd2;
  --paper: #f4f0e7;
  --card: #fffcf7;
  --sidebar: #141c18;
  --sidebar-ink: #f3f0e6;
  --signal: #e7f27a;
  --done: #1f7a62;
  --work: #c56a1a;
  --open: #8d8478;
  --danger: #9f2d2d;
  --shadow: 0 18px 40px rgba(23, 33, 28, 0.08);
  --sans: "Outfit", "Segoe UI", sans-serif;
  --serif: "Fraunces", "Iowan Old Style", Palatino, serif;
  --radius: 18px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
}

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-ink);
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand { display: flex; gap: 12px; align-items: center; }

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background:
    radial-gradient(circle at 50% 50%, transparent 46%, var(--signal) 47% 62%, transparent 63%),
    #24312b;
  box-shadow: inset 0 0 0 1px rgba(231, 242, 122, 0.25);
}

.brand-kicker, .eyebrow {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 560;
}

.brand-kicker { color: var(--signal); }
.brand-name { margin: 2px 0 0; font-family: var(--serif); font-size: 1.25rem; }

.nav { display: flex; flex-direction: column; gap: 8px; }

.nav-btn {
  text-align: left;
  background: transparent;
  color: inherit;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.nav-btn small { color: #b7c0b8; }

.nav-btn.is-active {
  background: #24312b;
  border-color: rgba(231, 242, 122, 0.35);
}

.user-box {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  background: #24312b;
}

.user-name, .user-role { margin: 0; }
.user-name { font-weight: 560; }
.user-role { color: #b7c0b8; font-size: 0.82rem; }

.sidebar-foot {
  color: #b7c0b8;
  font-size: 0.86rem;
  line-height: 1.45;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-brand { margin-bottom: 8px; }
.login-card .brand-kicker { color: var(--done); }
.login-card .brand-name { color: var(--ink); }
.login-card h1 { margin: 0; }
.login-submit { align-self: flex-start; }
.login-hint { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }

.staff-form h2 { margin: 0 0 14px; font-size: 1.4rem; }
.assignee-block { border: 1px solid var(--line); min-width: 0; }
.assignee-block legend { padding: 0 6px; font-family: var(--serif); font-size: 1.15rem; }
.assignee-list { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.staff-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.staff-card { padding: 14px 16px; }
.staff-card .order-top { align-items: center; }

dialog.narrow { width: min(460px, calc(100vw - 32px)); }

.sidebar-foot p { margin: 0 0 10px; }

.foot-actions { display: flex; gap: 14px; }

.text-btn, .file-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--signal);
  font-weight: 560;
}

.main { padding: 32px 36px 48px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}

.eyebrow { color: var(--muted); }
h1, h2 { font-family: var(--serif); font-weight: 560; letter-spacing: -0.03em; margin: 4px 0 0; }
h1 { font-size: clamp(2rem, 3vw, 2.7rem); }
h2 { font-size: 1.7rem; }

.primary, .ghost, .icon-btn, .chip {
  border-radius: 999px;
  border: 1px solid transparent;
}

.primary {
  background: var(--ink);
  color: #f7f4ec;
  padding: 12px 18px;
  font-weight: 560;
  white-space: nowrap;
}

.primary:hover { background: #24352c; }

.ghost {
  background: transparent;
  border-color: var(--line);
  padding: 12px 18px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  background: transparent;
  border-color: var(--line);
  font-size: 1.4rem;
  line-height: 1;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.stat, .panel, .order-card, .empty {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat { padding: 16px 18px 14px; }
.stat span, .panel-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}
.stat strong {
  display: block;
  margin-top: 8px;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 560;
  letter-spacing: -0.03em;
}
.stat em { font-style: normal; color: var(--muted); font-size: 0.85rem; }

.grid-2 {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 14px;
  margin-bottom: 14px;
}

.panel { padding: 20px 22px 18px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}
.panel h3 { margin: 0; font-size: 1.15rem; font-family: var(--serif); font-weight: 560; }

.donut-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.donut {
  width: 180px;
  height: 180px;
  position: relative;
  margin: 0 auto 8px;
}

.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut circle { fill: none; stroke-width: 14; }
.donut .track { stroke: #ece6db; }
.donut .value { stroke: var(--done); stroke-linecap: round; transition: stroke-dashoffset 0.45s ease; }

.donut-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
}
.donut-label strong {
  font-family: var(--serif);
  font-size: 2.3rem;
  font-weight: 560;
  letter-spacing: -0.04em;
  display: block;
}
.donut-label span { color: var(--muted); font-size: 0.78rem; }

.legend { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.legend li { display: flex; justify-content: space-between; gap: 12px; font-size: 0.95rem; }
.swatch { width: 10px; height: 10px; border-radius: 99px; display: inline-block; margin-right: 8px; }
.swatch.done { background: var(--done); }
.swatch.work { background: var(--work); }
.swatch.open { background: var(--open); }
.swatch.rest { background: #cfc6b8; }

.stack {
  display: flex;
  height: 18px;
  border-radius: 99px;
  overflow: hidden;
  background: #ece6db;
  margin: 8px 0 16px;
}
.stack span { display: block; height: 100%; }
.stack .done { background: var(--done); }
.stack .work { background: var(--work); }
.stack .open { background: #cfc6b8; }

.status-list { display: flex; flex-direction: column; gap: 12px; }
.status-row { display: flex; justify-content: space-between; align-items: baseline; }
.status-row strong { font-family: var(--serif); font-size: 1.45rem; font-weight: 560; }

.bars { display: flex; flex-direction: column; gap: 12px; max-height: 520px; overflow: auto; padding-right: 4px; }
.bar-row {
  width: 100%;
  text-align: left;
  background: #faf7f1;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.bar-row:hover { border-color: #cfc6b8; }
.bar-meta, .bar-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.bar-meta strong { font-weight: 560; }
.bar-meta span, .bar-foot { color: var(--muted); font-size: 0.86rem; }
.track-line {
  margin: 8px 0;
  height: 8px;
  border-radius: 99px;
  background: #ece6db;
  overflow: hidden;
}
.track-line i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--work);
}
.track-line i.is-done { background: var(--done); }
.track-line i.is-open { background: #cfc6b8; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}

.search { flex: 1 1 240px; }
.search input, .sort select, .field input, .field textarea, .qty-table input, .mini-table input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
}
.search input:focus, .sort select:focus, .field input:focus, .field textarea:focus, .qty-table input:focus, .mini-table input:focus {
  outline: 2px solid #d7e38a;
  border-color: #9aaa4a;
}
.sort select { background: var(--card); border-radius: 12px; padding: 11px 12px; border: 1px solid var(--line); }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: transparent;
  border-color: var(--line);
  padding: 8px 12px;
  color: var(--muted);
}
.chip.is-active { background: var(--ink); color: #f7f4ec; border-color: var(--ink); }

.order-list { display: flex; flex-direction: column; gap: 12px; }
.order-card { padding: 16px 18px; }
.order-top, .order-actions, .customer-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.order-top h3 { margin: 0; font-size: 1.2rem; }
.badge {
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 560;
  white-space: nowrap;
}
.badge.offen { background: #efeae2; color: #5c564e; }
.badge.in-arbeit { background: #f8e7d4; color: #8a4b10; }
.badge.abgeschlossen { background: #e5f3ee; color: #14614d; }
.customer-line { margin: 8px 0 4px; color: var(--muted); }
.order-actions { align-items: end; margin-top: 12px; }
.action-group { display: flex; flex-wrap: wrap; gap: 8px; }
.progress-edit { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.progress-edit span { font-size: 0.78rem; color: var(--muted); }
.progress-edit input { width: 110px; }
.linkish {
  background: none;
  border: 0;
  padding: 8px 0;
  color: var(--ink);
  font-weight: 560;
}
.linkish.danger { color: var(--danger); }
.note { margin: 8px 0 0; color: var(--muted); }

.empty {
  padding: 36px 24px;
  text-align: center;
}
.empty h3 { margin: 0 0 8px; font-family: var(--serif); font-size: 1.6rem; }
.empty p { margin: 0 auto 16px; max-width: 42ch; color: var(--muted); }
.empty-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

dialog {
  width: min(840px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 0;
  border-radius: 22px;
  padding: 0;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(20, 28, 24, 0.28);
}

.work-block {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #faf7f1;
}
.work-block h3, .section-label {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 560;
}
.section-label { font-size: 1.05rem; display: flex; justify-content: space-between; gap: 8px; }
.section-label span, .qty-sum { color: var(--muted); font-family: var(--sans); font-size: 0.82rem; font-weight: 460; }
.qty-sum { margin: 8px 0 0; }
.qty-table, .mini-table, .breakdown { width: 100%; border-collapse: collapse; }
.qty-table th, .breakdown th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 560;
  color: var(--muted);
  padding: 0 8px 6px 0;
}
.qty-table td, .mini-table td, .breakdown td { padding: 4px 8px 4px 0; vertical-align: middle; }
.qty-table input { max-width: 140px; }
.mini-table { font-size: 0.9rem; }
.mini-table input { width: 76px; padding: 7px 8px; }
.work-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 12px; }
.work-grid section { min-width: 0; }
.pair { display: flex; flex-direction: column; gap: 14px; }
.follow { margin-top: 14px; }
.table-scroll { overflow-x: auto; }
.pair-row > span { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.pair-row strong { font-weight: 560; }
.breakdown th:not(:first-child), .breakdown td:not(:first-child) { text-align: right; }
dialog::backdrop { background: rgba(20, 28, 24, 0.46); }
#order-form { padding: 22px; }
.dialog-head, .dialog-foot {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.dialog-foot { margin-top: 8px; justify-content: flex-end; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
  margin-top: 18px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 0.82rem; color: var(--muted); }
.span-2 { grid-column: span 2; }
.form-error { min-height: 1.2em; margin: 10px 0; color: var(--danger); font-size: 0.9rem; }
textarea { resize: vertical; }

#customer-map {
  height: min(68vh, 640px);
  min-height: 420px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #d5dece;
}
#customer-map img { max-width: none; }
.map-hint { flex-basis: 100%; margin: 0; }
.map-release {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
}
.map-release input { width: 18px; height: 18px; accent-color: var(--done); }
.map-pin {
  background: var(--ink);
  border: 3px solid var(--signal);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(23, 33, 28, 0.35);
}
.map-popup p, .map-popup ul { margin: 6px 0 0; padding: 0; }
.map-popup li { margin: 4px 0 0; list-style: none; }
.map-missing { margin-top: 12px; }
.map-missing ul { margin: 8px 0 0; padding-left: 18px; }
.leaflet-container { font-family: var(--sans); z-index: 0; }

.attach-label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  margin-top: 10px;
}
.attach-label.is-full { opacity: 0.45; pointer-events: none; }
.file-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.file-row .note { margin: 0; white-space: nowrap; }
.order-files { margin-top: 12px; }
.pdf-dialog { width: min(920px, calc(100vw - 32px)); height: min(86vh, 900px); }
.pdf-dialog iframe { width: 100%; height: calc(100% - 72px); border: 1px solid var(--line); border-radius: 12px; background: white; }

#toast {
  position: fixed;
  z-index: 5000;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: #f7f4ec;
  padding: 10px 14px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}
#toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 980px) {
  .stats, .grid-2, .donut-wrap { grid-template-columns: 1fr; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    padding: 16px;
    gap: 12px;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "brand actions" "nav nav" "user user";
    align-items: center;
  }
  .brand { grid-area: brand; }
  .user-box { grid-area: user; margin-top: 0; }
  .sidebar-foot { grid-area: actions; text-align: right; }
  .nav { grid-area: nav; flex-direction: row; }
  .nav-btn { flex: 1; }
  .sidebar-foot { margin-top: 0; }
  .sidebar-foot p { display: none; }
  .main { padding: 22px 16px 40px; }
  .form-grid, .span-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .order-top, .order-actions, .work-grid { flex-direction: column; align-items: stretch; }
  .work-grid { grid-template-columns: 1fr; }
  .donut { margin-inline: auto; }
  #customer-map { min-height: 320px; height: 62vh; }
}
