:root {
  --navy: #000a8c;
  --navy-dark: #00075f;
  --navy-soft: #e6e7f4;
  --navy-mid: #7b80cf;
  --gold: #ffc82d;
  --ink: #14181f;
  --ink-2: #374151;
  --muted: #4b5563;
  --line: #e3e6ea;
  --line-2: #cfd4db;
  --line-3: #eef0f3;
  --ground: #f4f5f7;
  --card: #ffffff;
  --chip: #f7f8fa;
  --warn-bg: #fdf0e4;
  --warn-ink: #8a3a06;
  --warn-line: #f1d9bd;
  --warn-card: #fdf7f0;
  --ok-bg: #e5f4e4;
  --ok-line: #b7dcb4;
  --ok-ink: #1d5a1a;
  --err-bg: #fdecea;
  --err-line: #f3c2bc;
  --err-ink: #9b1c11;
  --m1: #9a3412;
  --m2: #f59e0b;
  --m3: #cbd2db;
  --m4: #7b80cf;
  --m5: #000a8c;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--navy); }
a:hover { color: var(--navy-dark); }
:focus-visible { outline: 3px solid var(--navy-mid); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- inputs & buttons ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input {
  min-height: 48px; width: 100%;
  border: 1px solid var(--line-2); border-radius: 10px;
  padding: 0 12px; font-size: 16px; font-weight: 400;
  background: #fff; color: var(--ink);
}
textarea.input { padding: 10px 12px; line-height: 1.45; resize: vertical; min-height: 110px; }
.btn {
  min-height: 48px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--line-2); background: #fff; color: var(--navy);
  font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
.btn:hover { background: var(--chip); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-dark); }
.btn-primary[data-incomplete="true"] { background: #d3d5ec; border-color: #d3d5ec; color: var(--navy-dark); }
.btn-big { min-height: 54px; font-size: 17px; font-weight: 700; border-radius: 14px; width: 100%; }
.btn-danger { color: var(--err-ink); border-color: var(--err-line); }
.btn-danger:hover { background: var(--err-bg); }
.btn-small { min-height: 44px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .6; cursor: progress; }

.pill {
  min-height: 44px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  font-size: 14px; font-weight: 600;
}
.pill[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.pill.face { min-width: 44px; padding: 0 10px; font-size: 18px; }

.msg { border-radius: 12px; padding: 12px 14px; font-size: 14px; font-weight: 500; }
.msg-ok { background: var(--ok-bg); border: 1px solid var(--ok-line); color: var(--ok-ink); }
.msg-err { background: var(--err-bg); border: 1px solid var(--err-line); color: var(--err-ink); }
.hint { font-size: 13px; color: var(--muted); font-weight: 400; }
.warn-text { font-size: 13px; color: var(--warn-ink); }

.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag-yes { background: var(--navy-soft); color: var(--navy-dark); }
.tag-no { background: var(--warn-bg); color: var(--warn-ink); }
.tag-off { background: var(--line-3); color: var(--muted); }

/* ---------- sign-in ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; }
.auth-card {
  width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-top: 6px solid var(--gold);
  border-radius: 16px; padding: 28px 22px; display: flex; flex-direction: column; gap: 16px;
}
.auth-brand { display: flex; align-items: center; gap: 14px; }
.auth-brand img { width: 56px; height: auto; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--navy); }
.auth-card h1 { margin: 2px 0 0; font-size: 24px; }

/* ---------- app shell ---------- */
.topbar { background: var(--navy); color: #fff; border-bottom: 4px solid var(--gold); }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 14px 16px 0; display: flex; flex-direction: column; gap: 12px; }
.topbar-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { width: 40px; height: auto; display: block; background: #fff; border-radius: 6px; padding: 2px; }
.brand .eyebrow { color: var(--gold); }
.brand .hello { font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  width: 44px; height: 44px; border-radius: 22px; background: var(--navy-dark); color: #fff;
  border: 2px solid transparent; font-weight: 700; font-size: 15px; flex: none;
}
.avatar[aria-expanded="true"] { border-color: var(--gold); }
.menu {
  position: absolute; right: 16px; top: 64px; z-index: 20; background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.14);
  min-width: 220px; padding: 6px; display: flex; flex-direction: column;
}
.menu .who { padding: 10px 12px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line-3); margin-bottom: 4px; }
.menu .who strong { display: block; color: var(--ink); font-size: 15px; }
.menu button { min-height: 44px; text-align: left; padding: 0 12px; border: 0; background: transparent; border-radius: 8px; font-size: 15px; font-weight: 500; }
.menu button:hover { background: var(--chip); }
.tabs { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; max-width: 560px; }
.tab {
  min-height: 48px; background: transparent; border: 0; border-bottom: 3px solid transparent;
  color: #e3e4f3; font-size: 15px; font-weight: 600; padding: 0 8px;
}
.tab[aria-current="page"] { color: #fff; border-bottom-color: var(--gold); }

.main { max-width: 1200px; margin: 0 auto; padding: 16px 16px 64px; }
.narrow { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.label .soft { font-weight: 500; color: var(--muted); }

/* customer picker */
.pick-list { display: flex; flex-direction: column; }
.pick {
  min-height: 48px; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 4px; background: transparent; border: 0; border-bottom: 1px solid var(--line-3); text-align: left;
}
.pick:hover { background: var(--chip); }
.pick .nm { font-size: 15px; font-weight: 500; }
.pick .ar { font-size: 13px; color: var(--muted); white-space: nowrap; }
.chosen { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.chosen .nm { font-size: 16px; font-weight: 700; }

/* mood + yes/no */
.faces { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.face-btn {
  height: 60px; border-radius: 14px; font-size: 30px; padding: 0; line-height: 1;
  background: var(--chip); border: 2px solid transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.face-btn small { font-size: 10px; font-weight: 600; color: var(--muted); }
.face-btn[aria-pressed="true"] { background: var(--navy-soft); border-color: var(--navy); }
.face-btn[aria-pressed="true"] small { color: var(--navy-dark); }
.yn { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.yn button { min-height: 52px; border-radius: 12px; font-size: 16px; font-weight: 600; background: #fff; border: 1px solid var(--line-2); }
.yn button[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }

/* history */
.hist { display: flex; flex-direction: column; gap: 6px; text-align: left; width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
button.hist:hover { border-color: var(--line-2); }
.hist-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.hist .nm { font-size: 15px; font-weight: 700; }
.hist .meta { font-size: 12px; color: var(--muted); }
.hist .face { font-size: 28px; line-height: 1; }
.hist .notes { font-size: 14px; color: var(--ink-2); line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.day-head { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 8px 2px 0; }

/* ---------- dashboard ---------- */
.dash { display: flex; flex-direction: column; gap: 20px; }
.dash-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.dash-head h1 { margin: 0; font-size: 26px; letter-spacing: -.01em; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters .label { margin-right: 2px; }
.select { min-height: 44px; border: 1px solid var(--line-2); border-radius: 999px; padding: 0 14px; background: #fff; font-size: 14px; font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.kpi .k-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.kpi .k-val { font-size: 32px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; }
.kpi .k-val small { font-size: 16px; font-weight: 500; color: var(--muted); }
.kpi .k-sub { font-size: 13px; color: var(--muted); }
.meter { height: 8px; border-radius: 4px; background: var(--navy-soft); overflow: hidden; }
.meter > div { height: 8px; background: var(--navy); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel h2 { margin: 0; font-size: 16px; font-weight: 600; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
.bar-row { display: flex; flex-direction: column; gap: 6px; }
.bar-row .top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.bar-row .top span:last-child { color: var(--muted); text-align: right; }
.bar { height: 12px; border-radius: 6px; background: var(--line-3); overflow: hidden; }
.bar > div { height: 12px; border-radius: 6px; background: var(--navy); }
.mixbar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; gap: 2px; background: var(--line-3); }
.mixbar > div { height: 16px; }
.mix-cells { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.mix-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border-radius: 10px; background: var(--chip); }
.mix-cell .f { font-size: 26px; }
.mix-cell .n { font-size: 18px; font-weight: 700; }
.mix-cell .l { font-size: 12px; color: var(--muted); }
.mix-cell .sw { width: 18px; height: 4px; border-radius: 2px; }
.opps { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.opp { border: 1px solid var(--warn-line); background: var(--warn-card); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 4px; }
.opp .nm { font-size: 14px; font-weight: 600; }
.opp .meta { font-size: 13px; color: var(--muted); }
.opp .md { font-size: 13px; color: var(--warn-ink); font-weight: 500; }
.empty { font-size: 14px; color: var(--muted); }
.more-btn { align-self: flex-start; }

.table-box { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table.calls { width: 100%; min-width: 860px; border-collapse: collapse; }
table.calls th { font-weight: 600; font-size: 12px; color: var(--muted); text-align: left; padding: 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.calls td { font-size: 14px; padding: 12px; border-bottom: 1px solid var(--line-3); vertical-align: top; }
.sort {
  min-height: 40px; padding: 0 8px; border: 0; border-radius: 6px; font-size: 12px; font-weight: 600;
  background: transparent; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.sort.active { background: var(--navy-soft); color: var(--navy-dark); }
.sort .arr { font-size: 11px; }
td.nowrap { white-space: nowrap; }
td .sub { font-size: 12px; color: var(--muted); }
td.notes-cell { max-width: 380px; color: var(--ink-2); }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; }
.clamp.open { -webkit-line-clamp: unset; display: block; }
.linkish { border: 0; background: none; padding: 0; color: var(--navy); font-size: 13px; font-weight: 600; margin-top: 4px; min-height: 28px; }

/* ---------- people ---------- */
.people { display: flex; flex-direction: column; gap: 10px; }
.person { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.person .info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.person .nm { font-size: 16px; font-weight: 700; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.person .meta { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.person .acts { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- dialog ---------- */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(10, 14, 40, .45); }
.dlg { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.dlg h2 { margin: 0; font-size: 18px; }
.dlg-acts { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.temp-pw { font-family: ui-monospace, Menlo, monospace; font-size: 20px; font-weight: 700; letter-spacing: .04em; background: var(--chip); border: 1px dashed var(--line-2); border-radius: 10px; padding: 12px; text-align: center; user-select: all; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50;
  max-width: calc(100vw - 32px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.loading { padding: 40px 0; text-align: center; color: var(--muted); }

@media (min-width: 760px) {
  .topbar-inner { padding: 16px 24px 0; }
  .main { padding: 24px 24px 64px; }
  .brand img { width: 46px; }
}
