:root {
  --navy: #17233e;
  --navy-2: #213357;
  --blue: #2473e8;
  --blue-dark: #145dc8;
  --ink: #172033;
  --muted: #667085;
  --line: #e3e8ef;
  --surface: #ffffff;
  --background: #f4f6f9;
  --success: #087a55;
  --warning: #a35d00;
  --danger: #c93645;
  --radius: 14px;
  --shadow: 0 18px 55px rgba(23, 35, 62, .13);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--background);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; max-width: 100%; overflow-x: clip; }
body { background: var(--background); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.site-shell { min-height: 100vh; }
.site-header {
  height: 84px;
  padding: 0 clamp(20px, 4vw, 64px);
  background: var(--navy);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand { color: white; text-decoration: none; display: flex; align-items: center; gap: 22px; min-width: 0; }
.brand img { width: 142px; height: auto; display: block; }
.brand span { border-left: 1px solid rgba(255,255,255,.24); padding-left: 22px; display: grid; gap: 2px; }
.brand small { color: #b8c4d9; font-size: 11px; letter-spacing: .09em; text-transform: uppercase; }
.brand strong { font-size: 18px; letter-spacing: -.01em; }
.user-area { display: flex; align-items: center; gap: 18px; }
.user-meta { display: grid; text-align: right; gap: 2px; }
.user-meta small { color: #b8c4d9; }
.user-area form { margin: 0; }

.tab-bar {
  min-height: 56px;
  padding: 0 clamp(20px, 4vw, 64px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: stretch;
  gap: 26px;
}
.tab-list { display: flex; align-items: stretch; gap: 26px; min-width: 0; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 0 2px; cursor: pointer; font-weight: 650; border-bottom: 3px solid transparent; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.app-view { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 44px 0 72px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 24px; }
.page-heading h2 { margin: 3px 0 7px; font-size: clamp(28px, 3vw, 38px); letter-spacing: -.04em; }
.page-heading p:last-child { color: var(--muted); margin: 0; }
.eyebrow { color: var(--blue); font-size: 12px; text-transform: uppercase; letter-spacing: .12em; font-weight: 800; margin: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: 0 3px 12px rgba(23,35,62,.04); }
.panel h3 { margin: 0 0 18px; font-size: 19px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.section-heading h3 { margin: 2px 0 4px; }
.section-heading p:not(.section-kicker) { color: var(--muted); margin: 0; line-height: 1.45; }
.section-kicker { margin: 0; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.soft-badge, .count-badge { flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 28px; padding: 5px 10px; border-radius: 999px; background: #edf3fc; color: #315c98; font-size: 12px; font-weight: 750; }
.soft-badge.secure::before { content: ''; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--success); box-shadow: 0 0 0 3px rgba(8,122,85,.12); }
.count-badge { min-width: 30px; justify-content: center; background: var(--navy); color: white; }
.compact-loading { min-height: 120px; }
.loading, .empty { min-height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); gap: 6px; text-align: center; }
.empty strong { color: var(--ink); }
.muted { color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .07em; padding: 0 14px 12px; }
td { border-top: 1px solid var(--line); padding: 16px 14px; vertical-align: middle; }
td small { display: block; color: var(--muted); margin-top: 3px; }
.right { text-align: right; }
.status { display: inline-flex; border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 750; white-space: nowrap; background: #eef1f5; color: #4c566a; }
.status.submitted { background: #fff0d9; color: var(--warning); }
.status.correction { background: #feecee; color: var(--danger); }
.status.approved { background: #e5f7f0; color: var(--success); }

.button { display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 9px; min-height: 42px; padding: 9px 16px; cursor: pointer; font-weight: 700; text-decoration: none; transition: .16s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button.primary { background: var(--blue); color: white; }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { background: var(--navy); color: white; }
.button.secondary:hover { background: var(--navy-2); }
.button.ghost { border-color: var(--line); background: white; color: var(--ink); }
.site-header .button.ghost { border-color: rgba(255,255,255,.34); background: transparent; color: white; }
.button.danger { color: var(--danger); background: #fff; border-color: #f0bcc2; }
.button.compact { min-height: 34px; padding: 6px 11px; font-size: 13px; }
.button.disabled { opacity: .5; pointer-events: none; }

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.form-grid label, .stack-form label { display: grid; gap: 8px; color: #3d475a; font-size: 13px; font-weight: 700; }
.form-grid .wide { grid-column: 1 / -1; }
input, select, textarea { width: 100%; border: 1px solid #cdd5df; border-radius: 9px; background: white; color: var(--ink); padding: 11px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(36,115,232,.14); }
input[readonly] { background: #f3f5f8; color: #4d586b; cursor: default; }
textarea { resize: vertical; line-height: 1.5; }
.week-options { margin: 0; padding: 0; border: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.week-options legend { margin-bottom: 9px; color: #3d475a; font-size: 13px; font-weight: 700; }
.check-card { min-height: 74px; border: 1px solid #cdd5df; border-radius: 10px; padding: 13px 14px; display: flex !important; grid-template-columns: none !important; align-items: flex-start; gap: 11px !important; cursor: pointer; background: #fafbfc; }
.check-card:has(input:checked) { border-color: var(--blue); background: #eef5ff; box-shadow: 0 0 0 3px rgba(36,115,232,.09); }
.check-card.sick:has(input:checked) { border-color: var(--danger); background: #fff1f2; box-shadow: 0 0 0 3px rgba(201,54,69,.08); }
.check-card input { width: 18px; height: 18px; margin-top: 2px; flex: 0 0 auto; }
.check-card span { display: grid; gap: 3px; }
.check-card small { color: var(--muted); font-weight: 500; }
.required-note { color: var(--danger); font-style: normal; font-weight: 750; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; border-top: 1px solid var(--line); padding-top: 20px; }
.two-column { display: grid; grid-template-columns: 1.12fr .88fr; gap: 24px; align-items: start; }
.stack-form { display: grid; gap: 20px; }
.stack-form select[size] { padding: 4px; margin-top: 4px; }
.stack-form option { padding: 9px 10px; border-radius: 6px; }
.directory-hint { color: var(--muted); font-weight: 500; min-height: 18px; }
.compact-grid { grid-template-columns: 1fr 1fr; }

.ai-mode { display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 15px 17px; border: 1px solid #c8d9f1; border-radius: 12px; background: linear-gradient(100deg, #f5f9ff, #fbf8ff); }
.ai-mode > div { display: flex; align-items: center; gap: 12px; }
.ai-mode > div > div { display: grid; gap: 3px; }
.ai-mode small { color: var(--muted); font-weight: 500; line-height: 1.35; }
.ai-spark { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, #2473e8, #764ccf); color: white; font-size: 20px; box-shadow: 0 7px 18px rgba(70,78,190,.22); }
.mode-switch { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 8px !important; white-space: nowrap; }
.mode-switch > span { color: var(--muted); font-size: 12px; }
.mode-switch input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.mode-switch i { position: relative; width: 46px; height: 25px; border-radius: 999px; background: #b9c2d0; cursor: pointer; transition: .18s ease; }
.mode-switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 19px; height: 19px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(23,35,62,.25); transition: .18s ease; }
.mode-switch input:checked + i { background: linear-gradient(90deg, var(--blue), #744bc8); }
.mode-switch input:checked + i::after { transform: translateX(21px); }
.mode-switch input:focus-visible + i { outline: 3px solid rgba(36,115,232,.22); outline-offset: 2px; }
.ai-text-field { position: relative; }
.ai-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; padding: 10px 12px; margin-top: -2px; border: 1px solid #d6dded; border-radius: 9px; background: #f7f9fd; }
.ai-toolbar[hidden] { display: none !important; }
.ai-toolbar small { flex: 1 1 260px; color: var(--muted); font-weight: 500; line-height: 1.35; }
.ai-original { flex: 1 0 100%; display: grid; gap: 5px; margin-top: 3px; padding: 11px 12px; border-left: 3px solid #8c6bd1; border-radius: 0 8px 8px 0; background: white; color: #4c566a; font-size: 12px; font-weight: 500; line-height: 1.45; }
.ai-original[hidden] { display: none !important; }
.ai-original strong { color: #6546b1; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.button.ai-button { min-height: 36px; padding: 7px 12px; color: white; background: linear-gradient(100deg, #2473e8, #6d4bc2); font-size: 13px; }
.ai-confirmation { display: flex !important; grid-template-columns: none !important; align-items: flex-start; gap: 12px !important; padding: 16px; border: 1px solid #c6aef0; border-radius: 11px; background: #f8f4ff; cursor: pointer; }
.ai-confirmation[hidden] { display: none !important; }
.ai-confirmation:has(input:checked) { border-color: var(--success); background: #edf9f4; }
.ai-confirmation input { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 2px; }
.ai-confirmation > span { display: grid; gap: 4px; }
.ai-confirmation small { color: var(--muted); font-weight: 500; line-height: 1.4; }
.ai-reviewed-badge { display: inline-flex; align-items: center; width: fit-content; margin-top: 10px; padding: 5px 8px; border-radius: 7px; background: #f0e9ff; color: #6241aa; font-size: 11px; font-weight: 750; }

.test-mode-switch { margin-left: auto; display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 7px 0; }
.test-mode-switch > span { display: grid; gap: 1px; text-align: right; }
.test-mode-switch strong { color: var(--ink); font-size: 13px; }
.test-mode-switch small { color: var(--muted); font-size: 11px; }
.test-mode-switch input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.test-mode-switch i { position: relative; width: 44px; height: 24px; border-radius: 999px; background: #cbd2dc; transition: .18s ease; box-shadow: inset 0 0 0 1px rgba(23,35,62,.08); }
.test-mode-switch i::after { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: white; box-shadow: 0 2px 5px rgba(23,35,62,.26); transition: .18s ease; }
.test-mode-switch input:checked + i { background: var(--blue); }
.test-mode-switch input:checked + i::after { transform: translateX(20px); }
.test-mode-switch input:focus-visible + i { outline: 3px solid rgba(36,115,232,.24); outline-offset: 2px; }
.test-mode-banner { margin-bottom: 22px; padding: 15px 18px; border: 1px solid #9fc2f5; border-radius: 12px; background: linear-gradient(100deg, #eef5ff, #f7fbff); display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.test-mode-banner > div { display: flex; align-items: flex-start; gap: 11px; }
.test-mode-banner > div > div { display: grid; gap: 3px; }
.test-mode-banner small { color: #50627d; line-height: 1.35; }
.test-mode-dot { width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 5px rgba(36,115,232,.12); flex: 0 0 auto; }
.test-mode-banner label { display: grid; gap: 5px; min-width: min(360px, 42%); color: #3d475a; font-size: 11px; font-weight: 750; }

.role-management { margin-top: 24px; }
.role-admin-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 28px; align-items: start; }
.role-form { padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: #fafbfc; }
.role-choice-grid { margin: 0; padding: 0; border: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.role-choice-grid legend { grid-column: 1 / -1; margin-bottom: 1px; color: #3d475a; font-size: 13px; font-weight: 750; }
.role-choice { display: grid !important; grid-template-columns: auto auto 1fr !important; align-items: center; gap: 11px !important; min-height: 86px; padding: 14px; border: 1px solid #cdd5df; border-radius: 11px; background: white; cursor: pointer; }
.role-choice:has(input:checked) { border-color: var(--blue); background: #eff6ff; box-shadow: 0 0 0 3px rgba(36,115,232,.09); }
.role-choice input { width: 18px; height: 18px; }
.role-choice > span:last-child { display: grid; gap: 3px; }
.role-choice small { color: var(--muted); font-weight: 500; line-height: 1.35; }
.role-choice-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: #e5effd; color: var(--blue); font-weight: 850; }
.role-choice.examiner .role-choice-icon { background: #ece8ff; color: #6b4bc5; }
.role-choice.administrator { grid-column: 1 / -1; border-color: #e7d29d; background: #fffaf0; }
.role-choice.administrator:has(input:checked) { border-color: #b7791f; background: #fff5dc; box-shadow: 0 0 0 3px rgba(183,121,31,.1); }
.role-choice.administrator .role-choice-icon { background: #ffedbd; color: #8a5900; }
.role-form-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.role-form-footer small { color: var(--muted); line-height: 1.4; }
.role-form-footer .button { flex: 0 0 auto; }
.role-roster { min-width: 0; }
.role-roster h4 { margin: 0 0 10px; font-size: 13px; color: #3d475a; }
.role-person { display: flex; gap: 12px; align-items: flex-start; padding: 13px 0; border-top: 1px solid var(--line); }
.role-person:first-child { border-top: 0; }
.role-person-main { min-width: 0; display: grid; gap: 2px; }
.role-person-main > span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.role-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.role-tag { display: inline-flex; padding: 4px 7px; border-radius: 6px; background: #e8f1ff; color: #245d9f; font-size: 11px; font-weight: 750; }
.role-tag.examiner { background: #eeeaff; color: #6546b1; }
.role-tag.administrator { background: #fff0c9; color: #835600; }
.role-tag.signature { background: #e5f7f0; color: var(--success); }
.role-tag.signature.missing { background: #f1f3f6; color: #6b7280; }
.role-empty { min-height: 120px; }
.signature-uploader { display: grid; gap: 14px; padding: 17px; border: 1px solid #cdd8e8; border-radius: 11px; background: linear-gradient(120deg, #f6f9fd, #fff); }
.signature-copy { display: flex; align-items: flex-start; gap: 11px; }
.signature-copy > div { display: grid; gap: 3px; }
.signature-copy small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.signature-icon { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; background: #e4edf9; font-size: 18px; }
.signature-editor { display: grid; grid-template-columns: minmax(180px, .8fr) minmax(210px, 1.2fr); gap: 14px; align-items: stretch; }
.signature-preview { min-height: 92px; display: grid; place-items: center; overflow: hidden; padding: 10px; border: 1px dashed #aeb9c9; border-radius: 9px; background: white; color: var(--muted); font-size: 12px; text-align: center; }
.signature-preview img { display: block; max-width: 100%; max-height: 74px; object-fit: contain; }
.signature-actions { display: flex; align-content: center; flex-wrap: wrap; gap: 8px; }
.signature-actions small { flex: 1 0 100%; color: var(--muted); line-height: 1.35; }
.apprentice-signature-card { margin-bottom: 20px; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 28px; align-items: center; background: linear-gradient(120deg, #f7faff, #fff); }
.apprentice-signature-copy { display: flex; align-items: flex-start; gap: 13px; }
.apprentice-signature-copy h3 { margin: 3px 0 6px; }
.apprentice-signature-copy p:not(.section-kicker) { max-width: 650px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.apprentice-signature-editor { display: grid; grid-template-columns: minmax(150px, .85fr) minmax(180px, 1.15fr); gap: 12px; align-items: stretch; }
.apprentice-signature-card.preview-only { border-color: #b9c9df; background: linear-gradient(120deg, #f3f7fc, #fff); }
.apprentice-signature-card.preview-only .signature-preview { background: #f5f7fa; }
.apprentice-signature-card.preview-only .signature-actions { opacity: .72; }
.report-row-actions { display: inline-flex; justify-content: flex-end; gap: 7px; white-space: nowrap; }

.backup-management { margin-top: 24px; }
.backup-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); gap: 18px; }
.backup-status-card, .backup-action-card { padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: #fafbfc; }
.backup-status-head { display: flex; align-items: flex-start; gap: 11px; }
.backup-status-head > div { display: grid; gap: 3px; }
.backup-status-head small { color: var(--muted); line-height: 1.4; }
.backup-state-dot { width: 10px; height: 10px; flex: 0 0 auto; margin-top: 5px; border-radius: 50%; background: #98a2b3; box-shadow: 0 0 0 5px rgba(152,162,179,.12); }
.backup-status-card.success .backup-state-dot { background: var(--success); box-shadow: 0 0 0 5px rgba(8,122,85,.12); }
.backup-status-card.running .backup-state-dot { background: var(--blue); box-shadow: 0 0 0 5px rgba(36,115,232,.12); animation: backup-pulse 1s ease-in-out infinite alternate; }
.backup-status-card.failed .backup-state-dot, .backup-status-card.local_only .backup-state-dot { background: var(--warning); box-shadow: 0 0 0 5px rgba(163,93,0,.12); }
.backup-status-card dl { margin: 16px 0 0; display: grid; gap: 9px; }
.backup-status-card dl div { display: grid; grid-template-columns: 105px minmax(0, 1fr); gap: 10px; }
.backup-status-card dt { color: var(--muted); font-size: 12px; font-weight: 700; }
.backup-status-card dd { min-width: 0; margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.backup-status-card code { color: #34445f; font-size: 12px; }
.backup-action-card { display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: start; background: linear-gradient(135deg, #f5f9ff, #faf8ff); }
.backup-action-card p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.backup-action-card .button { grid-column: 1 / -1; width: 100%; margin-top: 5px; }
.backup-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--navy); color: white; font-size: 20px; }
@keyframes backup-pulse { to { opacity: .45; } }

.external-layout { display: grid; grid-template-columns: minmax(300px, .72fr) minmax(0, 1.28fr); gap: 22px; align-items: start; }
.organization-list { display: grid; gap: 9px; }
.organization-card { display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: #fafbfc; }
.organization-card.home { border-color: #c2d8f7; background: #f3f8ff; }
.organization-mark { width: 38px; height: 38px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; color: white; background: linear-gradient(135deg, var(--navy), var(--blue)); font-weight: 850; }
.organization-copy { min-width: 0; flex: 1 1 auto; display: grid; gap: 2px; }
.organization-card span, .organization-card small { color: var(--muted); font-size: 12px; }
.organization-card small { color: #43658f; }
.organization-actions, .external-row-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.entity-action { width: 31px; height: 31px; flex: 0 0 auto; display: grid; place-items: center; padding: 7px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; transition: .16s ease; }
.entity-action svg { width: 15px; height: 15px; fill: currentColor; }
.entity-action.edit { color: var(--blue); background: #edf4ff; }
.entity-action.edit:hover { border-color: #b9d0f2; background: #e2edfd; transform: translateY(-1px); }
.entity-action.delete { color: var(--danger); background: #fff0f2; }
.entity-action.delete:hover { border-color: #f0bcc2; background: #fee4e8; transform: translateY(-1px); }
.entity-action:focus-visible { outline: 3px solid rgba(36,115,232,.2); outline-offset: 2px; }
.entity-action:disabled { opacity: .5; cursor: wait; transform: none; }
.inline-create-form { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.inline-create-form label { min-width: 0; }
.inline-create-form .button { margin-bottom: 1px; }
.invite-panel .stack-form { margin-top: 6px; }
.compact-roles[hidden], #externalApprenticeFields[hidden] { display: none !important; }
.invite-submit { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.invite-submit small { max-width: 480px; color: var(--muted); line-height: 1.45; }
.invitation-list { margin-top: 22px; }
.invitation-list td small { display: block; margin-top: 3px; color: var(--muted); }
.invite-status { display: inline-flex; padding: 5px 8px; border-radius: 7px; font-size: 11px; font-weight: 800; background: #fff2cc; color: #805900; }
.invite-status.accepted { background: #e5f7f0; color: var(--success); }
.invite-status.blocked { background: #feecee; color: var(--danger); }

.people-list { display: grid; gap: 0; }
.people-list article { display: flex; align-items: center; gap: 13px; padding: 14px 0; border-top: 1px solid var(--line); }
.people-list article:first-child { border-top: 0; padding-top: 0; }
.people-list .person-main { min-width: 0; flex: 1 1 auto; display: grid; gap: 2px; }
.person-name-row { min-width: 0; display: flex; align-items: center; gap: 7px; }
.person-name-row strong { min-width: 0; overflow-wrap: anywhere; }
.person-edit-button { width: 29px; height: 29px; flex: 0 0 auto; display: grid; place-items: center; padding: 6px; border: 1px solid transparent; border-radius: 8px; color: var(--blue); background: #edf4ff; cursor: pointer; transition: .16s ease; }
.person-edit-button:hover { border-color: #b9d0f2; background: #e2edfd; transform: translateY(-1px); }
.person-edit-button:focus-visible { outline: 3px solid rgba(36,115,232,.2); outline-offset: 2px; }
.person-edit-button svg { width: 15px; height: 15px; fill: currentColor; }
.people-list span, .people-list small { color: var(--muted); }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: #e6effc; color: var(--blue); display: grid; place-items: center; font-weight: 800; flex: 0 0 auto; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(9,16,31,.68); padding: 28px; display: grid; place-items: center; z-index: 50; }
.modal-backdrop[hidden] { display: none; }
.modal-card { width: min(820px, 100%); max-height: calc(100vh - 56px); overflow: auto; background: white; border-radius: 16px; box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; gap: 20px; padding: 26px 28px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 4px 0 6px; }
.modal-head p:last-child { margin: 0; color: var(--muted); }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: #f0f2f5; font-size: 25px; cursor: pointer; }
.apprentice-edit-card { width: min(680px, 100%); }
.apprentice-edit-body { padding: 24px 28px 6px; display: grid; gap: 24px; }
.external-edit-card { width: min(620px, 100%); }
.external-user-edit-card { width: min(760px, 100%); }
.external-edit-body { padding: 24px 28px 6px; display: grid; gap: 22px; }
.external-edit-body > label { display: grid; gap: 8px; color: #3d475a; font-size: 13px; font-weight: 700; }
.apprentice-identity { display: flex; align-items: center; gap: 13px; padding: 15px; border: 1px solid #dbe5f2; border-radius: 11px; background: #f6f9fd; }
.apprentice-identity > div:last-child { min-width: 0; display: grid; gap: 2px; }
.apprentice-identity span, .apprentice-identity small { color: var(--muted); overflow-wrap: anywhere; }
.apprentice-edit-note { display: grid; gap: 3px; padding: 13px 15px; border-left: 3px solid var(--blue); border-radius: 0 8px 8px 0; background: #f4f8fe; }
.apprentice-edit-note strong { font-size: 12px; color: #315c98; }
.apprentice-edit-note span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.report-body { padding: 4px 28px; }
.report-body section { padding: 20px 0; border-bottom: 1px solid var(--line); }
.report-body h3 { font-size: 14px; margin: 0 0 10px; }
.report-body p { margin: 0; line-height: 1.6; }
blockquote { margin: 10px 0 0; padding: 14px 16px; border-left: 3px solid var(--warning); background: #fff8ec; }
blockquote small { display: block; color: var(--muted); margin-top: 7px; }
.modal-actions { padding: 20px 28px 26px; display: flex; justify-content: flex-end; gap: 10px; }
.print-book-card { width: min(980px, 100%); }
.print-book-picker { padding: 18px 28px; border-bottom: 1px solid var(--line); background: #f7f9fc; }
.print-book-picker label { display: grid; gap: 7px; max-width: 560px; color: #3d475a; font-size: 13px; font-weight: 750; }
.print-book-body { padding: 28px; background: #eef1f5; }
.print-book-cover { min-height: 180px; display: flex; align-items: center; gap: 30px; padding: 30px; border-radius: 12px 12px 0 0; background: var(--navy); color: white; }
.print-book-cover img { width: 150px; }
.print-book-cover div { display: grid; gap: 5px; padding-left: 28px; border-left: 1px solid rgba(255,255,255,.25); }
.print-book-cover p, .print-book-cover h1, .print-book-cover span, .print-book-cover small { margin: 0; }
.print-book-cover p { color: #aebbd1; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.print-book-cover h1 { font-size: 29px; }
.print-book-cover small { color: #c4cede; margin-top: 8px; }
.print-report-list { background: white; }
.print-report { padding: 30px; border-bottom: 10px solid #eef1f5; }
.print-report > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 2px solid var(--navy); }
.print-report > header h2 { margin: 4px 0 0; font-size: 22px; }
.print-report section { padding: 18px 0; border-bottom: 1px solid var(--line); }
.print-report section h3 { margin: 0 0 8px; color: #3d475a; font-size: 13px; }
.print-report section p { margin: 0; line-height: 1.55; }
.report-signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 38px; padding-top: 42px; }
.report-signature { min-width: 0; display: grid; gap: 5px; }
.signature-line { height: 58px; display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid #7c8798; }
.report-signature img { display: block; max-width: 92%; max-height: 55px; object-fit: contain; transform: translateY(3px); }
.report-signature > span { color: var(--muted); font-size: 11px; }
.report-signature > small { color: #707b8d; font-size: 10px; line-height: 1.3; }

.toast { position: fixed; right: 24px; bottom: 24px; max-width: 430px; color: white; background: var(--success); padding: 14px 18px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; z-index: 80; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.alert { border-radius: 9px; padding: 13px 15px; line-height: 1.45; }
.alert.error { color: #9b1c2a; background: #feecee; border: 1px solid #fac9cf; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at 15% 15%, #2c4a7c, transparent 36%), linear-gradient(135deg, #111a30, #1d2e50); }
.auth-card { width: min(460px, 100%); border: 1px solid rgba(255,255,255,.13); border-radius: 20px; padding: 46px; color: white; background: rgba(18,29,52,.9); box-shadow: 0 28px 90px rgba(0,0,0,.3); }
.auth-logo { width: 178px; height: auto; margin-bottom: 44px; }
.auth-card h1 { font-size: 34px; letter-spacing: -.04em; margin: 6px 0 12px; }
.auth-copy { color: #c5cede; line-height: 1.55; margin: 0 0 26px; }
.auth-card .eyebrow { color: #7fb2ff; }
.auth-note { color: #98a8c2; font-size: 12px; text-align: center; margin: 16px 0 0; }
.auth-card .alert { margin-bottom: 18px; }
.auth-actions { display: grid; gap: 11px; }
.microsoft-button { min-height: 52px; width: 100%; background: white; color: #172033; border-radius: 9px; display: flex; align-items: center; justify-content: center; gap: 13px; text-decoration: none; font-weight: 750; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.microsoft-button:hover { background: #f3f6fb; }
.external-login-button { min-height: 58px; width: 100%; padding: 9px 15px; border: 1px solid rgba(255,255,255,.26); border-radius: 9px; display: flex; align-items: center; justify-content: center; gap: 12px; color: white; background: rgba(255,255,255,.06); text-decoration: none; font-weight: 750; transition: .16s ease; }
.external-login-button:hover { border-color: rgba(255,255,255,.48); background: rgba(255,255,255,.11); }
.external-login-button > span:last-child { display: grid; gap: 1px; }
.external-login-button small { color: #aebcd0; font-size: 10px; font-weight: 600; }
.external-login-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: #2d75dd; font-size: 17px; }
.ms-mark { display: grid; grid-template-columns: 9px 9px; gap: 2px; }
.ms-mark i { width: 9px; height: 9px; display: block; }
.ms-mark i:nth-child(1) { background: #f35325; }.ms-mark i:nth-child(2) { background: #81bc06; }.ms-mark i:nth-child(3) { background: #05a6f0; }.ms-mark i:nth-child(4) { background: #ffba08; }

@media (max-width: 800px) {
  .site-header { height: auto; min-height: 78px; padding-block: 14px; }
  .brand span, .user-meta { display: none; }
  .brand img { width: 126px; }
  .tab-bar { overflow-x: auto; gap: 20px; }
  .tab-list { gap: 20px; }
  .tab { min-height: 52px; white-space: nowrap; }
  .app-view { width: min(100% - 24px, 1180px); padding-top: 28px; }
  .two-column, .form-grid { grid-template-columns: 1fr; }
  .week-options { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .form-actions { flex-direction: column-reverse; }
  .page-heading { align-items: flex-start; }
  .panel { padding: 18px; }
  .auth-card { padding: 34px 26px; }
  .tab-bar { flex-wrap: wrap; padding-bottom: 8px; }
  .test-mode-switch { width: 100%; justify-content: flex-end; border-top: 1px solid var(--line); }
  .test-mode-banner, .role-form-footer { align-items: stretch; flex-direction: column; }
  .test-mode-banner label { min-width: 0; width: 100%; }
  .role-admin-grid, .role-choice-grid, .signature-editor, .apprentice-signature-card, .apprentice-signature-editor, .backup-grid, .external-layout { grid-template-columns: 1fr; }
  .inline-create-form { grid-template-columns: 1fr; }
  .invite-submit { align-items: stretch; flex-direction: column; }
  .ai-mode { align-items: stretch; flex-direction: column; }
  .mode-switch { justify-content: flex-end; }
}

@media print {
  @page { size: A4; margin: 14mm; }
  html, body { background: white !important; }
  .site-header, .tab-bar, .app-view, .modal-actions, .icon-button { display: none !important; }
  .modal-backdrop { position: static; padding: 0; background: white; display: block !important; }
  .modal-card { max-height: none; width: 100%; box-shadow: none; }
  .print-book-controls { display: none !important; }
  .print-book-body { padding: 0; background: white; }
  .print-book-cover { min-height: 42mm; border-radius: 0; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .print-report { padding: 10mm 0 0; border: 0; break-before: page; page-break-before: always; }
  .print-report section { break-inside: avoid; }
  .report-signatures { break-inside: avoid; }
  .report-signature img { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .status { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
