:root {
  color-scheme: light;
  --canvas: #f7f7fa;
  --surface: #fff;
  --ink: #050038;
  --muted: #56556c;
  --line: #dcdce5;
  --field-line: #858398;
  --accent: #3655e8;
  --accent-hover: #2943bd;
  --accent-pressed: #21379d;
  --accent-soft: #edf0ff;
  --brand-yellow: #ffdd33;
  --yellow-line: #8d7413;
  --success: #1e654c;
  --success-bg: #eaf5ef;
  --warning: #795000;
  --warning-bg: #fff5d6;
  --danger: #ac263f;
  --danger-hover: #8b1d33;
  --danger-bg: #fdeef1;
  --neutral-bg: #ededf3;
  --avatar-bg: #e8deff;
  --avatar-ink: #3e2869;
  --radius-control: .5rem;
  --radius-panel: .75rem;
  --control-height: 2.75rem;
  --menu-shadow: 0 4px 16px #05003814;
  color: var(--ink);
  background: var(--canvas);
  font: 100%/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3, dd, legend, .section-intro, .notice { overflow-wrap: anywhere; }
h1 { font-size: 1.75rem; line-height: 2.25rem; letter-spacing: -.025em; }
h2 { font-size: 1.25rem; line-height: 1.75rem; font-weight: 650; }
h3 { font-size: 1rem; line-height: 1.5rem; font-weight: 650; }
a { color: var(--accent); text-underline-offset: .18em; }
a:hover { color: var(--accent-hover); }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }

