/* ── Reset & Variables ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #ffffff;
  --bg-2:     #f5f5f4;
  --bg-3:     #f0efed;
  --text:     #1a1a1a;
  --muted:    #6b6b68;
  --hint:     #9b9b97;
  --border:   rgba(0,0,0,0.12);
  --border-2: rgba(0,0,0,0.22);
  --blue:     #185FA5;
  --blue-bg:  #E6F1FB;
  --blue-txt: #185FA5;
  --green-bg: #EAF3DE;
  --green-txt:#3B6D11;
  --red-bg:   #FCEBEB;
  --red-txt:  #A32D2D;
  --amber-bg: #FAEEDA;
  --amber-txt:#854F0B;
  --gray-bg:  #F1EFE8;
  --gray-txt: #5F5E5A;
  --radius:   8px;
  --radius-lg:12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:       #1c1c1b;
    --bg-2:     #252524;
    --bg-3:     #2c2c2b;
    --text:     #f0efe8;
    --muted:    #a0a09a;
    --hint:     #6b6b68;
    --border:   rgba(255,255,255,0.12);
    --border-2: rgba(255,255,255,0.22);
    --blue:     #5ba3e0;
    --blue-bg:  #0c2a44;
    --blue-txt: #90c4f0;
    --green-bg: #0d2e0a;
    --green-txt:#7ec85a;
    --red-bg:   #2e0d0d;
    --red-txt:  #f09090;
    --amber-bg: #2e1f05;
    --amber-txt:#f0b860;
    --gray-bg:  #2c2c2a;
    --gray-txt: #b0b0a8;
  }
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-3);
}

/* ── Layout ─────────────────────────────────────────────────────── */
.app { display: grid; grid-template-rows: auto 1fr; min-height: 100vh; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 0.5px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.app-title { font-size: 15px; font-weight: 500; }

.main { display: grid; grid-template-columns: 200px 1fr 220px; height: calc(100vh - 45px); }

.sidebar {
  border-right: 0.5px solid var(--border);
  padding: 12px 0;
  background: var(--bg);
  overflow-y: auto;
}

.content { padding: 20px; overflow-y: auto; background: var(--bg-3); }

.sync-panel {
  border-left: 0.5px solid var(--border);
  padding: 14px;
  background: var(--bg);
  overflow-y: auto;
}

/* ── Status Pill ─────────────────────────────────────────────────── */
.pill {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
  background: var(--green-bg); color: var(--green-txt);
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: #639922; }

/* ── Navigation ─────────────────────────────────────────────────── */
.ns {
  padding: 4px 12px 5px;
  font-size: 10px; font-weight: 500;
  color: var(--hint);
  letter-spacing: .06em; text-transform: uppercase;
  margin-top: 10px;
}
.ni {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 16px;
  cursor: pointer; font-size: 13px;
  color: var(--muted);
  border-left: 2px solid transparent;
  transition: all .15s;
  user-select: none;
}
.ni:hover { background: var(--bg-2); color: var(--text); }
.ni.active { color: var(--blue); border-left-color: var(--blue); background: var(--blue-bg); }
.ni-sub { padding-left: 28px; font-size: 12px; }
.ni-icon { width: 15px; font-size: 13px; }

/* ── Pages ──────────────────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }
.page-title { font-size: 16px; font-weight: 500; margin-bottom: 4px; }
.page-sub { font-size: 12px; color: var(--muted); margin-bottom: 16px; }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 10px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-title { font-size: 13px; font-weight: 500; }

/* ── Badges ─────────────────────────────────────────────────────── */
.badge { padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.badge-synced  { background: var(--green-bg); color: var(--green-txt); }
.badge-pending { background: var(--amber-bg); color: var(--amber-txt); }
.badge-local   { background: var(--blue-bg);  color: var(--blue-txt); }
.badge-ok      { background: var(--green-bg); color: var(--green-txt); }
.badge-nok     { background: var(--red-bg);   color: var(--red-txt); }
.badge-status  { background: var(--blue-bg);  color: var(--blue-txt); }
.badge-cat     { background: var(--gray-bg);  color: var(--gray-txt); }

/* ── Metrics ────────────────────────────────────────────────────── */
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.metric { background: var(--bg-2); border-radius: var(--radius); padding: 10px; }
.metric-label { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.metric-value { font-size: 20px; font-weight: 500; }

/* ── Forms ──────────────────────────────────────────────────────── */
.form-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 9px; }
.form-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 9px; margin-bottom: 9px; }
.form-group { display: flex; flex-direction: column; gap: 3px; }
.form-group.full { grid-column: 1/-1; }

.form-divider {
  font-size: 10px; font-weight: 500; color: var(--hint);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 8px 0 2px;
  border-top: 0.5px solid var(--border);
  margin: 6px 0 2px; grid-column: 1/-1;
}

label { font-size: 12px; color: var(--muted); }

input, select, textarea {
  font-size: 13px; padding: 7px 10px;
  border: 0.5px solid var(--border-2);
  border-radius: var(--radius);
  background: var(--bg); color: var(--text);
  width: 100%; font-family: inherit;
}
textarea { resize: vertical; min-height: 56px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(24,95,165,.15);
}
input:disabled { color: var(--hint); background: var(--bg-2); }
input[type=number] { text-align: left; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  padding: 7px 14px; border-radius: var(--radius);
  font-size: 13px; cursor: pointer;
  font-family: inherit; transition: all .15s;
  border: 0.5px solid var(--border-2);
  background: transparent; color: var(--text);
}
.btn:hover { background: var(--bg-2); }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: #0C447C; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { border-color: var(--red-txt); color: var(--red-txt); }
.btn-danger:hover { background: var(--red-bg); }

/* ── Search bar ─────────────────────────────────────────────────── */
.search-bar { display: flex; gap: 7px; margin-bottom: 10px; }
.search-bar input { flex: 1; }

/* ── Tables ─────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 7px 9px;
  font-size: 10px; font-weight: 500;
  color: var(--muted);
  border-bottom: 0.5px solid var(--border);
  text-transform: uppercase; letter-spacing: .04em;
  white-space: nowrap; background: var(--bg-2);
}
td { padding: 8px 9px; border-bottom: 0.5px solid var(--border); white-space: nowrap; }
td input { padding: 4px 6px; font-size: 12px; border-radius: 4px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-2); }

/* ── Prüfung specifics ──────────────────────────────────────────── */
.norm-badge {
  font-size: 11px; color: var(--blue-txt);
  background: var(--blue-bg);
  padding: 5px 10px; border-radius: var(--radius);
  margin-bottom: 8px; font-weight: 500; display: inline-block;
}
.section-header {
  background: var(--bg-2); padding: 7px 12px;
  border-radius: var(--radius);
  font-size: 12px; font-weight: 500;
  margin-bottom: 8px; color: var(--text);
}
.inp-sm { width: 72px !important; text-align: right; }
.inp-md { width: 110px !important; }
.grenzwert {
  font-size: 10px; color: var(--hint);
  padding: 3px 6px; background: var(--bg-2);
  border-radius: 4px; white-space: nowrap;
}

/* ── Sync Panel ─────────────────────────────────────────────────── */
.stitle {
  font-size: 10px; font-weight: 500; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px;
}
.queue-item {
  padding: 9px; border: 0.5px solid var(--border);
  border-radius: var(--radius); margin-bottom: 7px; font-size: 12px;
}
.queue-item-type { font-weight: 500; margin-bottom: 2px; }
.queue-item-meta { color: var(--hint); font-size: 11px; }
.queue-empty { color: var(--hint); font-size: 12px; text-align: center; padding: 16px 0; }

.progress-bar {
  height: 3px; background: var(--bg-2);
  border-radius: 2px; overflow: hidden; margin-top: 7px;
}
.progress-fill { height: 100%; background: var(--blue); border-radius: 2px; transition: width .4s; }

/* ── Avatar ─────────────────────────────────────────────────────── */
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 500;
  background: var(--blue-bg); color: var(--blue-txt); flex-shrink: 0;
}

/* ── Toast ──────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 18px; right: 18px;
  padding: 9px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; z-index: 999;
  opacity: 0; transition: opacity .3s; pointer-events: none;
}
.toast.show { opacity: 1; }
.toast-success { background: #3B6D11; color: #fff; }
.toast-info    { background: var(--blue); color: #fff; }

/* ── Spinner ─────────────────────────────────────────────────────── */
.spinner {
  display: inline-block; width: 11px; height: 11px;
  border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
  border-radius: 50%; animation: spin .6s linear infinite; margin-right: 5px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utility ─────────────────────────────────────────────────────── */
.mono  { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 11px; }
.muted { color: var(--muted); }

/* ── Clickable metrics ───────────────────────────────────────────── */
.metric-link { cursor: pointer; transition: all .15s; }
.metric-link:hover { background: var(--bg-3); box-shadow: 0 0 0 1.5px var(--blue); }

/* ── Inline link button ──────────────────────────────────────────── */
.link-btn {
  background: none; border: none;
  color: var(--blue); font-size: 11px;
  cursor: pointer; padding: 0 0 0 6px;
  text-decoration: none; font-family: inherit;
  opacity: .8;
}
.link-btn:hover { opacity: 1; text-decoration: underline; }

/* ── Result badges ───────────────────────────────────────────────── */
.badge-offen { background: var(--gray-bg); color: var(--gray-txt); }

/* ── Modal ───────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: var(--bg);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  width: 660px; max-width: 95vw; max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 0.5px solid var(--border);
}
.modal-title { font-size: 14px; font-weight: 500; }
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--muted); padding: 0 4px; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 12px 16px;
  border-top: 0.5px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}
