:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --text: #1e293b;
  --muted: #64748b;
  --line: #d7e0ea;
  --line-strong: #c2cfdd;

  --accent: #0f766e;
  --accent-2: #2563eb;
  --danger: #b91c1c;
  --warn: #b45309;
  --ok: #15803d;

  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.06);
  --shadow-card: 0 8px 24px rgba(15, 23, 42, 0.05);

  --radius-xl: 24px;
  --radius-lg: 20px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

/* =========================================================
   Base
   ========================================================= */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.06), transparent 28%),
    linear-gradient(180deg, #f5f8fc 0%, #edf2f7 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

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

.muted,
.subtitle {
  color: var(--muted);
}

/* =========================================================
   Main shell layout
   ========================================================= */

.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 22px;
  min-height: 100vh;
  padding: 22px;
}

.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #162338 100%);
  color: #e2e8f0;
  border-radius: 26px;
  padding: 26px 20px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
  position: sticky;
  top: 22px;
  height: calc(100vh - 44px);
  overflow: auto;
}

.brand {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-bottom: 18px;
}

.user-box {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 14px 16px;
  margin-bottom: 18px;
}

.user-box .label {
  font-size: 0.75rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.user-box .value {
  margin-top: 4px;
  font-weight: 700;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-link {
  display: block;
  border-radius: 16px;
  padding: 12px 14px;
  font-weight: 600;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: all 0.16s ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-1px);
  color: #ffffff;
}

.nav-link.is-active {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.34), rgba(37, 99, 235, 0.22));
  border-color: rgba(96, 165, 250, 0.28);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.main {
  min-width: 0;
}

/* =========================================================
   Page header
   ========================================================= */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: var(--radius-xl);
  padding: 22px 24px;
  box-shadow: var(--shadow-soft);
}

.page-header h1 {
  margin: 0 0 6px 0;
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.search-form {
  display: flex;
  gap: 8px;
}

.search-form input {
  min-width: 240px;
  background: #fff;
}

/* =========================================================
   Flash / notice / tags / status
   ========================================================= */

.flash {
  margin-bottom: 14px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
}

.flash-success {
  border-left: 5px solid var(--ok);
}

.flash-error {
  border-left: 5px solid var(--danger);
}

.notice {
  margin-bottom: 10px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.notice-info {
  border-left: 5px solid var(--accent-2);
}

.notice-warn {
  border-left: 5px solid var(--warn);
}

.notice-danger {
  border-left: 5px solid var(--danger);
}

.tag {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f8fafc;
  font-size: 0.82rem;
}

.status {
  display: inline-block;
  padding: 6px 10px;
  font-size: 0.82rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.status-wartet,
.status-offen {
  border-left: 5px solid var(--warn);
}

.status-zugewiesen,
.status-disponiert {
  border-left: 5px solid var(--accent-2);
}

.status-uebernommen,
.status-angekommen {
  border-left: 5px solid var(--accent);
}

.status-abgeschlossen,
.status-abgerueckt {
  border-left: 5px solid var(--ok);
}

/* =========================================================
   Login
   ========================================================= */

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

/* =========================================================
   Sticky helpers / mobile nav
   ========================================================= */

.mobile-sticky {
  position: sticky;
  bottom: 0;
  background: rgba(243, 245, 248, 0.95);
  padding-top: 12px;
  margin-top: 18px;
}

.mobile-topbar {
  display: none;
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.mobile-brand {
  font-weight: 700;
}

.mobile-nav {
  display: none;
  background: #0f172a;
  color: #e2e8f0;
  padding: 0 16px 16px;
}

.mobile-nav.is-open {
  display: block;
}

.mobile-nav .nav {
  margin-top: 8px;
}

.desktop-only {
  display: block;
}

/* =========================================================
   Utility blocks still used in app
   ========================================================= */

.compact-notes {
  margin-bottom: 16px;
}

.compact-notes summary {
  cursor: pointer;
  list-style: none;
}

.compact-notes summary::-webkit-details-marker {
  display: none;
}

.compact-notes[open] {
  padding-bottom: 10px;
}

.split-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

/* =========================================================
   BR monitor / operational widgets
   ========================================================= */

.stats-grid-extended {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 18px 0;
}

.longest-grid {
  margin-top: 16px;
}

.big-number {
  font-size: 40px;
  font-weight: 700;
  line-height: 1.1;
}

.longest-card .longest-name {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.longest-card .longest-time,
.longest-card .longest-duration,
.footer-note {
  color: var(--muted);
}

.footer-note {
  margin-top: 8px;
  font-size: 0.92rem;
}

.live-status {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.95rem;
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--ok);
  display: inline-block;
}

.live-status.is-error .live-dot {
  background: var(--danger);
}

.live-status.is-paused .live-dot {
  background: var(--warn);
}

.badge-rd {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.18);
}

.badge-fw {
  background: rgba(185, 28, 28, 0.08);
  border-color: rgba(185, 28, 28, 0.18);
}

tr.entry-row-fw td {
  background: rgba(185, 28, 28, 0.03);
}

tr.entry-row-rd td {
  background: rgba(37, 99, 235, 0.03);
}

tr.entry-row-fw:hover td,
tr.entry-row-rd:hover td {
  background: rgba(15, 23, 42, 0.04);
}

.order-editor {
  display: flex;
  gap: 10px;
  align-items: center;
}

.order-input {
  min-width: 0;
  width: 100%;
}

.order-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.icon-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
}

.icon-action svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.secondary-action {
  background: #fff;
}

.primary {
  background: var(--accent-2);
  color: #fff;
  border-color: var(--accent-2);
}

.danger-action {
  background: #fff;
  color: var(--danger);
  border-color: var(--line);
}

/* =========================================================
   Header hints
   ========================================================= */

.header-hints {
  position: relative;
}

.header-hints summary {
  list-style: none;
}

.header-hints summary::-webkit-details-marker {
  display: none;
}

.hint-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}

.header-hints[open] .hint-toggle {
  border-color: rgba(37, 99, 235, 0.25);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.hint-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: min(420px, 92vw);
  max-height: 65vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.14);
  z-index: 80;
}

