/* Nossic Analytics (from Nossic Accounts). Colours and type from the Nossic Branding Pack (v1). */
@font-face { font-family: "Bricolage Grotesque"; src: url("/fonts/bricolage.ttf") format("truetype"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible Next"; src: url("/fonts/atkinson-next.ttf") format("truetype"); font-weight: 200 800; font-display: swap; }

:root {
  --blue: #266BD9; --yellow: #FFCC33; --navy: #1F2438;
  --bg: #EAF2FD; --surface: #FFFFFF; --surface-2: #F5F8FD; --fg: #1F2438; --muted: #5A6278; --line: #DCE3F0;
  --primary: #266BD9; --primary-fg: #FFFFFF; --primary-hover: #1A4FA8; --link: #1A4FA8;
  --good: #1F8A4C; --good-bg: #E5F5EC; --warn: #9A6B00; --warn-bg: #FFF4D1; --bad: #D9483B; --bad-bg: #FDECEA;
  --paper-shadow: 0 1px 3px rgba(31, 36, 56, .12), 0 8px 24px rgba(31, 36, 56, .08);
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12162A; --surface: #1A2036; --surface-2: #20283F; --fg: #EEF2FA; --muted: #A3ADC6; --line: #2C3552;
    --primary: #5A93F0; --primary-fg: #0E1424; --primary-hover: #82AEF5; --link: #8DB4F5;
    --good: #5FD08F; --good-bg: #173326; --warn: #FFCC33; --warn-bg: #3A3216; --bad: #FF8A80; --bad-bg: #3C1F22;
    --paper-shadow: 0 2px 10px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 16px; line-height: 1.55; min-height: 100vh; }
a { color: var(--link); }
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.15; text-wrap: balance; }
h1 { font-size: 1.85rem; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0; max-width: 65ch; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: var(--mono); font-size: .85em; overflow-wrap: anywhere; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; border-radius: 6px; }
.light-only { display: block; } .dark-only { display: none; }
@media (prefers-color-scheme: dark) { .light-only { display: none; } .dark-only { display: block; } }

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; }
.logo { height: 32px; width: auto; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
@media (max-width: 640px) { .who-name { display: none; } .logo { height: 28px; } }
@media (max-width: 480px) { .topbar { gap: 8px; padding-inline: 12px; } .who { gap: 2px; } .who .btn.sm { padding-inline: 7px; } }

/* Layout */
.wrap { max-width: 1040px; margin: 0 auto; padding: 28px 16px 64px; display: grid; gap: 20px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.page-head > div { display: grid; gap: 6px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: grid; gap: 14px; min-width: 0; }
.rows { display: grid; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.row:first-child { border-top: 0; padding-top: 0; }
.row:last-child { padding-bottom: 0; }
.row > div { display: grid; gap: 2px; min-width: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.empty { color: var(--muted); padding: 6px 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; align-items: start; }

/* Controls */
.btn { font: inherit; font-weight: 700; font-size: .92rem; border-radius: 9px; padding: 9px 16px; border: 1.5px solid transparent; cursor: pointer; background: var(--primary); color: var(--primary-fg); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--primary-hover); }
.btn.secondary { background: transparent; color: var(--fg); border-color: var(--line); }
.btn.secondary:hover { border-color: var(--primary); }
.btn.ghost { background: transparent; color: var(--fg); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.yellow { background: var(--yellow); color: var(--navy); }
.btn.yellow:hover { background: #F5BD1A; }
.btn.sm { padding: 6px 11px; font-size: .85rem; }
.btn.lg { padding: 13px 22px; font-size: 1rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
label.check input { width: 18px; height: 18px; accent-color: var(--primary); }
input, select, textarea { font: inherit; font-weight: 400; padding: 10px 12px; border-radius: 9px; border: 1.5px solid var(--line); background: var(--surface); color: var(--fg); width: 100%; min-width: 0; }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
input[type="range"] { padding: 0; border: 0; box-shadow: none; accent-color: var(--primary); }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; background: var(--surface-2); flex-wrap: wrap; }
.seg button { font: inherit; font-weight: 600; font-size: .88rem; border: 0; background: transparent; color: var(--fg); padding: 6px 12px; border-radius: 7px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

.state { min-height: calc(100vh - 70px); display: grid; place-items: center; padding: 16px; }
.state-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; display: grid; gap: 14px; justify-items: center; text-align: center; max-width: 460px; }
.state-card .mark { width: 52px; height: 52px; }
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 10px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 50; max-width: calc(100vw - 32px); }
.toast.error { background: var(--bad); }
.dialog { border: 1px solid var(--line); border-radius: 16px; padding: 0; background: var(--surface); color: var(--fg); width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
.dialog.wide { width: min(760px, calc(100vw - 24px)); }
.dialog::backdrop { background: rgba(18, 22, 42, .55); }
.dlg { padding: 22px; display: grid; gap: 16px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; position: sticky; bottom: 0; background: var(--surface); padding-top: 8px; }


/* Nav */
.nav { display: flex; gap: 4px; align-items: center; margin-left: 18px; margin-right: auto; }
.nav a { color: var(--fg); text-decoration: none; font-weight: 600; font-size: .92rem; padding: 6px 10px; border-radius: 8px; }
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); }
@media (max-width: 640px) { .nav { margin-left: 6px; } .nav a { padding: 6px 7px; } }
.wrap.wide { max-width: 1480px; }
.crumbs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: .9rem; }
.crumbs a { color: var(--muted); }
.ref { font-family: var(--mono); font-size: .8rem; color: var(--muted); white-space: nowrap; }

.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--good); display: inline-block; box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); animation: beat 2s infinite; }
.pulse.off { background: var(--muted); animation: none; }
@keyframes beat { 70% { box-shadow: 0 0 0 8px transparent; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; }
.sec-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .75rem; font-weight: 800; background: var(--primary); color: var(--primary-fg); flex: none; }
.avatar.ai, .avatar.bot { background: var(--yellow); color: var(--navy); }
.avatar.visitor { background: var(--surface-2); color: var(--fg); border: 1px solid var(--line); }
.ws-switch { width: auto; padding: 6px 10px; font-size: .88rem; font-weight: 600; max-width: 220px; }
.ws-name { font-weight: 700; color: var(--fg); text-decoration: none; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) { .ws-switch, .ws-name { display: none; } }
code.snippet, pre.code { display: block; font-family: var(--mono); font-size: .82rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.tag button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; font: inherit; line-height: 1; }

