/* =====================================================================
   The staff desk (/edit, /leadership): shell and shared pieces (e-*).
   Denser than the public pages: it's a working tool. Same paper, same
   inks, same rules; sheets (cards) only where something is filled in.
   ===================================================================== */
:root { --field: #ffffff; --e-side-w: 236px; }
:root[data-theme="dark"] { --field: #0f0f0e; }

body.e-mode { overflow-x: clip; }
body.e-mode main { padding-bottom: 0; }
.e-app { display: grid; grid-template-columns: var(--e-side-w) minmax(0, 1fr); min-height: calc(100vh - var(--bar-h) - 3px); font-size: .9375rem; }

/* ---------- sidebar ---------- */
.e-side { position: sticky; top: calc(var(--bar-h) + 3px); align-self: start; height: calc(100vh - var(--bar-h) - 3px); display: flex; flex-direction: column;
  border-right: 1px solid var(--rule); background: var(--paper); padding: 14px 12px 12px; overflow-y: auto; scrollbar-width: thin; }
.e-side-top { display: grid; gap: 10px; }
.e-menu { display: none; }
.e-search { position: relative; }
.e-search input { width: 100%; height: 36px; padding: 0 44px 0 10px; border-radius: var(--r); border: 1px solid var(--rule-2); background: var(--field); color: var(--ink); font: inherit; font-size: .875rem; outline: none; }
.e-search::after { content: "Ctrl K"; position: absolute; right: 8px; top: 9px; padding: 0 4px; font-family: var(--mono); font-size: .62rem; line-height: 18px; color: var(--muted); border: 1px solid var(--rule); border-radius: var(--r-sm); pointer-events: none; }
.e-search:focus-within::after { display: none; }
.e-search input::placeholder { color: var(--placeholder); }
.e-search input:focus { border-color: var(--ink-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sage) 28%, transparent); }
.e-search-list, .e-pick-list { display: none; position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40; background: var(--sheet);
  border: 1px solid var(--rule-2); border-radius: var(--r); padding: 4px; max-height: 380px; overflow-y: auto; box-shadow: var(--shadow); }
.e-search-list { width: 340px; }
.e-search-list.open, .e-pick-list.open { display: block; }
.e-search-label { padding: 8px 8px 4px; color: var(--muted); font-size: .75rem; }
.e-search-more { display: block; padding: 8px; color: var(--sage-ink); font-size: .8125rem; text-decoration: underline; text-underline-offset: 3px; }
.e-pick { position: relative; }
.e-pick-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--r-sm); cursor: pointer; }
.e-pick-item.hl, .e-pick-item:hover { background: var(--well); }
.e-who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.e-who .nm { font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.e-who .sub { margin-top: 0; color: var(--muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.e-nav { display: grid; gap: 1px; margin-top: 12px; }
.e-nav-label { margin: 14px 10px 4px; padding-top: 10px; border-top: 1px solid var(--rule); color: var(--muted); font-size: .75rem; letter-spacing: .02em; }
.e-nav a { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: var(--r-sm); color: var(--ink-2); line-height: 1.35; }
.e-nav a svg { display: none; }
.e-nav a:hover { background: var(--well); color: var(--ink); }
.e-nav a.on { background: var(--sheet); color: var(--ink); font-weight: 700; box-shadow: inset 3px 0 0 var(--sage), inset 0 0 0 1px var(--rule); }
.e-side-foot { margin-top: auto; padding: 12px 10px 2px; border-top: 1px solid var(--rule); display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: .8125rem; }
.e-side-foot > span:first-child { width: 100%; color: var(--ink); font-weight: 700; }
.e-side-foot a { color: var(--ink-2); padding: 3px 0; margin: -3px 0; }
.e-side-foot a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.e-side-foot .linkish { color: var(--ink-2); font-size: inherit; padding: 3px 0; margin: -3px 0; }
.e-side-foot .theme-sw { width: 100%; margin-top: 4px; }

.e-main { min-width: 0; padding: 24px clamp(18px, 2.6vw, 44px) 72px; }
.e-page { max-width: none; }
.e-empty { color: var(--muted); padding: 28px 2px; }
.e-muted { color: var(--muted); }

/* ---------- banners ---------- */
.e-banners { display: grid; gap: 8px; }
.e-banners:not(:empty) { margin-bottom: 18px; }
.e-banner { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--rule-2); border-left-width: 4px; border-radius: var(--r-sm); background: var(--sheet); color: var(--ink); }
.e-banner span { flex: 1; }
.e-banner.bad { border-color: var(--bad-line); border-left-color: var(--bad); background: var(--bad-wash); }
.e-banner.warn { border-color: var(--warn-line); border-left-color: var(--warn); background: var(--warn-wash); }
.e-banner.ok { border-color: color-mix(in srgb, var(--sage) 55%, transparent); border-left-color: var(--sage); background: var(--sage-wash); }
.e-banner.info { border-left-color: var(--info); }
.e-x { flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; margin: -5px -6px -5px 0; padding: 0; border: 0; border-radius: var(--r-sm); background: none; color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer; }
.e-x:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 7%, transparent); }

