/* Polarium app design kit (docs/design-kit/DESIGN.md), applied to this
   plain HTML/CSS app: the kit's tokens and component rules, translated from
   its Tailwind classes. Fonts are self-hosted in css/fonts.css. */

:root {
  /* Official Polarium palette (POL_BRANDING_SKILL.md) — hex values are
     canonical, names are implementation aliases only. */
  --polarium-white: #ffffff;
  --polarium-black: #000000;
  --polarium-green: #023e27;
  --polarium-blue: #12326a;
  --polarium-red: #8d2828;
  --polarium-ochre: #af7b27;
  --polarium-yellow: #f5be33;
  --polarium-gray: #909090;
  --polarium-gray-light: #d3d3d3;
  --polarium-gray-pale: #f2f2f2;
  --polarium-green-pale: #d6ebe5;
  --polarium-blue-pale: #d8e0ef;
  --polarium-red-pale: #f2e4e4;
  --polarium-yellow-light: #ffecb3;

  /* Semantic roles, mapped onto the palette above per the skill */
  --color-bg: var(--polarium-gray-pale);
  --color-surface: var(--polarium-white);
  --color-border: var(--polarium-gray-light);       /* decorative dividers only */
  --color-border-control: var(--polarium-gray);      /* inputs/selects — needs 3:1 */
  --color-text: var(--polarium-black);
  /* Design kit §2: hierarchy comes from size and weight, never grey text —
     no grey in the palette passes contrast for small text. Kept as a token
     so existing "secondary text" rules still have one place to point at. */
  --color-text-muted: var(--polarium-black);
  --color-primary: var(--polarium-black);
  --color-primary-soft: var(--polarium-gray-pale);
  --color-accent: var(--polarium-blue);
  --color-focus: var(--polarium-blue);
  --color-success: var(--polarium-green);
  --color-success-soft: var(--polarium-green-pale);
  --color-danger: var(--polarium-red);
  --color-danger-soft: var(--polarium-red-pale);
  --color-warning-soft: var(--polarium-yellow-light);
  --color-warning-text: var(--polarium-black);       /* warning text stays black per the skill */
  --color-warning-mark: var(--polarium-ochre);       /* icon/dot accent only, never text */
  --sidebar-width: 256px;
  --page-gutter: clamp(16px, 2.5vw, 56px); /* side padding of every page, grows with the screen */
  --radius: 6px;          /* controls, banners — kit: small radii */
  --radius-panel: 10px;   /* white work panels (kit's .pth-panel) */
  --radius-pill: 999px;
  /* Kit's .pth-panel: a soft shadow plus a hairline ring instead of a border. */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.12);
  --font-body: "Plus Jakarta Sans Variable", "Plus Jakarta Sans", Arial, Helvetica, sans-serif;
  --font-display: var(--font-body);
  --font-technical: "JetBrains Mono Variable", "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
  font-synthesis: none;
}

* { box-sizing: border-box; }

/* A class that also sets `display` (most of ours do) has the same
   specificity as the browser's built-in [hidden] rule and can win the
   cascade depending on load order — so anywhere JS toggles `.hidden`,
   this makes sure hidden always actually means hidden. */
[hidden] { display: none !important; }

/* Focus is always visible (kit §9): the blue 2px outline. */
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  transition: opacity 0.25s ease;
}
.loading-overlay.is-hidden { opacity: 0; pointer-events: none; }
.loading-logo {
  width: 72px;
  height: 72px;
  animation: loading-pulse 1.1s ease-in-out infinite;
}
@keyframes loading-pulse {
  0%, 100% { opacity: 0.45; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1); }
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
}

a {
  color: var(--polarium-blue);
  text-decoration: underline;
  text-underline-offset: 2px;
}
a:hover { text-decoration-color: currentColor; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--polarium-green);
  color: var(--polarium-white);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--polarium-white);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  /* Clear space around the wordmark (kit §1): at least its "m" height. */
  padding: 10px 12px 28px;
}

.sidebar .brand .brand-logo {
  height: 22px;
  width: auto;
  flex-shrink: 0;
  margin-right: 10px;
}
.sidebar .brand-app { padding-left: 12px; border-left: 1px solid rgba(255, 255, 255, 0.3); }

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--polarium-white);
  padding: 8px 10px;
  border-left: 3px solid transparent;
  border-radius: var(--radius);
  font-size: 14px;
  text-decoration: none;
}

