:root {
  --bg: #eef1f8;
  --bg-accent: linear-gradient(160deg, #e8ecf7 0%, #f4f6fb 45%, #eef1f8 100%);
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-border: #c7d2fe;
  --success: #059669;
  --success-soft: #ecfdf5;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --korridor: #7c3aed;
  --korridor-soft: #f5f3ff;
  --transit: #2563eb;
  --transit-soft: #eff6ff;
  --border: rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 8px 30px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.12);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  background-image: var(--bg-accent);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover { color: var(--accent-hover); }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

/* ── Header ─────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.app-header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  flex-shrink: 0;
}

.brand-static { cursor: default; }

.brand-logo {
  height: 36px;
  width: auto;
  max-width: 120px;
  border-radius: 10px;
  object-fit: contain;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(30, 58, 138, 0.18);
}

.brand-text small {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.brand:hover { color: inherit; }

.nav-home {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.12s;
}

.nav-home:hover {
  background: #e0e7ff;
  color: var(--accent-hover);
  transform: translateX(-1px);
}

.nav-home-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.app-nav {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}

.app-nav::-webkit-scrollbar { display: none; }

.app-header-end {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

.nav-logout-form { margin: 0; }

.btn-nav-logout {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}

.btn-nav-logout:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-nav-notify {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.btn-nav-notify:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-nav-notify.notify-on {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}

.btn-nav-notify.hidden {
  display: none;
}

.breadcrumb {
  margin: 0 0 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.breadcrumb a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }

/* Mobile bottom navigation */
.app-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
  text-decoration: none;
  text-align: center;
  line-height: 1.2;
}

.bottom-nav-item:hover { color: var(--accent); background: var(--accent-soft); }

.bottom-nav-item.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.bottom-nav-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.brand-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.brand-text small {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}