/* ---------- page heading, sheets, layout ---------- */
.e-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--rule); }
.e-head h1 { font-family: var(--serif); font-weight: 700; font-size: clamp(1.7rem, 2.4vw, 2.125rem); line-height: 1.05; letter-spacing: -0.01em; }
.e-head p { color: var(--muted); margin-top: 6px; font-size: .875rem; }
.e-card { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--r); padding: 16px 18px 18px; min-width: 0; }
.e-card + .e-card { margin-top: 14px; }
.e-card-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; font-weight: 700; font-size: .9375rem; color: var(--ink); }
.e-card-title small { color: var(--muted); font-weight: 400; font-size: .8125rem; }
.e-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.e-grid > .e-card + .e-card { margin-top: 0; }
@media (min-width: 1500px) { .e-grid { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); } }
.e-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.e-row.end { justify-content: flex-end; }
.e-sep { border: 0; border-top: 1px solid var(--rule); margin: 16px 0; }

/* ---------- forms ---------- */
.e-form { display: grid; gap: 14px; }
.e-fields { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.e-field { display: grid; gap: 5px; min-width: 0; }
.e-field > span:first-child, .e-label { color: var(--ink-2); font-size: .8125rem; }
.e-field input, .e-field select, .e-field textarea, .e-input {
  width: 100%; min-height: 38px; padding: 7px 10px; border-radius: var(--r); border: 1px solid var(--rule-2); background: var(--field); color: var(--ink); font: inherit; outline: none; }
.e-field select, select.e-input { padding-right: 28px; }
.e-field textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
.e-field input:focus, .e-field select:focus, .e-field textarea:focus, .e-input:focus { border-color: var(--ink-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sage) 28%, transparent); }
.e-field input[readonly], .e-field input:disabled, .e-field select:disabled, .e-field textarea:disabled, .e-input:disabled { color: var(--muted); background: var(--well); }
.e-field input.bad, .e-input.bad { border-color: var(--bad); }
.e-field input.warn { border-color: var(--warn); }
.e-hint { color: var(--muted); font-size: .8125rem; }
.e-hint.bad { color: var(--bad); } .e-hint.good { color: var(--sage-ink); } .e-hint.warn { color: var(--warn); }
.e-hint a { color: inherit; text-decoration: underline; font-weight: 700; }
.e-check { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.e-check input { width: 17px; height: 17px; accent-color: var(--sage); }
.e-seg { display: inline-flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--rule-2); border-radius: var(--r); background: var(--field); overflow: hidden; }
.e-seg button { border: 0; border-left: 1px solid var(--rule); background: none; color: var(--ink-2); padding: 6px 12px; font: inherit; font-size: .875rem; cursor: pointer; }
.e-seg button:first-child { border-left: 0; }
.e-seg button:hover { background: var(--well); color: var(--ink); }
.e-seg button.on { background: var(--sage-wash); color: var(--ink); font-weight: 700; box-shadow: inset 0 -2px 0 var(--sage); }

/* ---------- buttons ---------- */
.e-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 14px; border-radius: var(--r);
  border: 1px solid var(--rule-2); background: var(--sheet); color: var(--ink); font: inherit; font-size: .875rem; font-weight: 400; cursor: pointer; white-space: nowrap;
  transition: border-color .12s ease-out, background-color .12s ease-out; }
