/* smopi Maintenance — Admin UI
   Design tokens: kühle, technische Werkstatt-Anmutung.
   - dunkle, ruhige Navigations-Schiene (Ink), helle Arbeitsfläche
   - ein einziger Signalton (Teal) für Aktionen und Fokus
   - Messwerte/Seriennummern in Mono = "Daten lesen sich als Daten"
   - Status in domänentreuen Farben (pass/fail/attention)
*/
:root {
  --ink:        #16232E;
  --ink-2:      #223341;
  --ink-line:   #2E4150;
  --surface:    #EEF2F4;
  --card:       #FFFFFF;
  --line:       #DCE4E8;
  --line-2:     #C7D2D9;
  --text:       #182430;
  --muted:      #5A6C79;
  --muted-2:    #8496A2;

  --brand:      #0E9E86;   /* Teal — Primäraktion */
  --brand-ink:  #0A7A68;
  --brand-wash: #E3F4F0;

  --pass:       #1F9D57;
  --pass-wash:  #E3F5EA;
  --fail:       #CE3A2C;
  --fail-wash:  #FBE7E4;
  --warn:       #C77A0A;
  --warn-wash:  #FBEFDA;

  --radius:     10px;
  --radius-sm:  7px;
  --shadow:     0 1px 2px rgba(20,35,46,.06), 0 4px 14px rgba(20,35,46,.05);
  --shadow-lg:  0 8px 30px rgba(20,35,46,.12);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Roboto Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--ink);
  color: #C6D3DC;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: baseline; gap: 7px;
  padding: 6px 10px 18px;
  color: #fff; font-weight: 700; font-size: 18px; letter-spacing: -.2px;
}
.brand .reg { color: var(--brand); font-weight: 700; }
/* Wortmarke in den Logofarben: "sm" gruen, "opi" orange (aus dem Logo gesampelt) */
.brand .b-sm { color: #93BE30; }
.brand .b-opi { color: #FBB016; }
.brand small { color: var(--muted-2); font-weight: 500; font-size: 12px; letter-spacing: .02em; }

.nav-group { margin-top: 14px; padding: 0 10px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .09em; color: var(--muted-2); }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: #C6D3DC; font-weight: 500; font-size: 14.5px;
}
.nav a:hover { background: var(--ink-2); text-decoration: none; color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.nav a .ic { width: 18px; text-align: center; opacity: .9; }

.sidebar .spacer { flex: 1; }
.sidebar .who { padding: 10px; border-top: 1px solid var(--ink-line); margin-top: 10px; font-size: 13px; }
.sidebar .who .name { color: #fff; font-weight: 600; }
.sidebar .who form { margin-top: 8px; }
.linkbtn { background: none; border: 0; color: var(--muted-2); cursor: pointer; font-size: 13px; padding: 0; }
.linkbtn:hover { color: #fff; }

/* ---------- Main ---------- */
.main { min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 20px 28px; border-bottom: 1px solid var(--line); background: var(--card);
}
.topbar h1 { margin: 0; font-size: 20px; letter-spacing: -.2px; }
.topbar .crumb { color: var(--muted); font-size: 13px; margin-bottom: 2px; }
.content { padding: 24px 28px 60px; max-width: 1160px; }

/* ---------- Flash / errors ---------- */
.flash { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 14px; }
.flash.ok  { background: var(--pass-wash); color: #0d5c30; border: 1px solid #B7E3C6; }
.flash.err { background: var(--fail-wash); color: #8a231a; border: 1px solid #F1C3BD; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); }
.card + .card { margin-top: 20px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--line); }
.card-h h2 { margin: 0; font-size: 15.5px; }
.card-b { padding: 18px; }

/* ---------- Stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); }
.tile .n { font-size: 30px; font-weight: 700; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--muted); font-size: 13px; margin-top: 2px; }
.tile .l .ic { color: var(--brand); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #F7FAFB; }
.table .mono { font-family: var(--mono); font-size: 13px; color: var(--ink-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.7; }
.pill.pass { background: var(--pass-wash); color: #0d5c30; }
.pill.fail { background: var(--fail-wash); color: #8a231a; }
.pill.warn { background: var(--warn-wash); color: #8a5a06; }
.pill.mut  { background: #EDF1F3; color: var(--muted); }
.pill.ac   { background: #E7F0FB; color: #1f5aa8; }
.pill.dc   { background: var(--warn-wash); color: #8a5a06; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: #fff; color: var(--text); font: inherit; font-weight: 600;
  font-size: 14px; cursor: pointer; }
.btn:hover { background: #F4F7F8; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); }
.btn.danger { color: var(--fail); border-color: #E7BAB4; background: #fff; }
.btn.danger:hover { background: var(--fail-wash); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: #EDF1F3; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
label .opt { color: var(--muted-2); font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=date],
input[type=number], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  font: inherit; font-size: 14px; background: #fff; color: var(--text);
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-wash);
}
.check { flex-direction: row; align-items: center; gap: 9px; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }
.check label { font-weight: 500; }
.hint { font-size: 12.5px; color: var(--muted); }
.err-msg { color: var(--fail); font-size: 12.5px; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }

/* ---------- Toolbar / search ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.search { display: flex; gap: 8px; }
.search input { width: 280px; }

/* ---------- Detail definition lists ---------- */
.dl { display: grid; grid-template-columns: 170px 1fr; gap: 10px 18px; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .big { font-size: 15px; color: var(--text); font-weight: 600; margin-bottom: 4px; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 4px; list-style: none; padding: 0; margin: 18px 0 0; font-size: 14px; }
.pagination a, .pagination span { display: inline-block; padding: 6px 11px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: #fff; color: var(--text); }
.pagination .active span { background: var(--brand); border-color: var(--brand); color: #fff; }

.subhead { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  margin: 26px 0 10px; font-weight: 700; }
/* Aktionszellen: KEIN display:flex auf <td> — ein td mit Flex verliert sein
   table-cell-Verhalten, die Zelle richtet sich nicht mehr an der Zeilenmitte
   aus und der Inhalt sitzt sichtbar versetzt (aufgefallen in der Datenpflege
   neben zweizeiligen Nachbarzellen). Inline-Blocks + text-align leisten
   dasselbe, ohne die Tabellensemantik zu brechen. */
.row-actions { text-align: right; }
.row-actions > a, .row-actions > form, .row-actions > details,
.row-actions > span, .row-actions > button { display: inline-block; vertical-align: middle; }
.row-actions > * + * { margin-left: 6px; }
.inline-form { display: inline-block; vertical-align: middle; }
/* Anker fuer absolut positionierte Aufklapp-Dialoge (Datenpflege, Builder) */
details.inline-form { position: relative; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background:
  radial-gradient(1200px 600px at 20% -10%, #1d3140 0%, var(--ink) 55%); padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 30px 28px; }
.login-card .brand { padding: 0 0 6px; color: var(--ink); }
.login-card .sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.login-card .field { margin-bottom: 14px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar .spacer, .sidebar .nav-group { display: none; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dt { margin-top: 10px; }
  .content { padding: 18px; }
  .search input { width: 100%; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