/* Home: workspaces */
.wscards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.wscard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: grid; gap: 8px; text-decoration: none; color: inherit; }
.wscard:hover { border-color: var(--primary); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
/* Phones: the workspace links get their own row so the top bar never runs off the screen. */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .nav { order: 3; flex: 1 0 100%; margin: 0; overflow-x: auto; scrollbar-width: none; }
  .who { margin-left: auto; }
}

/* Shared bits */
.wrap.narrow { max-width: 640px; }
.error { color: var(--bad); font-weight: 600; }
.badge.free { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge.business { background: var(--good-bg); color: var(--good); }
.badge.enterprise { background: var(--warn-bg); color: var(--warn); }
input.code { font-family: var(--mono); font-size: 1.4rem; letter-spacing: .15em; text-transform: uppercase; max-width: 14ch; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.steps { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }
.meter { height: 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.meter > div { height: 100%; background: var(--primary); }
.meter.over > div { background: var(--bad); }

/* ---- Nossic Analytics ---- */
.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.sitecard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: grid; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.sitecard:hover { border-color: var(--primary); }
.sitecard .top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.sitecard .top > div { display: grid; gap: 2px; min-width: 0; }
.sitecard .dom { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sitecard .nums { display: flex; gap: 18px; flex-wrap: wrap; }
.sitecard .nums b { font-family: var(--display); font-size: 1.35rem; display: block; line-height: 1.1; }
.sitecard .nums span { color: var(--muted); font-size: .8rem; }
.spark { width: 100%; height: 42px; display: block; }
.spark path.l { fill: none; stroke: var(--primary); stroke-width: 2; }
.spark path.a { fill: color-mix(in srgb, var(--primary) 14%, transparent); stroke: none; }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 700; white-space: nowrap; }

.dash-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.dash-head h1 { font-size: 1.6rem; }
.dash-head .t { display: grid; gap: 4px; min-width: 0; }
.period { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.period select { width: auto; font-weight: 600; }
.period input[type=date] { width: auto; padding: 8px 10px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.filter { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; font-weight: 600; padding: 4px 6px 4px 10px; border-radius: 99px; background: color-mix(in srgb, var(--primary) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--primary) 40%, var(--line)); max-width: 100%; }
.filter span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter button { border: 0; background: none; color: var(--fg); cursor: pointer; font: inherit; font-size: 1rem; line-height: 1; padding: 0 4px; border-radius: 50%; }
.filter button:hover { background: var(--surface-2); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.kpi { background: var(--surface); padding: 14px 16px; display: grid; gap: 2px; text-align: left; border: 0; font: inherit; color: inherit; cursor: pointer; border-bottom: 3px solid transparent; }
.kpi:hover { background: var(--surface-2); }
.kpi[aria-pressed="true"] { border-bottom-color: var(--primary); }
.kpi .k { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.kpi .v { font-family: var(--display); font-size: 1.65rem; font-weight: 800; line-height: 1.15; }
.kpi .d { font-size: .8rem; font-weight: 700; }
.kpi .d.up { color: var(--good); } .kpi .d.down { color: var(--bad); } .kpi .d.same { color: var(--muted); }
.kpi[data-inverse] .d.up { color: var(--bad); } .kpi[data-inverse] .d.down { color: var(--good); }

.chart { position: relative; }
.chart svg { width: 100%; height: 260px; display: block; overflow: visible; }
.chart .grid line { stroke: var(--line); }
.chart .axis text { fill: var(--muted); font-size: 11px; font-family: var(--body); }
.chart path.now { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; }
.chart path.area { fill: color-mix(in srgb, var(--primary) 12%, transparent); }
.chart path.prev { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; opacity: .7; }
.chart circle.pt { fill: var(--surface); stroke: var(--primary); stroke-width: 2; }
.chart rect.hit { fill: transparent; cursor: crosshair; }
.chart line.cursor { stroke: var(--muted); stroke-dasharray: 3 3; }
.tip { position: absolute; pointer-events: none; background: var(--navy); color: #fff; padding: 8px 10px; border-radius: 8px; font-size: .82rem; white-space: nowrap; transform: translate(-50%, -110%); box-shadow: 0 6px 18px rgba(0,0,0,.25); z-index: 5; }
.tip b { font-family: var(--display); }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); align-items: center; flex-wrap: wrap; }
.legend i { display: inline-block; width: 18px; height: 0; border-top: 2.5px solid var(--primary); vertical-align: middle; margin-right: 6px; }
.legend i.prev { border-top: 1.5px dashed var(--muted); }

.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 20px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: grid; gap: 10px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tabs button { font: inherit; font-size: .85rem; font-weight: 700; border: 0; background: none; color: var(--muted); padding: 5px 9px; border-radius: 7px; cursor: pointer; }
.tabs button:hover { background: var(--surface-2); color: var(--fg); }
.tabs button[aria-selected="true"] { color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); }
.list-head-row { display: flex; justify-content: space-between; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 0 4px; gap: 10px; }
.list-head-row .cols, .bar-row .cols { display: flex; gap: 14px; flex: none; }
.list-head-row .cols span, .bar-row .cols span { width: 64px; text-align: right; }
.bars { display: grid; gap: 3px; }
.bar-row { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 7px; cursor: pointer; font-size: .9rem; min-height: 32px; border: 0; background: none; color: inherit; font: inherit; text-align: left; width: 100%; }
.bar-row:hover { background: var(--surface-2); }
.bar-row .fill { position: absolute; left: 0; top: 2px; bottom: 2px; border-radius: 6px; background: color-mix(in srgb, var(--primary) 13%, transparent); pointer-events: none; }
.bar-row .label { position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; display: flex; align-items: center; gap: 8px; }
.bar-row .label .ext { color: var(--muted); text-decoration: none; font-size: .8rem; }
.bar-row .cols { position: relative; font-variant-numeric: tabular-nums; }
.bar-row .cols span:first-child { font-weight: 700; }
.panel-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.flag { font-size: 1.05rem; line-height: 1; }
.fav { width: 16px; height: 16px; border-radius: 3px; flex: none; }

.vitals { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.vital { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 2px; }
.vital .k { font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.vital .v { font-family: var(--display); font-size: 1.3rem; font-weight: 800; }
.vital.good { border-color: color-mix(in srgb, var(--good) 50%, var(--line)); } .vital.good .v { color: var(--good); }
.vital.ni { border-color: color-mix(in srgb, var(--warn) 60%, var(--line)); } .vital.ni .v { color: var(--warn); }
.vital.poor { border-color: color-mix(in srgb, var(--bad) 50%, var(--line)); } .vital.poor .v { color: var(--bad); }
table.data { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.data th, table.data td { padding: 6px 6px; border-top: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; white-space: normal; overflow-wrap: anywhere; }
table.data th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-top: 0; }
.scroll-x { overflow-x: auto; }
.c-good { color: var(--good); font-weight: 700; } .c-ni { color: var(--warn); font-weight: 700; } .c-poor { color: var(--bad); font-weight: 700; }

.upbars { display: grid; grid-template-columns: repeat(56, 1fr); gap: 2px; height: 34px; align-items: stretch; }
.upbars i { border-radius: 2px; background: var(--good); }
.upbars i.part { background: var(--warn); } .upbars i.down { background: var(--bad); } .upbars i.none { background: var(--line); }
.upstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.upstats div { display: grid; gap: 2px; } .upstats b { font-family: var(--display); font-size: 1.25rem; } .upstats span { font-size: .78rem; color: var(--muted); }

.setup { border: 2px dashed color-mix(in srgb, var(--primary) 45%, var(--line)); background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.copyrow { display: flex; gap: 8px; align-items: stretch; }
.copyrow code { flex: 1; }
.note { font-size: .82rem; color: var(--muted); }
.note a { color: var(--muted); }
.shared-banner { background: color-mix(in srgb, var(--yellow) 20%, var(--surface)); border: 1px solid color-mix(in srgb, var(--yellow) 60%, var(--line)); border-radius: 12px; padding: 10px 14px; font-size: .9rem; }
.docs h2 { margin-top: 10px; } .docs h3 { margin-top: 6px; }
.docs p, .docs li { max-width: 80ch; }
.docs table.data td, .docs table.data th { white-space: normal; text-align: left; }
@media (max-width: 560px) { .kpi .v { font-size: 1.35rem; } .list-head-row .cols span, .bar-row .cols span { width: 50px; } .chart svg { height: 200px; } }
