/* RELAYZA theme: mirrors relayza.company (deep navy, teal-to-blue accent, Space Grotesk + DM Sans).
   Dark is the brand default; light is opt-in via the sidebar toggle (data-theme="light"). */
:root {
  --bg: #07111e;
  --surface: #0d1a2a;
  --surface-2: #12243a;
  --border: #223649;
  --text: #f4f7ff;
  --muted: #8fa4bb;
  --accent: #1fe5c9;
  --accent-strong: #3ff0d6;
  --accent-ink: #041928;
  --accent-soft: #0c363e;
  --accent-gradient: linear-gradient(120deg, #0df1c6, #39aefa);
  --text-gradient: linear-gradient(95deg, #20eed0, #24c0ef 58%, #5686ff);
  --warn: #fbbf24;
  --warn-soft: #3a2a0b;
  --danger: #ff7a85;
  --danger-soft: #3b1520;
  --info-soft: #14305a;
  --bubble-in: #12243a;
  --bubble-out: #0c3a40;
  --chart-a: #3d5a78;
  --chart-b: #1fe5c9;
  --glow-a: #1345b8;
  --glow-b: #085960;
  --shadow: none;
  --radius: 14px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f7fb;
  --surface: #ffffff;
  --surface-2: #eaf1f7;
  --border: #d6e0ea;
  --text: #07111e;
  --muted: #5b6f84;
  --accent: #0bbfa6;
  --accent-strong: #067a6d;
  --accent-soft: #d6f7f1;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info-soft: #e1ecff;
  --bubble-in: #ffffff;
  --bubble-out: #d6f7f1;
  --chart-a: #9fb3c8;
  --chart-b: #0bbfa6;
  --glow-a: #9cc0ff;
  --glow-b: #8ef0e0;
  --shadow: 0 1px 2px rgb(7 17 30 / 6%), 0 1px 3px rgb(7 17 30 / 8%);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Heebo", "Noto Sans Hebrew", sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; font-family: "Space Grotesk", "DM Sans", system-ui, sans-serif; letter-spacing: -0.01em; }
h1 { letter-spacing: -0.03em; }
.gradient-text { background: var(--text-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; margin-top: 1rem; }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--surface-2); padding: 0.1rem 0.35rem; border-radius: 6px; font-size: 0.85em; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.error-text { color: var(--danger); }

/* Shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-family: "Space Grotesk", "DM Sans", sans-serif; font-weight: 700; font-size: 1.3rem; letter-spacing: -0.05em; display: flex; align-items: center; gap: 0.5rem; color: var(--text); white-space: nowrap; }
.brand svg { width: 30px; height: 26px; flex-shrink: 0; }
.brand.big { font-size: 1.8rem; margin-bottom: 1.75rem; }
.brand.big svg { width: 42px; height: 36px; }
.brand-dot { color: var(--accent); }
.tenant-switch, .tenant-name { width: 100%; font-weight: 600; }
.tenant-name { padding: 0.4rem 0; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: var(--text); padding: 0.5rem 0.65rem; border-radius: 8px; display: flex; gap: 0.6rem; align-items: center; }
.sidebar nav a:hover { background: var(--surface-2); text-decoration: none; }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.nav-icon { width: 1.1rem; text-align: center; opacity: 0.8; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.4rem; align-items: flex-start; }
.sidebar-foot .foot-actions { display: flex; gap: 1rem; align-items: center; }
.sidebar-foot .muted { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { min-width: 0; }
.topbar { display: none; }
.content { padding: 1.5rem 2rem; max-width: 1400px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-header p { margin: 0; }
.actions, .row-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.row-actions { justify-content: flex-end; }

/* Controls */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.5rem 0.65rem; width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="checkbox"] { width: auto; }
textarea { resize: vertical; }
.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 0.45rem 0.9rem; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent-gradient); border-color: transparent; color: var(--accent-ink); box-shadow: 0 4px 18px rgb(2 214 205 / 18%); }
.btn.primary:hover:not(:disabled) { background: var(--accent-gradient); filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.btn.full { width: 100%; }
.link { background: none; border: 0; color: var(--accent-strong); cursor: pointer; padding: 0; font: inherit; }
.icon-btn { background: none; border: 0; color: var(--text); font-size: 1.3rem; cursor: pointer; padding: 0.2rem 0.5rem; border-radius: 6px; }
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.85rem; flex: 1; min-width: 0; }
.label { font-weight: 600; font-size: 0.85rem; }
.hint { color: var(--muted); font-size: 0.8rem; }
.row { display: flex; gap: 0.85rem; flex-wrap: wrap; }
.row > .field { min-width: 160px; }
.toggle { display: inline-flex; gap: 0.5rem; align-items: center; margin-bottom: 0.85rem; font-weight: 600; font-size: 0.9rem; }
.checks-inline { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; }
.checks-inline label { display: flex; gap: 0.35rem; align-items: center; }
.form-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.5rem; }
.search { margin-bottom: 0.75rem; }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.card.inner { box-shadow: none; margin: 0; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; align-items: start; }
.grid-2 > .card { margin: 0; }
.grid-agent { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); gap: 1rem; align-items: start; }
.callout { padding: 0.6rem 0.8rem; border-radius: 8px; margin: 0.5rem 0; background: var(--info-soft); }
.callout.error { background: var(--danger-soft); color: var(--danger); }
.callout.warn { background: var(--warn-soft); color: var(--warn); }
.callout.ok { background: var(--accent-soft); }
.badge { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--accent-soft); color: var(--accent-strong); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.accent { background: var(--info-soft); color: var(--text); }
.badge.muted { opacity: 0.7; }
.empty { text-align: center; padding: 2.5rem 1rem; display: flex; flex-direction: column; gap: 0.35rem; align-items: center; }
.loading { padding: 2rem; text-align: center; color: var(--muted); }
.center-card { max-width: 420px; margin: 15vh auto; text-align: center; }
.code { background: var(--surface-2); padding: 0.75rem; border-radius: 8px; overflow-x: auto; font-size: 0.82rem; white-space: pre-wrap; word-break: break-all; }
.plain { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Tables */
.table-wrap { overflow-x: auto; padding: 0.5rem; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); padding: 0.5rem; }
.table td { padding: 0.6rem 0.5rem; border-top: 1px solid var(--border); vertical-align: top; }
.table tr.dim td { opacity: 0.5; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }

/* Tabs & chips */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 0.5rem 0.75rem; font: inherit; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.count { background: var(--surface-2); border-radius: 999px; padding: 0 0.4rem; font-size: 0.75rem; }
.chips { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 0.25rem 0.75rem; font: inherit; font-size: 0.85rem; cursor: pointer; color: var(--text); }
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); font-weight: 600; }

/* Overview */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.kpi { margin: 0; }
.kpi-label { color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.kpi-value { font-family: "Space Grotesk", "DM Sans", sans-serif; font-size: 1.8rem; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.chart svg { width: 100%; height: 180px; display: block; }
.chart .bar.a { fill: var(--chart-a); }
.chart .bar.b { fill: var(--chart-b); }
.legend { font-size: 0.8rem; margin-top: 0.5rem; display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sw.a { background: var(--chart-a); }
.sw.b { background: var(--chart-b); }
.funnel { display: flex; flex-direction: column; gap: 0.35rem; }
.funnel-row { display: grid; grid-template-columns: 90px 1fr 40px; gap: 0.5rem; align-items: center; color: var(--text); font-size: 0.9rem; }
.funnel-bar { background: var(--surface-2); border-radius: 4px; height: 10px; overflow: hidden; }
.funnel-bar span { display: block; height: 100%; background: var(--accent-gradient); }
.setup ol { margin: 0; padding-inline-start: 1.25rem; display: flex; flex-direction: column; gap: 0.3rem; }
.setup li.done a { color: var(--muted); text-decoration: line-through; }

/* Inbox */
.inbox { display: grid; grid-template-columns: 340px 1fr; gap: 1rem; height: calc(100vh - 3rem); }
.inbox-list { overflow-y: auto; min-width: 0; }
.conv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.conv { display: block; padding: 0.65rem 0.75rem; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.conv:hover { text-decoration: none; border-color: var(--accent); }
.conv.active { border-color: var(--accent); background: var(--accent-soft); }
.conv-top { display: flex; justify-content: space-between; gap: 0.5rem; }
.conv-snippet { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.88rem; }
.conv-tags { margin-top: 0.25rem; }
.inbox-thread { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; overflow: hidden; display: flex; flex-direction: column; }
.thread { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.thread-head { display: flex; gap: 0.75rem; justify-content: space-between; align-items: flex-start; padding: 0.9rem 1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.thread-head h2 { margin: 0; }
.thread-head .back { display: none; }
.thread-body { display: grid; grid-template-columns: 1fr 260px; flex: 1; min-height: 0; }
.messages { overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; background: var(--surface-2); }
.msg { display: flex; flex-direction: column; max-width: 78%; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 0.5rem 0.75rem; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; background: var(--bubble-in); border: 1px solid var(--border); }
.msg.out .bubble { background: var(--bubble-out); border-color: transparent; }
.msg.staff .bubble { background: var(--info-soft); }
.msg.system .bubble { background: var(--warn-soft); }
.meta { font-size: 0.72rem; color: var(--muted); margin-top: 0.15rem; }
.contact-panel { border-inline-start: 1px solid var(--border); padding: 1rem; overflow-y: auto; }
.composer { display: flex; gap: 0.5rem; padding: 0.75rem; border-top: 1px solid var(--border); align-items: flex-end; background: var(--surface); }
.typing { display: inline-flex; gap: 4px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* Agent test chat */
.test-chat { position: sticky; top: 1rem; }
.phone { border: 1px solid var(--border); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; height: 520px; }
.phone .messages { flex: 1; }
.kb { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.kb li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.6rem 0; border-top: 1px solid var(--border); }

/* Services */
.resource-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.75rem; }
.hours { list-style: none; padding: 0; margin: 0.5rem 0 0; font-size: 0.85rem; }
.hours li { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.1rem 0; }
.hours-editor { display: flex; flex-direction: column; gap: 0.35rem; }
.hours-editor label { display: grid; grid-template-columns: 100px 1fr; align-items: center; gap: 0.5rem; font-size: 0.9rem; }

/* Bookings */
.day h2 { margin-bottom: 0.25rem; }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 0.35rem; max-height: 200px; overflow-y: auto; }
.slot { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 0.35rem; font: inherit; cursor: pointer; color: var(--text); }
.slot.active { background: var(--accent-gradient); color: var(--accent-ink); border-color: transparent; font-weight: 600; }

/* Modal & toast */
.modal-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / 45%); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 520px; box-shadow: 0 20px 50px rgb(0 0 0 / 25%); }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem 0; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 1rem 1.25rem 1.25rem; }
.toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 0.6rem 1rem; border-radius: 10px; z-index: 60; max-width: calc(100vw - 32px); }
.toast.error { background: var(--danger); color: #fff; }
:root:not([data-theme="light"]) .toast.error { color: var(--accent-ink); }

/* Auth */
.auth-page { position: relative; min-height: 100vh; overflow: hidden; }
.auth-page .ambient { position: absolute; pointer-events: none; border-radius: 50%; filter: blur(90px); opacity: 0.3; }
.auth-page .a1 { width: 600px; height: 600px; background: var(--glow-a); top: -120px; right: -340px; }
.auth-page .a2 { width: 500px; height: 500px; background: var(--glow-b); bottom: -200px; left: -340px; }
.auth-page .grid-surface { position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(#3c689b17 1px, transparent 1px), linear-gradient(90deg, #3c689b17 1px, transparent 1px); background-size: 42px 42px; mask-image: radial-gradient(ellipse at 30% 40%, black, transparent 70%); }
.auth { position: relative; z-index: 1; min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; gap: 2rem; align-items: center; padding: 2rem; max-width: 1100px; margin: 0 auto; }
.eyebrow { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--accent-strong); font-weight: 700; font-size: 0.68rem; letter-spacing: 0.15em; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: 40px; padding: 0.5rem 0.9rem; margin-bottom: 1rem; }
.pill-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.auth-pitch h1 { font-size: clamp(2.2rem, 4.5vw, 3.4rem); line-height: 1.08; letter-spacing: -0.045em; }
.auth-pitch p { font-size: 1.05rem; color: var(--muted); }
.checks { padding: 0; list-style: none; display: flex; flex-direction: column; gap: 0.4rem; }
.auth-pitch a:hover { text-decoration: none; }
.checks li::before { content: "✓ "; color: var(--accent); font-weight: 700; }
.auth-card { max-width: 420px; width: 100%; justify-self: center; }

/* Responsive */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform 0.2s; }
  .shell.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgb(0 0 0 / 30%); }
  .topbar { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
  .content { padding: 1rem 16px; }
  .grid-agent, .auth { grid-template-columns: 1fr; }
  .test-chat { position: static; }
  .inbox { grid-template-columns: 1fr; height: calc(100vh - 6rem); }
  .inbox.has-selection .inbox-list { display: none; }
  .inbox:not(.has-selection) .inbox-thread { display: none; }
  .thread-head .back { display: inline-block; }
  .thread-body { grid-template-columns: 1fr; }
  .contact-panel { display: none; }
  .msg { max-width: 90%; }
}