.hint-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.hint-item + .hint-item {
  margin-top: 10px;
}

.hint-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.hint-text {
  color: var(--text);
  line-height: 1.45;
}

.hint-empty {
  padding: 10px 12px;
  color: var(--muted);
}

.hint-danger {
  border-left: 5px solid var(--danger);
}

.hint-warn {
  border-left: 5px solid var(--warn);
}

.hint-info {
  border-left: 5px solid var(--accent-2);
}

.mobile-hints {
  margin-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 12px;
}

.mobile-hints summary {
  cursor: pointer;
  list-style: none;
  font-weight: 700;
}

.mobile-hints summary::-webkit-details-marker {
  display: none;
}

.mobile-hints-body {
  margin-top: 10px;
}

/* =========================================================
   Shared metric cards
   ========================================================= */

.grid-cards {
  display: grid;
  gap: 12px;
}

.grid-cards-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-cards-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-cards-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card {
  background: linear-gradient(180deg, #fff 0%, #f6faff 100%);
  border: 1px solid #d9e4f0;
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  min-height: 96px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.metric-card.is-zero .metric-value {
  opacity: 0.55;
}

.metric-card.is-available {
  border-left: 4px solid rgba(21, 128, 61, 0.7);
}

.metric-card.is-demand {
  border-left: 4px solid rgba(180, 83, 9, 0.7);
}

.metric-card.compact {
  min-height: 88px;
}

.metric-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.metric-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text);
}

.metric-sub {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 4px;
}

/* =========================================================
   Section wrappers
   ========================================================= */

.section-stack {
  display: grid;
  gap: 16px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head h2,
.section-head h3 {
  margin: 0;
  font-size: 1rem;
}

.section-head .subtitle {
  font-size: 0.88rem;
}

.overview-panel {
  background: linear-gradient(180deg, #fff 0%, #fbfdff 100%);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow-card);
}

.overview-panel .grid-cards {
  margin-top: 12px;
}

/* =========================================================
   Domain-specific accent cards
   ========================================================= */

.dashboard-sk-card.is-sk1 {
  border-left: 4px solid rgba(185, 28, 28, 0.75);
}

.dashboard-sk-card.is-sk2 {
  border-left: 4px solid rgba(180, 83, 9, 0.75);
}

.dashboard-sk-card.is-sk3 {
  border-left: 4px solid rgba(21, 128, 61, 0.75);
}

.dashboard-live-card {
  min-height: 100%;
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .mobile-topbar {
    display: flex;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  }

  .desktop-only {
    display: none;
  }

  .stats-grid-extended,
  .longest-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-cards-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 14px;
    gap: 14px;
  }

  .page-header {
    flex-direction: column;
    padding: 18px;
  }

  .search-form {
    width: 100%;
  }

  .search-form input {
    min-width: 0;
    flex: 1;
  }

  .split-fields,
  .stats-grid-extended,
  .longest-grid {
    grid-template-columns: 1fr;
  }

  .grid-cards-4,
  .grid-cards-3,
  .grid-cards-2 {
    grid-template-columns: 1fr 1fr;
  }

  .metric-card {
    min-height: 86px;
    padding: 12px 14px;
  }

  .metric-value {
    font-size: 1.7rem;
  }

  .big-number {
    font-size: 2rem;
  }

  .order-editor {
    flex-direction: column;
    align-items: stretch;
  }

  .order-actions {
    width: 100%;
  }

  .order-actions > * {
    flex: 1;
  }

  .header-hints {
    width: 100%;
  }

  .hint-toggle {
    width: 100%;
    justify-content: flex-start;
  }

  .hint-dropdown {
    left: 0;
    right: auto;
    width: 100%;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 420px) {
  .grid-cards-4,
  .grid-cards-3,
  .grid-cards-2 {
    grid-template-columns: 1fr;
  }
}