.nav-link {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-link.active {
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.user-chip {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  letter-spacing: 0.02em;
}

.app-main { padding-top: 28px; }

.page-head-compact {
  margin-bottom: 16px;
}

.page-head-compact h1 {
  font-size: 1.45rem;
  margin: 0;
}

.page-head {
  margin-bottom: 24px;
}

.page-head h1 {
  margin: 0 0 6px;
  font-size: clamp(1.5rem, 3vw, 1.85rem);
  letter-spacing: -0.03em;
  font-weight: 700;
}

.app-footer {
  padding: 24px 0 32px;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

.footer-inner {
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

/* ── Legacy topbar (fallback) ───────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.topbar h1 { margin: 0; font-size: 1.5rem; letter-spacing: -0.02em; }

.muted { color: var(--muted); font-size: 0.9rem; }

/* ── Cards ──────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease;
}

.card:hover { box-shadow: 0 12px 36px rgba(15, 23, 42, 0.09); }

.card h2 {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 1rem;
  flex-shrink: 0;
}

.card-icon.purple { background: var(--korridor-soft); }
.card-icon.blue { background: var(--transit-soft); }
.card-icon.green { background: var(--success-soft); }
.card-icon.indigo { background: var(--accent-soft); }
.card-icon.gray { background: var(--surface-2); }

.pdf-card,
.korridor-card {
  border-color: var(--accent-border);
  background: linear-gradient(145deg, #fafbff 0%, #fff 60%);
}

.card code {
  font-size: 0.78rem;
  background: var(--surface-2);
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* ── Forms & toolbar ────────────────────────────────── */
label {
  display: block;
  margin: 10px 0 5px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

label.inline { margin: 0 0 4px; font-size: 0.78rem; }

input, select, button, textarea { font: inherit; }

input, select {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent-border);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

input[type="file"] {
  padding: 10px;
  background: var(--surface-2);
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  align-items: center;
}

.toolbar input[type=date],
.toolbar input[type=search] {
  width: auto;
  min-width: 160px;
  flex: 1;
}

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
  color: #fff;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: #fff; color: var(--text); }

.btn-sm { padding: 8px 14px; font-size: 0.82rem; }

.btn-xs { padding: 6px 11px; font-size: 0.76rem; }

/* ── Lists & rows ───────────────────────────────────── */
.order-list { display: grid; gap: 12px; }

.order-row,
.session-row,
.stamm-row {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.order-row:hover,
.session-row:hover,
.stamm-row:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-sm);
}

.order-row header,
.session-row header,
.stamm-row header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.order-row strong,
.session-row strong,
.stamm-row strong { font-size: 0.95rem; }

.order-meta,
.session-meta { font-size: 0.84rem; color: var(--muted); line-height: 1.55; }

.order-actions,
.session-actions,
.stamm-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.stamm-row.editing {
  border-color: var(--accent-border);
  background: linear-gradient(180deg, #fafbff, #fff);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08);
}

.stamm-view { display: grid; gap: 4px; }
.stamm-edit { display: grid; gap: 10px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.source-tag {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}

.warenort-select { min-width: 220px; flex: 1; }

/* ── Badges ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge.transit { background: var(--transit-soft); color: var(--transit); border-color: #bfdbfe; }
.badge.korridor { background: var(--korridor-soft); color: var(--korridor); border-color: #ddd6fe; }
.badge.gzes { background: #ede9fe; color: #5b21b6; border-color: #ddd6fe; }
.badge.docs-missing { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.badge.docs-ok { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.remind-docs-btn { border-color: #fca5a5 !important; color: #b91c1c !important; }
.badge.gzas { background: #ffedd5; color: #c2410c; border-color: #fed7aa; }
.badge.rollender { background: #ccfbf1; color: #0f766e; border-color: #99f6e4; }
.badge.live { background: var(--success-soft); color: var(--success); border-color: #a7f3d0; }
.badge.wait { background: var(--warning-soft); color: var(--warning); border-color: #fde68a; }
.badge.done { background: var(--success-soft); color: var(--success); border-color: #a7f3d0; }

/* ── QR & session extras ────────────────────────────── */
.qr-mini {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  background: #fff;
}

/* ── PDF preview ────────────────────────────────────── */
.pdf-preview {
  margin-top: 12px;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.88rem;
  line-height: 1.55;
}

.pdf-preview dl {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px 12px;
  margin: 0;
}

.pdf-preview dt { color: var(--muted); margin: 0; font-weight: 500; }
.pdf-preview dd { margin: 0; font-weight: 600; }

/* ── Alerts ─────────────────────────────────────────── */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
}

.alert.error { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.alert.ok { background: var(--success-soft); color: var(--success); border-color: #a7f3d0; }

.hidden { display: none !important; }

/* ── Modal ──────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 200;
  animation: fadeIn 0.2s ease;
}

.modal {
  width: min(440px, 100%);
  background: var(--surface);
  border-radius: 22px;
  padding: 28px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}

.modal h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.link-box {
  word-break: break-all;
  font-size: 0.82rem;
  background: var(--surface-2);
  padding: 14px;
  border-radius: var(--radius-sm);
  margin: 14px 0;
  border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.qr {
  display: block;
  margin: 16px auto;
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.modal-actions { display: grid; gap: 8px; }

/* ── Test results ───────────────────────────────────── */
.test-results {
  margin-bottom: 14px;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid #ddd6fe;
  background: var(--korridor-soft);
}

.test-results h3 { margin: 0 0 10px; font-size: 0.95rem; }

.test-item {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}

.test-item:last-child { margin-bottom: 0; }
.test-item header { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.test-item .test-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.test-item .test-url { font-size: 0.72rem; word-break: break-all; color: var(--muted); }

/* ── Empty state ──────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* ── Animations ───────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 768px) {
  body.has-bottom-nav { padding-bottom: 72px; }
  .app-header-inner { padding: 8px 12px; gap: 8px; }
  .app-nav { display: none; }
  .app-bottom-nav { display: grid; }
  .nav-home-text { display: none; }
  .nav-home { padding: 8px 11px; }
  .btn-nav-logout { padding: 6px 8px; font-size: 0.7rem; }
  .wrap { padding: 0 14px 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .pdf-preview dl { grid-template-columns: 1fr; gap: 4px; }
  .pdf-preview dt { margin-top: 8px; }
  .modal-backdrop { place-items: end center; padding: 12px; }
  .modal { border-radius: 20px 20px 16px 16px; margin-bottom: 72px; }
  .app-footer { padding-bottom: 16px; }
}
