:root {
  --navy-950: #0A1524;
  --navy-800: #14243b;
  --navy-700: #1E3A5F;
  --blue-600: #2E7FD1;
  --blue-500: #356EB5;
  --blue-100: #e7f1fb;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --border: #e2e6ec;
  --text: #16202c;
  --text-muted: #5b6675;
  --danger: #c0392b;
  --success: #15803d;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 6px rgba(10, 21, 36, 0.05), 0 8px 20px rgba(10, 21, 36, 0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
}
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 650; color: var(--navy-950); margin: 0 0 .5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { line-height: 1.5; }

.app-shell { display: flex; min-height: 100vh; }

/* --- Sidebar --- */
.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-950), var(--navy-800));
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 20px; }
.sidebar .brand img { width: 32px; height: 32px; }
.sidebar .brand strong { color: #fff; font-size: 0.95rem; line-height: 1.2; display: block; }
.sidebar .brand span { font-size: 0.72rem; color: #93a5bd; }
.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sidebar .nav-section { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .06em; color: #64748b; margin: 14px 10px 4px; }
.sidebar a.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; color: #cbd5e1; font-size: 0.88rem;
}
.sidebar a.nav-link:hover { background: rgba(255,255,255,0.06); text-decoration: none; }
.sidebar a.nav-link.active { background: var(--blue-600); color: #fff; }
.sidebar .nav-link .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.sidebar .user-box { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 12px; margin-top: 8px; font-size: 0.82rem; }
.sidebar .user-box form { margin-top: 6px; }
.sidebar .user-box button { background: none; border: none; color: #93a5bd; cursor: pointer; font-size: 0.8rem; padding: 0; }
.sidebar .user-box button:hover { color: #fff; }

/* --- Main --- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar form.search { display: flex; }
.topbar input[type=search], .topbar input[type=text] {
  border: 1px solid var(--border); border-radius: 8px 0 0 8px; padding: 7px 12px; width: 260px; font-size: 0.88rem;
}
.content { padding: 24px 28px 60px; max-width: 1280px; }

/* --- Cards / Tiles --- */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 28px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); display: block; color: var(--text);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.tile:hover { border-color: var(--blue-600); text-decoration: none; transform: translateY(-2px); box-shadow: 0 10px 24px rgba(10,21,36,.10); }
.tile .tile-count { font-size: 2rem; font-weight: 700; color: var(--navy-950); }
.tile .tile-label { color: var(--text-muted); font-size: 0.85rem; margin-top: 2px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.card > h2, .card > h3 { margin-top: 0; }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 980px) { .two-col { grid-template-columns: 1fr; } }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; border: 1px solid transparent;
  padding: 8px 16px; font-size: 0.88rem; cursor: pointer; font-weight: 550;
  transition: transform .1s ease, background .12s ease, border-color .12s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--blue-600); color: #fff; }
.btn-primary:hover { background: var(--blue-500); text-decoration: none; }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--blue-600); text-decoration: none; }
.btn-danger { background: #fdecea; color: var(--danger); border-color: #f6c9c3; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- Forms --- */
label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=date], input[type=time],
input[type=password], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px;
  font-size: 0.9rem; font-family: inherit; background: #fff; color: var(--text);
  transition: border-color .12s ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue-600); }
