/* ==========================================================================
   Nexa design system
   One stylesheet for the landing page, sign-in pages, business dashboard
   and admin. Light and dark themes come from the same tokens.

   Rules this file follows
   - 4px spacing grid; type scale 12 / 13 / 14 / 16 / 18 / 22 / 28 / 36 / 48+
   - Body text contrast >= 7:1, secondary text >= 4.5:1 (WCAG AA)
   - Every interactive control >= 40px tall (44px on touch screens)
   - Visible keyboard focus on everything; no focus rings for mouse clicks
   - One accent colour, used sparingly for status and emphasis only
   - Motion is short (120-200ms) and switched off for reduced-motion users
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-2: #f5f5f4;
  --surface-3: #eeedeb;
  --line: #e7e5e4;
  --line-strong: #d6d3d1;
  --text: #0c0a09;
  --text-2: #57534e;
  --text-3: #6f6964;
  --accent: #ff5b14;
  --accent-ink: #c2410c;
  --accent-soft: #fff1e8;
  --ok: #15803d;
  --ok-soft: #ecfdf3;
  --warn: #a16207;
  --warn-soft: #fefce8;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --info: #1d4ed8;
  --info-soft: #eff4ff;
  --btn-bg: #0c0a09;
  --btn-fg: #ffffff;
  --btn-hover: #292524;
  --overlay: rgba(12, 10, 9, .42);

  --shadow-xs: 0 1px 2px rgba(12, 10, 9, .05);
  --shadow-sm: 0 1px 3px rgba(12, 10, 9, .06), 0 1px 2px rgba(12, 10, 9, .04);
  --shadow-lg: 0 24px 48px -12px rgba(12, 10, 9, .18), 0 4px 12px rgba(12, 10, 9, .06);

  --r-sm: 6px;
  --r: 8px;
  --r-lg: 12px;
  --r-xl: 16px;

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c0a09;
    --surface: #151311;
    --surface-2: #1c1917;
    --surface-3: #262220;
    --line: #2a2522;
    --line-strong: #3b3532;
    --text: #fafaf9;
    --text-2: #b5aea8;
    --text-3: #9a928c;
    --accent: #ff6a2b;
    --accent-ink: #fb923c;
    --accent-soft: #2a1709;
    --ok: #4ade80;
    --ok-soft: #0c2116;
    --warn: #facc15;
    --warn-soft: #251f07;
    --danger: #f87171;
    --danger-soft: #2a0f0f;
    --info: #93b4ff;
    --info-soft: #111a33;
    --btn-bg: #fafaf9;
    --btn-fg: #0c0a09;
    --btn-hover: #e7e5e4;
    --overlay: rgba(0, 0, 0, .6);
    --shadow-xs: none;
    --shadow-sm: 0 0 0 1px rgba(255, 255, 255, .02);
    --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .7);
  }
}
/* manual dark theme (app theme switch) */
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0c0a09;
    --surface: #151311;
    --surface-2: #1c1917;
    --surface-3: #262220;
    --line: #2a2522;
    --line-strong: #3b3532;
    --text: #fafaf9;
    --text-2: #b5aea8;
    --text-3: #9a928c;
    --accent: #ff6a2b;
    --accent-ink: #fb923c;
    --accent-soft: #2a1709;
    --ok: #4ade80;
    --ok-soft: #0c2116;
    --warn: #facc15;
    --warn-soft: #251f07;
    --danger: #f87171;
    --danger-soft: #2a0f0f;
    --info: #93b4ff;
    --info-soft: #111a33;
    --btn-bg: #fafaf9;
    --btn-fg: #0c0a09;
    --btn-hover: #e7e5e4;
    --overlay: rgba(0, 0, 0, .6);
    --shadow-xs: none;
    --shadow-sm: 0 0 0 1px rgba(255, 255, 255, .02);
    --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, .7);
  }


/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.55 var(--font);
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; color: var(--text); font-weight: 600; letter-spacing: -.015em; line-height: 1.25; text-wrap: balance; }
h1 { font-size: 28px; letter-spacing: -.025em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; }
p { margin: 0; text-wrap: pretty; }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
small { font-size: 13px; }
code { font: 500 12.5px/1 var(--mono); background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 2px 5px; }
img, svg { display: block; max-width: 100%; }
::selection { background: var(--accent-soft); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--btn-bg); color: var(--btn-fg); padding: 10px 14px; border-radius: var(--r); text-decoration: none; font-weight: 500; transition: top .15s var(--ease); }
.skip:focus { top: 12px; }

.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 20px; height: 20px; }