.sidebar nav a:hover { background: rgba(255, 255, 255, 0.1); }
/* Active = white pill + yellow left bar + semibold, never colour alone (kit §6). */
.sidebar nav a.active {
  background: var(--polarium-white);
  border-left-color: var(--polarium-yellow);
  color: var(--polarium-black);
  font-weight: 600;
}

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar .sidebar-footer {
  margin-top: auto;
  font-size: 12px;
  color: var(--polarium-white);
  padding: 12px 10px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: 28px var(--page-gutter) 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h1 {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0;
  font-weight: 600;
}

.topbar .subtitle {
  font-size: 14px;
  margin-top: 4px;
  max-width: 42rem;
}

/* Pages fill whatever screen they're on — no fixed max width — with side
   padding that grows with it, so a widescreen shows more columns and cards
   instead of a narrow strip with empty space beside it. */
.content {
  padding: 24px var(--page-gutter) 60px;
  width: 100%;
  /* .content is a flex item of .main's column layout, so it defaults to
     min-width: auto — without this, a wide descendant stretches the whole
     page instead of scrolling inside its own overflow-x: auto wrapper. */
  min-width: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--color-text);
  background: var(--color-surface);
  color: var(--color-text);
  height: 36px;
  padding: 0 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn:hover { background: var(--polarium-gray-pale); }

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

.btn-primary:hover, .btn-danger:hover { opacity: 0.85; }

.btn-danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: #fff;
}


.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.card {
  background: var(--color-surface);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: 20px; }

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header h2 { font-family: var(--font-display); font-size: 16px; margin: 0; font-weight: 600; }
.card-header p { margin: 4px 0 0; font-size: 13px; }

.card-body { padding: 20px; }

/* Collapsible card (<details class="card card-collapsible">) — the header
   is the toggle; it only gets its divider line while the card is open. */
.card-collapsible > summary { cursor: pointer; list-style: none; }
.card-collapsible > summary::-webkit-details-marker { display: none; }
.card-collapsible:not([open]) > summary { border-bottom: 0; }
.card-header-aside { display: flex; align-items: center; gap: 12px; }
.card-chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
.card-collapsible[open] > summary .card-chevron { transform: rotate(45deg); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 220px;
  position: relative;
}

.search-input input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius);
  font-size: 14px;
  background: #fff url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" stroke="%23000000" stroke-width="1.6"><circle cx="6.5" cy="6.5" r="5"/><line x1="10.2" y1="10.2" x2="14.5" y2="14.5"/></svg>') no-repeat 10px center;
}

select, input[type="text"], input[type="date"], input[type="tel"], input[type="email"], input[type="number"], textarea {
  font-family: inherit;
  font-size: 14px;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--color-border-control);
  border-radius: var(--radius);
  background: #fff;
  color: var(--color-text);
  width: 100%;
}

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

input[readonly] {
  background: var(--color-bg);
  color: var(--color-text-muted);
  cursor: default;
}
input[readonly]:focus {
  outline: none;
  border-color: var(--color-border-control);
}

.combobox { position: relative; }
.combobox input[type="text"] { padding-right: 32px; }
.combobox-clear {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
}
.combobox-clear:hover { background: var(--polarium-gray-pale); color: var(--color-text); }

.combobox-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 260px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.combobox-option {
  padding: 9px 12px;
  font-size: 14px;
  cursor: pointer;
}
.combobox-option .sub { display: block; font-size: 12px; color: var(--color-text-muted); }
.combobox-option:hover, .combobox-option.is-active { background: var(--color-primary-soft); }
.combobox-empty { padding: 9px 12px; font-size: 13px; color: var(--color-text-muted); }

#table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left;
  font-family: var(--font-display);
  font-size: 13px;
  background: var(--polarium-gray-pale);
  padding: 8px 12px;
  font-weight: 500;
}
tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
tbody tr:hover { background: var(--polarium-gray-pale); }
/* Rows open from anywhere (kit §7) — see enableRowLinks() in js/utils.js. */
tr[data-href] { cursor: pointer; }
tbody tr:last-child td { border-bottom: none; }