textarea { resize: vertical; min-height: 70px; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0 0 18px; }
legend { font-weight: 650; color: var(--navy-950); padding: 0 6px; font-size: 0.92rem; }
.hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 0.88rem; }
.alert-error { background: #fdecea; color: var(--danger); border: 1px solid #f6c9c3; }
.alert-success { background: #eafaf0; color: var(--success); border: 1px solid #bfe8cd; }
.alert-info { background: var(--blue-100); color: var(--navy-700); border: 1px solid #bcdcf5; }

/* --- Tables --- */
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 0.76rem; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: #fafbfd; }
.table-wrap { overflow-x: auto; }

/* --- Badges / status --- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; color: #fff;
}
.badge-outline { background: none; border: 1px solid var(--border); color: var(--text-muted); }
.urgency-dringend { color: #b45309; font-weight: 600; }
.urgency-sofort { color: #b91c1c; font-weight: 700; }

/* --- Positionen-Editor (KVA / Lieferschein) --- */
.line-items { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.line-item-row {
  display: grid; grid-template-columns: 1fr 70px 100px 100px 32px; gap: 8px; align-items: center;
}
.line-item-row input { margin: 0; }
.line-item-row .li-remove {
  border: none; background: #fdecea; color: var(--danger); border-radius: 6px; width: 28px; height: 28px; cursor: pointer;
}
.line-items-head {
  display: grid; grid-template-columns: 1fr 70px 100px 100px 32px; gap: 8px;
  font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px;
}
.line-items-totals { text-align: right; font-weight: 650; color: var(--navy-950); margin: 6px 0 14px; }
@media (max-width: 700px) {
  .line-item-row, .line-items-head { grid-template-columns: 1fr 50px 80px 80px 28px; font-size: 0.85rem; }
}

/* --- Positionen-Editor (Bestellungen) --- */
.po-items { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.po-item-row {
  display: grid; grid-template-columns: 220px 1fr 70px 110px 32px; gap: 8px; align-items: center;
}
.po-item-row input, .po-item-row select { margin: 0; }
.po-item-row .poi-remove {
  border: none; background: #fdecea; color: var(--danger); border-radius: 6px; width: 28px; height: 28px; cursor: pointer;
}
@media (max-width: 760px) {
  .po-item-row { grid-template-columns: 1fr; }
}

/* --- Timeline --- */
.timeline { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 16px 18px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--blue-600); }
.timeline .ts { font-size: 0.75rem; color: var(--text-muted); }

/* --- Tag input (Fehlerbeschreibung) --- */
.tag-input { border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; background: #fff; }
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.tag-chips:empty { margin-bottom: 0; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--blue-100); color: var(--navy-700);
  border-radius: 999px; padding: 3px 6px 3px 11px; font-size: 0.82rem;
}
.tag-chip button {
  border: none; background: rgba(10,21,36,0.12); color: var(--navy-700); border-radius: 50%;
  width: 16px; height: 16px; line-height: 1; cursor: pointer; font-size: 0.7rem; padding: 0;
}
.tag-input input[type=text] { border: none; padding: 4px 2px; width: 100%; }
.tag-input input[type=text]:focus { outline: none; }

/* --- Unlock pattern drawer --- */
.pattern-pad { display: inline-block; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.pattern-pad canvas { display: block; touch-action: none; }

/* --- Login --- */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, var(--navy-950), var(--navy-700)); }
.login-card { background: #fff; border-radius: 14px; padding: 36px 34px; width: 360px; box-shadow: 0 20px 50px rgba(0,0,0,0.35); }
.login-card .brand { text-align: center; margin-bottom: 22px; }
.login-card .brand img { width: 52px; margin-bottom: 8px; }

/* --- Public tracking --- */
.public-shell { min-height: 100vh; background: linear-gradient(160deg, var(--navy-950), var(--navy-700)); display: flex; align-items: flex-start; justify-content: center; padding: 60px 20px; }
.public-card { background: #fff; border-radius: 14px; padding: 34px; width: 420px; max-width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,0.35); }

/* --- Overlay-Dialoge (Warenwirtschaft „+ Neuer Artikel“ etc.) --- */
dialog { box-shadow: 0 24px 60px rgba(10,21,36,.25); }
dialog::backdrop { background: rgba(10,21,36,.45); backdrop-filter: blur(1px); }

/* --- Balkendiagramm (Auswertungen) --- */
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-chart-row { display: grid; grid-template-columns: 120px 1fr 36px; gap: 10px; align-items: center; font-size: 0.8rem; }
.bar-chart-label { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-chart-track { background: var(--bg); border-radius: 999px; height: 14px; overflow: hidden; }
.bar-chart-fill { background: linear-gradient(90deg, var(--blue-600), var(--blue-500)); height: 100%; border-radius: 999px; transition: width .2s ease; }
.bar-chart-value { text-align: right; font-weight: 650; color: var(--navy-950); }

/* --- Auftragsstatus-Donut (Dashboard) --- */
.status-donut {
  width: 168px; height: 168px; border-radius: 50%; position: relative; margin: 0 auto;
}
.status-donut::after {
  content: ""; position: absolute; inset: 20px; border-radius: 50%; background: var(--surface);
}
.status-donut-label {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 1;
}

/* --- Pill-Filter (Auftragsübersicht) --- */
.pill-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.pill-filter {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font-size: 0.84rem; font-weight: 550;
}
.pill-filter:hover { border-color: var(--blue-600); text-decoration: none; }
.pill-filter.active { background: var(--navy-950); border-color: var(--navy-950); color: #fff; }
.pill-filter .count {
  background: rgba(255,255,255,.25); border-radius: 999px; padding: 0 7px; font-size: 0.74rem;
}
.pill-filter:not(.active) .count { background: var(--bg); color: var(--text-muted); }

/* --- Auftragszeile (Auftragsübersicht) --- */
.order-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: var(--radius-sm);
  border-left: 4px solid var(--border); background: var(--surface); margin-bottom: 8px; cursor: pointer;
  transition: box-shadow .12s ease, transform .12s ease;
}
.order-row:hover { box-shadow: var(--shadow); transform: translateX(2px); }
.order-row .order-row-main { flex: 1; min-width: 0; }
.order-row .order-row-id { font-weight: 650; color: var(--navy-950); font-size: 0.86rem; }
.order-row .order-row-sub { color: var(--text-muted); font-size: 0.78rem; margin-top: 2px; }
.order-row .order-row-date { font-size: 0.76rem; color: var(--text-muted); white-space: nowrap; }

/* --- Calendar --- */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.calendar-cell { background: #fff; border: 1px solid var(--border); border-radius: 8px; min-height: 92px; padding: 6px; font-size: 0.78rem; }
.calendar-cell .day-num { font-weight: 650; color: var(--navy-950); margin-bottom: 4px; }
.calendar-appt { background: var(--blue-100); color: var(--navy-700); border-radius: 5px; padding: 2px 5px; margin-bottom: 3px; font-size: 0.72rem; }
.calendar-head { text-align: center; font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; padding-bottom: 4px; }

/* --- Utility --- */
.muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-14 { gap: 14px; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
