/* Capita User Manager
 * Ruhiges, technisches Interface fuer ein internes Admin-Tool.
 * Gleiche Sprache wie die uebrigen Capita Web-Tools (eine Akzentfarbe Rot,
 * Mono fuer technische Detail-Werte). Chips fuer Gruppen, Pills fuer User-Typ.
 */

:root {
  --bg: #f2f4f6;
  --surface: #ffffff;
  --ink: #17202d;
  --muted: #5d6a7a;
  --border: #dfe4ea;
  --accent: #d2232a;       /* Schweizer Rot, sparsam */
  --accent-dark: #a81b21;
  --planned: #1f5fa8;
  --ok: #1d7a4d;
  --mono: ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.hidden { display: none !important; }

/* ---------- Login ---------- */

.centered {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 6px;
  padding: 40px 48px;
  text-align: center;
  max-width: 460px;
}

.login-card p { color: var(--muted); margin: 12px 0 24px; }
.login-card code { font-family: var(--mono); background: var(--bg); padding: 1px 5px; border-radius: 3px; }

/* ---------- Brand / Header ---------- */

.brand {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand span { font-weight: 400; color: var(--muted); }

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-right { display: flex; align-items: center; gap: 10px; }
.user-name { color: var(--muted); margin-right: 8px; }

/* ---------- Layout ---------- */

main {
  max-width: 1320px;
  margin: 24px auto;
  padding: 0 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px 24px;
}

.panel h2 { font-size: 15px; margin-bottom: 14px; }
.panel h3 { font-size: 13px; margin-bottom: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.hint { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.hint code { font-family: var(--mono); background: var(--bg); padding: 1px 5px; border-radius: 3px; }
.label-hint { font-weight: 400; color: var(--muted); }
.sub { color: var(--muted); font-size: 12px; }
.sub a { color: var(--planned); text-decoration: none; }
.sub a:hover { text-decoration: underline; }

/* ---------- Info-Panel ---------- */

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

.mini-table { width: 100%; border-collapse: collapse; }
.mini-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
}
.mini-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.mini-table .num { text-align: right; font-family: var(--mono); }

/* ---------- Formular ---------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 20px;
}

.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field.span-2 { grid-column: span 2; }

label { font-weight: 600; font-size: 13px; }

input[type="text"],
input[type="email"],
input[type="search"],
select,
textarea {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
}

input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--planned);
  outline-offset: 1px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 4px 16px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
}

.checkbox-grid-modal { max-height: 280px; }

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  font-family: var(--mono);
  font-size: 13px;
  cursor: pointer;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.status-text { color: var(--muted); font-size: 13px; }
.status-text.error { color: var(--accent-dark); font-weight: 600; }

/* ---------- Buttons ---------- */

.btn {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 16px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.btn:hover { background: var(--bg); }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

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

.btn-ghost { border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); }

.btn-mini { padding: 3px 10px; font-size: 12.5px; }

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

/* ---------- Tabelle ---------- */

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.table-header h2 { margin: 0; }
.table-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.table-tools input[type="search"] { min-width: 220px; }

.count-badge {
  font-weight: 400;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  margin-left: 6px;
}

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  padding: 8px 10px;
}

td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:last-child td { border-bottom: none; }

.row-past { color: var(--muted); }

.cell-email { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.cell-groups { max-width: 360px; }
.cell-date { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }
.cell-actions { white-space: nowrap; text-align: right; }

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

/* ---------- Chips (Gruppen) ---------- */

.chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11.5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 7px;
  margin: 1px 0;
  white-space: nowrap;
}

/* ---------- Typ-Pill (Lokal / Entra) ---------- */

.type {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  border-radius: 3px;
  padding: 2px 8px;
}
.type-local { color: var(--muted); background: var(--bg); }
.type-entra { color: var(--planned); background: #e8f0fa; }

/* ---------- Status Badges ---------- */

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  border-radius: 3px;
  padding: 2px 8px;
  white-space: nowrap;
}

.badge-aktiv { color: var(--ok); background: #e6f4ec; }
.badge-geplant { color: var(--planned); background: #e8f0fa; }
.badge-gesperrt { color: var(--accent-dark); background: #fbeaea; }
.badge-vorbei { color: var(--muted); background: var(--bg); }

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23, 32, 45, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border-radius: 8px;
  border-top: 3px solid var(--accent);
  padding: 24px 28px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 { font-size: 16px; margin-bottom: 4px; }
.modal #modal-sub { font-family: var(--mono); font-size: 13px; color: var(--ink); margin-bottom: 14px; }

/* ---------- Tabs ---------- */

.tabs { display: flex; gap: 4px; }

.tab-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 5px;
  cursor: pointer;
}
.tab-btn:hover { background: var(--bg); color: var(--ink); }
.tab-btn.active { background: var(--bg); color: var(--accent-dark); }

.tab-content { display: flex; flex-direction: column; gap: 20px; }

/* ---------- Tier-Cards ---------- */

.tier-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.tier-card {
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: 5px;
  padding: 12px 14px;
  background: var(--surface);
}
.tier-card p { color: var(--muted); font-size: 13px; margin-top: 8px; }
.tier-card.tier-1 { border-left-color: var(--muted); }
.tier-card.tier-2 { border-left-color: var(--planned); }
.tier-card.tier-3 { border-left-color: var(--accent); }

.tier-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Tier-Pill ---------- */

.tier-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  border-radius: 3px;
  padding: 1px 6px;
  white-space: nowrap;
}
.tier-pill-0 { color: var(--muted); background: var(--bg); }
.tier-pill-1 { color: #41505f; background: #eceff2; }
.tier-pill-2 { color: var(--planned); background: #e8f0fa; }
.tier-pill-3 { color: var(--accent-dark); background: #fbeaea; }

/* ---------- Zugriffs-Matrix ---------- */

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

#matrix-table { width: 100%; border-collapse: collapse; }
#matrix-table th, #matrix-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
#matrix-table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
}
#matrix-table .col-tier, #matrix-table .col-app { text-align: center; }
#matrix-table td.cell { text-align: center; font-weight: 700; }
.cell-yes { color: var(--ok); }
.cell-always { color: var(--accent); }
.cell-no { color: var(--border); }

.matrix-foot { margin-top: 10px; }
.cell-mark { font-weight: 700; }

/* ---------- Gruppen-Detail ---------- */

.group-detail { padding: 12px 0; border-bottom: 1px solid var(--border); }
.group-detail:last-child { border-bottom: none; }

.gd-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.gd-role { font-size: 13px; color: var(--ink); }
.gd-count { font-size: 12px; color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }
.gd-desc { color: var(--muted); font-size: 13px; margin: 6px 0 8px; }
.gd-unlocks { font-size: 13px; }
.gd-label { color: var(--muted); margin-right: 6px; }
.chip-all { background: #fbeaea; border-color: #f3cccd; color: var(--accent-dark); }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-field.span-2 { grid-column: span 1; }
  .info-grid { grid-template-columns: 1fr; }
  main { padding: 0 14px; }
  header { padding: 12px 14px; }
}

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