/* braindinx Wartungsmonitor - design system
   Brand colors carried over 1:1 from www.braindinx.de (read out via
   getComputedStyle): warm red as the sole accent on an ink-gray base.
   --accent is the AA-safe text/button tone (E42242), --accent-bright
   the brighter signal tone from the live site (ED2E48) for purely
   decorative surfaces (login logo, gradient) with no contrast
   requirement. Status colors (ok/warn/missing) are deliberately kept
   separate from the brand color, so "critical" isn't mistaken for
   "brand".

   Light/dark: the base :root is light (default), @media
   prefers-color-scheme:dark switches to dark automatically (unless
   manually forced to light), and [data-theme="dark"] forces dark
   regardless of the system - set via the toggle button top right
   (see footer.php). The sidebar stays fixed dark (ink) in both
   modes, matching the logo/brand look. */

:root {
  /* fixed, theme-independent */
  --sidebar: #121212;
  --sidebar-hover: #1a1a1a;
  --sidebar-active: #262626;
  --accent: #e42242;
  --accent-dark: #a72828;
  --accent-bright: #ed2e48;
  --radius: 10px;

  /* Light (default) */
  --bg: #f5f5f5;
  --card: #ffffff;
  --border: #e5e5e5;
  --text: #121212;
  --text-muted: #6b6b6b;
  --neutral-bg: #efefef;
  --neutral-fg: #424242;
  --ok-bg: #ecfdf5;
  --ok-fg: #047857;
  --warn-bg: #fff8e6;
  --warn-fg: #92400e;
  --missing-bg: #fef2f2;
  --missing-fg: #991b1b;
  --hover-overlay: rgba(18, 18, 18, 0.04);
  --shadow: 0 1px 2px rgba(18, 18, 18, 0.05), 0 1px 6px rgba(18, 18, 18, 0.05);
  --shadow-md: 0 8px 24px rgba(18, 18, 18, 0.16);
  --modal-backdrop-color: rgba(18, 18, 18, 0.45);
  --login-gradient: linear-gradient(155deg, #eeeeee 0%, #ffffff 55%, #ffd2d9 130%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212;
    --card: #1c1c1c;
    --border: #2e2e2e;
    --text: #f2f2f0;
    --text-muted: #9e9e9e;
    --neutral-bg: #2a2a2a;
    --neutral-fg: #d4d4d4;
    --ok-bg: #052e1b;
    --ok-fg: #34d399;
    --warn-bg: #422006;
    --warn-fg: #fbbf24;
    --missing-bg: #450a0a;
    --missing-fg: #f87171;
    --hover-overlay: rgba(255, 255, 255, 0.05);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 6px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.55);
    --modal-backdrop-color: rgba(0, 0, 0, 0.6);
    --login-gradient: linear-gradient(155deg, #0d0d0d 0%, #1a1a1a 55%, #a72828 130%);
  }
}

:root[data-theme="dark"] {
  --bg: #121212;
  --card: #1c1c1c;
  --border: #2e2e2e;
  --text: #f2f2f0;
  --text-muted: #9e9e9e;
  --neutral-bg: #2a2a2a;
  --neutral-fg: #d4d4d4;
  --ok-bg: #052e1b;
  --ok-fg: #34d399;
  --warn-bg: #422006;
  --warn-fg: #fbbf24;
  --missing-bg: #450a0a;
  --missing-fg: #f87171;
  --hover-overlay: rgba(255, 255, 255, 0.05);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 6px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.55);
  --modal-backdrop-color: rgba(0, 0, 0, 0.6);
  --login-gradient: linear-gradient(155deg, #0d0d0d 0%, #1a1a1a 55%, #a72828 130%);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Segoe UI",
    -apple-system,
    BlinkMacSystemFont,
    "Inter",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
  font-size: 14px;
}

body,
.card,
.kpi-card,
.sidebar,
input,
select,
textarea,
.btn,
.pill,
.badge-admin {
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

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

/* --- Accessibility: screen-reader only / visible only on keyboard focus --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 12px;
  z-index: 1000;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 0 0 8px 8px;
  box-shadow: var(--shadow-md);
  font-weight: 600;
  font-size: 13.5px;
  transition: top 0.12s ease;
}

.skip-link:focus {
  top: 0;
}

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

/* --- Sidebar --- */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 20px 20px 20px;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 12px;
}

.sidebar-brand .brand-logo {
  width: 128px;
  height: auto;
  display: block;
}