/* ---------- brand: Corevia ----------
   The mark is an open ring (the "C") around a core dot.
   Markup: <svg class="logo-mark" viewBox="0 0 32 32"><path pathLength="100" d="M23.78 8.22A11 11 0 1 0 23.78 23.78"/><circle class="core" cx="16" cy="16" r="3.75"/></svg> */
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; font-weight: 650; font-size: 19px; letter-spacing: -.045em; color: var(--text); line-height: 1; }
.brand small { font-size: 12px; font-weight: 500; color: var(--text-3); letter-spacing: 0; }
.logo-mark { width: 26px; height: 26px; flex: none; color: var(--text); overflow: visible; }
.logo-mark path { fill: none; stroke: currentColor; stroke-width: 4; stroke-linecap: round; transform-box: view-box; transform-origin: 16px 16px; }
.logo-mark .core { fill: var(--accent); transform-box: view-box; transform-origin: 16px 16px; }
.brand:hover .logo-mark:not(.logo-draw) path { animation: logo-turn .9s var(--ease); }
.brand:hover .logo-mark .core { animation: core-beat .9s var(--ease); }
.logo-draw path { stroke-dasharray: 100; stroke-dashoffset: 100; animation: logo-draw 1.1s .15s var(--ease) forwards; }
.logo-draw .core { transform: scale(0); animation: core-in .55s .85s cubic-bezier(.3, 1.7, .5, 1) forwards; }
@keyframes logo-turn { to { transform: rotate(360deg); } }
@keyframes core-beat { 50% { transform: scale(1.4); } }
@keyframes logo-draw { to { stroke-dashoffset: 0; } }
@keyframes core-in { to { transform: scale(1); } }

/* ---------- brand: Nexa (the receptionist only; Corevia is the company and the product shell) ----------
   Source artwork: /assets/nexa.svg (191 × 120). Inline it as:
   <svg class="nx-mark" viewBox="0 0 191 120"><path d="…"/><circle cx="34.5" cy="28" r="27.5"/></svg>
   The shape takes the text colour; the dot is the logo's maroon on light grounds and Signal on ink. */
.nx-mark { --nx-dot: #4f0202; width: 1em; height: .63em; flex: none; overflow: visible; }
.nx-mark path { fill: currentColor; stroke: none; }
.nx-mark circle { fill: var(--nx-dot); }
.nx-av .nx-mark, .callcard-head .av .nx-mark { --nx-dot: var(--accent); }

/* ---------- loader (same geometry as the mark) ---------- */
.loader { width: 56px; height: 56px; overflow: visible; }
.loader .l-track { fill: none; stroke: var(--text); stroke-opacity: .08; stroke-width: 6; }
.loader .l-ring { fill: none; stroke: var(--text); stroke-width: 6; stroke-linecap: round; stroke-dasharray: 75 25; transform-box: view-box; transform-origin: 32px 32px;
  animation: l-spin 1.2s cubic-bezier(.65, .05, .35, .95) infinite, l-breathe 2.4s ease-in-out infinite; }
.loader .l-core { fill: var(--accent); transform-box: view-box; transform-origin: 32px 32px; animation: l-pulse 1.2s ease-in-out infinite; }
.loader .l-halo { fill: var(--accent); opacity: 0; transform-box: view-box; transform-origin: 32px 32px; animation: l-halo 1.2s ease-out infinite; }
@keyframes l-spin { from { transform: rotate(45deg); } to { transform: rotate(405deg); } }
@keyframes l-breathe { 0%, 100% { stroke-dasharray: 75 25; } 50% { stroke-dasharray: 25 75; } }
@keyframes l-pulse { 0%, 100% { transform: scale(.8); } 50% { transform: scale(1.1); } }
@keyframes l-halo { from { opacity: .45; transform: scale(1); } to { opacity: 0; transform: scale(2.8); } }

.preloader { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; background: var(--bg); transition: opacity .5s var(--ease), visibility .5s; }
.preloader .pl-inner { display: grid; justify-items: center; gap: 20px; }
.preloader .pl-word { font-size: 15px; font-weight: 650; letter-spacing: -.03em; color: var(--text-2); animation: pl-word 1.2s ease-in-out infinite alternate; }
.preloader.done { opacity: 0; visibility: hidden; pointer-events: none; }
.preloader.failsafe { animation: pl-out .45s 7s forwards; }
.preloader.timed { animation: pl-out .45s .9s forwards; }
@keyframes pl-word { from { opacity: .45; } to { opacity: 1; } }
@keyframes pl-out { to { opacity: 0; visibility: hidden; pointer-events: none; } }

/* ---------- shared motion ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.stagger > * { animation: rise .6s var(--ease) both; }
.stagger > *:nth-child(2) { animation-delay: .06s; } .stagger > *:nth-child(3) { animation-delay: .12s; }
.stagger > *:nth-child(4) { animation-delay: .18s; } .stagger > *:nth-child(5) { animation-delay: .24s; }
.stagger > *:nth-child(6) { animation-delay: .3s; } .stagger > *:nth-child(7) { animation-delay: .36s; }
.stagger > *:nth-child(n+8) { animation-delay: .42s; }
.btn .icon { transition: transform .2s var(--ease); }
.btn:hover .i-arrow { transform: translateX(3px); }
.card { transition: border-color .2s var(--ease), box-shadow .25s var(--ease), transform .25s var(--ease); }

/* ---------- buttons ---------- */
.btn {
  --h: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--h); padding: 0 16px;
  border-radius: var(--r); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap; text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .1s var(--ease);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--btn-bg); color: var(--btn-fg); border-color: var(--btn-bg); }
