/* braindinx Wartungsmonitor - Design-System
   Angelehnt an den minimalistischen braindinx-Markenauftritt (braindinx.de):
   Schwarz/Weiß, keine bunte Akzentfarbe, viel Weißraum. Status-Ampelfarben
   (ok/warn/offen) bleiben aus Gründen der Lesbarkeit farbig. */

:root {
  --bg: #fafafa;
  --sidebar: #0a0a0a;
  --sidebar-hover: #1a1a1a;
  --sidebar-active: #262626;
  --card: #ffffff;
  --border: #e5e5e5;
  --text: #111111;
  --text-muted: #6b6b6b;
  --accent: #111111;
  --accent-dark: #000000;
  --ok-bg: #ecfdf5;
  --ok-fg: #047857;
  --warn-bg: #fff8e6;
  --warn-fg: #92400e;
  --missing-bg: #fef2f2;
  --missing-fg: #991b1b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 6px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
}

* {
  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;
}

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

.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;
}

.sidebar-brand {
  padding: 0 20px 20px 20px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 12px;
}

.sidebar-brand span {
  color: #9ca3af;
  font-weight: 400;
}

.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;
}

.sidebar-link .icon {
  width: 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: #f0f0f0;
  color: #111111;
  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-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  border-left: 4px solid var(--accent);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-card.warn {
  border-left-color: #d97706;
}
.kpi-card.missing {
  border-left-color: #dc2626;
}
.kpi-card.ok {
  border-left-color: #059669;
}

.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-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;
}

/* --- 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: #f9fafb;
}

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

/* --- 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: #f3f4f6;
  color: var(--text-muted);
}

/* --- 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"],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

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

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: #fff;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: #f9fafb;
}

.btn-danger {
  background: #fff;
  color: #dc2626;
  border-color: #fecaca;
}
.btn-danger:hover {
  background: #fef2f2;
}

.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: #f0f0f0;
  color: #111111;
}

/* --- Login page --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #0a0a0a 0%, #262626 60%, #404040 130%);
}

.login-card {
  background: var(--card);
  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 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 4px;
}
.login-logo span {
  color: #6b6b6b;
  font-weight: 400;
}

.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: rgba(10, 10, 10, 0.45);
  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-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 560px;
  padding: 24px;
}
.modal h2 {
  margin-top: 0;
}

/* --- Responsive: schmale Bildschirme (Tablet/Handy) --- */
@media (max-width: 860px) {
  .layout {
    flex-direction: column;
  }

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

  .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;
  }
}
