:root {
  --navy: #092438;
  --navy-deep: #071c2c;
  --green: #367310; /* accessible text/button green */
  --brand-green: #438d12;
  --lime: #8bcb38;
  --mint: #f3f7f0;
  --mint-line: #d6e2cb;
  --ink: #092438;
  --muted: #3e5466;
  --subtle: #5b7183;
  --line: #e6ecf0;
  --panel: #f7f9fa;
  --danger: #b42318;
  --font-head: Geist, Inter, system-ui, sans-serif;
  --font-body: Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font-body); color: var(--ink); background: #fff; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--font-head); letter-spacing: -0.03em; font-weight: 600; margin: 0; }
a { color: var(--green); }
a:hover { color: var(--navy); }
button, input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; }
.pep { font-family: Lato, sans-serif; font-style: italic; font-weight: 900; letter-spacing: -0.01em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
:focus-visible { outline: 3px solid var(--lime); outline-offset: 2px; }

/* ---------- Shared controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 20px; border-radius: 999px; border: 0; cursor: pointer; font-family: var(--font-head); font-weight: 600; font-size: 16px; text-decoration: none; background: var(--navy); color: #fff; }
.btn:hover { color: #fff; filter: brightness(1.15); }
.btn-green { background: var(--green); }
.btn-lime { background: var(--lime); color: var(--navy); }
.btn-lime:hover { color: var(--navy); }
.btn-ghost { background: transparent; color: var(--navy); border: 1.5px solid var(--mint-line); }
.btn-ghost:hover { color: var(--navy); background: var(--mint); filter: none; }
.btn-danger { background: transparent; color: var(--danger); border: 1.5px solid #f3c4bf; }
.btn-danger:hover { color: var(--danger); background: #fff4f2; filter: none; }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.field input, .field textarea, .field select { font-weight: 400; font-size: 16px; padding: 11px 14px; border: 1.5px solid #cfd9e0; border-radius: 12px; background: #fff; min-height: 44px; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--green); outline: none; box-shadow: 0 0 0 3px rgba(139,203,56,.3); }
.hint { font-weight: 400; color: var(--subtle); font-size: 13px; }
.alert { padding: 12px 16px; border-radius: 12px; font-size: 15px; }
.alert-error { background: #fff4f2; color: var(--danger); border: 1px solid #f3c4bf; }
.alert-ok { background: var(--mint); color: var(--green); border: 1px solid var(--mint-line); }
.alert-warn { background: #fff8e6; color: #7a5200; border: 1px solid #f5dfa5; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px 16px; background: var(--mint); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border-radius: 24px; padding: 36px 32px; box-shadow: 0 20px 50px rgba(9,36,56,.08); display: flex; flex-direction: column; gap: 18px; }
.auth-card h1 { font-size: 28px; }

/* ---------- Dashboard ---------- */
.dash { display: flex; flex-wrap: wrap; min-height: 100vh; background: var(--panel); }
.dash-side { flex: 1 1 240px; max-width: 260px; background: var(--navy); color: #c9d6e0; padding: 24px 16px; display: flex; flex-direction: column; gap: 4px; }
.dash-side a.nav { display: flex; align-items: center; gap: 10px; color: #c9d6e0; text-decoration: none; padding: 11px 12px; border-radius: 10px; font-weight: 500; min-height: 44px; }
.dash-side a.nav:hover, .dash-side a.nav[aria-current="page"] { background: rgba(255,255,255,.08); color: #fff; }
.dash-side .badge { margin-left: auto; background: var(--lime); color: var(--navy); font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.dash-main { flex: 999 1 560px; min-width: 0; padding: 32px clamp(16px, 4vw, 48px) 64px; }
.dash-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.dash-head h1 { font-size: 30px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 24px; }
.card h2 { font-size: 20px; margin-bottom: 4px; }
.grid { display: flex; flex-wrap: wrap; gap: 20px; }
.grid > * { flex: 1 1 300px; min-width: 0; }
.stat { font-family: var(--font-head); font-size: 34px; font-weight: 600; letter-spacing: -0.03em; }
.meter { height: 10px; background: #e8eef2; border-radius: 999px; overflow: hidden; margin-top: 10px; }
.meter > span { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.meter.warn > span { background: #d18b00; }
.meter.full > span { background: var(--danger); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.tabs a { padding: 12px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2.5px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--navy); border-bottom-color: var(--green); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-weight: 600; color: var(--subtle); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
code.embed { display: block; white-space: pre-wrap; word-break: break-all; background: var(--navy); color: #d9f2b8; padding: 16px; border-radius: 12px; font-size: 13px; line-height: 1.6; }
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--mint); color: var(--green); }
.pill-warn { background: #fff4f2; color: var(--danger); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.transcript { display: flex; flex-direction: column; gap: 8px; }
.transcript .pt-msg { max-width: 80%; }

/* ---------- Chat window (embed) ---------- */
.pt-chat { --bot: #092438; height: 100vh; display: flex; flex-direction: column; background: #fff; font-size: 15px; }
.pt-chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--mint); border-bottom: 1px solid #e2ead9; }
.pt-chat-avatar { border-radius: 12px; background: #fff; }
.pt-chat-name { font-family: var(--font-head); font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-chat-status { font-size: 12.5px; color: var(--green); font-weight: 600; }
.pt-chat-tag { font-size: 12px; font-weight: 700; background: #fff8e6; color: #7a5200; padding: 3px 8px; border-radius: 999px; }
.pt-chat-close { width: 44px; height: 44px; border: 0; background: transparent; border-radius: 10px; cursor: pointer; color: var(--muted); display: flex; align-items: center; justify-content: center; }
.pt-chat-close:hover { background: rgba(9,36,56,.06); }
.pt-chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; line-height: 1.45; }
.pt-msg { max-width: 86%; padding: 10px 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.pt-msg-bot { align-self: flex-start; background: #eef2f5; border-radius: 16px 16px 16px 4px; }
.pt-msg-user { align-self: flex-end; background: var(--bot); color: #fff; border-radius: 16px 16px 4px 16px; }
.pt-typing { display: flex; gap: 4px; padding: 14px; }
.pt-typing span { width: 7px; height: 7px; border-radius: 999px; background: #8a9cab; animation: pt-bounce 1s infinite; }
.pt-typing span:nth-child(2) { animation-delay: .15s; } .pt-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes pt-bounce { 0%,80%,100% { transform: translateY(0); opacity: .5 } 40% { transform: translateY(-4px); opacity: 1 } }
.pt-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pt-chip { border: 1.5px solid var(--green); color: var(--green); background: #fff; font-weight: 600; font-size: 14px; padding: 9px 13px; border-radius: 999px; cursor: pointer; min-height: 40px; }
.pt-chip:hover { background: var(--mint); }
.pt-lead { display: flex; flex-direction: column; gap: 10px; background: var(--mint); border: 1px solid #e2ead9; border-radius: 16px; padding: 14px; }
.pt-lead-title { font-family: var(--font-head); font-weight: 600; }
.pt-lead label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.pt-lead input, .pt-lead textarea { border: 1.5px solid #cfd9e0; border-radius: 10px; padding: 9px 11px; font-size: 15px; font-weight: 400; background: #fff; }
.pt-btn { background: var(--bot); color: #fff; border: 0; border-radius: 999px; padding: 10px 16px; font-weight: 600; cursor: pointer; min-height: 44px; }
.pt-btn-ghost { background: transparent; border: 0; color: var(--muted); font-weight: 600; cursor: pointer; min-height: 44px; padding: 0 10px; }
.pt-error { color: var(--danger); font-size: 14px; }
.pt-chat-input { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); }
.pt-chat-input input { flex: 1; min-width: 0; border: 0; background: #f2f5f7; border-radius: 999px; padding: 12px 16px; font-size: 15px; }
.pt-chat-input input:focus { outline: 2px solid var(--lime); }
.pt-chat-input button { width: 44px; height: 44px; flex: none; border-radius: 999px; border: 0; background: var(--bot); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.pt-chat-input button[disabled] { opacity: .45; cursor: default; }
.pt-chat-foot { text-align: center; font-size: 12px; color: var(--subtle); padding: 0 12px 10px; min-height: 10px; }
.pt-chat-foot a { color: var(--subtle); text-decoration: none; }