.e-btn:hover:not(:disabled) { border-color: var(--ink-2); }
.e-btn:disabled { opacity: .5; cursor: default; }
.e-btn.primary { background: var(--sage); border-color: var(--sage); color: var(--on-sage); font-weight: 700; }
.e-btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--sage) 86%, var(--ink)); border-color: color-mix(in srgb, var(--sage) 86%, var(--ink)); }
.e-btn.danger { border-color: var(--bad-line); color: var(--bad); }
.e-btn.danger:hover:not(:disabled) { border-color: var(--bad); }
.e-btn.danger.armed, .e-btn.danger.solid { background: var(--bad-solid); border-color: var(--bad-solid); color: #fff; font-weight: 700; }
.e-btn.armed { border-color: var(--warn); color: var(--warn); font-weight: 700; }
.e-btn.small { min-height: 28px; padding: 0 9px; font-size: .8125rem; }
.e-btn.ghost { background: none; border-color: transparent; color: var(--sage-ink); padding: 0 6px; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; }
.e-btn.ghost:hover:not(:disabled) { border-color: transparent; text-decoration-color: currentColor; }
.e-status { min-height: 0; font-size: .875rem; }
.e-status:not(:empty) { min-height: 1.3em; }
.e-status.err { color: var(--bad); } .e-status.ok { color: var(--sage-ink); }
.e-savebar { position: sticky; bottom: 0; z-index: 4; display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 16px; padding: 12px 0;
  background: var(--paper); border-top: 1px solid var(--rule); }
.e-savebar .e-status { margin-right: auto; }

/* ---------- labels, stamps, ids, photos ---------- */
.e-chip { display: inline-flex; align-items: center; gap: 5px; padding: 0 7px; border-radius: var(--r-sm); border: 1px solid var(--rule-2); color: var(--ink-2);
  font-size: .75rem; font-weight: 400; line-height: 1.65; white-space: nowrap; }
.e-chip .k { color: var(--muted); font-size: .7rem; }
.e-chip.ok { color: var(--sage-ink); border-color: color-mix(in srgb, var(--sage) 55%, transparent); background: var(--sage-wash); }
.e-chip.warn { color: var(--warn); border-color: var(--warn-line); background: var(--warn-wash); }
.e-chip.bad { color: var(--bad); border-color: var(--bad-line); background: var(--bad-wash); }
.e-chip.former { color: var(--former); border-color: color-mix(in srgb, var(--former) 40%, transparent); }
.e-chip.gold { color: var(--gold); border-color: var(--gold-line); background: var(--gold-wash); }
.e-chip.dmo { color: var(--dmo); border-color: var(--dmo-line); }
.e-chip.cpm { color: var(--cpm); border-color: var(--cpm-line); }
.e-chip.accent { color: var(--on-sage); background: var(--sage); border-color: var(--sage); font-weight: 700; }
.e-clr { display: inline-flex; min-width: 28px; justify-content: center; padding: 0 5px; border-radius: var(--r-sm); border: 1px solid var(--rule-2);
  font-family: var(--mono); font-size: .68rem; font-weight: 700; letter-spacing: .06em; line-height: 1.75; color: var(--t-lr); }
.e-clr-MR { color: var(--t-mr); border-color: color-mix(in srgb, var(--t-mr) 50%, transparent); }
.e-clr-HR { color: var(--t-hr); border-color: color-mix(in srgb, var(--t-hr) 50%, transparent); }
.e-clr-EX { color: var(--t-ex); border-color: color-mix(in srgb, var(--t-ex) 50%, transparent); }
.e-empid { display: inline-flex; flex-direction: column; align-items: flex-end; padding: 4px 9px 5px; border: 1px solid var(--rule-2); border-radius: var(--r-sm); background: var(--field); line-height: 1.2; }
.e-empid span { font-size: .66rem; color: var(--muted); }
.e-empid b { font-family: var(--mono); font-size: 1rem; letter-spacing: .08em; }
.e-empid.none b { color: var(--muted); font-size: .8rem; letter-spacing: 0; }
.e-tag { display: inline-flex; padding: 0 7px; border-radius: var(--r-sm); font-size: .72rem; font-weight: 700; line-height: 1.75; background: var(--well); color: var(--ink-2); }
.e-tag.c-gold { background: var(--gold-wash); color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold-line); }
.e-tag.c-red { background: var(--bad-wash); color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad-line); }
.e-tag.c-orange { background: #f6e3d2; color: #8d4613; box-shadow: inset 0 0 0 1px #e0b58c; }
.e-tag.c-green { background: var(--sage-wash); color: var(--sage-ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sage) 55%, transparent); }
.e-tag.c-teal { background: #dbeeea; color: #1f5f57; box-shadow: inset 0 0 0 1px #94c8c0; }
.e-tag.c-blue { background: var(--info-wash); color: var(--info); box-shadow: inset 0 0 0 1px var(--info-line); }
.e-tag.c-purple { background: var(--cpm-wash); color: var(--cpm); box-shadow: inset 0 0 0 1px var(--cpm-line); }
.e-tag.c-pink { background: #f5e0ea; color: #873059; box-shadow: inset 0 0 0 1px #dca7c1; }
:root[data-theme="dark"] .e-tag.c-orange { background: #3d2715; color: #f2b27a; box-shadow: none; }
:root[data-theme="dark"] .e-tag.c-teal { background: #163432; color: #7fd4cb; box-shadow: none; }
:root[data-theme="dark"] .e-tag.c-pink { background: #3d1c2c; color: #f0a1c5; box-shadow: none; }
.e-av { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 38px; height: 38px; border-radius: var(--r-sm); overflow: hidden;
  background: var(--well); border: 1px solid var(--rule); color: var(--muted); font-family: var(--mono); font-size: .7rem; letter-spacing: .02em; }
.e-av img { width: 100%; height: 100%; object-fit: cover; }
.e-av.xs { width: 28px; height: 28px; font-size: .62rem; }
.e-av.lg { width: 64px; height: 64px; font-size: 1rem; }

/* ---------- tabs ---------- */
.e-tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--rule); margin-bottom: 20px; }
.e-tabs::-webkit-scrollbar { display: none; }
.e-tabs button { position: relative; border: 0; background: none; color: var(--muted); padding: 9px 12px 11px; font: inherit; cursor: pointer; white-space: nowrap; }
.e-tabs button:hover { color: var(--ink); }
.e-tabs button.on { color: var(--ink); font-weight: 700; }
.e-tabs button.on::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px; background: var(--sage); }

/* ---------- tables: ledgers ---------- */
.e-tablewrap { overflow: auto; border: 1px solid var(--rule); border-radius: var(--r); background: var(--sheet); max-height: calc(100vh - var(--bar-h) - 210px); }
.e-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.e-table th { position: sticky; top: 0; z-index: 1; background: var(--sheet); text-align: left; font-weight: 700; color: var(--ink-2); padding: 9px 12px 8px; white-space: nowrap;
  font-size: .75rem; box-shadow: inset 0 -2px 0 var(--rule-ink); }
.e-table td { padding: 8px 12px; border-top: 1px solid var(--rule); vertical-align: middle; font-variant-numeric: tabular-nums; }
.e-table tbody tr:first-child td { border-top: 0; }
.e-table .num { text-align: right; }
.e-table tr.trow { cursor: pointer; }
.e-table tr.trow:hover td, .e-table tr.trow:focus td { background: var(--well); }
.e-table tr.trow:focus { outline: none; }
.e-table tr.trow:focus-visible td:first-child { box-shadow: inset 3px 0 0 var(--sage); }
.e-table td .sub { display: block; margin-top: 0; color: var(--muted); font-size: .78rem; }
.e-sort { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 3px 0; margin: -3px 0; }
.e-sort:hover { color: var(--ink); }
.e-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.e-toolbar .e-input { width: auto; min-width: 220px; }
.e-toolbar select.e-input { min-width: 0; }
.e-count { color: var(--muted); font-size: .8125rem; margin-left: auto; }
.e-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); margin-right: 6px; vertical-align: 1px; }
.e-dot.active { background: var(--sage); } .e-dot.partially { background: var(--warn); } .e-dot.inactive { background: var(--bad); } .e-dot.loa { background: var(--info); }
.e-dot.eligible { background: var(--dmo); }

