:root {
  color-scheme: light;
  --bg: #f4f6fb; --card: #ffffff; --ink: #0e1a2b; --ink-2: #33415a; --muted: #66758c; --line: #e2e7f0; --line-2: #eef1f7;
  --blue: #2353d6; --blue-ink: #1a3fa8; --blue-soft: #e9effd; --blue-mist: #f3f6fe;
  --green: #12805c; --green-soft: #e2f3ec; --amber: #a36200; --amber-soft: #fdf0d9; --red: #c2362b; --red-soft: #fbe7e5;
  --radius: 14px; --shadow: 0 1px 2px rgba(14, 26, 43, .05), 0 4px 16px rgba(14, 26, 43, .04);
  --head: "Poppins", system-ui, sans-serif; --body: "Inter", system-ui, sans-serif;
  --top: 60px; --pa-w: 400px; --rail-w: 92px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { font-family: var(--head); margin: 0; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
a { color: var(--blue); }

/* ---------- sign-in */
#gate, #denied { min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 10% -10%, #dfe8ff 0, transparent 60%), var(--bg); }
.gate-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 32px 28px; max-width: 440px; width: 100%; text-align: center; box-shadow: var(--shadow); }
.gate-card h1 { font-size: 22px; margin: 14px 0 6px; }
.gate-card p { color: var(--muted); margin: 0 0 20px; }
#signin { display: flex; justify-content: center; }

/* ---------- layout */
#app { display: grid; height: 100%; grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--pa-w); grid-template-rows: var(--top) minmax(0, 1fr);
  grid-template-areas: "top top top" "rail main pa"; }
.top { grid-area: top; display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand strong { display: block; font: 600 16px/1.1 var(--head); }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.persona { display: flex; align-items: center; gap: 8px; margin-left: 12px; padding: 4px 4px 4px 12px; border-radius: 999px; background: var(--blue-soft); color: var(--blue-ink); font-size: 12px; font-weight: 600; }
.persona select { border: 0; background: var(--card); border-radius: 999px; padding: 6px 10px; font-size: 13px; font-weight: 500; color: var(--ink); max-width: 260px; }
.who { margin-left: auto; text-align: right; font-size: 13px; color: var(--muted); line-height: 1.25; }
.who strong { display: block; color: var(--ink); font-weight: 600; }

.rail { grid-area: rail; background: var(--card); border-right: 1px solid var(--line); padding: 12px 8px; display: flex; flex-direction: column; gap: 4px; }
.rail button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border: 0; background: none; border-radius: 12px; color: var(--muted); font-size: 12px; font-weight: 500; }
.rail button:hover { background: var(--blue-mist); color: var(--ink); }
.rail button[aria-current="page"] { background: var(--blue-soft); color: var(--blue-ink); }
.rail svg { width: 22px; height: 22px; }
.badge { position: absolute; top: 4px; right: 14px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font: 600 11px/18px var(--body); }
.only-mobile { display: none !important; }

main { grid-area: main; overflow: auto; padding: 24px; }
.view { max-width: 1120px; margin: 0 auto; }

/* ---------- cards & bits */
.hero { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 24px; margin-bottom: 20px; }
.hero h1 { font-size: 26px; }
.hero p { margin: 4px 0 0; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--blue-soft); color: var(--blue-ink); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.card-h { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-h h2 { font-size: 15px; font-weight: 600; }
.card-h .more { margin-left: auto; }
.section-title { font: 600 13px var(--body); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 28px 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.big { font: 700 40px/1 var(--head); letter-spacing: -.02em; }
.row { display: flex; align-items: center; gap: 10px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line-2); min-width: 0; }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .grow > * { overflow: hidden; text-overflow: ellipsis; }
.pill { flex: none; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--line-2); color: var(--ink-2); }
.pill.ok { background: var(--green-soft); color: var(--green); }
.pill.warn { background: var(--amber-soft); color: var(--amber); }
.pill.bad { background: var(--red-soft); color: var(--red); }
.pill.info { background: var(--blue-soft); color: var(--blue-ink); }
.bar { height: 8px; border-radius: 4px; background: var(--line-2); overflow: hidden; display: flex; margin: 12px 0 6px; }
.bar i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; background: var(--c); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 13px; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: #c9d3e4; background: var(--blue-mist); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-ink); }
.btn.ok { color: var(--green); }
.btn.bad { color: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn.ask { background: var(--blue-soft); border-color: transparent; color: var(--blue-ink); }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.field { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea { font-size: 14px; font-weight: 400; color: var(--ink); padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); min-width: 0; }
.field input:focus, .field select:focus, .field textarea:focus, .pa-input textarea:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; align-items: end; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; }