.cell-truncate {
  max-width: clamp(190px, 16vw, 420px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-cell > div { min-width: 0; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; flex-shrink: 0;
  color: var(--polarium-black);
}
.user-cell .name { font-weight: 600; font-size: 14px; }
.user-cell .name a, .org-name a { color: inherit; text-decoration: none; }
.user-cell .name a:hover, .org-name a:hover { text-decoration: underline; }
.user-cell .sub { font-size: 12.5px; color: var(--color-text-muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; }
.badge-active { background: var(--color-success-soft); color: var(--color-success); }
.badge-active .badge-dot { background: var(--color-success); }
.badge-inactive { background: var(--color-warning-soft); color: var(--color-warning-text); }
.badge-inactive .badge-dot { background: var(--color-warning-mark); }
.badge-disabled { background: var(--color-danger-soft); color: var(--color-danger); }
.badge-disabled .badge-dot { background: var(--color-danger); }
.badge-neutral { background: var(--polarium-gray-pale); color: var(--polarium-black); }
.badge-neutral .badge-dot { background: var(--polarium-gray); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning-text); }

.empty-state {
  padding: 24px 16px;
  border: 1px dashed var(--color-border-control);
  border-radius: var(--radius);
  font-size: 14px;
}

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

.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: var(--color-text); }
.hint { font-size: 12px; color: var(--color-text-muted); }
.field .error { font-size: 12px; color: var(--color-danger); }
.field.has-error input, .field.has-error select { border-color: var(--color-danger); }

.section-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 4px;
}

/* Admin settings — editable option lists (e.g. New employee template) */
.option-field { padding: 18px 0; border-bottom: 1px solid var(--color-border); }
.option-field:first-child { padding-top: 0; }
.option-field:last-child { border-bottom: none; padding-bottom: 0; }
.option-field .section-title { margin-bottom: 10px; }
.option-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.option-list:empty::after {
  content: "No options yet — add one below.";
  font-size: 13px;
  color: var(--color-text-muted);
}
.option-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  background: var(--color-surface);
}
.option-chip .option-remove {
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 50%;
}
.option-chip .option-remove:hover { background: var(--polarium-gray-pale); color: var(--color-danger); }
.option-add { display: flex; gap: 8px; max-width: 420px; }
.option-add input { flex: 1; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.banner {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.banner-info { background: var(--polarium-blue-pale); color: var(--polarium-blue); }
.banner-error { background: var(--color-danger-soft); color: var(--color-danger); }
.banner-warning { background: var(--color-warning-soft); color: var(--color-warning-text); }
.banner-success { background: var(--color-success-soft); color: var(--color-success); }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 14px 24px;
}
.detail-item .label { font-size: 12px; color: var(--color-text-muted); margin-bottom: 3px; }
.detail-item .value { font-size: 14px; font-weight: 500; }
.mono { font-family: var(--font-technical); font-size: 13px; }

.breadcrumb {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}
.breadcrumb a { color: var(--color-text-muted); }

.profile-header {
  display: flex;
  align-items: center;
  gap: 16px;
}
.profile-header .avatar { width: 52px; height: 52px; font-size: 17px; }
.profile-header h1 { margin: 0; font-size: 20px; }
.profile-header .sub { color: var(--color-text-muted); font-size: 13.5px; margin-top: 2px; }

.inline-flex { display: inline-flex; align-items: center; gap: 8px; }

/* "?" button, fixed bottom-right on every page (injected by setupHelpButton()
   in js/roles.js), linking to help.html. Below .modal-overlay/.loading-overlay
   so it never sits on top of a dialog or the initial load screen. */
.help-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--polarium-blue);
  color: var(--polarium-white);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow-md);
}
.help-fab:hover { background: var(--polarium-green); }
.help-fab:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

/* User guide (help.html) */
.role-list, .guide-list { margin: 0; padding-left: 20px; }
.role-list li, .guide-list li { margin-bottom: 10px; line-height: 1.5; }
.role-list li:last-child, .guide-list li:last-child { margin-bottom: 0; }
.guide-shot {
  margin-top: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  background: var(--color-bg);
}
.guide-shot img { display: block; width: 100%; height: auto; }

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

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.doc-modal { max-width: 720px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px;
  background: var(--color-primary-soft);
  border-bottom: 1px solid var(--color-border);
}
.modal-header-info { display: flex; align-items: center; gap: 14px; min-width: 0; }
.modal-avatar { width: 42px; height: 42px; font-size: 14px; }
.modal-header h2 { font-family: var(--font-display); margin: 0; font-size: 16px; }
.modal-subtitle { margin: 3px 0 0; font-size: 13px; color: var(--color-text-muted); }

