:root {
  --bg: #f4f5f7; --card: #fff; --ink: #1f2937; --muted: #6b7280; --line: #e5e7eb; --soft: #f8fafc;
  --green: #16a34a; --green-d: #15803d; --red: #dc2626; --red-d: #b91c1c; --blue: #2563eb; --blue-d: #1d4ed8;
  --amber: #d97706; --orange: #ea580c; --orange-d: #c2410c; --navy: #1e293b;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
body { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
h3.h { margin: 0 0 10px; font-size: 18px; }

/* top bar + shift line */
.top { position: sticky; top: 0; z-index: 7; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: var(--navy); color: #fff; }
.brand { font-weight: 800; font-size: 19px; letter-spacing: .2px; }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 15px; }
.inline { display: inline; margin: 0; }
.link { background: none; border: 0; color: #cbd5e1; text-decoration: underline; cursor: pointer; padding: 4px; }
.pill { border: 0; border-radius: 999px; padding: 6px 14px; font-size: 14px; font-weight: 700; cursor: pointer; }
.pill.on { background: #22c55e; color: #052e16; }
.pill.off { background: #f59e0b; color: #451a03; }
.pill.bad { background: #ef4444; color: #fff; }
.shiftbar { display: flex; align-items: center; gap: 8px; padding: 9px 16px; background: #e0e7ff; color: #1e1b4b;
  font-weight: 600; font-size: 15px; }
.shiftbar .dot { width: 10px; height: 10px; border-radius: 50%; background: #4f46e5; flex: none; }
.shiftbar.off { background: #f1f5f9; color: #475569; }
.shiftbar.off .dot { background: #94a3b8; }
.banner { background: #fef3c7; color: #78350f; padding: 12px 16px; text-align: center; font-weight: 600; cursor: pointer; }
.banner.red { background: #fee2e2; color: #7f1d1d; }

main { max-width: 1180px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border-radius: 18px; padding: 18px; box-shadow: 0 1px 3px rgba(15,23,42,.07); margin-bottom: 14px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 54px; padding: 10px 18px;
  border: 1px solid var(--line); border-radius: 14px; background: #fff; font-weight: 650; cursor: pointer;
  -webkit-tap-highlight-color: transparent; user-select: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.big { min-height: 64px; font-size: 20px; width: 100%; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn.green { background: var(--green); border-color: var(--green-d); color: #fff; }
.btn.red { background: var(--red); border-color: var(--red-d); color: #fff; }
.btn.blue { background: var(--blue); border-color: var(--blue-d); color: #fff; }
.btn.orange { background: var(--orange); border-color: var(--orange-d); color: #fff; }
.btn.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.sm { min-height: 42px; padding: 6px 14px; font-size: 15px; border-radius: 11px; }
.btn.icon { min-width: 58px; font-size: 22px; }
.link-dark { background: none; border: 0; color: var(--muted); }

/* dialer */
.dialer { max-width: 480px; margin: 0 auto 14px; }
.from { display: block; font-size: 14px; color: var(--muted); margin-bottom: 10px; }
select, input[type=text], input[type=search], input[type=tel], input:not([type]), input[type=password], input[type=number], textarea {
  width: 100%; padding: 12px; border: 1px solid #cbd5e1; border-radius: 12px; background: #fff; font-size: 17px; }
textarea { resize: vertical; }
.from select { margin-top: 4px; font-size: 18px; font-weight: 650; color: var(--ink); }
.numrow { display: flex; gap: 8px; }
.numrow input { font-size: 28px; font-weight: 650; text-align: center; letter-spacing: .5px; }
.hint { min-height: 24px; text-align: center; margin: 6px 0; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0 14px; }
.keypad button { min-height: 62px; border-radius: 16px; border: 1px solid var(--line); background: var(--soft); font-size: 26px;
  font-weight: 650; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.keypad button small { display: block; font-size: 10px; letter-spacing: 2px; color: var(--muted); font-weight: 650; }
.keypad button:active { background: #e2e8f0; }
.keypad.small button { min-height: 50px; font-size: 22px; }
.dialer .small { margin-top: 10px; }

/* on-call screen */
.leadbar { background: linear-gradient(90deg, var(--red), var(--orange)); color: #fff; font-weight: 900; font-size: 26px;
  letter-spacing: 1px; text-align: center; padding: 14px; border-radius: 16px; margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(234,88,12,.35); }
.oc-grid { display: grid; gap: 14px; }
.oc-main { border: 2px solid var(--green); }
.oncall.lead .oc-main { border-color: var(--orange); }
.oc-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chip-line { display: inline-block; background: #dcfce7; color: #14532d; font-weight: 800; padding: 5px 14px; border-radius: 999px; font-size: 17px; }
.oc-state { font-weight: 650; color: var(--green-d); }
.oc-name { font-size: 30px; font-weight: 800; margin-top: 10px; line-height: 1.15; }
.oc-num { font-size: 19px; color: var(--muted); margin-bottom: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.oc-main .btn.big { margin-top: 12px; }
.xfer { display: grid; gap: 8px; margin-top: 10px; }
.say { background: #eff6ff; border: 1px solid #bfdbfe; }
.say-l { font-size: 13px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; color: var(--blue-d); }
.say-t { font-size: 21px; font-weight: 650; margin-top: 4px; line-height: 1.35; }
.say-note { margin-top: 10px; padding-top: 10px; border-top: 1px solid #bfdbfe; font-weight: 650; color: #1e3a8a; }
.checklist { display: grid; gap: 8px; }
.ck { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 14px;
  background: #fff; cursor: pointer; text-align: left; width: 100%; -webkit-tap-highlight-color: transparent; }
.ck .box { width: 30px; height: 30px; border-radius: 9px; border: 2px solid #94a3b8; flex: none; display: flex;
  align-items: center; justify-content: center; font-size: 20px; font-weight: 900; color: #fff; }
.ck .t { font-weight: 700; }
.ck .s { font-size: 14px; color: var(--muted); }
.ck.on { background: #f0fdf4; border-color: #86efac; }
.ck.on .box { background: var(--green); border-color: var(--green); }
.rule { margin-top: 10px; font-size: 15px; background: #fff7ed; border-radius: 12px; padding: 10px 12px; color: #7c2d12; }
.jobs { display: grid; gap: 8px; }
.job { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 15px; }
.job b { font-size: 16px; }

/* Now tab */
.sec { margin: 4px 0 16px; }
.sec-h { display: flex; align-items: baseline; gap: 8px; margin: 0 2px 8px; font-size: 19px; font-weight: 800; }
.sec-h .n { font-size: 15px; color: var(--muted); font-weight: 650; }
.item { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 16px; padding: 14px;
  box-shadow: 0 1px 2px rgba(15,23,42,.06); margin-bottom: 8px; border-left: 6px solid #cbd5e1; cursor: pointer; }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 800; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { font-size: 14px; color: var(--muted); }
.item .acts { display: flex; gap: 8px; flex: none; }
.item.lead { border-left-color: var(--orange); background: #fff7ed; }
.item.lead .timer { color: var(--orange-d); font-weight: 800; }
.item.follow { border-left-color: var(--blue); }
.item.need { border-left-color: var(--red); background: #fef2f2; }
.item.live { border-left-color: var(--green); }
.item.live.parked { border-left-color: var(--amber); }
.item.live.ringing, .item.live.voicemail { border-left-color: #94a3b8; }
.clear { text-align: center; padding: 50px 20px; }
.clear-ico { width: 74px; height: 74px; border-radius: 50%; background: #dcfce7; color: var(--green-d); font-size: 40px;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; font-weight: 900; }
.clear-t { font-size: 24px; font-weight: 800; }

/* call log */
.chips { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.chip { border: 1px solid #cbd5e1; background: #fff; border-radius: 999px; padding: 9px 16px; font-weight: 650; cursor: pointer; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.list { display: grid; gap: 8px; }
.row { background: #fff; border-radius: 16px; padding: 12px 14px; box-shadow: 0 1px 2px rgba(15,23,42,.06); cursor: pointer; }
.row-main { display: flex; gap: 12px; align-items: center; }
.ico { width: 38px; height: 38px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex: none; background: #e2e8f0; }
.ico.missed { background: #fee2e2; color: var(--red); }
.ico.vm { background: #fef3c7; color: var(--amber); }
.ico.in { background: #dcfce7; color: var(--green-d); }
.ico.out { background: #dbeafe; color: var(--blue); }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .s { font-size: 14px; color: var(--muted); }
.row .ai { font-size: 14px; color: #374151; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tags { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.tag { display: inline-block; font-size: 12px; font-weight: 800; padding: 2px 9px; border-radius: 999px; background: #f1f5f9; white-space: nowrap; }
.tag.missed { background: #fee2e2; color: var(--red-d); }
.tag.voicemail { background: #fef3c7; color: #92400e; }
.tag.done, .tag.booked { background: #dcfce7; color: #14532d; }
.tag.lead { background: var(--orange); color: #fff; }
.tag.notbooked { background: #ffedd5; color: #9a3412; }
.tag.follow { background: #dbeafe; color: #1e3a8a; }
.tag.score { background: #ede9fe; color: #4c1d95; }
.row-extra { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--red);
  color: #fff; font-size: 12px; line-height: 20px; }
.badge.grey { background: #64748b; }

/* call detail */
.back { margin-bottom: 12px; }
.d-head { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.d-head .grow { flex: 1; min-width: 220px; }
.d-name { font-size: 28px; font-weight: 800; line-height: 1.2; }
.d-sub { color: var(--muted); }
.d-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.d-grid { display: grid; gap: 14px; }
.leadstrip { background: #fff7ed; color: var(--orange-d); border: 1px solid #fdba74; font-weight: 800; border-radius: 12px;
  padding: 9px 12px; margin-bottom: 12px; }
.d-recs { margin-top: 12px; display: grid; gap: 6px; }
.d-rec { display: flex; align-items: center; gap: 12px; }
.d-rec span { flex: none; min-width: 110px; }
.d-rec audio { flex: 1; margin: 0; height: 44px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 16px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 650; }
.summary { font-size: 18px; line-height: 1.5; }
.summary p { margin: 0 0 6px; }
.score-top { display: flex; align-items: baseline; gap: 10px; }
.score-pct { font-size: 34px; font-weight: 900; }
.scores { display: grid; gap: 6px; margin-top: 8px; }
.sc { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.sc .m { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 15px; flex: none; }
.sc.yes .m { background: #dcfce7; color: var(--green-d); }
.sc.no .m { background: #fee2e2; color: var(--red-d); }
.sc.na { color: #9ca3af; }
.sc.na .m { background: #f1f5f9; color: #9ca3af; }
.tips { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.tips li { background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 10px 12px; font-size: 16px; }
.tx { display: grid; gap: 8px; max-height: 560px; overflow-y: auto; padding-right: 4px; }
.bub { max-width: 82%; padding: 9px 12px; border-radius: 14px; font-size: 16px; }
.bub .w { font-size: 12px; font-weight: 800; color: var(--muted); margin-bottom: 2px; }
.bub.Customer, .bub.Caller, .bub.x { background: #f1f5f9; justify-self: start; border-bottom-left-radius: 4px; }
.bub.Dispatcher { background: #dbeafe; justify-self: end; border-bottom-right-radius: 4px; }
audio { width: 100%; margin: 6px 0; }
.pending { background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 12px; padding: 14px; color: var(--muted); }

/* bottom tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; border: 0; background: none; padding: 8px 0 10px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.tabs button .ti { display: block; font-size: 22px; line-height: 1.2; }
.tabs button.on { color: var(--blue); }

/* incoming ring */
.ring { position: fixed; inset: 0; z-index: 30; background: #0f172a; display: flex; align-items: center; justify-content: center; padding: 20px; }
.ring-card { width: 100%; max-width: 520px; text-align: center; color: #fff; }
.ring-lead { background: linear-gradient(90deg, var(--red), var(--orange)); font-size: 30px; font-weight: 900; letter-spacing: 1px;
  border-radius: 18px; padding: 16px; margin-bottom: 20px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.03); } }
.ring-top { font-size: 16px; opacity: .8; text-transform: uppercase; letter-spacing: 2px; }
.ring-line { margin: 18px auto 10px; display: inline-block; background: #22c55e; color: #052e16; font-size: 26px; font-weight: 900;
  padding: 12px 22px; border-radius: 16px; }
.ring-name { font-size: 36px; font-weight: 900; margin-top: 12px; }
.ring-num { font-size: 24px; opacity: .85; }
.ring-note { min-height: 24px; margin: 8px 0 26px; color: #fde68a; }
.ring-btns { display: grid; grid-template-columns: 1fr 1.6fr; gap: 16px; }
.ring-btns .btn { min-height: 84px; font-size: 24px; }

/* outcome sheet */
.sheet { position: fixed; inset: 0; z-index: 25; background: rgba(15,23,42,.6); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { width: 100%; max-width: 620px; background: #fff; border-radius: 22px 22px 0 0; padding: 22px 18px;
  padding-bottom: calc(22px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; }
.sheet-lead { font-size: 22px; font-weight: 900; color: var(--orange-d); }
.sheet-who { color: var(--muted); margin-bottom: 14px; font-size: 17px; }
.outcomes { display: grid; gap: 10px; }
.sh-q { font-weight: 800; font-size: 19px; margin: 4px 0 8px; }
.wins { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 8px 0 12px; }
.wins .btn { min-height: 56px; font-size: 17px; }

.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40;
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; max-width: 90vw; font-weight: 650;
  box-shadow: 0 4px 12px rgba(0,0,0,.25); }

/* admin */
.admin h2 { font-size: 21px; margin: 22px 0 8px; }
.admin .card h3 { margin: 0 0 6px; font-size: 18px; }
.admin label { display: block; margin: 10px 0 4px; font-size: 14px; font-weight: 650; color: #334155; }
.admin .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.admin .hours { display: grid; grid-template-columns: 54px 1fr 1fr 80px; gap: 6px 8px; align-items: center; margin-top: 6px; }
.admin input[type=time] { padding: 9px; border: 1px solid #cbd5e1; border-radius: 10px; width: 100%; font-size: 16px; }
.admin .check { display: flex; align-items: center; gap: 8px; font-weight: 650; margin: 10px 0; }
.admin .check input { width: 22px; height: 22px; }
.admin .note { font-size: 14px; color: var(--muted); }
.admin .ok { color: var(--green-d); font-weight: 700; }
.admin .warn { color: #92400e; font-weight: 700; }
.admin .save { margin-top: 12px; }
.shift-ed { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-top: 10px; }
.shift-ed .hd { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.shift-ed .times { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.shift-ed .people { display: grid; grid-template-columns: 1fr; gap: 6px; }
.admin details { margin-top: 12px; }
.admin summary { cursor: pointer; font-weight: 700; padding: 8px 0; }
.daygrid { display: grid; gap: 10px; }
.dayrow { border-top: 1px solid var(--line); padding-top: 8px; }

/* login */
body.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { margin: 0 0 4px; }
.login-card label { display: block; margin: 14px 0; font-weight: 650; }
.login-card input { margin-top: 6px; }
.err { background: #fee2e2; color: #7f1d1d; padding: 10px; border-radius: 10px; }

@media (min-width: 900px) {
  body { padding-bottom: 0; display: flex; flex-direction: column; min-height: 100vh; }
  .top { order: 0; } .tabs { order: 1; } .shiftbar { order: 2; } .banner { order: 3; } main { order: 4; width: 100%; }
  .tabs { position: sticky; top: 56px; bottom: auto; justify-content: center; border-top: 0; border-bottom: 1px solid var(--line); z-index: 6; }
  .tabs button { flex: none; width: 150px; font-size: 16px; padding: 12px 0; }
  .tabs button .ti { display: inline; font-size: 18px; margin-right: 6px; }
  .toast { bottom: 30px; }
  .oc-grid { grid-template-columns: 1fr 1fr; align-items: start; }
  .d-grid { grid-template-columns: 1.1fr 1fr; align-items: start; }
  .sheet { align-items: center; }
  .sheet-card { border-radius: 22px; }
  #tab-now { max-width: 860px; margin: 0 auto; }
  #tab-calls { max-width: 860px; margin: 0 auto; }
}
