/* ================================================================
   KAI Dienstplan – Stylesheet
   Color palette: deep hospital blue / white / light grey
   ================================================================ */

:root {
  --primary:   #1a4f7a;
  --primary-dk:#123656;
  --primary-lt:#2e7eb8;
  --accent:    #e8f4fd;
  --success:   #27ae60;
  --warn:      #e67e22;
  --error:     #c0392b;
  --border:    #d0d8e0;
  --bg:        #f2f5f8;
  --white:     #ffffff;
  --text:      #1e2a35;
  --text-muted:#6b7a89;
  --radius:    6px;
  --shadow:    0 2px 8px rgba(0,0,0,.12);
}

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  /* 100vh on iOS Safari means "viewport with the address bar hidden", so the
     page is taller than what is actually visible and the bottom gets cut off.
     dvh tracks the real viewport; keep vh as a fallback for older browsers. */
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── HEADER ── */
header {
  background: var(--primary);
  color: var(--white);
  padding: 0 1.5rem;
  box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 64px;
}
.header-title {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.header-logo { font-size: 1.8rem; line-height: 1; }
h1 { font-size: 1.25rem; font-weight: 700; letter-spacing: .02em; }
.header-sub { font-size: .75rem; opacity: .75; }

.header-status {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  opacity: .9;
}
.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background .4s;
}
.status-dot.ok    { background: var(--success); }
.status-dot.warn  { background: var(--warn); }
.status-dot.error { background: var(--error); }

/* ── TABS ── */
.tabs {
  background: var(--primary-dk);
  display: flex;
  gap: 0;
  padding: 0 1.5rem;
  max-width: 100%;
}
.tab {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.65);
  padding: .75rem 1.25rem;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  border-bottom: 3px solid transparent;
  transition: color .2s, border-color .2s;
}
.tab:hover { color: rgba(255,255,255,.9); }
.tab.active {
  color: var(--white);
  border-bottom-color: #5ab3f0;
}

/* ── MAIN ── */
main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── TOOLBAR ── */
.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.toolbar-left {
  display: flex;
  align-items: flex-end;
  gap: .75rem;
  flex-wrap: wrap;
}
.toolbar-right { display: flex; gap: .5rem; }

label {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 500;
}
input[type="text"],
input[type="date"] {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .65rem;
  font-size: .875rem;
  background: var(--white);
  color: var(--text);
  min-width: 160px;
  transition: border-color .2s;
}
input:focus {
  outline: none;
  border-color: var(--primary-lt);
  box-shadow: 0 0 0 3px rgba(46,126,184,.15);
}

.btn-primary, .btn-secondary {
  border: none;
  border-radius: var(--radius);
  padding: .5rem 1rem;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  transition: background .2s, transform .1s;
}
.btn-primary  { background: var(--primary); color: var(--white); }
.btn-primary:hover  { background: var(--primary-lt); }
.btn-secondary { background: var(--white); color: var(--primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--accent); }
.btn-primary:active, .btn-secondary:active { transform: scale(.97); }

