:root {
  --bg: #f6f7f9; --surface: #ffffff; --ink: #14181f; --muted: #5d6673; --line: #e3e6eb;
  --brand: #0f7a5a; --brand-ink: #ffffff; --brand-soft: #e3f3ed; --accent: #f2a03d;
  --danger: #c2372f; --ai: #eef1f5; --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1216; --surface: #171b21; --ink: #e8ebef; --muted: #98a1ad; --line: #262c34;
    --brand: #2fb589; --brand-soft: #16302a; --ai: #1d232b; --shadow: none; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100vh; display: flex; flex-direction: column; }
[hidden] { display: none !important; }
button, input { font: inherit; }

.top { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 10px; font-size: 17px; letter-spacing: .02em; }
.logo { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; }
.who { color: var(--muted); font-size: 14px; }

.center { flex: 1; display: grid; place-items: center; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.narrow { width: min(400px, 100%); display: flex; flex-direction: column; gap: 14px; }
h1 { font-size: 22px; margin: 0 0 4px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
input { padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); }
input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.primary { background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 600; cursor: pointer; }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; }
.small { padding: 6px 12px; font-size: 13px; border-radius: 8px; border: 0; background: var(--brand); color: var(--brand-ink); cursor: pointer; }
.small.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.error { color: var(--danger); min-height: 1em; margin: 0; font-size: 14px; }
.secret { display: block; padding: 10px; background: var(--bg); border-radius: 8px; word-break: break-all; font-size: 15px; letter-spacing: .08em; }

.crm { flex: 1; display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 0; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.side a { color: var(--ink); text-decoration: none; padding: 9px 12px; border-radius: 8px; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.side a:hover { background: var(--bg); }
.side a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 16px 12px 4px; }
.badge { background: var(--accent); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.main { min-width: 0; overflow-y: auto; padding: 24px 28px; display: flex; flex-direction: column; gap: 16px; }
.main h1 { font-size: 22px; margin: 0; }
.main h2 { font-size: 16px; margin: 8px 0 0; }
.lead { color: var(--muted); margin: -6px 0 0; font-size: 14px; }
.top-right { display: flex; align-items: center; gap: 14px; }
.stop-flag { background: var(--danger); color: #fff; border-radius: 8px; padding: 4px 10px; font-size: 13px; font-weight: 600; }
section[data-view] { display: flex; flex-direction: column; gap: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; color: var(--ink); }
.kpi b { display: block; font-size: 28px; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: 13px; }
.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.list li { padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.list li:last-child { border-bottom: 0; }
.cards { display: flex; flex-direction: column; gap: 12px; }
.card2 { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.card2 h3 { margin: 0; font-size: 15px; }
.card2 .body { font-size: 14px; white-space: pre-wrap; color: var(--ink); }
.empty { color: var(--muted); font-size: 14px; padding: 20px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.toolbar { display: flex; gap: 8px; align-items: center; }
.toolbar.wrap { flex-wrap: wrap; }
.toolbar input { flex: 1; min-width: 140px; }
select { padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font: inherit; }
textarea { padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font: inherit; min-height: 64px; resize: vertical; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--bg); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--bg); border: 1px solid var(--line); }
.pill.ok { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.pill.wait { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); border-color: transparent; }
.pill.off { color: var(--muted); }
.danger { background: var(--danger); color: #fff; border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 600; cursor: pointer; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; max-width: 560px; }
.form { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.detail { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.detail pre { white-space: pre-wrap; font: inherit; font-size: 14px; margin: 0; }
.jessy:not([hidden]) { display: grid !important; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 0 !important; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-height: 70vh; }
.stage { border-right: 1px solid var(--line); padding: 28px 20px; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.orb-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 24px; text-align: center; }
.orb { width: 160px; height: 160px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #4fd1a5, var(--brand) 60%, #0a4f3b); box-shadow: 0 0 0 0 rgba(47, 181, 137, .4); transition: transform .25s; }
.orb[data-state="listening"] { animation: breathe 2.4s ease-in-out infinite; }
.orb[data-state="hearing"] { transform: scale(1.06); box-shadow: 0 0 0 14px rgba(47, 181, 137, .18); }
.orb[data-state="thinking"] { animation: think 1s linear infinite; opacity: .85; }
.orb[data-state="speaking"] { animation: speak .5s ease-in-out infinite alternate; }
@keyframes breathe { 50% { transform: scale(1.03); } }
@keyframes think { 50% { opacity: .6; } }
@keyframes speak { to { transform: scale(1.08); box-shadow: 0 0 0 18px rgba(242, 160, 61, .18); } }
@media (prefers-reduced-motion: reduce) { .orb { animation: none !important; } }
.name { font-size: 22px; font-weight: 700; margin: 8px 0 0; letter-spacing: .02em; }
.status { font-weight: 600; margin: 0; color: var(--muted); }
.interim { color: var(--muted); min-height: 1.4em; margin: 0; max-width: 320px; font-style: italic; }
.controls { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 300px; }
.mic { background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 999px; padding: 13px; font-weight: 600; cursor: pointer; }
.mic[aria-pressed="true"] { background: var(--danger); }
.toggle { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; }
.mic-live { text-decoration: none; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--danger); font-weight: 600; }
.mic-live i { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); animation: breathe 1.2s infinite; }
.note { color: var(--muted); font-size: 13px; margin: 0; }
.stage .note { text-align: center; max-width: 300px; font-size: 12px; }

.chat { display: flex; flex-direction: column; min-height: 0; padding: 20px 24px; gap: 12px; max-height: 78vh; }
.messages { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 78%; padding: 11px 14px; border-radius: 14px; line-height: 1.45; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--ai); border-bottom-left-radius: 4px; }
.meta { font-size: 12px; color: var(--muted); margin-top: 6px; }
.learn { margin-top: 8px; padding: 10px; border: 1px dashed var(--brand); border-radius: 10px; background: var(--brand-soft); font-size: 14px; }
.learn .row, .initiative .row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.initiative { border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-radius: var(--radius); padding: 12px 14px; }
.initiative p { margin: 0; }
.composer { display: flex; gap: 8px; }
.composer input { flex: 1; min-width: 0; }

@media (max-width: 860px) {
  .crm { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .side { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .side a { white-space: nowrap; }
  .nav-group { display: none; }
  .main { padding: 16px; }
  .jessy:not([hidden]) { grid-template-columns: minmax(0, 1fr); }
  .table { display: block; overflow-x: auto; }
  .top-right .who { display: none; }
}
@media (max-width: 760px) {
  .stage { border-right: 0; border-bottom: 1px solid var(--line); padding: 20px 16px; }
  .orb { width: 110px; height: 110px; }
  .chat { padding: 16px; }
  .msg { max-width: 92%; }
}

.settings { width: 100%; max-width: 300px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.settings summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.settings form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.list a { color: var(--ink); text-decoration: none; font-weight: 500; } .list a:hover { color: var(--brand); text-decoration: underline; }

.demo-live { max-width: none; display: flex; flex-direction: column; gap: 10px; border-color: var(--danger); }
.demo-live video { width: 100%; max-height: 300px; background: #000; border-radius: 10px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); display: inline-block; animation: breathe 1.2s infinite; }
.demo-live .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.card2 a.small { text-decoration: none; display: inline-block; }

.start ol { margin: 8px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.start li.done { color: var(--muted); text-decoration: line-through; }
.start a { color: var(--brand); }
.start { max-width: none; }

.screen-btn[aria-pressed="true"] { border-color: var(--danger); color: var(--danger); font-weight: 600; }
