/*
 * MIND's own layer on top of Basecoat (static/vendor/basecoat-*.min.css): the page shells (sidebar
 * console, top bar, centred card), form layout, status badges and a few helpers. Basecoat's
 * component styles live in CSS layers, so everything here wins over them without !important.
 */

/*
 * Geist, the font Basecoat's --font-sans and --font-mono name first ("Geist Sans", "Geist Mono").
 * Variable fonts, so one file covers every weight; served from this origin (static/vendor/fonts).
 */
@font-face {
  font-family: "Geist Sans";
  src: url("/static/fonts/geist-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Sans";
  src: url("/static/fonts/geist-italic-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/static/fonts/geist-mono-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* The CSP allows no data: images, so Basecoat's inline icons are replaced by same-origin files. */
:root {
  --chevron-down-icon: url("/static/icons/chevron-down.svg");
  --chevron-down-icon-50: url("/static/icons/chevron-down.svg");
  --check-icon: url("/static/icons/check.svg");
  --ok: oklch(0.52 0.13 150);
}
html.dark {
  --chevron-down-icon: url("/static/icons/chevron-down-dark.svg");
  --chevron-down-icon-50: url("/static/icons/chevron-down-dark.svg");
  --check-icon: url("/static/icons/check-dark.svg");
  --ok: oklch(0.72 0.15 150);
}

body {
  font-size: 14px;
  line-height: 1.5;
}
/* Plain links only: buttons and card links carry their own colours. */
a:not(.btn, .card) {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in oklab, currentColor 35%, transparent);
}
a:not(.btn, .card):hover {
  text-decoration-color: currentColor;
}
a.btn {
  text-decoration: none;
}
code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--muted);
}
h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
h2 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
}
h3 {
  font-size: 14px;
  font-weight: 600;
}

/* ---- Shells ------------------------------------------------------------------------------ */

/* Console: sidebar plus content. */
.app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
  /* Paints the sidebar column the full page height; the sticky sidebar itself is one screen tall. */
  background: linear-gradient(
    90deg,
    var(--sidebar, var(--card)) 0 247px,
    var(--border) 247px 248px,
    var(--background) 248px
  );
}
.app > aside {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.app > aside .brand {
  font-weight: 600;
  font-size: 15px;
  padding: 4px 10px 12px;
  text-decoration: none;
  display: block;
}
.app > aside .brand span {
  display: block;
  font-weight: 400;
  font-size: 13px;
  color: var(--muted-foreground);
}
.app > aside .group {
  font-size: 12px;
  color: var(--muted-foreground);
  padding: 14px 10px 4px;
}
.app > aside nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.app > aside nav a {
  display: block;
  padding: 7px 10px;
  border-radius: calc(var(--radius) - 2px);
  color: var(--muted-foreground);
  text-decoration: none;
  white-space: nowrap;
}
.app > aside nav a:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}
.app > aside nav a[aria-current] {
  background: var(--accent);
  color: var(--accent-foreground);
  font-weight: 500;
}
.app > aside .foot {
  margin-top: auto;
  padding-top: 16px;
}
.app > main {
  padding: 28px 32px 48px;
  max-width: 1120px;
  width: 100%;
}