.sidebar-brand-sub {
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.brand-logo {
  color: inherit;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 13.5px;
  font-weight: 500;
  transition:
    background 0.12s ease,
    color 0.12s ease;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-link.active {
  background: var(--sidebar-active);
  color: #fff;
}

.icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.15em;
  flex-shrink: 0;
  fill: currentColor;
}
.sidebar-link .icon {
  width: 18px;
  height: 18px;
  text-align: center;
  opacity: 0.9;
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 20px 0 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: #9ca3af;
}

/* --- Main area --- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 700;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.badge-admin {
  background: var(--neutral-bg);
  color: var(--neutral-fg);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.content {
  padding: 24px 28px;
  flex: 1;
}

/* --- Cards / KPIs --- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  border-left: 4px solid var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-card.warn {
  border-left-color: var(--warn-fg);
}
.kpi-card.missing {
  border-left-color: var(--missing-fg);
}
.kpi-card.ok {
  border-left-color: var(--ok-fg);
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
}
.kpi-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 15px;
  margin: 0 0 14px 0;
  font-weight: 700;
}

/* --- Sub-navigation (Tab-Leiste innerhalb eines Moduls, z.B. /wartung) --- */
.subnav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.subnav-link {
  display: inline-block;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.subnav-link:hover {
  color: var(--text);
}

.subnav-link.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  text-align: left;
  padding: 10px 12px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
}
th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
tr:last-child td {
  border-bottom: none;
}
tr.clickable-row {
  cursor: pointer;
}
tr.clickable-row:hover {
  background: var(--hover-overlay);
}

.table-wrap {
  overflow-x: auto;
}

/* --- Simple inline bar chart (dashboard "Kunden nach Typ") ---
   Single-series magnitude chart (bar length = count), so a single flat
   accent fill is used rather than a categorical palette - the category
   identity is already carried by the row label, not by color. Rounded
   ends and a recessive track per the usual bar-chart mark spec. */
.bar-track {
  background: var(--neutral-bg);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}
.bar-fill {
  background: var(--accent);
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* --- Status pills --- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.pill.ok {
  background: var(--ok-bg);
  color: var(--ok-fg);
}
.pill.warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
}
.pill.missing {
  background: var(--missing-bg);
  color: var(--missing-fg);
}
.pill.neutral {
  background: var(--neutral-bg);
  color: var(--neutral-fg);
}

/* --- Forms --- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="file"],
input[type="email"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(228, 34, 66, 0.25);
}

textarea {
  resize: vertical;
  min-height: 70px;
}

.field {
  margin-bottom: 14px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-dark);
}

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--hover-overlay);
}

.btn-danger {
  background: var(--card);
  color: var(--missing-fg);
  border-color: #7f1d1d;
}
.btn-danger:hover {
  background: var(--missing-bg);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12.5px;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

/* --- Alerts / flash messages --- */
.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 18px;
  font-size: 13.5px;
  font-weight: 500;
}
.flash.success {
  background: var(--ok-bg);
  color: var(--ok-fg);
}
.flash.error {
  background: var(--missing-bg);
  color: var(--missing-fg);
}
.flash.info {
  background: var(--neutral-bg);
  color: var(--neutral-fg);
}

/* --- Login page --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--login-gradient);
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 36px 34px;
  width: 100%;
  max-width: 360px;
}

.login-card h1 {
  font-size: 19px;
  margin: 0 0 2px 0;
}
.login-card .subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 22px;
}

.login-logo {
  color: var(--accent-bright);
  margin-bottom: 12px;
}
.login-logo .brand-logo {
  width: 168px;
  height: auto;
  display: block;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.toolbar .actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.search-input {
  max-width: 280px;
}

.text-muted {
  color: var(--text-muted);
}
.mt-0 {
  margin-top: 0;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop-color);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 50;
}
.modal-backdrop.open {
  display: flex;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 560px;
  padding: 24px;
}
.modal h2 {
  margin-top: 0;
}

/* --- Responsive: narrow screens (tablet/mobile) --- */
@media (max-width: 860px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    padding: 12px 0;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    position: static;
    height: auto;
    overflow-y: visible;
  }

  .sidebar-brand {
    padding: 0 14px;
    margin-bottom: 0;
    border-bottom: none;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .sidebar-nav {
    flex-direction: row;
    padding: 0 8px;
    overflow-x: auto;
  }

  .sidebar-link {
    white-space: nowrap;
  }

  .sidebar-footer {
    display: none;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
  }

  .content {
    padding: 16px;
  }

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

  .form-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar .actions {
    margin-left: 0 !important;
  }
  .search-input {
    max-width: none;
  }
}

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

/* --- Dashboard (Startseite nach dem Login) --- */
.dashboard-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.dashboard-hero h2 {
  margin: 0 0 4px 0;
  font-size: 21px;
  font-weight: 700;
}
.dashboard-hero p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13.5px;
}

.kpi-card {
  position: relative;
}
.kpi-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}
.kpi-card-link .kpi-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.kpi-card {
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    border-color 0.12s ease;
}
.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.dashboard-cols {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 860px) {
  .dashboard-cols {
    grid-template-columns: 1fr;
  }
}

.dash-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dash-list-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.dash-list-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.dash-list-item .title {
  font-weight: 600;
}
.dash-list-item .meta {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.onboarding-progress-ring {
  display: flex;
  align-items: center;
  gap: 16px;
}
.onboarding-progress-ring .value {
  font-size: 26px;
  font-weight: 700;
}

.quicklink-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.quicklink-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 12px;
  text-decoration: none;
  color: var(--text);
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    border-color 0.12s ease;
}
.quicklink-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.quicklink-card .icon {
  width: 26px;
  height: 26px;
  color: var(--accent);
}
.quicklink-card span:last-child {
  font-size: 12.5px;
  font-weight: 600;
}
