/* Corevia app: design layer on top of nexa.css and the page's base styles.
   Ink sidebar, overview hero, KPI tiles, richer rows, command palette and micro-interactions. */

/* ---------- shell ---------- */
.app { grid-template-columns: 256px minmax(0, 1fr); }
main { position: relative; isolation: isolate; }
main::before { content: ""; position: absolute; z-index: -1; left: 0; right: 0; top: 0; height: 380px; pointer-events: none; opacity: .55;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 75% 80% at 50% 0%, #000 5%, transparent 70%); -webkit-mask-image: radial-gradient(ellipse 75% 80% at 50% 0%, #000 5%, transparent 70%); }

/* ink sidebar: local tokens so every child component adapts */
.side {
  --text: #fafaf9; --text-2: #bdb6b0; --text-3: #8a827c;
  --line: rgba(255, 255, 255, .08); --line-strong: rgba(255, 255, 255, .16);
  --surface: #0f0d0c; --surface-2: rgba(255, 255, 255, .07); --surface-3: rgba(255, 255, 255, .12); --bg: rgba(255, 255, 255, .04);
  --btn-bg: #fafaf9; --btn-fg: #0c0a09; --btn-hover: #e7e5e4;
  color: var(--text); background: #0f0d0c; border-right-color: #000; gap: 14px;
  background-image: radial-gradient(360px 240px at 0% 0%, rgba(255, 91, 20, .18), transparent 70%), radial-gradient(300px 300px at 100% 100%, rgba(255, 91, 20, .06), transparent 70%);
}
.side .brand { color: var(--text); }
.nav { gap: 3px; }
.nav a { min-height: 40px; border-radius: 10px; }
.nav a .icon { width: 18px; height: 18px; }
.nav a[aria-current="page"] { background: rgba(255, 255, 255, .1); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); }
.nav a[aria-current="page"] .icon { color: var(--accent); }
.nav a:active { transform: scale(.98); }
.nav .nav-k { margin-left: auto; font: 500 10px/1 var(--mono); letter-spacing: .06em; color: var(--text-3); opacity: 0; transition: opacity .2s var(--ease); }
.nav .count + .nav-k { margin-left: 8px; }
.nav a:hover .nav-k { opacity: 1; }
.side .count { background: var(--accent); color: #1a0a02; }
.side .count.zero, .side .count:empty { background: var(--surface-3); color: var(--text-3); }

/* Nexa status card */
.bizcard { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 1px 12px; align-items: center; padding: 12px; border-radius: 14px; background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .08); }
.bizcard .nx-av { grid-row: span 2; }
.bizcard .biz-name { align-self: end; }
.bizcard .status { margin-top: 0; align-self: start; }
.bizcard .tag { grid-column: 1 / -1; justify-self: start; }

/* Nexa avatar (app) */
.nx-av { position: relative; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--btn-bg); color: var(--btn-fg); font-size: 22px; }
.nx-av .nx-mark { --nx-dot: var(--accent); }
.nx-av::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--ok); border: 2px solid var(--surface); }
.nx-av.lg { width: 48px; height: 48px; font-size: 28px; }
.nx-av.sm { width: 30px; height: 30px; font-size: 17px; }
.nx-av.sm::after { width: 9px; height: 9px; }
.nx-av.speaking::before { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--accent); animation: ping 1.5s var(--ease) infinite; }

/* search / command button */
.cmdk-btn { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 0 8px 0 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text-3); font: 500 13px var(--font); cursor: pointer; transition: color .2s var(--ease), border-color .2s var(--ease), background .2s var(--ease); }
.cmdk-btn .icon { width: 16px; height: 16px; }
.cmdk-btn:hover { color: var(--text); border-color: var(--line-strong); background: var(--surface-2); }
.cmdk-btn kbd, .cmdk kbd { margin-left: auto; font: 500 10.5px/1 var(--mono); padding: 4px 6px; border-radius: 5px; border: 1px solid var(--line-strong); color: var(--text-2); background: var(--bg); }
.theme-btn .icon { width: 17px; height: 17px; }

