/* The app's look, taken from the website's home page: navy, white and pale blue-grey,
   a blue → violet gradient, Inter. Plain CSS with custom properties; no build step.
   Light and dark themes follow the device setting. Client reports have their own
   stylesheet (report.css) carrying the MSP's brand, not ours. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212,
    U+2215, U+FEFF, U+FFFD;
}

/* ---- Tokens ---------------------------------------------------------------------------- */
:root {
  color-scheme: light;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Brand (the website) */
  --navy: #070b18;
  --navy-2: #0b1124;
  --navy-line: rgba(147, 180, 255, 0.14);
  --gradient: linear-gradient(135deg, #2563eb, #6d28d9);
  --gradient-text: linear-gradient(90deg, #60a5fa 0%, #a78bfa 50%, #f472b6 100%);
  --violet: #7c3aed;

  /* Surfaces and text */
  --bg: #f8faff;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --fg: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  --link: #4f46e5;
  --focus: #6366f1;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);

  /* Status */
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --bad: #b42318;
  --bad-bg: #fef3f2;
  --info: #1d4ed8;
  --info-bg: #eff6ff;

  --radius: 12px;
  --radius-lg: 18px;
  --space: 1rem;
  --sidebar: 248px;

  /* Kept for reports and the brand preview: the MSP's own colours override these. */
  --brand-primary: #4f46e5;
  --brand-accent: #7c3aed;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #070b18;
    --surface: #0f1629;
    --surface-2: #151e36;
    --fg: #e2e8f0;
    --muted: #94a3b8;
    --border: rgba(147, 180, 255, 0.16);
    --link: #a5b4fc;
    --focus: #a5b4fc;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    --ok: #75e0a7;
    --ok-bg: rgba(18, 183, 106, 0.14);
    --warn: #fec84b;
    --warn-bg: rgba(247, 144, 9, 0.14);
    --bad: #fda29b;
    --bad-bg: rgba(240, 68, 56, 0.14);
    --info: #93c5fd;
    --info-bg: rgba(59, 130, 246, 0.14);
  }
}

/* ---- Base ------------------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-feature-settings: "cv11", "ss01";
  color: var(--fg);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; color: var(--fg); }
h1 { font-size: clamp(1.6rem, 2.6vw, 2rem); font-weight: 800; margin: 0 0 1rem; }
h2 { font-size: 1.25rem; font-weight: 700; margin: 2rem 0 .75rem; }
h3 { font-size: 1.05rem; font-weight: 700; }
.h3 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.narrow { max-width: 560px; }
.prose { max-width: 70ch; }
.inline { display: inline; }
.row { display: flex; gap: var(--space); flex-wrap: wrap; }
.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
code { font-size: .9em; background: var(--surface-2); padding: .1em .35em; border-radius: 6px; }
details summary { cursor: pointer; font-weight: 600; }
.skip-link { position: absolute; left: -9999px; z-index: 10; }
.skip-link:focus { left: 16px; top: 8px; background: var(--surface); color: var(--fg); padding: .5rem .75rem; border-radius: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---- Wordmark (built from BRAND_NAME; mark from the logo kit) -------------------------- */
.wordmark { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: #fff; }
.wordmark-mark { width: 30px; height: 30px; flex: none; }
.wordmark-text { font-size: 1.3rem; font-weight: 900; letter-spacing: -0.045em; line-height: 1; }
.wordmark-tail { background: var(--gradient-text); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---- App shell: navy sidebar + work area ----------------------------------------------- */
.shell {
  display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh;
  /* The sidebar colour runs the full height of long pages. */
  background: linear-gradient(to right, var(--navy-2) var(--sidebar), transparent var(--sidebar));
}
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 1.25rem;
  padding: 1.25rem 1rem;
  background: var(--navy-2);
  border-right: 1px solid var(--navy-line);
  color: #cbd5e1;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: .25rem .5rem; }
.nav-toggle, .nav-toggle-label { display: none; }
.side-nav { display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.side-nav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .75rem; border-radius: 10px;
  color: #cbd5e1; text-decoration: none; font-weight: 600; font-size: .95rem;
}
.side-nav a::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: rgba(203, 213, 225, .35); }
.side-nav a:hover { background: rgba(147, 180, 255, .08); color: #fff; }
.side-nav a[aria-current="page"] { background: rgba(147, 180, 255, .14); color: #fff; }
.side-nav a[aria-current="page"]::before { background: var(--gradient-text); }
.side-nav .nav-label { margin: 1rem .75rem .25rem; font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #94a3b8; }
.sidebar-foot { border-top: 1px solid var(--navy-line); padding: 1rem .5rem 0; font-size: .85rem; }
.sidebar-foot .org { color: #fff; font-weight: 700; }
.sidebar-foot .who { color: #94a3b8; word-break: break-all; }
.sidebar-foot button.link { color: #c4b5fd; margin-top: .5rem; }

.work { display: flex; flex-direction: column; min-width: 0; }
.content { width: 100%; max-width: 1160px; padding: 2rem 2.5rem 3rem; flex: 1; }
.app-footer { padding: 1.25rem 2.5rem; border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem 1.5rem; }
.app-footer p { margin: 0; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; background: none; }
  .sidebar { position: static; height: auto; padding: .75rem 1rem; gap: 0; }
  .nav-toggle-label {
    display: inline-flex; align-items: center; min-height: 40px; padding: .4rem .8rem;
    border: 1px solid var(--navy-line); border-radius: 10px; color: #fff; font-weight: 600; font-size: .9rem; cursor: pointer;
  }
  .side-nav, .sidebar-foot { display: none; }
  .nav-toggle:checked ~ .side-nav, .nav-toggle:checked ~ .sidebar-foot { display: flex; flex-direction: column; }
  .nav-toggle:checked ~ .side-nav { padding-top: .75rem; }
  .nav-toggle:focus-visible + .sidebar-top .nav-toggle-label { outline: 3px solid var(--focus); outline-offset: 2px; }
  .content { padding: 1.25rem 1rem 2rem; }
  .app-footer { padding: 1rem; }
}

/* ---- Signed-out pages: card on the website's navy hero ---------------------------------- */
.auth-body {
  min-height: 100vh; display: flex; flex-direction: column;
  background:
    radial-gradient(700px 420px at 85% -10%, rgba(124, 58, 237, .35), transparent 65%),
    radial-gradient(600px 380px at 0% 110%, rgba(37, 99, 235, .25), transparent 65%),
    var(--navy);
  color: #cbd5e1;
}
.auth-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; max-width: 1160px; width: 100%; margin: 0 auto; padding: 1.25rem 20px; }
.auth-head nav { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.auth-head nav a { color: #cbd5e1; text-decoration: none; font-weight: 600; font-size: .95rem; }
.auth-head nav a:hover { color: #fff; }
.auth-head nav a.btn { color: #fff; }
.auth-main { flex: 1; display: flex; justify-content: center; align-items: flex-start; padding: 2rem 16px 3rem; }
.auth-card {
  width: 100%; max-width: 480px;
  background: var(--surface); color: var(--fg);
  border: 1px solid var(--border); border-radius: 22px;
  box-shadow: 0 30px 80px rgba(7, 11, 24, .45);
  padding: 2rem;
}
.auth-card.wide { max-width: 1000px; }
.auth-card .narrow { max-width: none; }
.auth-foot { max-width: 1160px; width: 100%; margin: 0 auto; padding: 1.25rem 20px; font-size: .85rem; color: #94a3b8; display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem 1.5rem; }
.auth-foot p { margin: 0; }
.auth-foot a { color: #c4b5fd; }
@media (max-width: 520px) { .auth-card { padding: 1.4rem; border-radius: 18px; } }

/* ---- Buttons ----------------------------------------------------------------------------- */
.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 42px; padding: .55rem 1.1rem;
  background: var(--gradient); color: #fff;
  border: 0; border-radius: var(--radius);
  font: inherit; font-weight: 700; font-size: .95rem; text-decoration: none; cursor: pointer;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .22);
  transition: filter .15s, transform .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.btn-secondary { background: var(--surface); color: var(--fg); border: 1px solid var(--border); box-shadow: none; }
.btn.btn-secondary:hover { border-color: var(--link); filter: none; }
.btn.btn-danger { background: transparent; color: var(--bad); border: 1px solid currentColor; box-shadow: none; }
.btn.btn-small { min-height: 34px; padding: .35rem .75rem; font-size: .85rem; }
button.link { background: none; border: 0; padding: 0; color: var(--link); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.actions, .toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: 1rem 0; }
.actions .field, .toolbar select { width: auto; }
.actions .field { min-width: 180px; }

/* ---- Forms --------------------------------------------------------------------------------- */
.stack { display: grid; gap: 1rem; }
.field { display: grid; gap: .35rem; }
.field span { font-weight: 600; font-size: .9rem; }
.field small { color: var(--muted); font-size: .82rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; min-height: 42px;
  font: inherit; color: var(--fg);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: .55rem .75rem;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
input[readonly] { background: var(--surface-2); }
input[type=color] { width: 4rem; height: 2.6rem; padding: .2rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
input[type=checkbox] { width: 1.05rem; height: 1.05rem; accent-color: var(--violet); margin-top: .2rem; flex: none; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem 1.1rem; display: grid; gap: .9rem; background: var(--surface); margin: 0; }
legend { font-weight: 700; padding: 0 .4rem; }
.check { display: flex; gap: .55rem; align-items: flex-start; }

/* ---- Messages ------------------------------------------------------------------------------ */
.flash, .notice, .errors, .demo-banner { border-radius: var(--radius); padding: .8rem 1rem; margin: 0 0 1.25rem; border: 1px solid; }
.flash { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--fg); }
.notice { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.errors { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 40%, transparent); color: var(--bad); }
.errors ul { margin: 0; padding-left: 1.2rem; }
.demo-banner { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 40%, transparent); color: var(--warn); font-size: .88rem; }
.placeholder { padding: 1rem; background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---- Cards ------------------------------------------------------------------------------------ */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin: 1rem 0 2rem; }
.card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.25rem; box-shadow: var(--shadow);
}
.card header { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.card h3 { margin: 0 0 .4rem; font-size: 1.05rem; }
.card h3 a { color: var(--fg); text-decoration: none; }
.card h3 a:hover { color: var(--link); }
.card p { margin: .3rem 0; }
.card footer { margin-top: auto; padding-top: 1rem; display: flex; gap: 1rem; align-items: center; }
.compare-summary { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.compare-summary .card h3 { margin: 0; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.big { font-size: 1.75rem; font-weight: 800; letter-spacing: -0.03em; margin: .3rem 0; }
.checks { margin: .4rem 0; padding-left: 1.1rem; color: var(--muted); font-size: .92rem; }

/* ---- Tables -------------------------------------------------------------------------------- */
.table {
  width: 100%; margin: 1rem 0;
  border-collapse: separate; border-spacing: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .92rem; overflow: hidden;
}
.table th, .table td { text-align: left; padding: .7rem .85rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table thead th { background: var(--surface-2); color: var(--muted); font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.table tbody tr:last-child td, .table tfoot tr:last-child td, .table tfoot tr:last-child th { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.table-wrap, .scroll-x { overflow-x: auto; }
.scroll-x .table, .table-wrap .table { margin: 1rem 0; }

/* ---- Badges, status, trends --------------------------------------------------------------- */
.badge, .tag, .status {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .72rem; font-weight: 700; letter-spacing: .02em;
  padding: .12rem .55rem; border-radius: 999px; white-space: nowrap; vertical-align: middle;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.sev-critical { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.sev-high { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.sev-medium, .badge-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.sev-low { background: var(--info-bg); color: var(--info); border-color: transparent; }
.sev-info { background: var(--surface-2); color: var(--muted); }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-completed { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.status-failed { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
.status-queued, .status-running { color: var(--info); background: var(--info-bg); border-color: transparent; }
.tag-live { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.tag-soon { color: var(--muted); }
.trend { font-weight: 700; }
.trend-better { color: var(--ok); }
.trend-worse { color: var(--bad); }
.trend-same, .trend-na { color: var(--muted); }
.pill-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.pill-list li { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: .25rem .75rem; font-size: .88rem; }

/* ---- Lists, facts, misc ------------------------------------------------------------------- */
.list { padding-left: 1.2rem; }
.list li { margin: .2rem 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.25rem; margin: 1.25rem 0; padding: 1rem 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.facts dt { color: var(--muted); font-weight: 600; font-size: .9rem; }
.facts dd { margin: 0; font-weight: 600; }
.subnav { display: flex; flex-wrap: wrap; gap: .35rem; margin: -.25rem 0 1.5rem; padding: .3rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); width: fit-content; max-width: 100%; }
.subnav a { padding: .4rem .8rem; border-radius: 9px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .9rem; }
.subnav a:hover { color: var(--fg); }
.subnav a[aria-current="page"] { background: var(--gradient); color: #fff; }
.shares { margin: 1rem 0; }
.logo-preview { max-height: 64px; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; font-size: 1.05rem; }
.qr { background: #fff; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); }
.secret { word-break: break-all; }
.spinner { display: inline-block; width: .9rem; height: .9rem; border: 2px solid var(--border); border-top-color: var(--violet); border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } .btn { transition: none; } }

/* The in-app report keeps the client's document look (light, MSP-branded) in any theme. */
.report-frame { color-scheme: light; }

@media (max-width: 640px) {
  .table { display: block; overflow-x: auto; }
  .facts { grid-template-columns: 1fr; }
}
