/* Shura Anwesenheitssystem – MKAD */

:root {
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --ink: #0f1d2c;
  --muted: #5d6b7a;
  --line: #e2e7ee;
  --brand: #1a2948;
  --brand-2: #283d68;
  --gold: #c8a650;
  --ok: #157a3f;
  --ok-bg: #e7f5ec;
  --warn: #a35a00;
  --warn-bg: #fff3dd;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 29, 44, .06), 0 4px 16px rgba(15, 29, 44, .06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}
img { max-width: 100%; }
a { color: var(--brand-2); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.5rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.show-sm { display: none; }
@media (max-width: 640px) { .show-sm { display: block; } }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- Header (Design Majlis-e-Shura 2026) ---------- */
@font-face { font-family: "Poppins"; font-weight: 600; font-display: swap; src: url("../fonts/poppins-600-latin.woff2") format("woff2"); }
@font-face { font-family: "Poppins"; font-weight: 800; font-display: swap; src: url("../fonts/poppins-800-latin.woff2") format("woff2"); }

.topbar {
  position: relative;
  color: #fff;
  background:
    url("../img/shura26/kalligraphie.webp") no-repeat right -40px center / auto 210%,
    var(--brand);
}
.bismillah { text-align: center; padding-top: 10px; line-height: 0; }
.bismillah img { height: 30px; width: auto; opacity: .95; }
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 4px 20px 12px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.topbar-pattern {
  height: 46px;
  background: url("../img/shura26/muster.webp") repeat-x center 58% / 1400px auto, var(--brand);
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; margin-right: auto; }
.brand img { height: 48px; width: 48px; display: block; filter: drop-shadow(0 2px 6px rgba(0,0,0,.35)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong {
  font-family: "Poppins", var(--font);
  font-weight: 800;
  font-size: 1.12rem;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.brand-text span { font-size: .78rem; opacity: .72; letter-spacing: .02em; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  color: rgba(255,255,255,.86);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 500;
  font-size: .92rem;
}
.nav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav a.active { background: #fff; color: var(--brand); }
.day-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gold);
  color: #1d1600;
  font-weight: 700;
  font-size: .85rem;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.day-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #1d1600; opacity: .55; }

.site-footer {
  margin-top: 8px;
  color: rgba(255,255,255,.75);
  font-size: .8rem;
  letter-spacing: .03em;
  text-align: center;
  padding: 70px 20px 18px;
  background: url("../img/shura26/muster.webp") repeat-x center top / 1400px auto, var(--brand);
}

/* ---------- Layout ---------- */
.page { max-width: 1280px; margin: 0 auto; padding: 24px 20px 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.grid { display: grid; gap: 18px; }
.grid-checkin { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
@media (max-width: 960px) {
  /* Einspaltig: Scanner, dann Zahlen, dann Listen */
  .grid-checkin { display: flex; flex-direction: column; align-items: stretch; }
  .grid-checkin > .stack { display: contents; }
  .grid-checkin .scan-card { order: 1; }
  .grid-checkin .kpis { order: 2; }
  .grid-checkin .bar { order: 3; }
  .grid-checkin .recent-card { order: 4; }
  .grid-checkin .scans-card { order: 5; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }

/* ---------- Buttons & Inputs ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font: inherit;
  font-weight: 600;
  font-size: .92rem;
  cursor: pointer;
  text-decoration: none;
  background: var(--brand);
  color: #fff;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--brand-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); border-color: #cfd7e1; }
.btn-danger { background: var(--bad); }
.btn-danger:hover { background: #8f1c13; }
.btn-warn { background: var(--surface); color: var(--warn); border-color: #f0cf96; }
.btn-warn:hover { background: var(--warn-bg); }
.btn-sm { padding: 6px 11px; font-size: .84rem; }
.btn-lg { padding: 14px 22px; font-size: 1rem; }

input[type="text"], input[type="password"], input[type="number"], input[type="search"], select {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #cdd5df;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
}
input:focus, select:focus, .btn:focus-visible { outline: 3px solid rgba(40, 61, 104, .25); outline-offset: 1px; border-color: var(--brand-2); }
label { font-weight: 600; font-size: .88rem; display: block; margin-bottom: 6px; }
.field { margin-bottom: 14px; }

.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.segmented button {
  font: inherit; font-weight: 600; font-size: .88rem;
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 14px; border-radius: 999px; cursor: pointer;
}
.segmented button.active { background: var(--brand); color: #fff; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-label { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.kpi-value { font-size: 2rem; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: 4px; }
.kpi-sub { font-size: .85rem; color: var(--muted); }
.kpi.ok .kpi-value { color: var(--ok); }
.kpi.bad .kpi-value { color: var(--bad); }

.bar { height: 8px; background: #e6ebf1; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .4s ease; }

/* ---------- Badges ---------- */
.badges { display: inline-flex; flex-wrap: wrap; gap: 5px; }
.badge {
  display: inline-flex; align-items: center;
  font-size: .74rem; font-weight: 700; letter-spacing: .02em;
  padding: 2px 8px; border-radius: 999px;
  background: #edf1f6; color: #33475b; white-space: nowrap;
}
.badge-gewaehlt { background: #e3ecf8; color: #14406d; }
.badge-ernannt { background: #efe7fb; color: #5b2ca0; }
.badge-qm { background: #e2f4f2; color: #0f6b63; }
.badge-rq { background: #fbf1d6; color: #7a5a00; }
.badge-amla { background: #e7f5ec; color: #157a3f; }
.badge-mitarbeiter { background: #eceff3; color: #475569; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- Check-in ---------- */
.scan-card { padding: 24px; }
.scan-form { display: flex; gap: 10px; }
.scan-form input {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: .04em;
  padding: 16px 18px;
  border-width: 2px;
  font-variant-numeric: tabular-nums;
}
.scan-hint { margin: 10px 0 0; color: var(--muted); font-size: .88rem; }
.scan-result {
  margin-top: 20px;
  border-radius: var(--radius);
  border: 2px dashed var(--line);
  min-height: 180px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: background .2s, border-color .2s;
}
.scan-result.idle { align-items: center; text-align: center; color: var(--muted); }
.scan-result.ok { background: var(--ok-bg); border: 2px solid #9fd5b3; }
.scan-result.duplicate { background: var(--warn-bg); border: 2px solid #f0cf96; }
.scan-result.not_found { background: var(--bad-bg); border: 2px solid #f1aaa3; }
.scan-status { font-size: .85rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.ok .scan-status { color: var(--ok); }
.duplicate .scan-status { color: var(--warn); }
.not_found .scan-status { color: var(--bad); }
.scan-name { font-size: 1.9rem; font-weight: 800; margin: 6px 0 10px; letter-spacing: -.01em; }
.scan-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px 18px; margin-top: 12px; }
.scan-meta div span { display: block; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.scan-meta div strong { font-size: 1rem; }
.scan-actions { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { font-size: .84rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-time { font-size: .84rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--ok); }
.dot.duplicate { background: var(--gold); }
.dot.not_found { background: var(--bad); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.region-row { cursor: pointer; }
tr.region-row:hover td { background: var(--surface-2); }
tr.region-row td:first-child { font-weight: 650; }
tr.region-row .chev { display: inline-block; width: 16px; color: var(--muted); transition: transform .15s; }
tr.region-row.open .chev { transform: rotate(90deg); }
tr.detail-row > td { background: var(--surface-2); padding: 14px; }
.pct-cell { min-width: 140px; }
.pct-cell .bar { margin-top: 4px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 800px) { .split { grid-template-columns: 1fr; } }
.people { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.people h4 { margin: 0; padding: 9px 12px; font-size: .85rem; display: flex; justify-content: space-between; }
.people.present h4 { background: var(--ok-bg); color: var(--ok); }
.people.absent h4 { background: var(--bad-bg); color: var(--bad); }
.people table th, .people table td { padding: 7px 12px; font-size: .88rem; }
.people table th { background: var(--surface); }

/* ---------- Gruppen ---------- */
.groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.group-card { display: flex; flex-direction: column; gap: 8px; }
.group-card .kpi-value { font-size: 1.7rem; }
.group-card .row { display: flex; justify-content: space-between; font-size: .86rem; color: var(--muted); }
.group-card .actions { display: flex; gap: 6px; margin-top: 4px; }
.group-card.empty-group { opacity: .65; }

/* ---------- Admin ---------- */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }
.day-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.day-option {
  border: 2px solid var(--line); border-radius: var(--radius); padding: 16px; text-align: left;
  background: var(--surface); cursor: pointer; font: inherit;
}
.day-option strong { display: block; font-size: 1.15rem; }
.day-option span { color: var(--muted); font-size: .88rem; }
.day-option.active { border-color: var(--brand); background: #eef1f7; box-shadow: inset 0 0 0 1px var(--brand); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.report { margin-top: 14px; font-size: .9rem; }
.report ul { margin: 6px 0 0; padding-left: 18px; max-height: 180px; overflow: auto; }
.notice { padding: 10px 12px; border-radius: var(--radius-sm); font-size: .9rem; }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline input[type="number"] { width: 90px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: calc(100vh - 320px); display: grid; place-items: center; padding: 40px 20px;
  border-radius: var(--radius);
  background:
    url("../img/shura26/muster.webp") repeat-x center bottom / 1400px auto,
    url("../img/shura26/kalligraphie.webp") no-repeat right -30px top 10px / auto 85%,
    var(--brand);
}
.login-card { width: 100%; max-width: 380px; }

/* ---------- Dialog & Toast ---------- */
dialog.confirm {
  border: 0; border-radius: var(--radius); padding: 0; width: min(440px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(0,0,0,.3); color: var(--ink);
}
dialog.confirm::backdrop { background: rgba(10, 20, 35, .55); }
dialog.confirm .body { padding: 22px 22px 8px; }
dialog.confirm .body p { color: var(--muted); margin: 8px 0 0; white-space: pre-line; }
dialog.confirm .body input { margin-top: 12px; }
dialog.confirm .foot { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 8px; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow); font-weight: 600; font-size: .9rem; max-width: 380px;
  animation: toast-in .2s ease;
}
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Kamera ---------- */
.camera { margin-top: 14px; border-radius: var(--radius); overflow: hidden; background: #000; position: relative; }
.camera video { width: 100%; display: block; max-height: 360px; object-fit: cover; }
.camera .frame { position: absolute; inset: 22% 12%; border: 3px solid rgba(255,255,255,.85); border-radius: 12px; pointer-events: none; }

.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 20px 24px; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .topbar { background-size: 260px auto, auto; background-position: right -70px top -10px, 0 0; }
  .topbar-inner {
    display: grid; grid-template-columns: 1fr auto; align-items: center;
    padding: 2px 14px 8px; gap: 8px 10px;
  }
  .brand { grid-column: 1; grid-row: 1; }
  .day-pill { grid-column: 2; grid-row: 1; }
  .nav {
    grid-column: 1 / -1; grid-row: 2; flex-wrap: nowrap; overflow-x: auto;
    scrollbar-width: none; -webkit-overflow-scrolling: touch; margin: 0 -14px; padding: 0 14px;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; }
  .bismillah { padding-top: 8px; }
  .bismillah img { height: 20px; }
  .brand img { height: 40px; width: 40px; }
  .brand-text strong { font-size: .92rem; }
  .brand-text span { display: none; }
  .topbar-pattern { height: 24px; background-size: 900px auto, auto; }
  .site-footer { padding-top: 50px; background-size: 1000px auto, auto; }
  .nav a { padding: 7px 10px; font-size: .86rem; }
  .page { padding: 16px 14px 40px; }
  .scan-form { flex-direction: column; }
  .scan-name { font-size: 1.5rem; }
  .kpi-value { font-size: 1.6rem; }
  .hide-sm { display: none; }
  .pct-cell { min-width: 0; }
  th, td { padding: 8px 6px; }
  .region-name { display: inline-flex; }
  tr.detail-row > td { padding: 8px 4px; }
  .people table th, .people table td { padding: 6px 8px; }
}

/* ---------- Druck ---------- */
@media print {
  .topbar, .no-print, .toasts, .footer, .site-footer, .sim-banner { display: none !important; }
  body { background: #fff; font-size: 11px; }
  .page { padding: 0; max-width: none; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
  tr.detail-row { display: table-row !important; }
  tr.detail-row > td { background: #fff; }
}

/* ---------- Dashboard / Diagramme ---------- */
:root { --series-1: #2a78d6; --series-2: #eb6834; --bar: #2a78d6; }
.viz-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.viz-note { font-size: .85rem; }
.viz { width: 100%; min-height: 120px; }
.viz svg { display: block; width: 100%; height: auto; overflow: visible; }
.viz .grid { stroke: #e9edf2; stroke-width: 1; }
.viz .axis { stroke: #c9d2dc; stroke-width: 1; }
.viz .goal { stroke: #c9d2dc; stroke-width: 1; stroke-dasharray: 4 4; }
.viz .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz .end-label { fill: var(--ink); font-size: 12px; font-weight: 650; }
.viz .crosshair { stroke: #9aa7b4; stroke-width: 1; }
.viz .cross-dot { stroke: #fff; stroke-width: 2; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .86rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.legend .legend-swatch { margin-right: 0; }

.hbars { display: flex; flex-direction: column; gap: 4px; }
.hbar {
  display: grid; grid-template-columns: minmax(90px, 220px) 1fr 120px; align-items: center; gap: 12px;
  padding: 5px 6px; border-radius: 8px; cursor: default; outline: none;
}
.hbar:hover, .hbar:focus-visible { background: var(--surface-2); }
.hbar-label { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 12px; background: #eef1f5; border-radius: 4px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 0; transition: width .4s ease; }
.hbar-value { font-size: .84rem; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.viz-tooltip {
  position: fixed; z-index: 60; pointer-events: none; background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(15,29,44,.16);
  padding: 8px 11px; font-size: .84rem; line-height: 1.45; max-width: 260px;
}
@media (max-width: 640px) {
  .hbar { grid-template-columns: minmax(80px, 36%) 1fr 58px; gap: 6px; }
  .hbar-value .muted { display: none; }
}

/* ---------- Simulation & Nachträge ---------- */
.sim-banner {
  background: repeating-linear-gradient(135deg, #fff3dd 0 14px, #ffe9bf 14px 28px);
  color: #6b3d00; border-bottom: 1px solid #f0cf96; text-align: center;
  padding: 9px 16px; font-weight: 700; font-size: .92rem;
}
.sim-banner a { color: #6b3d00; margin-left: 8px; }
.sim-card.sim-on { border-color: #f0cf96; box-shadow: inset 0 0 0 1px #f0cf96, var(--shadow); }
.span-2 { grid-column: span 2; }
@media (max-width: 760px) { .span-2 { grid-column: auto; } }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.checkbox-field { display: flex; align-items: flex-end; }
.checkbox-field label { display: flex; gap: 8px; align-items: center; font-weight: 600; padding-bottom: 10px; }
.badge-manuell { background: #fdf0e6; color: #9a4a12; }
code { font-size: .85em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.add-person-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: var(--radius-sm); font-size: .88rem; }