/* ---------- page heads ---------- */
.page-head h1 { font-size: 30px; letter-spacing: -.03em; }
.card-head h2 .h-ic, .h-ic { width: 26px; height: 26px; border-radius: 8px; display: inline-grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.h-ic .icon { width: 14px; height: 14px; }

/* ---------- overview hero ---------- */
.ov-hero {
  --text: #fafaf9; --text-2: #c9c2bc; --text-3: #938b85;
  --line: rgba(255, 255, 255, .1); --line-strong: rgba(255, 255, 255, .2);
  --surface: #171412; --surface-2: rgba(255, 255, 255, .1);
  --btn-bg: #fafaf9; --btn-fg: #0c0a09; --btn-hover: #e7e5e4;
  position: relative; isolation: isolate; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px;
  align-items: stretch; padding: 30px; margin-bottom: 20px; border-radius: 22px; background: #0f0d0c; color: var(--text);
  border: 1px solid rgba(255, 255, 255, .06); box-shadow: var(--shadow-lg);
}
.ov-hero::before { content: ""; position: absolute; z-index: -1; width: 560px; height: 560px; right: -160px; top: -300px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 91, 20, .45), transparent 62%); filter: blur(10px); animation: orb-breathe 7s ease-in-out infinite; }
.ov-hero::after { content: ""; position: absolute; z-index: -1; inset: 0; opacity: .5;
  background-image: linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px); background-size: 40px 40px;
  mask-image: linear-gradient(100deg, #000, transparent 65%); -webkit-mask-image: linear-gradient(100deg, #000, transparent 65%); }
@keyframes orb-breathe { 50% { transform: scale(1.12); opacity: .8; } }
.ov-ring { position: absolute; z-index: -1; left: -150px; bottom: -260px; width: 520px; height: 520px; color: #fff; opacity: .07; animation: spin-slow 90s linear infinite; }
.ov-ring path { fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linecap: round; }
@keyframes spin-slow { to { transform: rotate(360deg); } }
.ov-hero-main { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.ov-hero .eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-3); }
.ov-hero .eyebrow::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.ov-hero h1 { font-size: clamp(26px, 3.2vw, 36px); letter-spacing: -.035em; margin: 10px 0 10px; color: var(--text); }
.ov-sum { color: var(--text-2); font-size: 15px; max-width: 48ch; }
.ov-sum b { color: var(--text); font-weight: 600; }
.ov-sum .hot { color: #ff8a50; }
.ov-hero .btnrow { margin-top: 22px; }
.ov-hero .btn { background: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .14); color: var(--text); }
.ov-hero .btn:hover { background: rgba(255, 255, 255, .13); border-color: rgba(255, 255, 255, .24); }
.ov-hero .btn.primary { background: #fafaf9; color: #0c0a09; border-color: #fafaf9; }
.ov-hero .btn.primary:hover { background: #fff; }
.ov-agent { display: flex; flex-direction: column; gap: 12px; padding: 18px; border-radius: 16px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .09); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.ov-agent .agent-top { display: flex; align-items: center; gap: 12px; }
.ov-agent h3 { font-size: 15px; color: var(--text); }
.ov-agent .agent-top p { font-size: 13px; color: var(--text-2); }
.ov-agent .nx-av::after { border-color: #1a1715; }
#ov-agent-calendar { font-size: 12.5px; color: var(--text-3); }
.ov-agent .btnrow .btn { flex: 1; justify-content: center; }
.ov-wave { display: flex; align-items: center; gap: 3px; height: 38px; padding: 0 2px; }
.ov-wave i { flex: 1; height: var(--h, 50%); border-radius: 3px; background: rgba(255, 255, 255, .16); transform-origin: center; animation: wv-idle 2.6s ease-in-out infinite alternate; animation-delay: calc(var(--k) * -110ms); }
.ov-agent.live .ov-wave i { background: var(--accent); animation: wv-live .55s ease-in-out infinite alternate; animation-delay: calc(var(--k) * -60ms); }
@keyframes wv-idle { from { transform: scaleY(.25); } to { transform: scaleY(.55); } }
@keyframes wv-live { from { transform: scaleY(.2); } to { transform: scaleY(1); } }
@media (max-width: 1000px) { .ov-hero { grid-template-columns: minmax(0, 1fr); padding: 24px 20px; gap: 20px; } }

/* ---------- KPI tiles ---------- */
.kpis { gap: 14px; border: 0; background: none; box-shadow: none; overflow: visible; }
.kpi { position: relative; display: flex; flex-direction: column; padding: 16px 18px 16px; border: 1px solid var(--line) !important; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-xs);
  color: inherit; text-decoration: none; overflow: hidden; transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s var(--ease); --tone: var(--text-2); --tone-soft: var(--surface-2); }
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--line-strong) !important; background: var(--surface); }
.kpi:active { transform: translateY(-1px) scale(.99); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kpi-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--tone-soft); color: var(--tone); transition: transform .4s cubic-bezier(.3, 1.6, .5, 1); }
.kpi:hover .kpi-ic { transform: rotate(-8deg) scale(1.08); }
.kpi-ic .icon { width: 17px; height: 17px; }
.kpi .go { width: 16px; height: 16px; color: var(--text-3); opacity: 0; transform: translateX(-4px); transition: opacity .25s var(--ease), transform .25s var(--ease); }
.kpi:hover .go { opacity: 1; transform: none; }
.kpi .lbl { font-size: 13px; color: var(--text-2); }
.kpi b { margin-top: 2px; font-size: 30px; letter-spacing: -.03em; }
.kpi small { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.t-accent { --tone: var(--accent-ink); --tone-soft: var(--accent-soft); }
.kpi.t-info { --tone: var(--info); --tone-soft: var(--info-soft); }
.kpi.t-ok { --tone: var(--ok); --tone-soft: var(--ok-soft); }
.kpi.t-warn { --tone: var(--warn); --tone-soft: var(--warn-soft); }
.kpi.hot { border-color: color-mix(in srgb, var(--accent) 35%, transparent) !important; background: linear-gradient(180deg, var(--accent-soft), var(--surface) 75%); }
.kpi.hot b { animation: none; color: var(--accent-ink); }
.kpi.hot .kpi-ic { animation: kpi-nudge 2.4s var(--ease) infinite; }
@keyframes kpi-nudge { 0%, 70%, 100% { transform: none; } 75% { transform: rotate(-12deg); } 85% { transform: rotate(10deg); } 92% { transform: rotate(-4deg); } }
.spark { position: absolute; right: 16px; bottom: 18px; width: 88px; height: 32px; overflow: visible; }
.spark .area { fill: color-mix(in srgb, var(--accent) 14%, transparent); }
.spark .ln { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: spark-draw 1.2s var(--ease) forwards .3s; }
.spark .pt { fill: var(--accent); }
@keyframes spark-draw { to { stroke-dashoffset: 0; } }
@media (max-width: 720px) { .kpis { gap: 10px; } .kpi { padding: 14px; } .kpi b { font-size: 24px; } .spark { display: none; } }

/* ---------- cards ---------- */
.card { --mx: -999px; --my: -999px; }
.card:hover { background-image: radial-gradient(520px circle at var(--mx) var(--my), color-mix(in srgb, var(--accent) 5%, transparent), transparent 45%); }
.card-head { gap: 10px; }

/* callback rows: avatar with a stable hue per person */
.who-av { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 12.5px; font-weight: 600; letter-spacing: .02em;
  color: hsl(var(--h) 45% 30%); background: hsl(var(--h) 70% 93%); }
.who-av.urgent { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--danger); animation: who-pulse 2s ease-in-out infinite; }
@keyframes who-pulse { 50% { box-shadow: 0 0 0 2px var(--surface), 0 0 0 7px color-mix(in srgb, var(--danger) 25%, transparent); } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .who-av { color: hsl(var(--h) 70% 82%); background: hsl(var(--h) 30% 18%); } }
:root[data-theme="dark"] .who-av { color: hsl(var(--h) 70% 82%); background: hsl(var(--h) 30% 18%); }
.row { transition: background .15s var(--ease); }
.row:hover { background: var(--surface-2); }
.row .btn.small { transition: transform .2s var(--ease), background .15s; }
.row:hover .btn.small { transform: translateX(-2px); }