.workspace {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100svh;
}
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 2rem 1rem 1.5rem;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.product-name {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: .5rem;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: .065em;
}
.sidebar > .product-name { margin-inline: .75rem; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 2rem;
  height: 2rem;
  border-radius: .375rem;
  border: 1px solid var(--yellow-line);
  background: var(--brand-yellow);
  color: var(--ink);
  font-size: 1.125rem;
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0;
}
.sidebar-menu {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}
.sidebar nav { display: grid; gap: .25rem; }
.nav-link {
  display: flex;
  align-items: center;
  min-height: var(--control-height);
  padding: .625rem .75rem;
  border-left: 3px solid transparent;
  border-radius: var(--radius-control);
  color: var(--muted);
  font-size: .875rem;
  line-height: 1.25rem;
  font-weight: 600;
  text-decoration: none;
}
.nav-link:hover { background: var(--canvas); color: var(--ink); }
.nav-link[aria-current] {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.session {
  display: grid;
  justify-items: start;
  margin-top: auto;
  padding: 1rem .75rem 0;
  border-top: 1px solid var(--line);
  font-size: .875rem;
  color: var(--muted);
}
.session button {
  min-height: var(--control-height);
  padding: 0;
  border: 0;
  color: var(--accent);
  background: transparent;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: .18em;
  cursor: pointer;
}
.session button:hover { color: var(--accent-hover); }
.content {
  width: 100%;
  min-width: 0;
  max-width: 90rem;
  margin-inline: auto;
  padding: 2rem;
}
.menu-close { align-self: flex-start; }

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .5rem;
  min-height: var(--control-height);
  max-width: 100%;
  padding: .625rem 1rem;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
  font-size: .875rem;
  line-height: 1.25rem;
  font-weight: 650;
  text-decoration: none;
  text-align: center;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: background-color 120ms, border-color 120ms, color 120ms;
}
.button:hover { background: #f0f0f7; color: var(--ink); }
.button:active { background: #e5e5f0; }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button.primary:active { background: var(--accent-pressed); border-color: var(--accent-pressed); }
.button.danger { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.button.danger:hover, .button.danger:active { background: var(--danger-hover); border-color: var(--danger-hover); }
.button:disabled { background: var(--neutral-bg); border-color: var(--line); color: var(--muted); cursor: not-allowed; }

label {
  display: block;
  margin-bottom: .5rem;
  font-size: .875rem;
  line-height: 1.25rem;
  font-weight: 650;
}
input:not([type="hidden"], [type="checkbox"], [type="radio"]), select, textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: var(--control-height);
  padding: .5625rem .75rem;
  border: 1px solid var(--field-line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
textarea { resize: vertical; }
input[type="checkbox"], input[type="radio"] {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--accent);
}
input:not([type="hidden"])[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] {
  border-color: var(--danger);
}
input:not([type="hidden"]):disabled, select:disabled, textarea:disabled {
  background: var(--neutral-bg);
  color: var(--muted);
}
input[type="file"] { overflow: hidden; }
input::file-selector-button {
  margin-right: .5rem;
  padding: .25rem .5rem;
  border: 1px solid var(--field-line);
  border-radius: .25rem;
  background: var(--canvas);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.toolbar, .actions, .contact-actions, .list-nav, .pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
}
.toolbar { justify-content: space-between; gap: 1rem; }
.toolbar > *, .actions > *, .profile-layout > * { min-width: 0; }
.actions { margin-top: 1.5rem; }
.panel { border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); }
.person-panel { max-width: 45rem; margin-top: 1.5rem; padding: 1.5rem; }
form.person-panel > div + div { margin-top: 1rem; }
form.person-panel > :is(p, input, select, textarea) + label { margin-top: 1rem; }
form.person-panel > :is(p, ul) + :is(p, input, select) { margin-top: .5rem; }
form.person-panel > .helptext, .form-grid .helptext { margin-block: .25rem .5rem; }
dt, .help-text, .helptext, .section-intro, .empty { color: var(--muted); }
dt, .help-text, .helptext { font-size: .875rem; line-height: 1.25rem; }
dd { margin: .25rem 0 1rem; }
.help-text { margin-top: .5rem; }
.empty-value, .section-intro { margin-block: 1rem; }
.notice {
  margin-bottom: 1rem;
  padding: .75rem 1rem;
  border-radius: var(--radius-control);
  background: var(--accent-soft);
  color: var(--ink);
}
.notice.success { background: var(--success-bg); color: var(--success); }
.notice.warning { background: var(--warning-bg); color: var(--warning); }
.handover-fields, #executive-conflict { margin-top: 1rem; }
.handover-fields .notice > * + * { margin-top: .5rem; }
.handover-fields summary { cursor: pointer; padding-block: .625rem; }
.handover-fields ul { padding-left: 1.25rem; }
.handover-outcome { margin: 1rem 0; padding: 0; border: 0; min-width: 0; }
.handover-outcome legend { font-weight: 650; padding: 0; }
.handover-outcome label { display: flex; align-items: center; gap: .5rem; min-height: var(--control-height); margin: 0; cursor: pointer; }
.handover-outcome #id_handover_outcome { display: flex; flex-wrap: wrap; gap: 0 1.25rem; }
.handover-plan { display: grid; gap: .75rem; }
.handover-plan .notice, .handover-fields > .notice { margin: 0; }
.notice.error { background: var(--danger-bg); color: var(--danger); }
.errorlist {
  padding-left: 1.25rem;
  margin: .25rem 0 .5rem;
  color: var(--danger);
  font-size: .875rem;
  line-height: 1.25rem;
}
.back-link, .list-nav a, .pagination a {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-height);
  font-size: .875rem;
}
.list-nav {
  margin: 1rem 0;
  border-bottom: 1px solid var(--line);
  gap: 1.5rem;
}
.list-nav a {
  padding: .5rem .125rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--muted);
  font-weight: 650;
  text-decoration: none;
}
.list-nav a:hover { color: var(--accent-hover); }
.list-nav a[aria-current] { border-bottom-color: var(--accent); color: var(--accent); }
.pagination { justify-content: flex-end; border-top: 1px solid var(--line); }
.pagination, .empty, .list-header { padding: 1rem 1.5rem; }
.pagination { color: var(--muted); font-size: .875rem; }
.list-header h2 { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.count {
  padding: .125rem .5rem;
  border-radius: .375rem;
  background: var(--neutral-bg);
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.125rem;
  font-variant-numeric: tabular-nums;
}
.search-form { max-width: 100%; }
.search-controls { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.search-controls input[type="search"] { width: auto; flex: 1 1 10rem; }
.search-controls a { display: inline-flex; align-items: center; min-height: var(--control-height); font-size: .875rem; }
table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: .875rem; line-height: 1.25rem; }
td, th {
  padding: .75rem 1.5rem;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}
td { height: 3.25rem; font-variant-numeric: tabular-nums; }
th { background: var(--canvas); color: var(--muted); font-size: .75rem; font-weight: 650; }
.panel > table:first-child thead th { border-top: 0; }
.panel > table:first-child thead th:first-child { border-top-left-radius: var(--radius-panel); }
.panel > table:first-child thead th:last-child { border-top-right-radius: var(--radius-panel); }
td a { font-weight: 650; }
.people-table th:first-child { width: 46%; }
.people-table th:last-child { width: 22%; }
.person-cell { display: flex; gap: .75rem; align-items: center; min-width: 0; }
.person-summary { display: grid; justify-items: start; min-width: 0; gap: .25rem; }
.list-avatar, .profile-photo { flex-shrink: 0; border-radius: 50%; background: var(--avatar-bg); color: var(--avatar-ink); }
.list-avatar, .profile-placeholder { display: grid; place-items: center; font-weight: 650; }
.list-avatar { width: 2.25rem; height: 2.25rem; font-size: .875rem; }
.access-status {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  max-width: 100%;
  padding: .125rem .5rem;
  border-radius: .375rem;
  background: var(--neutral-bg);
  color: var(--muted);
  font-size: .75rem;
  font-weight: 650;
  line-height: 1.125rem;
}
.access-status::before {
  content: "";
  flex: none;
  width: .375rem;
  height: .375rem;
  border-radius: 50%;
  background: currentColor;
}
.status-granted { background: var(--success-bg); color: var(--success); }
.status-pending { background: var(--accent-soft); color: var(--accent); }
.mobile-label { display: none; }

.profile-layout {
  display: grid;
  gap: 1rem;
  max-width: 54rem;
  margin-top: 1.5rem;
}
form.profile-layout { max-width: 45rem; }
.profile-section { padding: 1.5rem; min-width: 0; }
.profile-identity { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.profile-identity > div { min-width: 0; overflow-wrap: anywhere; }
.profile-identity p { color: var(--muted); }
.profile-photo { width: 6rem; height: 6rem; object-fit: cover; }
.profile-placeholder { font-size: 2.5rem; }
.detail-grid, .form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .75rem 1.5rem;
  margin-top: 1rem;
}
.detail-grid > div, .form-grid > div { min-width: 0; overflow-wrap: anywhere; }
.detail-grid dd { margin-bottom: .5rem; }
.profile-section h3 { margin-top: 1.5rem; }
.photo-field { margin-top: 1rem; }
.relative-card {
  min-width: 0;
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
}
.relative-card legend { padding: 0 .5rem; font-weight: 650; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; min-height: var(--control-height); margin: 1rem 0 0; }
.profile-layout > .actions { margin-top: 0; }
.contact-entry {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.contact-entry .help-text, .contact-entry .detail-grid { margin-top: .25rem; }
.contact-entry dd { margin-bottom: 0; }
.contact-actions { margin-top: 1rem; }
.contact-actions .help-text { flex-basis: 100%; margin: 0; font-weight: 650; }
.contact-pending-delete { border-style: dashed; border-color: var(--warning); background: var(--warning-bg); }
.contact-pending-delete .contact-delete-status { color: var(--warning); }

.standalone, .login {
  width: min(76rem, calc(100% - 4rem));
  margin: 2rem auto;
  border-radius: var(--radius-panel);
  border: 1px solid var(--line);
  background: var(--surface);
}
.standalone { display: grid; max-width: 45rem; gap: 1rem; padding: 2rem; }
.standalone .person-panel { margin: 0; padding: 0; border: 0; }
.login {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: min(43rem, calc(100svh - 4rem));
}
.login-hero {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2rem;
  padding: clamp(1.5rem, 4vw, 3rem);
  border-radius: var(--radius-panel) 0 0 var(--radius-panel);
  background: linear-gradient(180deg, #050038cd, #05003826 40%, #050038eb), url("facade-login.png") center / cover;
  color: var(--surface);
}
.login-hero p { max-width: 14ch; font-size: clamp(1.5rem, 3.5vw, 3rem); line-height: 1.1; letter-spacing: -.035em; font-weight: 700; }
.login-content { display: grid; align-items: center; justify-items: center; padding: clamp(1.5rem, 4vw, 4rem); }
.login-content form { width: min(100%, 23rem); min-width: 0; }
.login-content h1 { margin-bottom: 1.5rem; }
.login-content form > input:not([type="hidden"]) { margin-bottom: 1rem; }
.login-content button { width: 100%; margin-top: .5rem; }
.login-content .back-link { margin-top: .25rem; }

.form-dialog {
  width: min(30rem, calc(100% - 2rem));
  max-height: calc(100svh - 2rem);
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--menu-shadow);
  overflow: auto;
}
.form-dialog::backdrop, .sidebar-menu::backdrop { background: #05003866; }
.form-dialog p { margin-top: 1rem; }
.form-errors a { color: inherit; }
.form-errors ul { margin: .5rem 0 0; padding-left: 1.25rem; }
form[aria-busy="true"] button[aria-disabled="true"] { cursor: progress; }

@media (max-width: 1199px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: .5rem 1rem;
    padding: .75rem 1.5rem;
    border: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar > .product-name { margin: 0; }
  .sidebar-menu:not([popover]) { flex-basis: 100%; }
  .sidebar-menu[popover]:not(:popover-open) { display: none; }
  .sidebar-menu[popover]:popover-open {
    position: fixed;
    inset: .75rem .75rem auto auto;
    width: min(21rem, calc(100% - 1.5rem));
    max-height: calc(100svh - 1.5rem);
    margin: 0;
    padding: 1rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--line);
    border-radius: var(--radius-panel);
    box-shadow: var(--menu-shadow);
    background: var(--surface);
    color: var(--ink);
  }
  .sidebar-menu .session { margin-top: 0; }
  .content { padding: 1.5rem; }
}

@media (max-width: 767px) {
  h1 { font-size: 1.5rem; line-height: 2rem; }
  .sidebar { padding: .5rem 1rem; }
  .content { padding: 1rem; }
  .person-panel, .profile-section { padding: 1rem; }
  .toolbar > .button.primary { width: 100%; }
  .profile-layout, .person-panel { margin-top: 1rem; }
  .profile-photo { width: 4.5rem; height: 4.5rem; }
  .profile-identity { margin-bottom: 1rem; }
  .form-grid, .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .profile-section .actions { align-items: stretch; }
  .profile-section .actions > *, .profile-section .actions form .button { width: 100%; }
  .list-header, .pagination, .empty, .contact-entry { padding: 1rem; }
  .list-header { align-items: flex-start; flex-direction: column; gap: .75rem; }
  .search-form { width: 100%; }
  .search-controls input[type="search"] { flex-basis: min(9rem, 50%); }
  th, td { padding: .75rem 1rem; }

  .list-panel:has(> .people-table) { background: transparent; border: 0; }
  .list-panel:has(> .people-table) > :is(.list-header, .pagination) {
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-panel);
  }
  .list-panel:has(> .people-table) > .pagination { margin-top: .75rem; }
  .people-table { display: block; }
  .people-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .people-table tbody { display: grid; gap: .75rem; margin-top: .75rem; }
  .people-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: .75rem 1rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-panel);
    background: var(--surface);
  }
  .people-table td { display: block; height: auto; padding: 0; border: 0; }
  .people-table td:first-child { grid-column: 1 / -1; }
  .mobile-label {
    display: block;
    margin-bottom: .25rem;
    color: var(--muted);
    font-size: .75rem;
    line-height: 1.125rem;
  }
  .standalone, .login { width: calc(100% - 2rem); margin: 1rem auto; }
  .standalone, .form-dialog { padding: 1rem; }
  .login { grid-template-columns: minmax(0, 1fr); min-height: auto; }
  .login-hero { min-height: 12rem; padding: 1.5rem; border-radius: var(--radius-panel) var(--radius-panel) 0 0; }
  .login-content { padding: 1.5rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .button { transition: none; }
}