.modal-close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}
.modal-close:hover { background: rgba(0, 0, 0, 0.08); color: var(--color-text); }

.modal-body {
  padding: 22px 24px 24px;
  overflow-y: auto;
}

.doc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  max-height: 320px;
  overflow-y: auto;
}

.doc-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-panel);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.doc-item:hover { border-color: var(--color-primary); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06); }
.doc-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--color-primary-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.doc-info { flex: 1; min-width: 0; }
.doc-name-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.doc-name {
  font-size: 13.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.doc-meta { font-size: 12px; color: var(--color-text-muted); }
.doc-actions { display: flex; gap: 6px; flex-shrink: 0; }

.doc-upload-row {
  border-top: 1px solid var(--color-border);
  padding-top: 18px;
  display: flex;
  gap: 24px;
}
.doc-upload {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.upload-btn { cursor: pointer; }
.upload-btn.is-busy { opacity: 0.6; pointer-events: none; }

/* Document preview lightbox */
.preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 120;
}

.preview-box {
  background: var(--color-surface);
  border-radius: var(--radius-panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  width: 100%;
  max-width: 880px;
  height: min(85vh, 900px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
  font-weight: 600;
}
.preview-header span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.preview-body {
  flex: 1;
  overflow: auto;
  background: var(--polarium-gray-pale);
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-body iframe { width: 100%; height: 100%; border: none; }
.preview-body img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Delete confirmation dialog */
.confirm-modal { max-width: 380px; }
.confirm-body { text-align: center; padding: 28px 24px 24px; }
.confirm-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-danger-soft);
  color: var(--color-danger);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin: 0 auto 14px;
}
.confirm-body h3 { margin: 0 0 6px; font-size: 16px; }
.confirm-body p { margin: 0; }
.confirm-actions { display: flex; justify-content: center; gap: 10px; margin-top: 22px; }
#confirm-overlay { z-index: 130; }

/* Org chart — a "focus" view: the manager chain as breadcrumbs, the
   manager above, the person in focus, and their direct reports as a grid
   of cards below. Clicking any card moves the focus to that person. */
.org-chart-wrap { padding: 4px 0 8px; }

.org-crumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
  font-size: 13px;
}
.org-crumbs li + li::before { content: "›"; margin-right: 6px; }
.org-crumbs li[aria-current] { font-weight: 600; }
.org-crumb {
  padding: 2px 4px;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--color-accent);
  font: inherit;
  cursor: pointer;
}
.org-crumb:hover { text-decoration: underline; }
.org-crumb-note { font-style: italic; }

.org-stage { display: flex; flex-direction: column; align-items: center; }
.org-line { width: 2px; height: 22px; background: var(--color-border-control); }

/* Any card that moves the focus. Plain <button>, so it's reachable and
   usable from the keyboard. */
.org-person {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease;
}
.org-person:hover { border-color: var(--polarium-green); transform: translateY(-1px); }
.org-person:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.org-manager { width: 100%; max-width: 340px; }
.org-person-compact { padding: 8px 12px; }

.org-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.org-name { font-weight: 600; font-size: 14px; }
.org-sub { font-size: 12.5px; color: var(--color-text-muted); }
.org-count { margin-top: 4px; font-size: 12.5px; font-weight: 600; color: var(--polarium-green); }
.org-arrow { font-size: 15px; line-height: 1; }

/* The person in focus: larger, and marked with the kit's yellow accent bar. */
.org-focus-card {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 520px;
  padding: 18px 20px;
  border-left: 4px solid var(--polarium-yellow);
  border-radius: var(--radius-panel);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
}
.org-focus-card .org-text { flex: 1; }
.org-focus-name { margin: 0; font-size: 18px; font-weight: 700; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }

.org-person-inactive { border-style: dashed; border-color: var(--color-border-control); box-shadow: none; }
.org-focus-card.org-person-inactive { border-left-style: solid; }