/* ── INFO BANNER ── */
.info-banner {
  background: var(--accent);
  border: 1px solid var(--primary-lt);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  margin-bottom: 1rem;
  font-size: .85rem;
  color: var(--primary-dk);
}
.info-banner.warn { background: #fef9ec; border-color: var(--warn); color: #7d4e00; }
.info-banner.error { background: #fdeeec; border-color: var(--error); color: var(--error); }

/* ── SUMMARY CARDS ── */
.summary-cards {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.summary-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1.25rem;
  min-width: 120px;
  box-shadow: var(--shadow);
}
.summary-card .card-num {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}
.summary-card .card-label {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

/* ── TABLE ── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.schedule-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  font-size: .85rem;
}
.schedule-table thead {
  background: var(--primary);
  color: var(--white);
}
.schedule-table thead th {
  padding: .65rem .85rem;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}
.schedule-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.schedule-table tbody tr:hover { background: var(--accent); }
.schedule-table td {
  padding: .55rem .85rem;
  vertical-align: top;
}
.schedule-table .date-cell { white-space: nowrap; font-variant-numeric: tabular-nums; }
.schedule-table .dow-cell  { white-space: nowrap; color: var(--text-muted); }
.schedule-table .name-cell { font-weight: 600; }
.schedule-table .role-badge {
  display: inline-block;
  background: var(--accent);
  color: var(--primary);
  border-radius: 3px;
  padding: .1rem .4rem;
  font-size: .8rem;
  font-weight: 500;
}

/* Weekend rows */
.schedule-table tr.weekend { background: #fafbff; }
.schedule-table tr.weekend:hover { background: var(--accent); }

/* ── EMPLOYEE SEARCH ── */
.employee-search-box {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  max-width: 600px;
  box-shadow: var(--shadow);
}
.employee-search-box h2 { margin-bottom: .4rem; }
.employee-search-box p  { color: var(--text-muted); font-size: .85rem; margin-bottom: 1rem; }
.search-row {
  display: flex;
  gap: .5rem;
}
.search-row input { flex: 1; }

.suggestions {
  margin-top: .5rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.suggestion-item {
  padding: .5rem .85rem;
  cursor: pointer;
  transition: background .15s;
}
.suggestion-item:hover { background: var(--accent); }

/* ── ARCHIVE ── */
.archive-list { display: flex; flex-direction: column; gap: 1.2rem; }
.archive-group { display: flex; flex-direction: column; gap: .5rem; }
.archive-group-title {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: .3rem;
  margin-bottom: .1rem;
}
.archive-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}
.archive-item.current { border-left: 4px solid var(--success); }
.archive-item .archive-meta { flex: 1; min-width: 0; }
.archive-item .archive-time { font-weight: 600; }
.archive-item .archive-hash { font-size: .75rem; color: var(--text-muted); font-family: monospace; }
.archive-badge {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: .15rem .45rem;
  border-radius: 3px;
  background: var(--success);
  color: var(--white);
}
.analysis-badge {
  font-size: .72rem;
  padding: .15rem .4rem;
  border-radius: 3px;
  font-weight: 500;
}
.analysis-badge.done    { background: #d5f5e3; color: #1e8449; }
.analysis-badge.pending { background: #fef9ec; color: #935f00; }
.analysis-badge.failed  { background: #fadbd8; color: #922b21; }
.analysis-badge.layout-warning { background: #fef3cd; color: #856404; }
.analysis-badge.layout-anomaly { background: #f8d7da; color: #842029; }
.engine-badge {
  font-size: .72rem;
  padding: .15rem .4rem;
  border-radius: 3px;
  font-weight: 500;
}
.engine-badge.engine-rule { background: #e8f4fd; color: #1a4f7a; }
.engine-badge.engine-llm  { background: #f3e8fd; color: #5a1a7a; }
.archive-actions { display: flex; gap: .5rem; }

/* ── LOADING / EMPTY ── */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 1rem;
}
.loading::after {
  content: "";
  display: inline-block;
  width: 18px; height: 18px;
  border: 3px solid var(--border);
  border-top-color: var(--primary-lt);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin-left: .6rem;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  font-size: .95rem;
}

/* ── FOOTER ── */
footer {
  background: var(--primary-dk);
  color: rgba(255,255,255,.55);
  font-size: .75rem;
  padding: .6rem 1.5rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

/* ── CHANGES TAB ── */
.changes-list { display: flex; flex-direction: column; gap: .75rem; }
.changes-more-btn { display: block; margin: .75rem auto 0; }
.change-entry-loading { padding: .5rem 1rem; color: var(--text-secondary); font-size: .85rem; }

.change-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.change-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  cursor: pointer;
  transition: background .15s;
  flex-wrap: wrap;
}
.change-header:hover { background: var(--accent); }
.change-header.expanded { border-bottom: 1px solid var(--border); }
.change-header.no-expand { cursor: default; }

.change-time {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  white-space: nowrap;
  min-width: 130px;
}
.change-plan {
  flex: 1;
  font-size: .85rem;
  color: var(--text-muted);
  min-width: 120px;
}
.change-summary { display: flex; gap: .4rem; flex-wrap: wrap; }
.change-toggle {
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: transform .2s;
  flex-shrink: 0;
}
.change-header.expanded .change-toggle { transform: rotate(90deg); }

.change-badge-added,
.change-badge-removed,
.change-badge-changed,
.change-badge-pending,
.change-badge-unchanged {
  padding: .12rem .4rem;
  border-radius: 3px;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
}
.change-badge-added     { background: #d5f5e3; color: #1e8449; }
.change-badge-removed   { background: #fadbd8; color: #922b21; }
.change-badge-changed   { background: #fef3cd; color: #7d5a00; }
.change-badge-pending   { background: #fef9ec; color: #935f00; }
.change-badge-unchanged { background: #f0f0f0; color: var(--text-muted); }

.change-details { display: none; padding: .25rem 0; }
.change-details.visible { display: block; }

.change-entry {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  padding: .35rem 1rem;
  font-size: .84rem;
  border-bottom: 1px solid #f4f4f4;
}
.change-entry:last-child { border-bottom: none; }
.change-entry.added   { background: #f0faf4; }
.change-entry.removed { background: #fdf4f3; }
.change-entry.changed { background: #FFCE85; }

.change-entry-icon {
  font-weight: 800;
  width: .9rem;
  text-align: center;
  flex-shrink: 0;
}
.change-entry.added   .change-entry-icon { color: #1e8449; }
.change-entry.removed .change-entry-icon { color: #922b21; }

.change-entry-info { flex: 1; }
.change-entry.removed .change-entry-info { text-decoration: line-through; opacity: .75; }

.change-entry-date {
  font-size: .78rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.change-entry-empty {
  padding: .75rem 1rem;
  font-size: .85rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── PDF VISUAL DIFF ───────────────────────────────────────────── */

.pdf-diff-section {
  border-top: 1px solid var(--border);
  padding: .5rem 1rem .75rem;
}

.pdf-diff-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--primary);
  cursor: pointer;
  font-size: .82rem;
  padding: .25rem .7rem;
}
.pdf-diff-toggle:hover { background: var(--hover-bg, #f5f5f5); }

.pdf-diff-viewer { margin-top: .6rem; }

.pdf-diff-pages {
  display: flex;
  gap: .4rem;
  margin-bottom: .5rem;
}
.pdf-diff-page-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: .8rem;
  padding: .15rem .55rem;
}
.pdf-diff-page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.pdf-diff-img-wrap { text-align: center; }
.pdf-diff-img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.pdf-diff-spinner { display: inline-block; margin: 1rem 0; }

/* ── STAFF PROFILES ────────────────────────────────────────────── */

.toolbar-hint {
  font-size: .82rem;
  color: var(--text-muted);
  margin: 0;
}
.toolbar-hint a { color: var(--primary); }

.profiles-fetched-hint {
  font-size: .8rem;
  color: var(--text-muted);
  align-self: center;
}

.profiles-grid {
  padding: .5rem 0;
}

.profiles-category-heading {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 2px solid var(--primary-lt);
  padding-bottom: .3rem;
  margin: 1.5rem 0 .75rem;
}
.profiles-category-heading:first-child { margin-top: .25rem; }

.profiles-former-section { margin-top: 1.5rem; }
.profiles-former-summary {
  cursor: pointer;
  list-style: none;
  opacity: .7;
}
.profiles-former-summary::-webkit-details-marker { display: none; }
.profiles-former-summary::before { content: "▸ "; font-size: .85em; }
details[open] .profiles-former-summary::before { content: "▾ "; }
.profiles-former-count { font-weight: 400; font-size: .88em; opacity: .8; }

.profiles-subgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: .85rem;
  margin-bottom: .5rem;
}

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
  outline: none;
}
.profile-card:hover,
.profile-card:focus {
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
  transform: translateY(-2px);
  border-color: var(--primary-lt);
}

.profile-card-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--primary-lt);
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.profile-initials {
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--primary);
  background: #e8f0f8;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: .05em;
}

.profile-card-body {
  padding: .75rem .85rem .85rem;
}

.profile-name {
  font-weight: 600;
  font-size: .92rem;
  color: var(--text);
  line-height: 1.3;
}

.profile-position {
  font-size: .78rem;
  color: var(--primary);
  margin-top: .3rem;
  font-weight: 500;
}

/* ── Profile detail panel ── */

.profile-back-btn {
  margin-bottom: 1.25rem;
}

.profile-detail {
  padding: .5rem 0;
}

.profile-detail-header {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 1rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.profile-detail-photo {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.profile-detail-info { flex: 1; min-width: 0; }

.profile-detail-name {
  margin: 0 0 .5rem;
  font-size: 1.25rem;
  color: var(--primary);
}

.detail-position {
  font-weight: 600;
  font-size: .95rem;
  color: var(--text);
  margin-bottom: .35rem;
}

.detail-contact {
  font-size: .88rem;
  color: var(--text-muted);
  margin-top: .25rem;
}
.detail-contact a {
  color: var(--primary);
  text-decoration: none;
}
.detail-contact a:hover { text-decoration: underline; }

.plan-type-cell {
  font-size: .78rem;
  color: var(--text-muted);
}

/* ── Inline spinner (used in empty-state messages) ── */
.inline-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary-lt);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: middle;
  margin-left: .3rem;
}

/* ── ALIAS SECTION ── */
.alias-section {
  margin: 1.25rem 0;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.alias-heading {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 .6rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.alias-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .75rem;
  min-height: 1.5rem;
}
.alias-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: var(--primary-lt);
  color: var(--primary);
  border-radius: 2rem;
  padding: .2rem .6rem .2rem .75rem;
  font-size: .82rem;
  font-weight: 500;
}
.alias-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary);
  font-size: 1rem;
  line-height: 1;
  padding: 0 .1rem;
  opacity: .6;
}
.alias-delete-btn:hover { opacity: 1; }
.alias-none {
  font-size: .82rem;
  color: var(--text-secondary);
  font-style: italic;
}
.alias-add-row {
  display: flex;
  gap: .5rem;
  align-items: center;
}
.alias-input {
  flex: 1;
  padding: .35rem .6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  background: var(--bg);
  color: var(--text);
}
.alias-input:focus { outline: none; border-color: var(--primary); }
.alias-add-btn { white-space: nowrap; }

/* ── EINSATZPLAN – TAGESANSICHT ── */

/* Tages-Navigation */
.day-nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0;
}

.day-nav-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem 1rem .25rem;
}

.day-nav-kw-select {
  flex: 1;
  min-width: 0;
  padding: .3rem .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  font-size: .85rem;
  color: var(--text);
  cursor: pointer;
}
.day-nav-kw-select:focus { outline: 2px solid var(--primary-lt); outline-offset: 1px; }

.day-nav-pdf-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.day-nav-scroll {
  display: flex;
  align-items: flex-start;
  gap: .4rem;
  flex-wrap: wrap;
  padding: .25rem 1.5rem .5rem;
}

/* Week separator chip */
.day-week-sep {
  flex: 0 0 100%;        /* force line break before each new week */
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted, #888);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .6rem 0 .2rem;
  border-top: 1px solid var(--border);
  margin-top: .3rem;
}
.day-week-sep:first-child { border-top: none; margin-top: 0; padding-top: 0; }

.day-btn {
  min-width: 58px;
  padding: .4rem .6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  cursor: pointer;
  font-size: .8rem;
  text-align: center;
  line-height: 1.3;
  color: var(--text);
  transition: background .15s, border-color .15s;
}
.day-btn:hover { background: var(--accent); border-color: var(--primary-lt); }
.day-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
  font-weight: 600;
}
/* Past days: compact (just day number) + greyed out */
.day-btn.past {
  opacity: .45;
  background: var(--bg, #f7f8fa);
  min-width: 32px;
  padding: .4rem .2rem;
}
.day-btn.past:hover { opacity: .75; }
/* Selected past day: full size again */
.day-btn.past.active {
  opacity: 1;
  min-width: 58px;
  padding: .4rem .6rem;
}

/* Today: subtle ring */
.day-btn.today {
  border-color: var(--primary);
  font-weight: 600;
}
.day-btn.today.active { box-shadow: 0 0 0 2px var(--primary-lt); }

.day-btn.weekend { color: var(--warn); }
.day-btn.weekend.active { color: var(--white); }
.day-btn-date { font-size: .75rem; opacity: .85; }

/* Tages-Heading */
.einsatz-view {
  max-width: 1200px;
  margin: 0 auto;
  padding: .5rem 1.5rem 2rem;
}
.day-heading {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--primary);
}
.day-heading-wd {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
}
.day-heading-date {
  font-size: .95rem;
  color: var(--text-muted);
}

/* Bereiche-Grid */
.day-sections {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: .75rem;
}

/* Einzelner Bereich */
.day-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.day-section-header {
  background: var(--primary);
  color: var(--white);
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .35rem .7rem;
}
.sec-names-flat {
  padding: .4rem .8rem;
  font-size: .88rem;
  color: var(--text);
  line-height: 1.7;
}

.sec-func-row {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  padding: .25rem .8rem;
  font-size: .88rem;
  line-height: 1.6;
}
.sec-func-row + .sec-func-row {
  border-top: 1px solid var(--border);
}
.sec-func-label {
  flex: 0 0 5.5rem;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted, #666);
  text-transform: uppercase;
  letter-spacing: .03em;
}
.sec-func-names {
  flex: 1;
  color: var(--text);
}

.emp-link {
  cursor: pointer;
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}
.emp-link:hover { color: var(--primary-dk); }
.emp-link-highlight {
  background: #fff3bf;
  color: #1f2937;
  border-radius: 4px;
  box-shadow: 0 0 0 2px #f59f00;
  padding: .05rem .25rem;
  text-decoration: none;
  animation: emp-highlight-pulse 1.4s ease-out 1;
}

@keyframes emp-highlight-pulse {
  0% { box-shadow: 0 0 0 5px rgba(245, 159, 0, .45); }
  100% { box-shadow: 0 0 0 2px #f59f00; }
}

/* ── PDF INLINE VIEWER ── */
.pdf-viewer-panel {
  margin: .75rem 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #f5f5f5;
}
.pdf-nav-bar {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .6rem;
  background: #eee;
  border-bottom: 1px solid var(--border);
}
.pdf-viewer-panel img {
  display: block;
  width: 100%;
  height: auto;
}
.info-banner { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }

/* ── PDF UPLOAD / IMPORT ── */
.upload-section {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 1.5rem;
  background: var(--bg-card);
}
.upload-section > summary {
  padding: .75rem 1rem;
  cursor: pointer;
  font-weight: 500;
  user-select: none;
  list-style: none;
}
.upload-section > summary::-webkit-details-marker { display: none; }
.upload-body { padding: .75rem 1rem 1rem; display: flex; flex-direction: column; gap: .75rem; }
.upload-row  { display: flex; gap: 1rem; flex-wrap: wrap; }
.upload-row label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; font-weight: 500; }
.upload-row select, .upload-row input { font-size: .9rem; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); }
.upload-drop {
  border: 2px dashed var(--border);
  border-radius: 6px;
  padding: 1.5rem;
  text-align: center;
  color: #666;
  font-size: .9rem;
  transition: border-color .15s, background .15s;
}
.upload-drop.drag-over { border-color: var(--primary); background: #eef4ff; }
.upload-file-list { display: flex; flex-direction: column; gap: .25rem; }
.upload-file-item { display: flex; align-items: center; gap: .5rem; font-size: .85rem; background: #f5f7fa; border-radius: 4px; padding: .25rem .5rem; }
.upload-file-item span:first-child { flex: 1; }
.upload-file-size { color: #888; }
.upload-actions { display: flex; gap: .5rem; }
.upload-results { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; }
.upload-result-item { padding: .35rem .5rem; border-radius: 4px; background: #f5f7fa; }
.upload-result-item.queued    { background: #eafaf1; }
.upload-result-item.duplicate { background: #fef9e7; }
.upload-result-item.error     { background: #fdecea; }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; text-decoration: underline; font-size: inherit; }

/* ── PARSING LOG PANEL ── */
.parsing-log-panel {
  margin-top: .75rem;
  border-top: 1px solid var(--border);
  padding-top: .5rem;
  font-family: monospace;
  font-size: .78rem;
  line-height: 1.5;
  max-height: 300px;
  overflow-y: auto;
}
.log-entry { display: flex; gap: .5rem; padding: .1rem 0; }
.log-time  { color: #888; flex-shrink: 0; }
.log-src   { color: #555; flex-shrink: 0; min-width: 7rem; }
.log-msg   { color: #222; word-break: break-word; }
.log-info  .log-src { color: #4a7fc1; }
.log-warn  { background: #fffbea; }
.log-warn  .log-msg { color: #7d5a00; }
.log-error { background: #fff0f0; }
.log-error .log-msg { color: #c0392b; }
.log-loading, .log-empty { color: #888; padding: .25rem 0; font-style: italic; }

/* ── DEBUG DATA TABLE (archive version data view) ── */
.data-summary { font-size: .85rem; color: #555; padding: .3rem 0 .5rem; }
.data-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.data-table th { background: #f0f0f0; text-align: left; padding: .3rem .5rem; border-bottom: 2px solid #ccc; }
.data-table td { padding: .2rem .5rem; border-bottom: 1px solid #eee; vertical-align: top; }
.data-table tr.data-date-first td { border-top: 1px solid #ccc; }
.data-table tr:hover { background: #f9f9f9; }

/* ── UNRESOLVED NAMES PANEL (admin archive) ── */
.unresolved-panel { margin-top: .6rem; border: 1px solid #f0c040; border-radius: 6px; background: #fffbea; padding: .5rem .75rem; }
.unresolved-header { font-weight: 600; color: #7d5a00; margin-bottom: .4rem; font-size: .9rem; }
.unresolved-row { display: flex; align-items: center; gap: .4rem; padding: .25rem 0; flex-wrap: wrap; border-top: 1px solid #f5e8a0; }
.unresolved-row:first-of-type { border-top: none; }
.unresolved-row--done { opacity: .7; }
.unresolved-raw { font-weight: 600; min-width: 6rem; }
.unresolved-hint { color: #888; font-size: .85rem; flex-shrink: 0; }
.unresolved-input { flex: 1; min-width: 8rem; max-width: 16rem; font-size: .85rem; padding: .2rem .4rem; border: 1px solid #ccc; border-radius: 4px; }
.unresolved-done-label { font-size: .85rem; color: #555; flex: 1; }
.btn-undo { flex-shrink: 0; }
.unresolved-done-list { margin-top: .3rem; padding-top: .3rem; border-top: 1px dashed #e0c060; }
.btn-xs { font-size: .75rem; padding: .2rem .5rem; border-radius: 4px; border: none; cursor: pointer; flex-shrink: 0; }
.btn-xs.btn-primary { background: #3a7bd5; color: #fff; }
.btn-xs.btn-primary:hover { background: #2c63b8; }
.btn-xs.btn-secondary { background: #ccc; color: #333; }
.btn-xs.btn-secondary:hover { background: #bbb; }

/* ── UTILITIES ── */
.hidden { display: none !important; }

/* ── TABS WRAPPER ── */
.tabs-wrapper { position: relative; }

/* ── RESPONSIVE – Tablet ── */
@media (max-width: 900px) {
  main { padding: 1rem; }
}

/* ── RESPONSIVE – Mobile ── */
@media (max-width: 640px) {

  /* ─ Header ─ */
  header { padding: 0 .75rem; }
  .header-inner { height: auto; padding: .5rem 0; }
  .header-logo { font-size: 1.3rem; }
  h1 { font-size: .98rem; }
  .header-sub { display: none; }
  #status-text { font-size: .75rem; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* ─ Tabs: horizontal scrollen, Verlauf-Fade zeigt weiteren Inhalt ─ */
  .tabs-wrapper::after {
    content: '';
    position: absolute;
    right: 0; top: 0; bottom: 0;
    width: 2.5rem;
    background: linear-gradient(to right, transparent, var(--primary-dk));
    pointer-events: none;
  }
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: .78rem;
    padding: .7rem .85rem;
  }

  /* ─ Main ─ */
  main { padding: .75rem .5rem; }

  /* ─ Toolbar ─ */
  .toolbar { flex-direction: column; align-items: stretch; gap: .6rem; }
  .toolbar-left { flex-direction: column; align-items: stretch; gap: .5rem; }
  .toolbar-right { flex-direction: row; flex-wrap: wrap; gap: .5rem; }

  /* ─ Labels + Inputs: volle Breite, ≥16 px damit iOS nicht reinzoomt ─ */
  label { width: 100%; }
  input[type="text"],
  input[type="date"],
  select { min-width: 0; width: 100%; font-size: 1rem; }

  /* ─ Buttons (Touch-Mindestgröße 44 px) ─ */
  .btn-primary, .btn-secondary { min-height: 44px; padding: .6rem 1rem; }

  /* ─ Summary Cards ─ */
  .summary-cards { gap: .5rem; }
  .summary-card { padding: .6rem .85rem; min-width: 90px; }
  .summary-card .card-num   { font-size: 1.4rem; }
  .summary-card .card-label { font-size: .7rem; }

  /* ─ Tabellen ─ */
  .schedule-table { font-size: .78rem; }
  .schedule-table thead th { padding: .5rem .55rem; }
  .schedule-table td        { padding: .45rem .55rem; }

  /* ─ Änderungsprotokoll ─ */
  .change-time { min-width: 0; font-size: .82rem; }
  .change-plan { min-width: 0; }

  /* ─ Day-Navigation ─ */
  .day-nav-header { padding: .4rem .5rem .2rem; }
  .day-nav-kw-select { font-size: .8rem; }
  .day-nav-scroll { padding: .2rem .5rem .4rem; }
  .day-btn { min-width: 50px; padding: .35rem .4rem; font-size: .75rem; }

  /* ─ Einsatzplan ─ */
  .einsatz-view { padding: .4rem .5rem 1.5rem; }
  .day-sections { grid-template-columns: 1fr; }
  .day-heading-wd { font-size: 1.1rem; }

  /* ─ Profile ─ */
  .profiles-subgrid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; }
  .profile-detail-header { flex-direction: column; gap: 1rem; }
  .profile-detail-photo  { width: 80px; height: 80px; }

  /* ─ Mitarbeitersuche ─ */
  .employee-search-box { padding: 1rem; margin-bottom: 1rem; max-width: 100%; }

  /* ─ Archiv-Upload ─ */
  .upload-drop { padding: 1rem; }
  .upload-row  { flex-direction: column; }

  /* ─ Footer ─ */
  footer { flex-direction: column; gap: .2rem; padding: .5rem .75rem; text-align: center; }
}

/* ================================================================
   Auth / Login
   ================================================================ */

/* Header-Right: Status + Logout nebeneinander */
.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Logout-Button im Header */
.btn-logout {
  background: rgba(255,255,255,.15);
  color: var(--white);
  border: 1px solid rgba(255,255,255,.35);
  border-radius: var(--radius);
  padding: .3rem .75rem;
  font-size: .8rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.25); }

/* Login-Overlay */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.login-overlay.hidden { display: none; }

.login-card {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  padding: 2.5rem 2rem;
  width: min(380px, 90vw);
  text-align: center;
}

.login-logo { font-size: 3rem; margin-bottom: .5rem; }
.login-card h2 { font-size: 1.3rem; font-weight: 700; color: var(--primary); margin-bottom: .25rem; }
.login-sub { font-size: .8rem; color: var(--text-muted); margin-bottom: 1.75rem; }

.login-label {
  display: block;
  text-align: left;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
}
.login-label input {
  display: block;
  width: 100%;
  margin-top: .35rem;
  padding: .55rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  outline: none;
  transition: border-color .15s;
}
.login-label input:focus { border-color: var(--primary-lt); }

.login-error {
  background: #fdecea;
  color: var(--error);
  border-radius: var(--radius);
  padding: .4rem .75rem;
  font-size: .85rem;
  margin-bottom: .75rem;
}
.login-error.hidden { display: none; }

.login-btn {
  width: 100%;
  padding: .6rem;
  font-size: 1rem;
  margin-top: .25rem;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: .9rem 0 .65rem;
  color: var(--text-muted);
  font-size: .8rem;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border, #ddd);
}
.login-divider.hidden { display: none; }

.empty-state-hint {
  display: inline-block;
  margin-top: .4rem;
  font-size: .85rem;
  color: var(--text-muted);
}

.maintenance-msg {
  font-size: .95rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-top: 1rem;
}

/* ── Tab badge (admin notification) ───────────────────────────────── */
.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 .3rem;
  background: var(--error, #d32f2f);
  color: #fff;
  border-radius: 99px;
  font-size: .65rem;
  font-weight: 700;
  margin-left: .3rem;
  vertical-align: middle;
}
.tab-badge.hidden { display: none; }

/* ── Feedback modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.hidden { display: none; }

.modal-card {
  background: var(--surface, #fff);
  border-radius: var(--radius, 8px);
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  padding: 1.5rem;
  width: min(420px, 90vw);
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.modal-card h3 {
  margin: 0;
  font-size: 1.1rem;
}
.modal-subtitle {
  margin: 0;
  font-size: .85rem;
  color: var(--text-muted, #666);
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.form-group label {
  font-size: .85rem;
  font-weight: 600;
}
.form-group select,
.form-group textarea {
  border: 1px solid var(--border, #ddd);
  border-radius: var(--radius, 6px);
  padding: .4rem .6rem;
  font-size: .9rem;
  font-family: inherit;
  resize: vertical;
}
.modal-actions {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  margin-top: .25rem;
}
.feedback-success {
  background: #e8f5e9;
  color: #2e7d32;
  border-radius: var(--radius, 6px);
  padding: .4rem .7rem;
  font-size: .85rem;
}
.feedback-error {
  background: #fdecea;
  color: var(--error, #d32f2f);
  border-radius: var(--radius, 6px);
  padding: .4rem .7rem;
  font-size: .85rem;
}

/* ── Administration tab ─────────────────────────────────────────── */
.admin-settings {
  max-width: 640px;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
.settings-group h3 {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted, #888);
  margin: 0 0 .75rem;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: .75rem 1rem;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border, #e0e0e0);
  border-radius: var(--radius, 6px);
}
.setting-info {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.setting-info strong { font-size: .95rem; }
.setting-desc {
  font-size: .8rem;
  color: var(--muted, #888);
  line-height: 1.4;
}
.settings-status {
  font-size: .8rem;
  margin-top: .5rem;
  padding: .3rem .6rem;
  border-radius: var(--radius, 6px);
}
.settings-status.ok  { background: #e8f5e9; color: #2e7d32; }
.settings-status.err { background: #fdecea; color: var(--error, #d32f2f); }

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 24px;
  cursor: pointer;
  transition: background .2s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary, #1976d2); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Push notification panel ────────────────────────────────────── */
.push-panel {
  position: fixed;
  z-index: 200;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 340px;
  padding: .75rem 1rem;
  font-size: .875rem;
}
.push-active {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.push-form {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.push-form label { display: flex; flex-direction: column; gap: .25rem; font-weight: 500; }
.push-form select { font-size: .875rem; padding: .25rem .4rem; border: 1px solid var(--border); border-radius: var(--radius); }
.push-note { color: var(--text-muted); margin: 0; }
.push-error { color: var(--error); font-size: .8rem; }
.btn-sm { font-size: .8rem; padding: .25rem .6rem; }
.toolbar-right { position: relative; }

.push-steps {
  margin: .4rem 0 0 1rem;
  padding: 0;
  font-size: .82rem;
  color: var(--text);
  line-height: 1.7;
}
.push-icon {
  font-size: 1rem;
  vertical-align: middle;
}

/* ── Push panel – multi-select ──────────────────────────────────── */
.push-active-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .3rem;
}
.push-active-label { font-weight: 600; }
.push-active-names {
  font-size: .8rem;
  color: var(--text-muted);
  line-height: 1.4;
  word-break: break-word;
}
.push-active-footer {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-top: .6rem;
  flex-wrap: wrap;
}
.push-test-status {
  font-size: .78rem;
  color: var(--text-muted);
  line-height: 1.3;
}
.push-test-status.ok  { color: var(--success, #2e7d32); }
.push-test-status.err { color: var(--danger, #c62828); }
.push-form-hint {
  font-size: .8rem;
  color: var(--text-muted);
  margin: 0 0 .4rem;
}
.push-name-filter {
  width: 100%;
  box-sizing: border-box;
  padding: .3rem .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .85rem;
  margin-bottom: .4rem;
}
.push-cb-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .25rem 0;
  margin-bottom: .5rem;
}
.push-cb-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .25rem .6rem;
  cursor: pointer;
  font-size: .875rem;
}
.push-cb-row:hover { background: var(--accent); }
.push-cb-row input { accent-color: var(--primary); flex-shrink: 0; }
.push-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.push-selected-count { font-size: .8rem; color: var(--text-muted); }

/* ── Calendar subscription panel ───────────────────────────────────── */
#calendar-panel { max-width: 360px; }
.cal-feed-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .75rem; }
.cal-feed {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .6rem;
  background: var(--accent, #f8fafc);
}
.cal-feed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.cal-feed-names { font-size: .78rem; color: var(--text-muted); margin: .1rem 0 .35rem; }
.cal-feed-url {
  width: 100%;
  font-size: .74rem;
  font-family: monospace;
  padding: .25rem .35rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--white);
  margin-bottom: .35rem;
}
.cal-feed-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.cal-feed-actions a { text-decoration: none; }

/* ── Statistik tab ─────────────────────────────────────────────────── */
.stats-view-toggle {
  display: flex;
  gap: .5rem;
  margin: 1rem 0 .75rem;
}
.stats-view-btn {
  padding: .4rem .9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: .875rem;
  transition: background .15s, color .15s;
}
.stats-view-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.stats-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
  padding: .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stats-controls label {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .875rem;
}
.stats-controls input[type=date], .stats-controls select {
  padding: .3rem .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: .875rem;
}
.stats-view { margin-top: .5rem; }
.stats-filter-row {
  margin-bottom: .75rem;
  font-size: .875rem;
}
.stats-filter-col label {
  display: block;
  margin-bottom: .4rem;
}
.stats-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.stats-chip {
  padding: .3rem .6rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font-size: .8rem;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.stats-chip:hover {
  border-color: var(--primary);
}
.stats-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.stats-filter-row select {
  padding: .3rem .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: .875rem;
  min-width: 200px;
}
.stats-result { margin-top: .5rem; }
.stats-chart-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: .75rem;
}
.stats-empty {
  color: var(--text-muted);
  font-size: .875rem;
  padding: 1rem 0;
}

/* Bar chart */
.stats-bar-chart { display: flex; flex-direction: column; gap: .35rem; }
.stats-bar-row {
  display: grid;
  grid-template-columns: 140px 1fr 40px;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
}
.stats-bar-label {
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stats-bar-track {
  background: var(--accent);
  border-radius: 3px;
  height: 18px;
  overflow: hidden;
}
.stats-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width .3s;
}
.stats-bar-value {
  font-weight: 600;
  text-align: right;
  font-size: .8rem;
}

/* Heatmap */
.stats-heatmap-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.stats-heatmap {
  border-collapse: collapse;
  font-size: .75rem;
  min-width: 100%;
}
.stats-heatmap th, .stats-heatmap td {
  border: 1px solid var(--border);
  padding: .2rem .35rem;
  white-space: nowrap;
}
.stats-hm-emp-col { min-width: 100px; }
.stats-hm-dept-col {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  max-height: 80px;
  font-size: .7rem;
  padding: .4rem .2rem;
  text-align: left;
}
.stats-hm-name {
  font-weight: 500;
  text-align: right;
  padding-right: .5rem;
}
.stats-hm-cell {
  text-align: center;
  min-width: 30px;
}
.stats-hm-filled {
  background: rgba(26, 79, 122, var(--hm-intensity, 0));
  color: var(--text);
}
.stats-hm-total {
  font-weight: 700;
  text-align: right;
  padding-left: .4rem;
  border-left: 2px solid var(--border);
}

@media (max-width: 600px) {
  .stats-bar-row {
    grid-template-columns: 100px 1fr 35px;
  }
  .stats-controls { gap: .5rem; }
}

/* Krankenstand chart */
.ks-summary {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1rem;
}
.ks-summary-card {
  flex: 1 1 180px;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.ks-summary-label {
  font-size: .75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.ks-summary-value {
  font-size: 1.5rem;
  font-weight: 700;
  margin: .2rem 0;
}
.ks-summary-sub {
  font-size: .75rem;
  color: var(--text-muted);
}
.ks-bar-chart {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-bottom: .75rem;
}
.ks-bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 55px 70px;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
}
.ks-bar-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}
.ks-bar-track {
  background: var(--accent);
  border-radius: 3px;
  height: 18px;
  overflow: hidden;
  display: flex; /* Krank- und Urlaub-Segment nebeneinander */
}
.ks-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: hsl(var(--ks-hue, 200), 65%, 45%);
  transition: width .3s;
  flex-shrink: 0;
}
.ks-bar-fill-urlaub {
  background: hsl(210, 45%, 65%);
  border-radius: 0 3px 3px 0;
}
.ks-bar-value {
  font-weight: 600;
  text-align: right;
  font-size: .8rem;
}
.ks-bar-count {
  font-size: .75rem;
  color: var(--text-muted);
  text-align: right;
}
@media (max-width: 600px) {
  .ks-bar-row {
    grid-template-columns: 80px 1fr 50px 60px;
    font-size: .8rem;
  }
}
.stats-loading {
  color: var(--text-muted);
  font-size: .875rem;
  padding: 1rem 0;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

/* ── Namen tab ─────────────────────────────────────────────────────── */
.names-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  background: var(--surface);
}
.names-panel-header {
  font-weight: 600;
  font-size: .95rem;
  padding: .7rem 1rem;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: .5rem;
  user-select: none;
}
.names-panel-header::-webkit-details-marker { display: none; }
.names-panel-body {
  padding: .75rem 1rem 1rem;
  border-top: 1px solid var(--border);
}
.names-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-bottom: .75rem;
}
.names-search {
  padding: .35rem .6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: .875rem;
  min-width: 180px;
  flex: 1;
  max-width: 260px;
}
.names-input, .names-select {
  padding: .35rem .6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: .875rem;
}
.names-toggle-label {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .85rem;
  cursor: pointer;
  white-space: nowrap;
}
.alias-add-form {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  margin-bottom: .75rem;
  padding: .6rem .75rem;
  background: var(--accent);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.alias-add-form .names-input { flex: 1; min-width: 140px; }
.alias-add-form .names-select { min-width: 150px; }
.names-table-wrap { overflow-x: auto; }
.names-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.names-table th {
  text-align: left;
  padding: .4rem .6rem;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}
.names-table td {
  padding: .35rem .6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.names-table tr:last-child td { border-bottom: none; }
.alias-cell-alias { font-family: monospace; font-size: .85rem; }
.alias-cell-name  { font-weight: 500; }
.alias-cell-action { width: 40px; text-align: center; }
.btn-danger { color: var(--danger, #c0392b) !important; }
.names-empty {
  color: var(--text-muted);
  font-size: .875rem;
  padding: .5rem 0;
}

/* Unresolved rows */
.unresolved-list { display: flex; flex-direction: column; gap: .4rem; }
.ur-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem 1rem;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: .875rem;
}
.ur-row.ur-resolved {
  opacity: .6;
  background: var(--surface);
}
.ur-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  flex: 1;
  min-width: 0;
}
.ur-raw   { font-weight: 600; }
.ur-hint  { color: var(--text-muted); font-size: .8rem; }
.ur-ctx   { color: var(--text-muted); font-size: .78rem; white-space: nowrap; }
.ur-actions {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.ur-input {
  padding: .25rem .5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: .85rem;
  width: 160px;
}
.ur-resolved-label {
  font-size: .82rem;
  color: var(--text-muted);
  font-style: italic;
}
.btn-sm {
  padding: .25rem .6rem;
  font-size: .8rem;
}
.names-pagination {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-top: .75rem;
  font-size: .875rem;
}

@media (max-width: 600px) {
  .ur-row { flex-direction: column; align-items: flex-start; }
  .ur-actions { width: 100%; }
  .ur-input { width: 100%; }
}

/* Replanning stats */
.settings-subheading {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 1rem 0 .4rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.replanning-table-wrap {
  overflow-x: auto;
  margin-bottom: .75rem;
}
.replanning-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.replanning-table th,
.replanning-table td {
  padding: .3rem .6rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.replanning-table th {
  font-weight: 600;
  color: var(--text-muted);
  text-align: left;
}
.replanning-table tbody tr:hover { background: var(--bg-alt, #f5f7fa); }
.text-right { text-align: right !important; }
.week-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 56px;
  padding: 4px 0;
  margin-bottom: .75rem;
}
.week-bar {
  flex: 1;
  background: var(--accent, #1a56a0);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  cursor: default;
  opacity: .75;
  transition: opacity .15s;
}
.week-bar:hover { opacity: 1; }

/* Ambiguous name entries */
.ur-hint--ambiguous {
  color: var(--warning, #b45309);
  font-style: italic;
}
.ur-ambiguous .ur-raw {
  font-weight: 600;
}
.ur-ambiguous .ur-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: center;
}
.ur-snippet {
  grid-column: 1 / -1;
  margin-top: .5rem;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border, #dde3ec);
}
.ur-snippet-img {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: auto;
}
.ur-snippet-err,
.ur-snippet-loading {
  display: block;
  padding: .5rem .75rem;
  font-size: .8rem;
  color: var(--muted, #6b7a89);
}

/* ── Stub profile cards (schedule-only) ──────────────────────── */
.profile-card--stub { opacity: .75; border-style: dashed; }
.profile-card--stub .profile-initials { background: var(--border, #dde3ec); color: var(--muted, #6b7a89); }
.profile-stub-hint { font-size: .78rem; color: var(--muted, #6b7a89); font-style: italic; }

/* ── Personal tab sub-navigation ─────────────────────────────── */
.personal-subnav {
  display: flex;
  gap: .25rem;
  padding: .75rem 1rem .25rem;
  border-bottom: 1px solid var(--border, #dde3ec);
  margin-bottom: 1rem;
}
.personal-subtab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: .4rem .75rem;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  color: var(--muted, #6b7a89);
  border-radius: var(--radius) var(--radius) 0 0;
  transition: color .15s, border-color .15s;
}
.personal-subtab.active {
  color: var(--primary, #1a56db);
  border-bottom-color: var(--primary, #1a56db);
}
.personal-subtab:hover:not(.active) {
  color: var(--text, #1e2a35);
}
.personal-subview.hidden { display: none; }

/* ── Employment periods ───────────────────────────────────────── */
.employment-section { margin: 1.5rem 0; }
.employment-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.employment-table th {
  text-align: left;
  padding: .35rem .5rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border, #dde3ec);
  color: var(--muted, #6b7a89);
}
.employment-table td {
  padding: .3rem .5rem;
  border-bottom: 1px solid var(--accent, #f0f4ff);
  vertical-align: middle;
}
.employment-table input[type="date"],
.employment-table input[type="text"] {
  border: 1px solid var(--border, #dde3ec);
  border-radius: 4px;
  padding: .2rem .4rem;
  font-size: .85rem;
}

/* ── Dienstprogression ─────────────────────────────────────────── */
.prog-summary {
  display: flex;
  gap: 1rem;
  margin: 1rem 0 1.5rem;
  flex-wrap: wrap;
}
.prog-summary-card {
  background: var(--accent, #f0f4ff);
  border-radius: 8px;
  padding: .75rem 1.25rem;
  min-width: 130px;
  text-align: center;
}
.prog-summary-label { font-size: .8rem; color: var(--muted, #6b7a89); }
.prog-summary-median { font-size: 2rem; font-weight: 700; color: var(--primary, #2563eb); line-height: 1.1; }
.prog-summary-sub { font-size: .75rem; color: var(--muted, #6b7a89); }

.prog-table-wrap { overflow-x: auto; }
.prog-table {
  border-collapse: collapse;
  width: 100%;
  font-size: .88rem;
}
.prog-table th {
  text-align: left;
  padding: .4rem .75rem;
  border-bottom: 2px solid var(--border, #dde3ec);
  color: var(--muted, #6b7a89);
  font-weight: 600;
  white-space: nowrap;
}
.prog-table td { padding: .3rem .75rem; border-bottom: 1px solid var(--accent, #f0f4ff); }
.prog-name { font-weight: 500; }
.prog-date { color: var(--muted, #6b7a89); font-size: .82rem; white-space: nowrap; }
.prog-cell { text-align: center; width: 7rem; }
.prog-empty { color: var(--muted, #dde3ec); }
.prog-filled {
  font-weight: 600;
  border-radius: 4px;
  background: hsla(var(--prog-hue, 120), 60%, 92%, 1);
  color: hsla(var(--prog-hue, 120), 60%, 28%, 1);
}
.prog-note {
  margin-top: 1rem;
  font-size: .78rem;
  color: var(--muted, #6b7a89);
}

/* ── Canonical corrections panel ─────────────────────────────────────────── */
.corrections-list { display: flex; flex-direction: column; gap: .35rem; }
.corr-row {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px;
  padding: .5rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.corr-row.corr-done { opacity: .5; }
.corr-main { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.corr-name { font-weight: 600; font-size: .93rem; word-break: break-all; }
.corr-count { font-size: .78rem; color: var(--muted, #6b7a89); white-space: nowrap; }
.corr-flags { display: flex; gap: .3rem; flex-wrap: wrap; }
.corr-flag {
  font-size: .7rem; font-weight: 600; padding: .1rem .4rem;
  border-radius: 3px; white-space: nowrap;
}
.flag-danger { background: #fee2e2; color: #991b1b; }
.flag-warn   { background: #fef3c7; color: #92400e; }
.flag-info   { background: #e0f2fe; color: #075985; }
.corr-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.btn-danger { background: #ef4444; color: #fff; border: none; }
.btn-danger:hover { background: #dc2626; }
.corr-inline { padding: .5rem 0 .25rem; }

/* ── Corrections modals ───────────────────────────────────────────────────── */
.corr-modal-hint { font-size: .83rem; color: var(--muted, #6b7a89); margin: .25rem 0 .75rem; }
.split-parts-list { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .5rem; }
.split-part-row { display: flex; gap: .4rem; align-items: center; }
.split-part-row .names-input { flex: 1; }

/* ── Namenzuordnung (unified panel) ─────────────────────────────────────── */
.na-tabs {
  display: flex;
  gap: .3rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}
.na-tab {
  padding: .35rem .75rem;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px;
  background: var(--bg-card, #fff);
  color: var(--text, #1e293b);
  font-size: .83rem;
  cursor: pointer;
  white-space: nowrap;
}
.na-tab.active {
  background: var(--primary, #2563eb);
  color: #fff;
  border-color: var(--primary, #2563eb);
}
.na-tab .tab-badge { margin-left: .25rem; }
.na-tab.active .tab-badge { background: rgba(255,255,255,.25); color: #fff; }

.na-list {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  margin-top: .5rem;
}
.na-row {
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px;
  padding: .5rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  transition: opacity .2s;
}
.na-row.na-done { opacity: .45; }
.na-status-aliased { border-left: 3px solid #22c55e; }
.na-status-ambiguous { border-left: 3px solid #f59e0b; }
.na-status-ignored { border-left: 3px solid #94a3b8; }
.na-status-open { border-left: 3px solid #3b82f6; }

.na-main {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.na-raw {
  font-weight: 600;
  font-size: .93rem;
  word-break: break-all;
}
.na-count {
  font-size: .78rem;
  color: var(--muted, #6b7a89);
  white-space: nowrap;
}
.na-count-zero { opacity: .5; }
.na-assigned {
  font-size: .85rem;
  color: #15803d;
}
.na-canon-hint {
  font-size: .78rem;
  color: var(--muted, #6b7a89);
  font-weight: 400;
}
.na-ambiguous { font-size: .83rem; color: #92400e; }
.na-ignored   { font-size: .83rem; color: var(--muted, #6b7a89); }
.na-unassigned { font-size: .83rem; color: var(--muted, #6b7a89); }

.na-actions {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  align-items: center;
}
.na-staff-select {
  font-size: .83rem;
  padding: .25rem .4rem;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 4px;
  background: var(--bg-card, #fff);
  max-width: 280px;
}
.na-snippet { padding: .25rem 0; }
.na-snippet-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: baseline;
  font-size: .8rem;
  color: var(--muted, #6b7a89);
  margin-bottom: .3rem;
}
.na-snippet-meta strong { color: var(--text, #1e293b); }
.na-snippet-approx {
  display: block;
  font-size: .78rem;
  color: #92400e;
  margin-bottom: .25rem;
}
.na-snippet-dates {
  font-size: .78rem;
  color: var(--muted, #6b7a89);
  margin-bottom: .3rem;
}
/* The raw name doubles as the trigger for the plan excerpt. */
.na-raw-btn {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px dotted var(--muted, #94a3b8);
}
.na-raw-btn:hover { color: var(--primary, #2563eb); border-bottom-color: currentColor; }

/* ── Analyse-Fortschritt ─────────────────────────────────────────────────── */
.progress-block { margin-bottom: 1rem; }
.progress-label { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: .3rem; color: var(--text-muted, #6b7a89); }
.progress-bar-wrap { background: var(--border, #e2e8f0); border-radius: 4px; overflow: hidden; height: 8px; }
.progress-bar-wrap.large { height: 14px; border-radius: 6px; }
.progress-bar-fill { height: 100%; background: var(--accent, #3b82f6); border-radius: inherit; transition: width .4s ease; }
.progress-bar-fill.active { background: linear-gradient(90deg, var(--accent, #3b82f6), #60a5fa); animation: progress-pulse 2s ease-in-out infinite; }
@keyframes progress-pulse { 0%,100% { opacity:1; } 50% { opacity:.75; } }
.progress-sub { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .35rem; font-size: .8rem; }
.badge-pending    { background: #fef3c7; color: #92400e; border-radius: 4px; padding: 1px 6px; }
.badge-failed     { background: #fee2e2; color: #991b1b; border-radius: 4px; padding: 1px 6px; }
.badge-other      { background: #dbeafe; color: #1e40af; border-radius: 4px; padding: 1px 6px; }
.badge-scheduled  { background: #dcfce7; color: #166534; border-radius: 4px; padding: 1px 6px; font-size: .8em; }
.badge-predeploy  { background: #fef3c7; color: #92400e; border-radius: 4px; padding: 1px 6px; font-size: .8em; }
.badge-manual     { background: #e0e7ff; color: #3730a3; border-radius: 4px; padding: 1px 6px; font-size: .8em; }
.stats-table { width: 100%; border-collapse: collapse; font-size: .83rem; }
.stats-table th, .stats-table td { padding: .3rem .5rem; border-bottom: 1px solid var(--border, #e2e8f0); }
.stats-table th { text-align: left; color: var(--text-muted, #6b7a89); font-weight: 600; }
.stats-table .text-right { text-align: right; }

/* ── Profile management: new elements ───────────────────────────────────── */

/* Inactive cards */
.profile-card--inactive { opacity: .45; }

/* Unresolved badge on card corner */
.profile-card-photo { position: relative; }
.profile-badge--unresolved {
  position: absolute;
  top: -4px; right: -4px;
  background: #f97316;
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  border-radius: 50%;
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}

/* Source + inactive badges in profile header */
.profile-header-meta { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .25rem; }
.profile-source-badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  border-radius: 4px;
  padding: 1px 7px;
}
.profile-source-badge.badge-stub    { background: #f1f5f9; color: #64748b; }
.profile-source-badge.badge-website { background: #dbeafe; color: #1d4ed8; }
.profile-inactive-badge {
  display: inline-block;
  font-size: .72rem;
  font-weight: 600;
  border-radius: 4px;
  padding: 1px 7px;
  background: #fee2e2;
  color: #991b1b;
}

/* Editable name form */
.profile-name-edit-form { display: flex; flex-direction: column; gap: .25rem; }
.profile-name-display { display: flex; align-items: center; gap: .4rem; }
.profile-name-inputs { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.profile-name-inputs input { padding: .3rem .5rem; border: 1px solid var(--border, #dde3ec); border-radius: 6px; font-size: .95rem; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 1rem; padding: 0 .25rem; opacity: .6; }
.btn-icon:hover { opacity: 1; }

/* Admin action buttons row */
.profile-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  padding: .75rem 0;
  margin-bottom: .5rem;
  border-bottom: 1px solid var(--border, #dde3ec);
}

/* Unresolved candidates section */
.ur-candidates-section { margin: 1.5rem 0; }

/* Profile link button in Namenzuordnung */
.na-btn-profile { font-size: .8rem; padding: 0 .3rem; vertical-align: middle; }

.history-action-cell { white-space: nowrap; }
.profile-history-day-btn {
  padding: .2rem .45rem;
  font-size: .78rem;
}

/* Auto-action grid in Namenzuordnung admin toolbar */
.na-auto-actions {
  margin-bottom: 1.25rem;
  padding: .9rem 1rem;
  background: var(--surface-alt, #f7f9fc);
  border: 1px solid var(--border, #dde3ec);
  border-radius: 8px;
}
.na-auto-desc { margin: 0 0 .85rem; }
.na-auto-grid {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.na-auto-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: .6rem .75rem;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #dde3ec);
  border-radius: 6px;
}
.na-auto-info { flex: 1; min-width: 0; }
.na-auto-info strong { display: block; margin-bottom: .2rem; font-size: .95rem; }
.na-auto-info .setting-desc { font-size: .83rem; line-height: 1.4; }
.na-auto-item .btn-secondary { white-space: nowrap; flex-shrink: 0; }

/* ── User management / account UI ─────────────────────────────────────────── */
.login-title { font-size: 1.4rem; margin: .4rem 0 .2rem; }
.settings-heading { font-size: 1rem; margin: 1.2rem 0 .4rem; }
.settings-hint { font-size: .85rem; color: var(--muted, #64748b); margin: .4rem 0; }
.pw-hint { font-size: .82rem; color: var(--muted, #64748b); margin: .3rem 0 .6rem; line-height: 1.4; }
.pw-hint.pw-ok { color: #166534; }
.pw-hint.pw-bad { color: #b91c1c; }
.msg-ok { color: #166534; font-size: .88rem; margin: .4rem 0; }
.msg-bad { color: #b91c1c; font-size: .88rem; margin: .4rem 0; }
.initpw-box { background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 6px;
  padding: .8rem 1rem; margin: .8rem 0; text-align: center; }
.initpw-box code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.25rem; letter-spacing: .06em; word-break: break-all; user-select: all; }
.users-table { width: 100%; border-collapse: collapse; margin-top: .6rem; font-size: .9rem; }
.users-table th, .users-table td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid #e2e8f0; }
.users-table th { font-weight: 600; color: var(--muted, #475569); }
.users-table .text-right { text-align: right; }
.user-disabled td { opacity: .55; }
.user-create-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: .8rem 0; }
.user-create-row input, .user-create-row select { padding: .35rem .5rem; }
.badge-role-admin { background: #fef3c7; color: #92400e; border-radius: 4px; padding: 1px 6px; font-size: .8em; }
.badge-role-user  { background: #dcfce7; color: #166534; border-radius: 4px; padding: 1px 6px; font-size: .8em; }

/* ── Feature permissions ────────────────────────────────────────────
   Elements gated by data-feature. A dedicated class (not .hidden) so it
   never collides with the show/hide logic of the feature itself. */
[data-feature].feature-locked { display: none !important; }

/* Permission matrix: users × features. Scrolls horizontally on its own so a
   wide catalog never makes the page scroll sideways. */
.perm-matrix-wrap { overflow-x: auto; margin-top: .6rem; }
.perm-matrix { border-collapse: collapse; font-size: .85rem; min-width: 100%; }
.perm-matrix th, .perm-matrix td {
  border-bottom: 1px solid #e2e8f0;
  padding: .4rem .5rem;
  text-align: center;
}
.perm-matrix thead th { font-weight: 600; color: var(--muted, #475569); vertical-align: bottom; }
.perm-matrix .perm-group-head {
  border-bottom: 2px solid var(--border);
  background: #f8fafc;
  font-size: .8rem;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.perm-matrix .perm-feature-head { max-width: 7.5rem; font-weight: 500; line-height: 1.25; }
.perm-matrix .perm-feature-head.perm-child { font-style: italic; color: var(--text-muted); }
.perm-matrix .perm-user,
.perm-matrix .perm-user-head { text-align: left; white-space: nowrap; position: sticky; left: 0; background: var(--white, #fff); }
.perm-matrix .perm-user { font-weight: 600; }
.perm-matrix .perm-actions { text-align: right; white-space: nowrap; }
.perm-matrix tbody tr:hover td { background: #f8fafc; }
.perm-matrix tbody tr:hover .perm-user { background: #f8fafc; }
/* Group boundaries make the wide grid readable. */
.perm-matrix .perm-group-start { border-left: 2px solid var(--border); }
/* A cell that deviates from the catalog default is marked, so an admin can
   tell "explicitly set" apart from "just the default". */
.perm-cell.perm-override { background: #fef9c3; }
.perm-cell input { width: 1.05rem; height: 1.05rem; cursor: pointer; }
.perm-cell input:disabled { cursor: not-allowed; opacity: .45; }
.perm-admin-row td { color: var(--text-muted); font-style: italic; }
.perm-legend { font-size: .8rem; color: var(--text-muted); margin: .5rem 0 0; }
.perm-saving { opacity: .5; }

/* ── Mobile input zoom (iOS Safari) ─────────────────────────────────
   Safari zooms the whole page in whenever a focused form control has a
   font-size below 16px, and it does not zoom back out on blur — so tapping
   the login field left the layout shifted and horizontally scrollable.
   16px is the documented threshold; only raise it on small screens so the
   denser desktop sizing is untouched. */
@media (max-width: 640px) {
  input[type="text"],
  input[type="date"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  input[type="email"],
  select,
  textarea {
    font-size: 16px;
  }
}

/* ── Safe areas (notched iPhones, PWA standalone) ───────────────────
   The manifest uses display:standalone and index.html sets
   viewport-fit=cover, so the page now extends under the notch and the home
   indicator. env() resolves to 0 without them, making these rules inert on
   every other device.

   Only the vertical insets are set globally: the horizontal padding is
   deliberately left alone because the 640px block above tightens it
   (main: .5rem) to win back width on small screens, and a longhand
   padding-left/right here would silently undo that. Sideways insets only
   matter in landscape, handled separately below. */
header  { padding-top: env(safe-area-inset-top); }
footer  { padding-bottom: calc(.6rem + env(safe-area-inset-bottom)); }
.login-overlay,
.modal-overlay {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
.push-panel { margin-bottom: env(safe-area-inset-bottom); }

/* Landscape: the notch moves to a side, so content needs horizontal insets.
   Base values repeat the 640px block's so they are not widened. */
@media (max-width: 900px) and (orientation: landscape) {
  header { padding-left: calc(.75rem + env(safe-area-inset-left));
           padding-right: calc(.75rem + env(safe-area-inset-right)); }
  main   { padding-left: calc(.5rem + env(safe-area-inset-left));
           padding-right: calc(.5rem + env(safe-area-inset-right)); }
  footer { padding-left: calc(.75rem + env(safe-area-inset-left));
           padding-right: calc(.75rem + env(safe-area-inset-right)); }
}

/* ── Stacked tables on small screens ────────────────────────────────
   Data tables with 4-6 columns cannot shrink to phone width; the wrapper
   just turned them into a horizontal scroller, so the right-hand columns
   were effectively invisible. Under 640px each row becomes its own card
   and every cell shows its column heading beside the value. The headings
   come from data-label, filled in by labelStackedTables() in app.js from
   the table's own <thead>, so no markup has to repeat them.

   Opt-in via .stack-mobile: layout tables (heatmap, progress bars) must
   keep their grid and are deliberately excluded. */
@media (max-width: 640px) {
  table.stack-mobile,
  table.stack-mobile tbody,
  table.stack-mobile tr,
  table.stack-mobile td {
    display: block;
    width: auto;
  }
  table.stack-mobile thead { display: none; }
  table.stack-mobile tr {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: .5rem;
    padding: .2rem 0;
  }
  table.stack-mobile tr:last-child { margin-bottom: 0; }
  table.stack-mobile td {
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    gap: .6rem;
    padding: .3rem .7rem;
    border: none;
    text-align: left;
    white-space: normal;
  }
  /* Column heading in front of the value. Cells with no heading (action
     buttons) keep the full width instead of an empty gutter. */
  table.stack-mobile td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 38%;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-muted);
  }
  /* The wrapper's horizontal scroll is pointless once rows are stacked and
     would otherwise clip the card borders. */
  .table-wrapper { overflow-x: visible; box-shadow: none; }
}

/* ── Day view: role labels wrap instead of eating a fixed column ─────
   .sec-func-label reserves a fixed 5.5rem, which on a phone leaves too
   little room for the names next to it. Stack the label above its names. */
@media (max-width: 640px) {
  .sec-func-row {
    flex-direction: column;
    gap: .1rem;
    padding: .35rem .8rem;
  }
  .sec-func-label { flex: none; }
}