.btn.primary:hover { background: var(--btn-hover); border-color: var(--btn-hover); }
.btn.accent { background: var(--accent); color: #1a0a02; border-color: var(--accent); font-weight: 600; }
.btn.accent:hover { filter: brightness(1.05); }
.btn.quiet, .btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.quiet:hover, .btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); background: var(--surface); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small, .btn.sm { --h: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn.lg { --h: 48px; padding: 0 22px; font-size: 15px; border-radius: 10px; }
.btn.icon-only { padding: 0; width: var(--h); }
.btn[disabled], .btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn .icon { width: 16px; height: 16px; }

.link { color: var(--text); font-weight: 500; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--text); }
.link-quiet { color: var(--text-2); font-size: 13px; font-weight: 500; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.link-quiet:hover { color: var(--text); }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > span, .label { font-size: 13px; font-weight: 500; color: var(--text); }
.field .hint, .hint { font-size: 12.5px; color: var(--text-3); line-height: 1.45; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=search], input[type=date], input[type=time], input[type=datetime-local], input[type=url], input:not([type]),
select, textarea {
  width: 100%; min-width: 0; min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface); color: var(--text);
  font-size: 14px; line-height: 1.4;
  box-shadow: var(--shadow-xs);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
textarea { resize: vertical; min-height: 96px; line-height: 1.55; }
select { appearance: none; -webkit-appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2378716c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
input::placeholder, textarea::placeholder { color: var(--text-3); opacity: .8; }
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus-visible, select:focus-visible, textarea:focus-visible,
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--text);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 0; accent-color: var(--text); flex: none; }
.check { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); cursor: pointer; min-height: 32px; }
.formmsg { font-size: 13px; color: var(--text-3); margin: 8px 0 0; line-height: 1.5; }
.formmsg:empty { display: none; }
.formmsg.bad { color: var(--danger); }
.formmsg.good { color: var(--ok); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid2 .wide, .grid2 > .wide { grid-column: 1 / -1; }
.btnrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); min-height: 56px; }
.card-head h2, .card-head h3 { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 16px 20px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--line); }

/* ---------- tags / badges ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); vertical-align: middle;
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.tag.plain::before, .tag.none::before { display: none; }
.tag.ok, .tag.booked { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.tag.warn, .tag.urgent { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.tag.trial, .tag.message { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.tag.info, .tag.ai { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 20%, transparent); }
.tag.live, .tag.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--text); color: var(--bg); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.count.zero, .count:empty { background: var(--surface-3); color: var(--text-3); }

/* ---------- status dot ---------- */
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; position: relative; }
.dot.live::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--ok); opacity: 0; animation: ping 2s var(--ease) infinite; }
.dot.warn { background: var(--warn); }
.dot.off { background: var(--text-3); }
@keyframes ping { 0% { transform: scale(.6); opacity: .7; } 80%, 100% { transform: scale(1.6); opacity: 0; } }

/* ---------- alerts ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); font-size: 14px; color: var(--text); }
.alert.bad, .alert.error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, transparent); color: var(--danger); }
.alert.good { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, transparent); color: var(--ok); }
.alert.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); color: var(--warn); }

/* ---------- misc ---------- */
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.empty { padding: 28px 20px; text-align: center; color: var(--text-3); font-size: 14px; }
.meter { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: var(--text); transition: width .4s var(--ease); }
.meter > i.over { background: var(--danger); }
.divider { height: 1px; background: var(--line); border: 0; margin: 16px 0; }
.kbd { font: 500 11px/1 var(--mono); padding: 3px 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; color: var(--text-2); }

/* ---------- dialog ---------- */
dialog.modal {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  padding: 0; border: 1px solid var(--line); border-radius: var(--r-xl);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: var(--overlay); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: pop .18s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- touch sizing ---------- */
@media (pointer: coarse) {
  .btn { --h: 44px; }
  .btn.small, .btn.sm { --h: 38px; }
  input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
  input[type=search], input[type=date], input[type=time], input[type=datetime-local], input:not([type]), select { min-height: 44px; font-size: 16px; }
  textarea { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