/* ---------- figures, bars, lists ---------- */
.e-tiles { display: grid; gap: 0; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 18px; border-top: 2px solid var(--rule-ink); border-bottom: 1px solid var(--rule); }
/* page-wide figure rows stay on one line (no lone tile wrapping onto a second row) */
.e-tiles:not(.ac-tiles) { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.e-tile { position: relative; padding: 11px 16px 13px; border-left: 1px solid var(--rule); }
.e-tile:first-child { border-left: 0; padding-left: 0; }
.e-tile b { display: block; font-family: var(--serif); font-size: 1.875rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums lining-nums; }
.e-tile span { color: var(--muted); font-size: .8125rem; }
.e-tile.bad b { color: var(--bad); } .e-tile.warn b { color: var(--warn); } .e-tile.good b { color: var(--sage-ink); }
@media (max-width: 720px) {
  .e-tiles, .e-tiles:not(.ac-tiles) { grid-template-columns: 1fr 1fr; grid-auto-flow: row; }
  .e-tile:nth-child(odd) { border-left: 0; padding-left: 0; }
  .e-tile:nth-child(n+3) { border-top: 1px solid var(--rule); }
}
.e-bars { display: grid; grid-template-columns: minmax(0, 170px) 1fr 40px; gap: 7px 10px; align-items: center; font-size: .8125rem; }
.e-bars .t { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.e-bars .b { height: 8px; background: var(--well); overflow: hidden; }
.e-bars .b i { display: block; height: 100%; background: var(--sage); }
.e-bars .n { text-align: right; font-variant-numeric: tabular-nums; }
.e-list { display: grid; grid-template-columns: minmax(0, 1fr); }
.e-list > * { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-top: 1px solid var(--rule); }
.e-list > *:first-child { border-top: 0; }
.e-list button.e-li { width: 100%; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: var(--r-sm); }
.e-list button.e-li:hover, .e-list button.e-li.hl { background: var(--well); }
.e-list a.e-li { color: inherit; border-radius: var(--r-sm); }
.e-list a.e-li:hover { background: var(--well); }

/* ---------- dialogs ---------- */
.e-modal { position: fixed; inset: 0; z-index: 100; background: var(--scrim); display: flex; align-items: center; justify-content: center; padding: 16px; }
.e-modal-card { width: 100%; max-width: 380px; background: var(--sheet); border: 1px solid var(--rule-2); border-top: 3px solid var(--rule-ink); border-radius: var(--r); padding: 20px 22px; display: grid; gap: 12px; box-shadow: var(--shadow); }
.e-modal-card h2 { font-family: var(--serif); font-size: 1.375rem; font-weight: 700; }
.e-modal-card input { height: 40px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--rule-2); background: var(--field); color: var(--ink); font: inherit; }

/* ---------- person header (older screens) ---------- */
.e-phead { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 6px; }
.e-phead .who { flex: 1; min-width: 200px; }
.e-phead h1 { font-family: var(--serif); font-weight: 700; font-size: clamp(1.6rem, 3vw, 2.2rem); line-height: 1.05; }
.e-phead .handle { color: var(--muted); }
.e-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.e-former { display: inline-block; margin-bottom: 10px; padding: 1px 8px; border: 1px solid color-mix(in srgb, var(--former) 45%, transparent); border-radius: var(--r-sm);
  color: var(--former); font-size: .78rem; font-weight: 700; }

/* ---------- phones ---------- */
@media (max-width: 900px) {
  .e-app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .e-side { position: sticky; top: 0; z-index: 25; height: auto; flex-direction: column; padding: 10px var(--gutter); border-right: 0; border-bottom: 1px solid var(--rule); overflow: visible; }
  .e-side-top { grid-template-columns: auto 1fr; align-items: center; }
  .e-search::after { display: none; }
  .e-search input { padding-right: 10px; }
  .e-menu { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--rule-2); background: var(--sheet); color: var(--ink); font: inherit; font-size: .875rem; cursor: pointer; }
  .e-menu::before { content: ""; width: 14px; height: 9px; border-top: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; background: linear-gradient(currentColor, currentColor) center / 100% 1.5px no-repeat; }
  .e-search-list { width: auto; }
  .e-nav, .e-side-foot { display: none; }
  .e-app.menu-open .e-nav { display: grid; max-height: 62vh; overflow-y: auto; }
  .e-app.menu-open .e-side-foot { display: flex; }
  .e-main { padding: 18px var(--gutter) 56px; }
  .e-tablewrap { max-height: none; }
  .e-bars { grid-template-columns: minmax(0, 120px) 1fr 34px; }
}
