@font-face {
  font-family: "Alexandria";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/alexandria-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Alexandria";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/alexandria-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #eaebe2;
  --surface: #f7f2ea;
  --wash: #f4efe6;
  --line: #ead6ba;
  --line-2: #e3c9a2;
  --ink: #3f322b;
  --text: #5f4b40;
  --muted: #987e6f;
  --faint: #b1916b;
  --forest: #3f322b;
  --forest-2: #543024;
  --brass: #b1916b;
  --brass-soft: #f4efe6;
  --ivory: #f7f2ea;
  --out: #3a72d8;
  --in: #11998a;
  --ok: #1f9d6e;
  --re: #c47f1d;
  --miss: #d24b65;
  --appt: #6f55c9;
  --book: #b8913f;
  --unc: #97a39c;
  --shadow: 0 1px 2px rgba(63, 50, 43, 0.04), 0 10px 28px -16px rgba(63, 50, 43, 0.22);
  --enter: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
  font-family: "Alexandria", "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: "Alexandria", "Segoe UI", Tahoma, sans-serif; font-size: 14px; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
button, input, select, .nav-item, .text-button { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { opacity: 0.55; cursor: wait; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
svg { flex: 0 0 auto; }

input, select {
  min-width: 0;
  padding: 8px 11px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input:focus-visible, select:focus-visible { outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px rgba(184, 145, 63, 0.16); }
input::placeholder { color: var(--faint); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }

.muted { color: var(--muted); font-size: 13px; line-height: 1.8; }
.tiny { font-size: 12px; }
.eyebrow { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 600; color: var(--brass); }
.form-error { font-size: 13px; line-height: 1.8; color: #b4384f; }
.form-error:empty { display: none; }
.notice { margin-bottom: 16px; padding: 12px 14px; border: 1px solid #ecd6a8; border-radius: 12px; background: #fdf6e7; color: #8a6420; font-size: 13px; line-height: 1.9; }
.notice.error { border-color: #f0c9d1; background: #fdf0f2; color: #a5324a; }

.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px;
  background: var(--forest); color: var(--ivory);
  font-size: 13px; font-weight: 700;
  box-shadow: inset 0 -2px 0 var(--brass);
  transition: transform 0.14s var(--enter), background-color 0.2s ease;
}
.primary:active, .secondary:active { transform: scale(0.98); }
.secondary {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 13px; border: 1px solid var(--line-2); border-radius: 10px;
  background: var(--surface); color: var(--ink);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.14s var(--enter);
}
.secondary svg, .text-button svg, .nav-item svg, .metric-icon svg, .hero-label svg, .split-item svg, .call-directions svg, .person-bottom svg, .last-call svg {
  width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.danger { color: #b4384f; }

#app { display: grid; grid-template-columns: 272px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }

/* Sidebar */
.sidebar {
  font-family: "Alexandria", "Segoe UI", Tahoma, sans-serif;
  position: sticky; top: 0; z-index: 2; overflow: hidden;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 28px 18px 20px;
  background:
    radial-gradient(80% 36% at 100% 0%, rgba(227, 201, 162, 0.2), transparent 60%),
    var(--forest);
  color: var(--ivory);
  box-shadow: inset 1px 0 0 rgba(227, 201, 162, 0.28);
}
.sidebar::before,
.sidebar::after {
  content: "";
  position: absolute;
  pointer-events: none;
}
.sidebar::before {
  width: 280px; height: 280px; top: -90px; left: -120px;
  border: 1px solid rgba(247, 242, 234, 0.14);
  border-radius: 50%;
}
.sidebar::after {
  width: 46px; height: 72px; left: 24px; bottom: 96px; opacity: 0.28;
  background:
    linear-gradient(#e3c9a2, #e3c9a2) 0 24px / 8px 48px no-repeat,
    linear-gradient(#e3c9a2, #e3c9a2) 18px 12px / 8px 60px no-repeat,
    linear-gradient(#e3c9a2, #e3c9a2) 36px 0 / 8px 72px no-repeat;
}
.brand, .nav-item, .sidebar-bottom { position: relative; z-index: 1; }
.brand { display: grid; gap: 10px; padding: 0 6px 22px; margin-bottom: 8px; border-bottom: 1px solid rgba(227, 201, 162, 0.28); }
.brand-logo { display: block; width: 196px; height: auto; }
.brand-sub { font-size: 13px; font-weight: 500; color: #e3c9a2; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 14px; border-radius: 14px;
  color: rgba(247, 242, 234, 0.72); font-family: "Alexandria", "Segoe UI", Tahoma, sans-serif; font-size: 14px; font-weight: 600; text-align: start; text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.nav-item.selected { background: #f7f2ea; color: #3f322b; }
.nav-item.selected svg { color: #62392b; }
.sidebar-bottom { margin-top: auto; display: grid; gap: 4px; padding-top: 16px; border-top: 1px solid rgba(227, 201, 162, 0.22); }
.text-button { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: 12px; color: rgba(247, 242, 234, 0.72); font-family: "Alexandria", "Segoe UI", Tahoma, sans-serif; font-size: 13px; font-weight: 600; transition: color 0.2s ease, background-color 0.2s ease; }

/* Top bar */
main { position: relative; min-width: 0; }
main::before {
  content: "";
  position: absolute; z-index: 0; top: -140px; left: -80px;
  width: 420px; height: 420px; border-radius: 50%;
  border: 1px solid rgba(98, 57, 43, 0.08);
  pointer-events: none;
}
main > * { position: relative; z-index: 1; }
.topbar {
  position: sticky; top: 0; z-index: 6;
  height: 56px; padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(234, 235, 226, 0.9);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  font-size: 12px; color: var(--muted);
}
.slash { margin: 0 8px; color: var(--line-2); }
.topbar b { color: var(--ink); font-weight: 600; }
.account { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; font-size: 13px; }
.avatar {
  width: 38px; height: 38px; flex: 0 0 auto;
  display: grid; place-items: center; border-radius: 50%;
  border: 1px solid #e3c9a2; background: #fff;
  color: #62392b; font-size: 15px; font-weight: 700;
}
.avatar.small { width: 30px; height: 30px; font-size: 13px; }

/* Page */
.content { max-width: 1760px; margin: 0 auto; padding: 24px 28px 20px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.page-heading h1 { font-size: 26px; font-weight: 800; line-height: 1.3; color: var(--ink); }
.page-heading .muted { margin-top: 2px; }
.title-dot { color: var(--brass); }
.heading-actions { display: flex; align-items: center; gap: 8px; }
.live-badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px;
  border: 1px solid #e3c9a2; border-radius: 999px; background: #f7f2ea; color: #62392b;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.live-badge i { width: 6px; height: 6px; border-radius: 50%; background: #b1916b; animation: ring 2.4s ease-out infinite; }
.live-badge.is-history { border-color: #ecd6a8; background: #fdf6e7; color: #8a6420; }

/* Filters */
.filter-bar {
  position: relative; z-index: 4;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px; margin-bottom: 18px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow);
}
.filter-bar label { flex-direction: row; align-items: center; gap: 8px; }
.mode-switch { display: flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--wash); border: 1px solid var(--line); }
.mode-switch button { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; transition: background-color 0.2s ease, color 0.2s ease; }
.mode-switch button.selected { background: var(--forest); color: var(--ivory); }
.project-filter { padding-inline-start: 10px; border-inline-start: 1px solid var(--line); }
.update-label { margin-inline-start: auto; font-size: 11px; color: var(--faint); }

.employee-picker { position: relative; min-width: 220px; max-width: 100%; font-size: 13px; }
.employee-picker > summary {
  display: flex; align-items: center; gap: 8px; padding: 7px 11px;
  border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface);
  color: var(--muted); font-weight: 600; cursor: pointer; list-style: none;
}
.employee-picker > summary::-webkit-details-marker { display: none; }
.employee-picker > summary strong { color: var(--ink); font-weight: 600; }
.picker-arrow { margin-inline-start: auto; transition: transform 0.2s var(--enter); }
.employee-picker[open] .picker-arrow { transform: rotate(180deg); }
.employee-picker.has-selection > summary, .employee-picker[open] > summary { border-color: var(--brass); background: #fffaf0; }
.employee-picker.has-selection > summary strong { color: #8a6a26; }
.employee-popover {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 30;
  width: 360px; max-width: calc(100vw - 32px); padding: 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  box-shadow: 0 24px 60px -20px rgba(18, 38, 29, 0.3);
  animation: pop 0.2s var(--enter); transform-origin: top right;
}
.filter-bar .employee-search-label { display: block; margin-bottom: 8px; font-size: 13px; color: var(--ink); }
.employee-popover #employee-search { width: 100%; }
.employee-picker-actions { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.employee-picker-actions button, .selection-reset { color: #8a6a26; font-size: 12px; font-weight: 600; }
.employee-picker-actions button:last-child { color: var(--muted); }
.employee-options { max-height: 300px; overflow-y: auto; overscroll-behavior: contain; padding: 4px 0; }
.employee-group { display: flex; align-items: center; gap: 8px; padding: 10px 8px 4px; font-size: 12px; font-weight: 700; color: var(--project-color); }
.filter-bar .employee-option { flex-direction: row; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; color: var(--ink); cursor: pointer; }
.employee-option:hover, .employee-option:has(input:checked) { background: var(--project-soft); }
.employee-option input { width: 16px; height: 16px; margin: 0; flex: 0 0 auto; accent-color: var(--project-color); }
.employee-option span { display: block; min-width: 0; }
.employee-option b { display: block; font-size: 13px; font-weight: 600; }
.employee-option small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.picker-help { padding-top: 8px; border-top: 1px solid var(--line); font-size: 11px; line-height: 1.8; color: var(--faint); }
.picker-empty { padding: 20px 8px; text-align: center; font-size: 12px; line-height: 1.9; color: var(--muted); }
.employee-selection { flex: 0 0 100%; min-width: 0; padding-top: 10px; border-top: 1px solid var(--line); }
.selection-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
.employee-chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 140px; overflow-y: auto; padding: 2px; }
.employee-chip {
  display: flex; align-items: center; gap: 8px; max-width: 100%;
  padding: 5px 11px; border: 1px solid var(--project-border); border-radius: 999px;
  background: var(--project-soft); color: var(--ink); font-size: 12px; font-weight: 600; text-align: start;
}
.employee-chip small { display: block; font-size: 10px; color: var(--project-color); }
.employee-chip > span:last-child { font-size: 16px; color: var(--muted); }

/* Summary */
.summary-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 2fr); gap: 14px; margin-bottom: 30px; }
.hero-card {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; gap: 14px;
  padding: 20px 22px 18px; border-radius: 20px;
  background:
    radial-gradient(90% 70% at 100% 0%, rgba(177, 145, 107, 0.28), transparent 58%),
    linear-gradient(165deg, #543024, #3f322b 68%);
  color: var(--ivory);
  box-shadow: 0 24px 50px -30px rgba(15, 36, 27, 0.7);
}
.team-pulse { position: absolute; inset: auto 0 0 0; z-index: -1; width: 100%; height: 30%; opacity: 0.16; pointer-events: none; }
.team-pulse rect { fill: #e3c9a2; }
.hero-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hero-label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: rgba(244, 238, 226, 0.86); }
.hero-label svg { color: #e3c9a2; }
.hero-scope { padding: 3px 10px; border: 1px solid rgba(244, 238, 226, 0.18); border-radius: 999px; font-size: 11px; color: rgba(244, 238, 226, 0.7); }
.hero-value {
  display: block; font-size: clamp(52px, 4.6vw, 76px); font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
  background: linear-gradient(180deg, #f7f2ea 30%, #e3c9a2 130%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.split-row { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.split-item { display: inline-flex; align-items: baseline; gap: 6px; font-size: 12px; font-weight: 600; color: rgba(244, 238, 226, 0.66); }
.split-item svg { align-self: center; }
.split-item b { font-size: 19px; font-weight: 700; color: var(--ivory); font-variant-numeric: tabular-nums; }
.split-item em { font-style: normal; font-size: 11px; color: rgba(244, 238, 226, 0.5); }
.split-out svg { color: #8fb9ff; }
.split-in svg { color: #5fd6c3; }
.hero-sub { display: block; margin-bottom: 7px; font-size: 11px; font-weight: 600; color: rgba(244, 238, 226, 0.55); }
.hero-card .summary-foot { margin-top: auto; color: rgba(244, 238, 226, 0.55); }
.hero-card .bar { background: rgba(244, 238, 226, 0.1); }
.hero-card .bar rect { stroke: var(--forest); }
.hero-card .seg-out { fill: #8fb9ff; } .hero-card .seg-in { fill: #5fd6c3; }
.hero-card .seg-ok { fill: #46c393; } .hero-card .seg-re { fill: #e3a34b; } .hero-card .seg-miss { fill: #e66a80; } .hero-card .seg-unc { fill: #74827b; }

.bar { display: block; width: 100%; height: 6px; border-radius: 999px; overflow: hidden; background: #ead6ba; }
.bar rect { stroke: var(--surface); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.split-bar { height: 8px; }
.seg-out { fill: var(--out); } .seg-in { fill: var(--in); }
.seg-ok { fill: var(--ok); } .seg-re { fill: var(--re); } .seg-miss { fill: var(--miss); } .seg-unc { fill: var(--unc); }

.metric-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.summary-card {
  --tone: var(--brass);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px 16px 14px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); box-shadow: var(--shadow);
  transition: border-color 0.25s ease, transform 0.25s var(--enter), box-shadow 0.25s ease;
}
.summary-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--tone); opacity: 0.85; }
.metric-successful { --tone: var(--ok); } .metric-rescheduled { --tone: var(--re); } .metric-no_answer { --tone: var(--miss); }
.metric-unclassified { --tone: var(--unc); } .metric-appointments { --tone: var(--appt); } .metric-appointment_days { --tone: var(--brass); }
.metric-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text); }
.metric-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: color-mix(in srgb, var(--tone) 12%, white); color: var(--tone); }
.summary-value { display: block; font-size: clamp(26px, 2.1vw, 34px); font-weight: 800; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
.tile-bar { height: 4px; }
.summary-foot { display: block; font-size: 11px; line-height: 1.7; color: var(--faint); }
.is-partial .summary-foot { color: #8a6420; }
.is-partial .summary-foot::before { content: "● "; color: var(--re); }

/* Sections */
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.section-heading h2 { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; color: var(--ink); }
.count-badge { padding: 1px 9px; border-radius: 999px; background: #ead6ba; font-size: 12px; font-weight: 600; color: #62392b; font-variant-numeric: tabular-nums; }

/* Projects */
.theme-fursan { --project-color: #a87a26; --project-soft: rgba(168, 122, 38, 0.08); --project-border: rgba(168, 122, 38, 0.3); }
.theme-bashaer { --project-color: #7f52b8; --project-soft: rgba(127, 82, 184, 0.08); --project-border: rgba(127, 82, 184, 0.28); }
.theme-dhahran { --project-color: #2f6fb8; --project-soft: rgba(47, 111, 184, 0.08); --project-border: rgba(47, 111, 184, 0.28); }
.theme-hadhabah { --project-color: #c0603f; --project-soft: rgba(192, 96, 63, 0.08); --project-border: rgba(192, 96, 63, 0.28); }
.theme-khozam { --project-color: #8d3d55; --project-soft: rgba(141, 61, 85, 0.08); --project-border: rgba(141, 61, 85, 0.28); }
.theme-jeddah { --project-color: #138a84; --project-soft: rgba(19, 138, 132, 0.08); --project-border: rgba(19, 138, 132, 0.28); }
.project-swatch { display: inline-block; flex: 0 0 auto; width: 9px; height: 9px; border-radius: 3px; background: var(--project-color); box-shadow: 0 0 0 3px var(--project-soft); }
.projects-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 30px; }
.project-card {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px 16px 14px; border: 1px solid var(--line); border-radius: 16px;
  background: linear-gradient(160deg, var(--surface) 55%, var(--project-soft)), var(--surface);
  box-shadow: var(--shadow); color: var(--text); text-align: start;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s var(--enter);
}
.project-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--project-color); }
.project-card.selected { border-color: var(--project-color); box-shadow: 0 0 0 1px var(--project-color), 0 16px 34px -22px var(--project-color); }
.project-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.project-name { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 14px; font-weight: 700; color: var(--project-color); }
.project-indicator { flex: 0 0 auto; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(31, 157, 110, 0.14); }
.project-indicator.partial { background: var(--re); box-shadow: 0 0 0 3px rgba(196, 127, 29, 0.14); }
.project-indicator.error { background: var(--miss); box-shadow: 0 0 0 3px rgba(210, 75, 101, 0.14); }
.project-total { display: flex; align-items: baseline; gap: 8px; }
.project-total b { font-size: 30px; font-weight: 800; line-height: 1.1; color: var(--ink); font-variant-numeric: tabular-nums; }
.project-total small { font-size: 12px; color: var(--muted); }
.project-bar { height: 5px; }
.project-numbers { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.project-numbers > span { padding: 7px 9px; border-radius: 10px; background: var(--wash); }
.project-numbers b { display: block; font-size: 16px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.project-numbers small { display: block; font-size: 11px; color: var(--muted); }
.incoming-number { color: var(--in) !important; }
.project-warning { display: block; padding: 6px 9px; border: 1px solid #ecd6a8; border-radius: 10px; background: #fdf6e7; font-size: 11px; line-height: 1.8; color: #8a6420; }

/* Team */
.team-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.team-tools input, .team-tools select { max-width: 220px; }
.team-tools input { min-width: 200px; }
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.person-card {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: 18px;
  background: linear-gradient(170deg, var(--project-soft), var(--surface) 34%), var(--surface);
  box-shadow: var(--shadow);
  transition: border-color 0.25s ease, transform 0.25s var(--enter), box-shadow 0.25s ease;
}
.person-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--project-color); }
.person-card::after {
  content: attr(data-brand); position: absolute; left: -4px; top: 58px; z-index: -1;
  font-size: 30px; font-weight: 900; white-space: nowrap; color: var(--project-color); opacity: 0.06; pointer-events: none;
}
.person-header { display: flex; align-items: center; gap: 10px; padding: 16px 16px 0; }
.person-header .avatar { border-color: var(--project-border); background: var(--surface); color: var(--project-color); }
.person-id { min-width: 0; flex: 1; }
.person-header h3 { overflow: hidden; font-size: 14px; font-weight: 700; line-height: 1.5; color: var(--ink); text-overflow: ellipsis; white-space: nowrap; }
.person-project { font-size: 11px; font-weight: 600; color: var(--project-color); }
.person-sites { display: grid; gap: 6px; padding: 10px 16px 0; }
.person-site { display: grid; grid-template-columns: auto minmax(0,1fr) auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center; padding: 7px 9px; border-radius: 10px; background: var(--wash); }
.person-site .project-swatch { grid-row: 1 / span 2; }
.person-site > span { overflow: hidden; font-size: 12px; font-weight: 700; color: var(--project-color); text-overflow: ellipsis; white-space: nowrap; }
.person-site > b { font-size: 14px; font-variant-numeric: tabular-nums; color: var(--ink); }
.person-site > small { grid-column: 2 / -1; color: var(--muted); font-size: 10px; font-weight: 600; }
.is-refreshing #updated { color: var(--brass); }
.is-loading { position: relative; }
.is-loading::before { content: ""; position: sticky; top: 0; z-index: 5; display: block; height: 3px; margin: -24px -28px 24px; background: linear-gradient(90deg, transparent, #b1916b, #241806, #b1916b, transparent); background-size: 220% 100%; animation: load-bar 1.1s linear infinite; }
.is-loading .hero-value, .is-loading .summary-value, .is-loading .project-total b, .is-loading .project-numbers b, .is-loading .calls-total, .is-loading .call-directions b, .is-loading .count-badge { animation: load-num 1.15s ease-in-out infinite; }
.is-loading .project-card, .is-loading .person-card, .is-loading .hero-card, .is-loading .summary-card { background-image: linear-gradient(100deg, transparent 30%, rgba(177, 145, 107, 0.16) 50%, transparent 70%); background-size: 220% 100%; animation: skeleton 1.3s ease infinite; }
@keyframes skeleton { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes load-num { 0%, 100% { opacity: 0.28; } 50% { opacity: 1; } }
@keyframes load-bar { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.person-rank {
  flex: 0 0 auto; display: grid; place-items: center; min-width: 28px; height: 28px; padding: 0 7px; border-radius: 9px;
  background: var(--wash); color: var(--muted); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.person-rank.rank-1 { background: linear-gradient(180deg, #edcd7d, #c39741); color: #241806; box-shadow: 0 6px 16px -8px rgba(184, 145, 63, 0.9); }
.person-rank.rank-2 { background: linear-gradient(180deg, #e6e9e5, #b4bab4); color: #1b201c; }
.person-rank.rank-3 { background: linear-gradient(180deg, #e9b993, #b0734a); color: #23130a; }
.calls-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; padding: 14px 16px 10px; }
.calls-main { display: grid; gap: 2px; }
.calls-label { font-size: 11px; font-weight: 600; color: var(--muted); }
.calls-total { font-size: 38px; font-weight: 800; line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.person-status { padding: 3px 9px; border-radius: 999px; background: #eaf7f0; color: #157a55; font-size: 11px; font-weight: 600; white-space: nowrap; }
.person-status.inactive { background: #fdf3e2; color: #8a6420; }
.person-status.unknown { background: var(--wash); color: var(--muted); }
.call-directions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 0 16px; }
.call-directions > div { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 7px 10px; border-radius: 10px; background: var(--wash); }
.call-directions span { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.dir-out svg { color: var(--out); } .dir-in svg { color: var(--in); }
.call-directions b { font-size: 17px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.dir-bar { width: auto; height: 4px; margin: 8px 16px 0; }
.call-results-label { margin: 14px 16px 6px; font-size: 11px; font-weight: 600; color: var(--faint); }
.call-results { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 0 16px; text-align: center; }
.call-results > div { padding: 7px 4px; border-radius: 10px; }
.res-ok { background: #ecf7f1; } .res-re { background: #fdf4e4; } .res-miss { background: #fcEef1; }
.call-results b { display: block; font-size: 19px; font-weight: 700; line-height: 1.3; font-variant-numeric: tabular-nums; }
.call-results small { font-size: 11px; font-weight: 600; color: var(--muted); }
.good { color: var(--ok); } .follow { color: var(--re); } .missed { color: var(--miss); }
.outcome-bar { height: 5px; }
.person-card .outcome-bar { width: auto; height: 4px; margin: 8px 16px 0; }
.person-bottom { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 12px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.person-bottom div { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; padding: 8px 6px; font-size: 12px; font-weight: 600; line-height: 1.35; text-align: center; color: var(--muted); }
.person-bottom div + div { border-inline-start: 1px solid var(--line); }
.person-bottom div:first-child svg { color: var(--appt); } .person-bottom div:last-child svg { color: var(--brass); }
.person-bottom b { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.appointment-number { color: var(--appt); } .appointment-day-number { color: var(--brass); }
.unclassified { margin: -4px 16px 10px; font-size: 11px; line-height: 1.8; color: var(--faint); }
.last-call { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; margin-top: auto; padding: 9px 16px; border-top: 1px solid var(--line); background: var(--wash); font-size: 11px; color: var(--muted); }
.last-call span:first-child { display: inline-flex; align-items: center; gap: 5px; }
.last-call svg { width: 13px; height: 13px; }

.is-changed { animation: changed 1.6s var(--enter); }
.empty { grid-column: 1 / -1; padding: 44px 20px; border: 1px dashed var(--line-2); border-radius: 16px; background: var(--surface); text-align: center; font-size: 14px; line-height: 2; color: var(--muted); }

.definitions { margin-top: 26px; padding: 14px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); font-size: 13px; line-height: 2.1; color: var(--muted); }
.definitions summary { cursor: pointer; font-weight: 700; color: var(--ink); }
.definitions p { max-width: 1100px; margin-top: 10px; }
footer { display: flex; flex-wrap: wrap; gap: 8px; padding: 20px 0 4px; font-size: 12px; color: var(--faint); }
#footer-period { margin-inline-start: auto; }

/* Users */
.users-list { display: grid; gap: 10px; }
.user-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.user-details { flex: 1; min-width: 220px; }
.user-details h3 { margin-bottom: 2px; font-size: 15px; color: var(--ink); }
.user-details p { font-size: 13px; line-height: 1.8; color: var(--muted); }
.user-details .user-access { color: #8a6a26; font-weight: 600; }
.user-actions { display: flex; flex-wrap: wrap; gap: 6px; }

dialog {
  width: min(520px, 94vw); max-height: 90vh; overflow-y: auto; padding: 24px;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text);
  box-shadow: 0 30px 80px -24px rgba(15, 36, 27, 0.4);
}
dialog[open] { animation: pop 0.22s var(--enter); }
dialog::backdrop { background: rgba(63, 50, 43, 0.46); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog form { display: grid; gap: 16px; }
dialog input, dialog select { width: 100%; font-size: 14px; }
dialog h2 { font-size: 20px; color: var(--ink); }
dialog small { font-weight: 500; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; }
.close-dialog { width: 32px; height: 32px; border-radius: 9px; font-size: 22px; color: var(--muted); }
.project-permissions { min-width: 0; margin: 0; padding: 14px; border: 1px solid var(--line-2); border-radius: 12px; }
.project-permissions legend { padding: 0 6px; font-size: 14px; font-weight: 700; color: var(--ink); }
#user-project-help { margin-bottom: 10px; font-size: 12px; line-height: 1.9; color: var(--muted); }
.permission-actions { display: flex; gap: 18px; margin-bottom: 10px; }
.permission-actions button { color: #8a6a26; font-size: 12px; font-weight: 700; }
.user-project-options { display: grid; gap: 6px; max-height: 240px; overflow-y: auto; }
.project-permission { flex-direction: row; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--project-border); border-radius: 10px; background: var(--project-soft); color: var(--ink); cursor: pointer; font-size: 13px; }
.project-permission input { width: 16px; height: 16px; margin: 0; accent-color: var(--project-color); }

.toast {
  position: fixed; bottom: 20px; left: 20px; z-index: 50;
  padding: 12px 18px; border-radius: 12px; background: var(--forest); color: var(--ivory);
  font-size: 13px; font-weight: 600; box-shadow: 0 16px 40px -16px rgba(15, 36, 27, 0.6);
  animation: rise 0.3s var(--enter);
}

.fullscreen #app { grid-template-columns: minmax(0, 1fr); }
.fullscreen .sidebar, .fullscreen .topbar { display: none; }
.fullscreen .content { max-width: none; }

@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(177, 145, 107, 0.5); } 70%, 100% { box-shadow: 0 0 0 6px rgba(177, 145, 107, 0); } }
@keyframes pop { from { opacity: 0; transform: scale(0.97) translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes changed { 0% { color: var(--brass); text-shadow: 0 0 16px rgba(184, 145, 63, 0.55); } 100% { text-shadow: 0 0 0 transparent; } }

@media (hover: hover) and (pointer: fine) {
  .secondary:hover { background: var(--wash); border-color: #d6c3a8; }
  .primary:hover { background: var(--forest-2); }
  .nav-item:not(.selected):hover, .text-button:hover { background: rgba(244, 238, 226, 0.06); color: var(--ivory); }
  .mode-switch button:not(.selected):hover { color: var(--ink); }
  .summary-card:hover { border-color: color-mix(in srgb, var(--tone) 40%, white); transform: translateY(-2px); }
  .project-card:hover { border-color: var(--project-border); transform: translateY(-2px); }
  .person-card:hover { border-color: var(--project-border); transform: translateY(-2px); box-shadow: 0 18px 36px -24px var(--project-color); }
  .close-dialog:hover { background: var(--wash); color: var(--ink); }
}

@media (min-width: 1700px) { .people-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

@media (max-width: 1280px) {
  #app { grid-template-columns: 248px minmax(0, 1fr); }
  .brand-logo { width: 170px; }
  .summary-grid { grid-template-columns: minmax(0, 1fr); }
  .content { padding: 20px; }
  .topbar { padding: 0 20px; }
}

@media (max-width: 900px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; padding: 12px 14px; }
  .brand { padding: 0; margin: 0 0 0 auto; border: 0; }
  .brand-logo { width: 128px; }
  .brand-sub, .sidebar::before, .sidebar::after { display: none; }
  .nav-item { width: auto; padding: 8px 10px; font-size: 12px; }
  .sidebar-bottom { flex-basis: 100%; display: flex; gap: 4px; margin: 0; padding-top: 6px; }
  .topbar { position: static; height: 48px; padding: 0 14px; }
  .content { padding: 16px 12px; }
  .page-heading { flex-direction: column; align-items: flex-start; }
  .metric-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .project-filter { padding: 0; border: 0; }
  .update-label { flex-basis: 100%; margin: 0; }
  .employee-picker { flex: 1 0 100%; min-width: 0; }
  .employee-popover { width: 100%; }
  .section-heading { flex-direction: column; align-items: flex-start; }
  .team-tools, .team-tools input, .team-tools select { width: 100%; max-width: none; min-width: 0; }
  .section-heading .tiny { display: none; }
}

@media (max-width: 560px) {
  .hero-card { padding: 18px; }
  .hero-value { font-size: 56px; }
  .summary-card { padding: 14px; }
  .summary-value { font-size: 26px; }
  .projects-grid, .people-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
