/* Sawhorse client portal */
@font-face { font-family: "Display"; src: url("/portal/display.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Body"; src: url("/portal/body.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
	--base: #111111; --surface: #1c1c1c; --raised: #242424; --line: #3a3a3a;
	--text: #f6f3ea; --muted: #a8a397; --accent: #ffd60a; --red: #ff2e63; --ok: #4cc97a;
	--ignite: linear-gradient(115deg, #ffd60a 0%, #ff8a00 50%, #ff2e63 100%);
	--r: 18px; --pop: cubic-bezier(.34, 1.56, .64, 1);
	color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--base); color: var(--text); font: 16px/1.55 "Body", system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: "Display", "Body", system-ui, sans-serif; letter-spacing: -.02em; line-height: 1.1; margin: 0 0 .5em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; }
h2 { font-size: 1.5rem; font-weight: 750; }
h3 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0 0 1em; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.noscript { padding: 2rem; text-align: center; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

/* ---------- buttons ---------- */
.btn { appearance: none; border: 1px solid transparent; border-radius: 999px; padding: .7em 1.3em; font: inherit; font-weight: 700; cursor: pointer;
	background: var(--ignite); background-size: 220% 220%; color: #111; white-space: nowrap;
	transition: transform .2s var(--pop), box-shadow .2s, background-color .2s, color .2s, border-color .2s; }
.btn:hover, .btn:focus-visible { transform: translateY(-3px) scale(1.04); box-shadow: 0 14px 30px -10px rgba(255, 46, 99, .6), 0 0 0 2px rgba(255, 214, 10, .35); }
.btn:active { transform: scale(.96); transition-duration: .08s; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.ghost { background: transparent; color: var(--text); border-color: rgba(246, 243, 234, .35); }
.btn.ghost:hover, .btn.ghost:focus-visible { background: var(--text); color: #111; border-color: var(--text); }
.btn.small { padding: .45em .95em; font-size: .875rem; }
.btn.danger { background: transparent; color: #ff8fa8; border-color: rgba(255, 46, 99, .5); }
.btn.danger:hover { background: var(--red); color: #111; }
.linkbtn { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }
.linkbtn:hover { color: var(--accent); }

/* ---------- sign in ---------- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
	background: radial-gradient(50rem 26rem at 85% -10%, rgba(255, 214, 10, .12), transparent 60%), var(--base); }
.signin-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 32px 28px; box-shadow: 0 30px 70px -30px #000; }
.brand { display: flex; align-items: center; gap: 10px; font-family: "Display", sans-serif; font-weight: 800; font-size: 1.35rem; letter-spacing: -.02em; }
.brand img { width: 34px; height: 34px; }
.signin-card .brand { margin-bottom: 28px; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--base); border: 1px solid var(--line); border-radius: 10px; padding: .7em .85em;
	transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 214, 10, .2); }
textarea { min-height: 90px; resize: vertical; }
input.code { font-size: 1.6rem; letter-spacing: .45em; text-align: center; font-variant-numeric: tabular-nums; }
.field { margin-bottom: 16px; }
.hint { font-size: .82rem; color: var(--muted); margin-top: 6px; }
.error { background: rgba(255, 46, 99, .12); border: 1px solid rgba(255, 46, 99, .4); color: #ffb3c3; padding: .6em .85em; border-radius: 10px; margin-bottom: 14px; font-size: .92rem; }
.notice { background: rgba(255, 214, 10, .08); border: 1px solid rgba(255, 214, 10, .35); padding: .7em .9em; border-radius: 12px; margin-bottom: 14px; font-size: .92rem; }
.signin-card .btn { width: 100%; margin-top: 4px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; }

/* ---------- app shell ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(17, 17, 17, .88); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 16px; }
.topbar .spacer { flex: 1; }
.switcher { width: auto; max-width: 260px; padding: .45em .8em; border-radius: 999px; }
.who { font-size: .85rem; color: var(--muted); }
.tabs { max-width: 1180px; margin: 0 auto; padding: 14px 20px 0; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.tab { appearance: none; font: inherit; font-weight: 600; font-size: .95rem; color: var(--text); background: rgba(255, 255, 255, .03); border: 1px solid rgba(246, 243, 234, .16);
	border-radius: 999px; padding: .5em 1.05em; cursor: pointer; white-space: nowrap;
	transition: transform .2s var(--pop), background-color .2s, color .2s, border-color .2s, box-shadow .2s; }
.tab:hover, .tab:focus-visible { background: var(--raised); color: var(--accent); border-color: rgba(255, 214, 10, .5); transform: translateY(-3px) scale(1.05); box-shadow: 0 12px 26px -12px rgba(255, 214, 10, .55); }
.tab:active { transform: scale(.95); background: var(--ignite); color: #111; border-color: transparent; }
.tab[aria-selected="true"] { background: var(--text); color: #111; border-color: var(--text); }
main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 80px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head p { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; margin-bottom: 18px; }
.card h3 { margin-bottom: .35em; }
.grid { display: grid; gap: 18px; }
.grid { margin-bottom: 18px; }
.grid .grid { margin-bottom: 0; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.stat .num { font-family: "Display", sans-serif; font-weight: 800; font-size: 2rem; line-height: 1; }
.stat .lbl { color: var(--muted); font-size: .85rem; margin-top: 6px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: .25em .7em; border-radius: 999px; background: var(--raised); color: var(--muted); white-space: nowrap; }
.badge.live { background: rgba(76, 201, 122, .14); color: var(--ok); }
.badge.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.badge.warn { background: rgba(255, 214, 10, .14); color: var(--accent); }
.badge.bad { background: rgba(255, 46, 99, .14); color: #ff8fa8; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: .55em 0; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border-bottom: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; }
.sticky-save { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--base) 35%); padding: 24px 0 8px; display: flex; justify-content: flex-end; gap: 10px; }

/* editable lists */
.item { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.item > input, .item > textarea { flex: 1; }
.iconbtn { flex: none; appearance: none; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--base); color: var(--muted); cursor: pointer; font-size: 1.1rem; line-height: 1; transition: color .15s, border-color .15s; }
.iconbtn:hover { color: #ff8fa8; border-color: rgba(255, 46, 99, .5); }

/* rules */
.rule { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.rule:last-child { border-bottom: 0; }
.rule .body { flex: 1; min-width: 0; }
.rule .title { font-weight: 700; }
.rule .text { color: var(--muted); font-size: .92rem; margin-top: 2px; }
.kind { font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.switch { position: relative; flex: none; width: 46px; height: 26px; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--text); transition: transform .2s var(--pop); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); background: #111; }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }
.switch input:disabled + span { opacity: .55; }
.custom-rule { background: var(--base); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.custom-rule .head { display: grid; grid-template-columns: 1fr 150px auto auto; gap: 8px; align-items: center; margin-bottom: 8px; }

/* schedule */
.hours { display: grid; grid-template-columns: 70px auto 1fr 1fr; gap: 10px 12px; align-items: center; }
.hours .day { font-weight: 700; }
.hours input[type=time] { padding: .5em .6em; }
.closed { color: var(--muted); font-size: .9rem; grid-column: span 2; }

/* calendars */
.provider { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--base);
	transition: transform .25s var(--pop), border-color .25s, box-shadow .25s, background-color .25s; }
.provider:hover { transform: translateY(-4px) scale(1.02); border-color: rgba(255, 214, 10, .6); background: var(--raised); box-shadow: 0 22px 44px -22px rgba(255, 214, 10, .45); }
.provider .name { font-weight: 700; }

/* calls */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { appearance: none; font: inherit; font-size: .85rem; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: .35em .85em; cursor: pointer;
	transition: transform .2s var(--pop), border-color .2s, color .2s; }
.chip:hover { transform: translateY(-2px); border-color: rgba(255, 214, 10, .5); color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--text); color: #111; border-color: var(--text); }
.calls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 18px; align-items: start; }
.call-list { display: flex; flex-direction: column; gap: 8px; }
.call-row { appearance: none; text-align: left; font: inherit; color: inherit; width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
	transition: transform .2s var(--pop), border-color .2s, background-color .2s, box-shadow .2s; }
.call-row:hover, .call-row:focus-visible { transform: translateY(-3px); border-color: rgba(255, 214, 10, .55); background: var(--raised); box-shadow: 0 16px 34px -18px rgba(255, 214, 10, .45); }
.call-row[aria-current="true"] { border-color: var(--accent); background: var(--raised); }
.call-row .caller { color: var(--text); font-weight: 700; font-size: 1rem; }
.call-row .what { grid-column: 1 / -1; color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-row .when { color: var(--muted); font-size: .82rem; }
.call-row .status { justify-self: end; color: var(--muted); font-size: .82rem; }
.company { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.detail { position: sticky; top: 130px; max-height: calc(100vh - 150px); overflow: auto; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 12px 0 18px; font-size: .93rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.transcript { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.msg { max-width: 85%; padding: .6em .85em; border-radius: 14px; font-size: .93rem; }
.msg.agent { background: var(--accent); color: #111; border-bottom-left-radius: 4px; }
.msg.caller { background: var(--raised); align-self: flex-end; border-bottom-right-radius: 4px; }
.msg .spk { display: block; font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .65; margin-bottom: 2px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; border: 1px dashed var(--line); border-radius: var(--r); }
.copy { display: flex; align-items: center; gap: 10px; font-family: "Display", sans-serif; font-size: 1.4rem; font-weight: 800; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 50;
	background: var(--text); color: #111; font-weight: 700; padding: .7em 1.2em; border-radius: 999px; box-shadow: 0 16px 40px -12px #000; transition: opacity .2s, transform .25s var(--pop); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--red); color: #fff; }

@media (max-width: 860px) {
	.calls { grid-template-columns: 1fr; }
	.detail { position: static; max-height: none; }
	.custom-rule .head { grid-template-columns: 1fr 1fr; }
	.who { display: none; }
}
@media (max-width: 600px) {
	.topbar-in { gap: 10px; padding: 10px 16px; }
	.brand-name { display: none; }
	.company { font-size: .95rem; }
	.switcher { max-width: 160px; }
	.tabs { padding: 12px 16px 0; }
}
@media (max-width: 520px) {
	.hours { grid-template-columns: 52px auto 1fr 1fr; gap: 8px; }
	main { padding: 18px 16px 80px; }
	.card { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