/* onboarding */
.onboard { background: linear-gradient(135deg, #2353d6, #3d6ff0); color: #fff; border: 0; }
.onboard .muted { color: #d6e1ff; }
.onboard .bar { background: rgba(255, 255, 255, .25); }
.onboard .bar i { background: #fff; }
.steps { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.steps li { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.steps .tick { width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .6); display: grid; place-items: center; flex: none; font-size: 12px; }
.steps .done .tick { background: #fff; color: var(--blue); border-color: #fff; }
.steps .done span { opacity: .75; text-decoration: line-through; }
.onboard .btn { background: #fff; color: var(--blue-ink); border-color: #fff; }

/* rota */
.rota { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 8px; }
.rota div { border: 1px solid var(--line-2); border-radius: 10px; padding: 8px 10px; font-size: 12px; background: var(--blue-mist); }
.rota strong { display: block; font-size: 13px; color: var(--ink); margin-bottom: 2px; }
.rota .today { border-color: var(--blue); background: var(--blue-soft); }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--blue-mist); }

/* ---------- PA panel */
.pa { grid-area: pa; display: flex; flex-direction: column; min-height: 0; background: var(--card); border-left: 1px solid var(--line); }
.pa-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.pa-head strong { display: block; font: 600 15px var(--head); }
.pa-head small { display: block; color: var(--muted); font-size: 12px; }
.pa-head .icon-btn { margin-left: auto; }
.pa-avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: #fff; font: 700 16px var(--head); background: var(--blue); flex: none; }
.pa-log { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 16px; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.msg p { margin: 0 0 6px; } .msg p:last-child { margin: 0; }
.msg ul { margin: 4px 0 6px; padding-left: 18px; }
.msg.me { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 5px; }
.msg.ai { align-self: flex-start; background: var(--line-2); border-bottom-left-radius: 5px; }
.msg.sys { align-self: center; background: none; color: var(--muted); font-size: 12px; padding: 2px; }
.msg.typing { color: var(--muted); }
.typing i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin: 0 2px; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25 } 40% { opacity: 1 } }
.acts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.act { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--green-soft); color: var(--green); }
.act.err { background: var(--amber-soft); color: var(--amber); }
.pa-suggest { display: flex; gap: 6px; padding: 0 16px 8px; overflow-x: auto; scrollbar-width: none; }
.pa-suggest button { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 12px; color: var(--ink-2); }
.pa-suggest button:hover { border-color: var(--blue); color: var(--blue-ink); }
.pa-input { display: flex; align-items: flex-end; gap: 6px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.pa-input textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 18px; padding: 9px 14px; max-height: 140px; font-size: 14px; background: var(--bg); }
.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 0; background: none; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--blue-mist); color: var(--ink); }
.mic[aria-pressed="true"] { background: var(--red); color: #fff; animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(194, 54, 43, .45) } 70% { box-shadow: 0 0 0 10px rgba(194, 54, 43, 0) } 100% { box-shadow: 0 0 0 0 rgba(194, 54, 43, 0) } }
.send { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--blue); color: #fff; flex: none; }
.send:disabled { opacity: .45; }

/* ---------- colleague chat */
.chat-wrap { display: grid; grid-template-columns: 280px minmax(0, 1fr); height: calc(100vh - var(--top) - 48px); min-height: 420px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.people { border-right: 1px solid var(--line); overflow: auto; }
.people h2 { font-size: 15px; padding: 16px 16px 8px; }
.person { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 16px; border: 0; background: none; text-align: left; }
.person:hover { background: var(--blue-mist); }
.person[aria-current="true"] { background: var(--blue-soft); }
.person .grow { flex: 1; min-width: 0; }
.person strong { display: block; font-size: 14px; }
.person small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; font: 600 13px var(--head); flex: none; }
.unread { background: var(--red); color: #fff; border-radius: 9px; min-width: 18px; height: 18px; font: 600 11px/18px var(--body); text-align: center; padding: 0 5px; }
.convo { display: flex; flex-direction: column; min-height: 0; }
.convo-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.convo-log { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; background: var(--blue-mist); }
.convo-log .msg.ai { background: var(--card); border: 1px solid var(--line); }
.stamp { font-size: 11px; opacity: .7; margin-top: 2px; text-align: right; }
.empty { margin: auto; text-align: center; color: var(--muted); padding: 24px; }
.back { display: none; }

/* ---------- inbox & policies */
.split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.thread { border-left: 3px solid var(--blue-soft); padding: 4px 0 4px 12px; margin: 10px 0; }
.thread .from { font-weight: 600; font-size: 13px; }
.unread-row { font-weight: 600; }
.unread-row .grow > :first-child::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); margin-right: 6px; }
.search { width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 14px; margin-bottom: 12px; background: var(--card); }
.policy-text { white-space: pre-wrap; font-size: 14px; line-height: 1.6; max-height: 60vh; overflow: auto; padding-right: 6px; }
.policy-text h3 { font-size: 15px; margin: 14px 0 4px; white-space: normal; }

/* ---------- modal & toast */
dialog { border: 0; border-radius: 18px; padding: 24px; width: min(720px, calc(100% - 32px)); max-height: calc(100% - 48px); box-shadow: 0 20px 60px rgba(14, 26, 43, .25); }
dialog::backdrop { background: rgba(14, 26, 43, .4); }
.modal-x { position: absolute; right: 12px; top: 10px; }
.modal-x button { border: 0; background: none; font-size: 26px; color: var(--muted); }
#modal-body h2 { font-size: 20px; margin-bottom: 4px; padding-right: 28px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 50; max-width: calc(100% - 32px); box-shadow: var(--shadow); }

/* ---------- responsive */
@media (max-width: 1180px) { :root { --pa-w: 360px; } }
@media (max-width: 960px) {
  :root { --top: 56px; }
  #app { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--top) minmax(0, 1fr) auto; grid-template-areas: "top" "main" "rail"; }
  .rail { flex-direction: row; justify-content: space-around; border-right: 0; border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .rail button { flex: 1; font-size: 11px; padding: 6px 2px; }
  .badge { right: calc(50% - 22px); }
  .only-mobile { display: flex !important; }
  .pa { grid-area: main; border-left: 0; }
  #app:not(.pa-open) .pa { display: none; }
  #app.pa-open main { display: none; }
  main { padding: 16px; }
  .who { display: none; }
  .persona { margin-left: auto; }
  .persona span { display: none; }
  .persona select { max-width: 200px; }
  .brand small { display: none; }
  .chat-wrap { grid-template-columns: minmax(0, 1fr); height: calc(100vh - var(--top) - 110px); }
  .chat-wrap.open .people { display: none; }
  .chat-wrap:not(.open) .convo { display: none; }
  .back { display: grid; }
  .hero h1 { font-size: 22px; }
}
@media (max-width: 420px) { .grid { grid-template-columns: minmax(0, 1fr); } .persona select { max-width: 150px; } }