/* recent call icons */
.call-ic { width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.call-ic .icon { width: 16px; height: 16px; }
.call-ic.booked { background: var(--ok-soft); color: var(--ok); }
.call-ic.message { background: var(--warn-soft); color: var(--warn); }
.call-ic.urgent { background: var(--danger-soft); color: var(--danger); }

/* week strip: dots show how full each day is */
.week { gap: 6px; }
.wk { padding: 10px 2px 10px; border-radius: 12px; }
.wk:hover { transform: translateY(-2px); }
.wk .pips { display: flex; justify-content: center; gap: 3px; height: 5px; margin-top: 5px; }
.wk .pips i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.wk .pips i.more { width: 9px; border-radius: 3px; opacity: .6; }
.wk.today:not(.selected) { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); }
.wk.selected .pips i { background: var(--btn-fg); }

/* usage ring */
.ring-meter { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 16px; align-items: center; }
.ring-meter .rm { position: relative; width: 112px; height: 112px; }
.ring-meter svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-meter .trk { fill: none; stroke: var(--surface-3); stroke-width: 10; }
.ring-meter .val { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; stroke-dasharray: var(--p) 100; animation: ring-in 1.3s var(--ease) both .2s; }
.ring-meter .val.over { stroke: var(--danger); }
@keyframes ring-in { from { stroke-dasharray: 0 100; } }
.ring-meter .rc { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-meter .rc b { font-size: 24px; font-weight: 650; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.ring-meter .rc span { font-size: 11.5px; color: var(--text-3); }
.ring-meter .mini { margin-top: 0; grid-template-columns: minmax(0, 1fr); gap: 10px; }

/* connections */
.conn { border-radius: 10px; }
.conn .dot { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
.conn .dot.warn { box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 18%, transparent); }
.conn .dot.off { box-shadow: none; }

/* test call header avatar */
.phone .card-head h2 { gap: 10px; }

/* ---------- button ripple ---------- */
.btn { position: relative; overflow: hidden; }
.btn .rip { position: absolute; border-radius: 50%; pointer-events: none; background: currentColor; opacity: .18; transform: scale(0); animation: rip .6s var(--ease) forwards; }
@keyframes rip { to { transform: scale(1); opacity: 0; } }

/* ---------- view switch ---------- */
body.switching main > section[data-view] { animation: view-in .45s var(--ease) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- command palette ---------- */
.cmdk { width: min(640px, calc(100vw - 32px)); max-width: none; margin: 12vh auto auto; padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text); box-shadow: 0 40px 80px -20px rgba(12, 10, 9, .45), 0 0 0 1px rgba(12, 10, 9, .04); overflow: hidden; }
.cmdk[open] { animation: cmdk-in .22s var(--ease); }
.cmdk::backdrop { background: color-mix(in srgb, #0c0a09 40%, transparent); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
@keyframes cmdk-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
.cmdk-search { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.cmdk-search .icon { color: var(--text-3); }
.cmdk-search input { flex: 1; border: 0; outline: 0; background: none; box-shadow: none; padding: 4px 0; font: 400 16px var(--font); color: var(--text); min-height: 0; }
.cmdk-search input:focus { box-shadow: none; }
.cmdk-list { max-height: min(420px, 56vh); overflow-y: auto; padding: 8px; }
.cmdk-group { padding: 10px 10px 6px; font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.cmdk-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border: 0; border-radius: 10px; background: none; color: var(--text); font: 500 14px var(--font); text-align: left; cursor: pointer; }
.cmdk-item .ci { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--surface-2); color: var(--text-2); }
.cmdk-item .ci .icon { width: 15px; height: 15px; }
.cmdk-item .ct { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-item .ct small { margin-left: 8px; font-size: 12.5px; font-weight: 400; color: var(--text-3); }
.cmdk-item kbd { margin-left: 8px; }
.cmdk-item.on { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
.cmdk-item.on .ci { background: var(--btn-bg); color: var(--btn-fg); }
.cmdk-empty { padding: 28px; text-align: center; color: var(--text-3); font-size: 14px; }
.cmdk-foot { display: flex; gap: 16px; flex-wrap: wrap; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--surface-2); font-size: 12px; color: var(--text-3); }
.cmdk-foot kbd { margin: 0 3px 0 0; padding: 2px 5px; }

/* ---------- keyboard hint toast ---------- */
.keyhint { position: fixed; left: 50%; bottom: 28px; z-index: 90; transform: translateX(-50%); display: inline-flex; gap: 8px; align-items: center; padding: 8px 14px; border-radius: 999px; background: var(--btn-bg); color: var(--btn-fg); font: 500 13px var(--font); box-shadow: var(--shadow-lg); animation: rise .25s var(--ease); }
.keyhint kbd { font: 500 11px var(--mono); padding: 2px 6px; border-radius: 5px; background: color-mix(in srgb, var(--btn-fg) 18%, transparent); }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .side { background-image: none; }
  .cmdk-btn { width: 38px; padding: 0; justify-content: center; flex: none; }
  .cmdk-btn span, .cmdk-btn kbd { display: none; }
  .bizcard { display: flex; }
  .bizcard .nx-av { display: none; }
  .nav .nav-k { display: none; }
  .theme-btn { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ov-hero::before, .ov-ring, .ov-wave i, .kpi.hot .kpi-ic, .who-av.urgent, .spark .ln, .ring-meter .val { animation: none !important; }
  .spark .ln { stroke-dashoffset: 0; }
}