.org-reports { width: 100%; }
.org-reports-title { margin: 0 0 12px; font-size: 14px; font-weight: 600; text-align: center; }
/* Cards keep a readable width and the rows are centred under the person
   in focus, however wide the screen is. */
.org-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 280px));
  justify-content: center;
  gap: 12px;
}
.org-none { margin: 16px 0 0; font-size: 13px; }

.org-unattached { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--color-border); }
.org-unattached > summary { cursor: pointer; font-weight: 600; }
.org-unattached .hint { margin: 6px 0 12px; }

@media (max-width: 720px) {
  .org-focus-card { flex-wrap: wrap; padding: 16px; }
  .org-focus-card .btn { width: 100%; justify-content: center; }
}

.checkbox-label { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }

/* Org chart's Departments filter: an anchored checklist panel, same
   positioning recipe as .combobox-results. */
.dept-filter { position: relative; }
.dept-filter-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  min-width: 240px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 10px 12px;
}
.dept-filter-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}
.dept-filter-actions button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-accent);
  cursor: pointer;
}
.dept-filter-actions button:hover { text-decoration: underline; }
.dept-filter-panel .checkbox-label { display: flex; padding: 4px 0; }
.dept-filter .org-toggle-chevron {
  width: 6px;
  height: 6px;
  margin-left: 2px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
}

/* Admin settings → Assign direct reports: a scrollable tick list. */
/* Single pickers don't need the full width of a wide screen. */
#org-root-select, #reports-manager-combobox { max-width: 560px; }

/* Grows into several columns on a wide screen, and taller on a tall one. */
.reports-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  align-content: start;
  max-height: clamp(440px, 60vh, 900px);
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.reports-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
}
.reports-item:last-child { border-bottom: 0; }
.reports-item:hover { background: var(--polarium-gray-pale); }
.reports-item input { margin-top: 3px; }
.reports-item.is-disabled { cursor: not-allowed; }
.reports-item.is-disabled .reports-name { text-decoration: line-through; }
.reports-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.reports-name { font-weight: 600; font-size: 14px; }
.reports-sub { font-size: 12.5px; }
.reports-list .empty-state { margin: 12px; }
.reports-summary { margin-right: auto; align-self: center; font-size: 13.5px; }

/* Phones and tablets (design kit §6): a slim top bar with a menu button
   opens the sidebar as a drawer — see setupMobileMenu() in js/roles.js. */
.mobile-bar, .menu-backdrop { display: none; }

/* Profile pages (user detail, My profile) and the user form: on a wide
   screen the section cards sit side by side instead of one long column.
   Banners, the form's Save/Cancel row and anything else that isn't a card
   still span the full width. */
@media (min-width: 1400px) {
  #detail-content, #user-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    align-items: start;
  }
  #detail-content > :not(.card), #user-form > :not(.card) { grid-column: 1 / -1; }
  #detail-content > :empty { display: none; }
  #detail-content > .card + .card, #user-form > .card + .card { margin-top: 0; }
}
@media (min-width: 1400px) {
  /* Admin settings → Field options: the option lists side by side. */
  #options-sections {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 8px 40px;
  }
  #options-sections .option-field { padding: 10px 0; border-bottom: 0; }
}
@media (min-width: 2200px) {
  #detail-content, #user-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1023px) {
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--polarium-green);
    color: var(--polarium-white);
    position: sticky;
    top: 0;
    z-index: 40;
  }
  .mobile-menu-btn {
    display: inline-flex;
    padding: 6px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: inherit;
    cursor: pointer;
  }
  .mobile-menu-btn:hover { background: rgba(255, 255, 255, 0.1); }
  .mobile-bar-logo { height: 18px; width: auto; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .menu-open .sidebar { transform: none; }
  .menu-open .menu-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.4);
  }

  .topbar { padding-top: 20px; }
  .content { padding-top: 16px; padding-bottom: 48px; }
}

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .topbar h1 { font-size: 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .card-header, .card-body { padding-left: 16px; padding-right: 16px; }
  /* Wide tables scroll inside their own wrapper, never the page (kit §6). */
  .card-body:has(> table), .card-body:has(> #table-wrap) { overflow-x: auto; }
}