/* Top bar for the home page and agent settings. */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.topbar .brand {
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
}
.topbar .actions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted-foreground);
}
.topbar + main {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

/* Centred card for sign-in and two-factor pages. */
.center {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.center > .card {
  width: 100%;
  max-width: 420px;
}

/* ---- Page heading ------------------------------------------------------------------------ */

.crumbs {
  font-size: 13px;
  color: var(--muted-foreground);
  margin: 0 0 4px;
}
.crumbs a {
  color: inherit;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 16px;
}
main > .page-head:not(:first-child) {
  margin-top: 32px;
}
main > .crumbs + .page-head {
  margin-top: 0;
}
.page-head h1 {
  margin: 0;
}
.lead {
  color: var(--muted-foreground);
  margin: 4px 0 0;
  max-width: 70ch;
}

/* ---- Content blocks ---------------------------------------------------------------------- */

main > * + *,
.card > section > * + * {
  margin-top: 16px;
}
main > h2 {
  margin-top: 28px;
}
.muted {
  color: var(--muted-foreground);
}
.small {
  font-size: 13px;
}
.err {
  color: var(--destructive);
}
.ok {
  color: var(--ok);
}
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 12px;
}
.stats .card > section {
  display: grid;
  gap: 2px;
}
.stats .card > section > * + * {
  margin-top: 0;
}
.stats strong {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 12px;
}
a.card {
  text-decoration: none;
  transition: border-color 0.15s;
}
a.card:hover {
  border-color: var(--ring);
}
.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 16px;
  align-items: start;
}
.panels > * {
  margin: 0;
}
.list {
  display: grid;
  gap: 12px;
}
.list > .card {
  margin: 0;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
form.inline {
  display: inline;
}
.alert {
  margin-bottom: 0;
}
.alert[data-tone="ok"] {
  color: var(--ok);
}

/* ---- Forms ------------------------------------------------------------------------------- */

form.stack {
  display: grid;
  gap: 16px;
  max-width: 480px;
}
form.stack.wide {
  max-width: none;
}
label.field {
  display: grid;
  gap: 6px;
  font-weight: 500;
}
label.field > :is(input, select, textarea) {
  width: 100%;
  font-weight: 400;
}
label.field > small,
label.field > span.hint {
  font-weight: 400;
  color: var(--muted-foreground);
  font-size: 13px;
}
label.check {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 500;
}
form.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  gap: 12px;
  align-items: end;
}
form.filters .row {
  grid-column: 1 / -1;
}
details > summary {
  cursor: pointer;
  font-weight: 500;
  list-style: none;
}
details > summary::-webkit-details-marker {
  display: none;
}
details > summary::before {
  content: "\25B8";
  display: inline-block;
  width: 1.1em;
  color: var(--muted-foreground);
}
details[open] > summary::before {
  content: "\25BE";
}
details.card {
  padding-block: 16px;
  gap: 0;
}
div.stack {
  display: grid;
  gap: 8px;
}
.card h2 .muted {
  font-weight: 400;
  font-size: 13px;
}
.card h2 a {
  text-decoration: none;
}
details[open] > summary {
  margin-bottom: 12px;
}
details.card > summary {
  padding: 0 24px;
}
details.card[open] > summary + * {
  padding: 0 24px;
}

/* ---- Tables ------------------------------------------------------------------------------ */

.table-container {
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.table td {
  vertical-align: top;
}
.table td.wrap {
  overflow-wrap: break-word;
  white-space: normal;
}
td.nowrap,
th.nowrap {
  white-space: nowrap;
}
td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
td.detail {
  max-width: 360px;
  white-space: normal;
}
.table td input,
.table td select {
  min-width: 170px;
}

/* ---- Badges ------------------------------------------------------------------------------ */

.badge[data-tone="ok"] {
  background: color-mix(in oklab, var(--ok) 14%, transparent);
  color: var(--ok);
  border-color: transparent;
}

/* ---- Misc -------------------------------------------------------------------------------- */

/* White in dark mode too: authenticator cameras need the light quiet zone around the code. */
.qr {
  width: 220px;
  max-width: 100%;
  padding: 0;
  background: #fff;
  border-radius: 8px;
  line-height: 0;
}
.qr svg {
  width: 100%;
  height: auto;
  display: block;
}

@media (max-width: 800px) {
  .app {
    grid-template-columns: 1fr;
    background: var(--background);
  }
  .app > aside {
    position: static;
    height: auto;
    background: var(--sidebar, var(--card));
    border-bottom: 1px solid var(--border);
    padding: 12px;
  }
  .app > aside nav {
    flex-direction: row;
    overflow-x: auto;
  }
  .app > aside .group {
    display: none;
  }
  .app > aside .foot {
    margin-top: 8px;
    padding-top: 0;
  }
  .app > main {
    padding: 20px 16px 40px;
  }
  .topbar {
    padding: 12px 16px;
  }
  .topbar + main {
    padding: 20px 16px 40px;
  }
  input,
  select,
  textarea {
    font-size: 16px;
  }
}
