/* munch dashboard and sign-in. Uses ds.css for fonts and the Button component, restyled here for the app:
   Geist, neutral surfaces, rounded corners, light and dark themes (system by default, data-theme on <html>). */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f5f5f5;
  --hover: rgba(0, 0, 0, 0.04);
  --active: rgba(0, 0, 0, 0.07);
  --line: #eaeaea;
  --line-strong: #d9d9d9;
  --text: #171717;
  --text-2: #4d4d4d;
  --muted: #6b6b6b;
  --accent: #5b3fe0;
  --accent-soft: rgba(91, 63, 224, 0.1);
  --accent-bar: #c9bff7;
  --success: #138a4c;
  --warning: #9a5b00;
  --danger: #c4231a;
  --danger-soft: #fdf0ef;
  --on-danger: #fff;
  --code-bg: #fafafa;
  --shadow-s: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-l: 0 0 0 1px rgba(0, 0, 0, 0.06), 0 16px 40px -8px rgba(0, 0, 0, 0.18);
  --radius: 12px;
  --radius-s: 8px;
  --font: "Geist", var(--ds-font-sans);
  --mono: var(--ds-font-mono);

  /* ds.css buttons follow the app's palette. */
  --ds-ink: var(--text);
  --ds-ink-hover: #383838;
  --ds-paper: var(--surface);
  --ds-chip: var(--surface-2);
  --ds-chip-hover: #ebebeb;
  --ds-line-strong: var(--line-strong);
  --ds-violet: var(--accent);
  --ds-focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a0a0a;
    --surface: #111111;
    --surface-2: #1a1a1a;
    --hover: rgba(255, 255, 255, 0.05);
    --active: rgba(255, 255, 255, 0.09);
    --line: #262626;
    --line-strong: #3a3a3a;
    --text: #ededed;
    --text-2: #c7c7c7;
    --muted: #a1a1a1;
    --accent: #9d8cff;
    --accent-soft: rgba(157, 140, 255, 0.14);
    --accent-bar: #3f3587;
    --success: #3ecf8e;
    --warning: #f0b45a;
    --danger: #ff6b61;
    --danger-soft: rgba(255, 107, 97, 0.1);
    --on-danger: #1f0806; /* white on this light red reads at 2.8:1; near-black reads at 7:1 */
    --code-bg: #0d0d0d;
    --shadow-s: none;
    --shadow-l: 0 0 0 1px #2a2a2a, 0 16px 40px -8px rgba(0, 0, 0, 0.7);
    --ds-ink-hover: #cccccc;
    --ds-chip-hover: #242424;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0a0a;
  --surface: #111111;
  --surface-2: #1a1a1a;
  --hover: rgba(255, 255, 255, 0.05);
  --active: rgba(255, 255, 255, 0.09);
  --line: #262626;
  --line-strong: #3a3a3a;
  --text: #ededed;
  --text-2: #c7c7c7;
  --muted: #a1a1a1;
  --accent: #9d8cff;
  --accent-soft: rgba(157, 140, 255, 0.14);
  --accent-bar: #3f3587;
  --success: #3ecf8e;
  --warning: #f0b45a;
  --danger: #ff6b61;
  --danger-soft: rgba(255, 107, 97, 0.1);
  --on-danger: #1f0806;
  --code-bg: #0d0d0d;
  --shadow-s: none;
  --shadow-l: 0 0 0 1px #2a2a2a, 0 16px 40px -8px rgba(0, 0, 0, 0.7);
  --ds-ink-hover: #cccccc;
  --ds-chip-hover: #242424;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  background: var(--bg);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1,
h2,
h3,
p {
  margin: 0;
}
ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
a {
  color: inherit;
  text-decoration: none;
}
img {
  display: block;
}
code,
kbd {
  font-family: var(--mono);
  font-size: 12.5px;
}
[hidden] {
  display: none !important;
}
button:not(:disabled),
select,
summary,
label.check,
[role="tab"],
[role="radio"],
[role="option"] {
  cursor: pointer;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
#main:focus {
  outline: none;
}
.visually-hidden {
  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-link {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: var(--radius-s);
  background: var(--text);
  color: var(--bg);
}
.skip-link:focus {
  top: 12px;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 12.5px;
}
.block {
  display: block;
}
.nowrap {
  white-space: nowrap;
}
.link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-underline-offset: 3px;
}
.link:hover {
  text-decoration-color: currentColor;
}

/* ---------- Buttons (ds.css), app treatment ---------- */
.btn {
  gap: 6px;
  border-radius: 6px;
  font-family: var(--font);
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}
.btn--secondary {
  background: var(--surface);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-s);
}
.btn--secondary:hover {
  background: var(--surface-2);
}
.btn--ghost {
  color: var(--text-2);
}
.btn--ghost:hover {
  background: var(--hover);
  color: var(--text);
}
.btn:disabled,
.btn[aria-disabled="true"],
.btn--primary:disabled,
.btn--secondary:disabled,
.btn--ghost:disabled {
  opacity: 0.5;
  color: inherit;
}
.btn--primary:disabled {
  color: var(--surface);
}
.btn[aria-busy="true"] {
  cursor: progress;
}
.btn--danger {
  background: var(--danger);
  color: var(--on-danger);
}
.btn--danger:hover {
  background: color-mix(in srgb, var(--danger) 85%, #000);
}
.btn--danger-text:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: none;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}
.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}
.icon-btn--s {
  width: 28px;
  height: 28px;
}
.icon-btn:disabled {
  cursor: progress;
}

kbd {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

/* ---------- Shell ---------- */
.app {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-family: var(--ds-font-brand);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.logo__mark {
  position: relative;
  width: 20px;
  height: 20px;
  flex: none;
}
.logo__mark img {
  position: absolute;
  top: 50%;
  left: 50%;
  width: auto;
  height: 22px;
  transform: translate(-50%, -50%);
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100vh;
  height: 100dvh;
  padding: 14px 12px 12px;
  border-right: 1px solid var(--line);
  background: var(--bg);
}
.sidebar__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 30px;
  padding: 0 6px;
}
.sidebar__close {
  display: none;
}

.workspace {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin: 10px 0 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-s);
  transition: border-color 120ms ease;
}
.workspace:hover {
  border-color: var(--line-strong);
}
.workspace__avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, #7b5cff, #ff8c78);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}
.workspace__id {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.workspace__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 500;
}
.workspace__credit {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  white-space: nowrap;
}

.sidebar__nav {
  flex: 1;
  min-height: 0;
  margin: 0 -4px;
  padding: 0 4px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.sidenav__label {
  margin: 14px 0 4px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.sidenav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sidenav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 8px;
  border-radius: 6px;
  color: var(--text-2);
  font-size: 14px;
  white-space: nowrap;
  transition: background-color 100ms ease, color 100ms ease;
}
.sidenav__link svg {
  flex: none;
  color: var(--muted);
}
.sidenav__link:hover {
  background: var(--hover);
  color: var(--text);
}
.sidenav__link[aria-current="page"],
.sidenav__link.is-section {
  background: var(--active);
  color: var(--text);
  font-weight: 500;
}
.sidenav__link[aria-current="page"] svg,
.sidenav__link.is-section svg {
  color: var(--text);
}
.sidenav__sub {
  margin: 4px 0 6px 16px;
  padding-left: 10px;
  border-left: 1px solid var(--line);
}
.sidenav__group {
  margin: 10px 0 2px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
}
.sidenav__group:first-child {
  margin-top: 4px;
}
.sidenav__sub a {
  display: block;
  overflow: hidden;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background-color 100ms ease, color 100ms ease;
}
.sidenav__sub a code {
  font-size: 12px;
}
.sidenav__sub a:hover {
  background: var(--hover);
  color: var(--text);
}
.sidenav__sub a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.sidebar__search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 34px;
  margin: 0 0 10px;
  padding: 0 6px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color 120ms ease;
}
.sidebar__search span {
  flex: 1;
  text-align: left;
}
.sidebar__search:hover {
  border-color: var(--line-strong);
  color: var(--text-2);
}

.sidebar__foot {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.account-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  padding: 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}
.account-btn:hover {
  background: var(--hover);
}
.account-btn__id {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.main-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Phones only: the menu button and the current page. Wider screens keep everything in the sidebar. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: none;
  align-items: center;
  gap: 12px;
  height: 56px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
}
.topbar__menu {
  display: none;
  margin-left: -6px;
}
.crumbs {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 14px;
  white-space: nowrap;
}
.crumbs a {
  color: var(--text-2);
  border-radius: 6px;
  transition: color 100ms ease;
}
.crumbs a:hover {
  color: var(--text);
}
.crumbs__sep {
  color: var(--line-strong);
  font-size: 18px;
  font-weight: 300;
}
.crumbs__here {
  overflow: hidden;
  color: var(--text);
  font-weight: 500;
  text-overflow: ellipsis;
}
.user__avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff9fb0, #7fd3cc);
  color: #111;
  font-size: 11px;
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--line);
}
.user__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 40px 72px;
}
.main > * {
  min-width: 0;
  max-width: 100%;
}
.main.is-entering > * {
  animation: enter 180ms ease-out backwards;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-head__title {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.page-head h1 {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.035em;
}
.page-head p {
  color: var(--muted);
  font-size: 14.5px;
}
.page-head__actions {
  display: flex;
  gap: 8px;
}

/* Thin progress bar while a page is on its way (rare: pages are prefetched). */
.nav-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  width: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
}
.is-navigating .nav-progress {
  width: 85%;
  opacity: 1;
  transition: width 8s cubic-bezier(0.1, 0.7, 0.1, 1), opacity 100ms;
}

/* ---------- Account menu (popover) ---------- */
.menu {
  position: fixed;
  inset: auto auto 64px 12px;
  width: 264px;
  margin: 0;
  padding: 6px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-l);
}
.menu:popover-open {
  animation: pop 140ms ease-out;
}
.user__name {
  font-weight: 500;
}
.user__name:empty {
  display: none;
}
.user__email {
  color: var(--muted);
  font-size: 13px;
}
.user__name,
.user__email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  color: var(--text-2);
}
.theme-switch {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.theme-switch button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.theme-switch button:hover {
  color: var(--text);
}
.theme-switch button[aria-checked="true"] {
  background: var(--active);
  color: var(--text);
}
.menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.menu__item svg {
  color: var(--muted);
}
.menu__item:hover {
  background: var(--hover);
  color: var(--text);
}
.menu__item.is-busy {
  opacity: 0.6;
  cursor: progress;
}

/* ---------- Command menu ---------- */
.cmdk {
  width: min(620px, calc(100% - 32px));
  max-height: min(520px, calc(100dvh - 120px));
  margin: 12vh auto auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-l);
}
.cmdk[open] {
  display: flex;
  flex-direction: column;
  animation: pop 140ms ease-out;
}
.cmdk::backdrop {
  background: rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.cmdk__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}
.cmdk__bar input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15.5px;
  outline: none;
}
.cmdk__bar input::placeholder {
  color: var(--muted);
}
.cmdk__list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  scroll-padding: 6px;
}
.cmdk__group {
  padding: 10px 10px 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.cmdk__item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
}
.cmdk__item svg {
  flex: none;
  color: var(--muted);
}
.cmdk__item span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cmdk__item small {
  color: var(--muted);
  font-size: 12px;
}
.cmdk__item[aria-selected="true"] {
  background: var(--active);
  color: var(--text);
}
.cmdk__item[aria-selected="true"] svg {
  color: var(--text);
}
.cmdk__empty {
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

/* ---------- Feedback: banner, toast, skeletons ---------- */
.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: var(--radius-s);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
  animation: enter 160ms ease-out;
}
.banner p {
  flex: 1;
  min-width: 0;
}
.banner .icon-btn {
  color: inherit;
}
/* Toast: a popover, so it sits in the top layer above any open dialog. */
.toast {
  position: fixed;
  inset: auto max(20px, env(safe-area-inset-right, 0px)) max(20px, env(safe-area-inset-bottom, 0px)) auto;
  z-index: 50;
  width: auto;
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 10px 14px;
  border: 0;
  border-radius: var(--radius-s);
  background: var(--text);
  color: var(--bg);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-l);
  animation: enter 160ms ease-out;
}
.toast:empty {
  display: none;
}

.is-loading [data-skeleton],
.skel {
  color: transparent !important;
  border-radius: 4px;
  background: var(--surface-2);
  animation: pulse 1.2s ease-in-out infinite;
}
.is-loading [data-skeleton] {
  display: inline-block;
  align-self: flex-start;
  max-width: 100%;
}
.skel {
  display: block;
  width: 100%;
  max-width: 520px;
  height: 14px;
}
.skeleton-row td {
  padding-top: 16px !important;
  padding-bottom: 16px !important;
}
.list .skeleton-row {
  padding: 16px 20px;
}

/* ---------- Cards and summary ---------- */
.card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-s);
}
.card--pad {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 24px;
}
.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 12px 20px;
}
.card__head h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.card__foot {
  display: flex;
  justify-content: center;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.card__foot:has([hidden]:only-child) {
  display: none;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.grid-2--wide {
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
}


.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-s);
}
.tile__label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.tile__value {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.tile__value--big {
  font-size: 40px;
}
.tile__note {
  color: var(--muted);
  font-size: 13px;
}
.meter {
  height: 4px;
  margin-top: 2px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}
.meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 400ms ease;
}
.meter.is-high span {
  background: var(--warning);
}

.chart {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 180px;
  margin: 4px 20px 0;
  border-bottom: 1px solid var(--line);
  background-image: linear-gradient(var(--line) 1px, transparent 1px);
  background-size: 100% 25%;
  background-position: 0 -1px;
}
.chart__bar {
  position: relative;
  flex: 1;
  min-width: 2px;
  height: var(--h, 0%);
  border-radius: 3px 3px 0 0;
  background: var(--accent-bar);
  transition: background-color 120ms ease, height 300ms ease;
}
.chart__bar:hover,
.chart__bar:focus,
.chart__bar.is-today {
  background: var(--accent);
}
.chart__bar:focus {
  outline: none;
}
.chart__bar:focus-visible {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}
/* The tip shows on hover, on keyboard focus (arrow keys) and on a tap (which focuses the bar). */
.chart__bar:hover::after,
.chart__bar:focus::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  z-index: 2;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 11.5px;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}
.chart__bar:first-child:hover::after,
.chart__bar:first-child:focus::after {
  left: 0;
  transform: none;
}
.chart__bar:last-child:hover::after,
.chart__bar:last-child:focus::after {
  right: 0;
  left: auto;
  transform: none;
}
.chart__empty {
  margin: -110px 0 72px;
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}
.chart__axis {
  display: flex;
  justify-content: space-between;
  padding: 8px 20px 16px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
}

.list__row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  transition: background-color 100ms ease;
}
a.list__link {
  color: inherit;
}
a.list__link:hover {
  background: var(--hover);
}
a.list__link:focus-visible {
  outline-offset: -2px;
}
.list__main {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.list__main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list__main code {
  color: var(--muted);
  font-size: 11.5px;
}
.list__empty {
  padding: 28px 20px !important;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
  white-space: normal !important;
}
.list__when {
  min-width: 72px;
  text-align: right;
}
.cost {
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.tool-row__bar {
  display: block;
  height: 4px;
  margin-top: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}
.tool-row__bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

/* ---------- Tables ---------- */
.table-wrap {
  position: relative;
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th {
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
.table td {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}
.table thead + tbody tr:first-child td {
  border-top: 0;
}
.table th:first-child,
.table td:first-child {
  padding-left: 20px;
}
.table th:last-child,
.table td:last-child {
  padding-right: 20px;
}
.table tbody tr[data-call] {
  cursor: pointer;
}
.table tbody tr[data-call]:hover {
  background: var(--hover);
}
/* The brief opens the row's details: a plain-looking button, so the keyboard can reach every row. */
.row-open {
  display: block;
  max-width: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  text-overflow: ellipsis;
  white-space: inherit;
  cursor: pointer;
}
.row-open:focus-visible {
  outline-offset: 4px;
}
.table .actions {
  text-align: right;
}
.table .brief {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Usage, as a table: the brief takes what the other columns leave, so the row never overflows its card. */
@media (min-width: 1400px) {
  .table.table--usage .brief {
    width: 100%;
    max-width: 0;
  }
}
.table .num {
  text-align: right;
}
.table .cell-key {
  max-width: 260px;
}
.cell-key__in {
  display: flex;
  flex-wrap: wrap; /* a narrow cell puts the masked key on its own line rather than cut it */
  align-items: baseline;
  gap: 0 6px;
  min-width: 0;
}
.cell-key__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Only for keys that share a name: the part that tells them apart never shortens. */
.cell-key__masked {
  flex: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}
.table td:first-child strong {
  font-weight: 500;
  white-space: normal;
}
.table-wrap.is-busy tbody {
  opacity: 0.55;
  transition: opacity 120ms ease;
}
.key-chip {
  padding: 3px 6px;
  border-radius: 5px;
  background: var(--surface-2);
}
.key-new {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.key-new__text {
  min-width: 0;
  padding: 3px 6px;
  border-radius: 5px;
  background: var(--surface);
  white-space: normal;
  overflow-wrap: anywhere;
}
.key-new__hint {
  display: block;
  margin-top: 6px;
  color: var(--warning);
  font-size: 12.5px;
  font-weight: 500;
  white-space: normal;
}
.table--keys tr.is-new {
  background: var(--accent-soft);
}
.menu.menu--key {
  position: absolute;
  inset: auto;
  width: 176px;
}
.menu__item--danger,
.menu__item--danger svg {
  color: var(--danger);
}
.menu__item--danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--line-strong);
  vertical-align: 1px;
}
.dot--on {
  background: var(--success);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 20%, transparent);
}
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}
.status--more::before {
  background: var(--accent);
}
.status--refused::before,
.status--error::before {
  background: var(--danger);
}
.status--refused,
.status--error {
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger);
}

.revoked {
  border-top: 1px solid var(--line);
}
.revoked summary {
  padding: 12px 20px;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  list-style-position: inside;
}
.revoked summary:hover {
  color: var(--text);
}
.revoked .list__row {
  color: var(--muted);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.filters__summary {
  flex: 1;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12.5px;
  text-align: right;
}

/* ---------- Dropdown (a <select> made into a button and a listbox popover) ---------- */
.select {
  position: relative;
  display: inline-flex;
  min-width: 0;
}
.select__btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-width: 150px;
  max-width: 260px;
  height: 34px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  box-shadow: var(--shadow-s);
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}
.select__btn:hover {
  border-color: color-mix(in srgb, var(--text) 30%, var(--line-strong));
}
.select__btn[aria-expanded="true"],
.select__btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.select__btn svg {
  flex: none;
  color: var(--muted);
  transition: transform 150ms ease;
}
.select__btn[aria-expanded="true"] svg {
  transform: rotate(180deg);
}
.select__value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}
.select__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.select__detail {
  flex: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}
.select__list [role="option"] .select__detail {
  margin-left: auto;
  padding-left: 12px;
}
.select__list {
  position: fixed;
  inset: auto;
  max-width: min(360px, calc(100vw - 16px));
  max-height: min(320px, calc(100dvh - 120px));
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-l);
}
.select__list:popover-open {
  animation: pop 120ms ease-out;
}
.select__list [role="option"] {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px 0 8px;
  border-radius: 6px;
  color: var(--text-2);
  font-size: 13.5px;
  white-space: nowrap;
  outline: none;
}
.select__list [role="option"] svg {
  flex: none;
  visibility: hidden;
  color: var(--accent);
}
.select__list [role="option"][aria-selected="true"] {
  color: var(--text);
  font-weight: 500;
}
.select__list [role="option"][aria-selected="true"] svg {
  visibility: visible;
}
.select__list [role="option"]:focus,
.select__list [role="option"]:hover {
  background: var(--active);
  color: var(--text);
}

/* ---------- Call details: open in place, under the row ---------- */
.table tbody tr.is-open,
.table tbody tr.is-open:hover,
.table tbody tr.call-detail-row {
  background: var(--surface-2);
}
.table tbody tr.call-detail-row td {
  padding-top: 0;
  border-top: 0;
}
.call-detail {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 2px 0 16px;
  white-space: normal;
}
.call-detail__main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.call-detail__brief {
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.call-detail__note {
  color: var(--text-2);
  font-size: 13px;
}
.call-detail__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
}
.call-detail__meta div {
  display: flex;
  gap: 6px;
}
.call-detail__meta dd {
  margin: 0;
  color: var(--text-2);
}
.call-detail .btn {
  flex: none;
}

/* ---------- Connect: one row per agent ---------- */
.connect {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 20px;
  align-items: start;
}
.connect__agents,
.connect__more {
  display: grid;
  gap: 16px;
  min-width: 0;
}
.connect__more .card--pad {
  gap: 12px;
}
.connect__more .cmd {
  align-self: stretch;
}
.cmd--block .cmd__text {
  font-size: 12.5px;
}
.connect__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.agent-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}
.agent-row + .agent-row {
  border-top: 1px solid var(--line);
}
.agent-row__main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 10px 16px 10px 20px;
}
.agent-row__main .client-mark {
  color: var(--text);
}
.agent-row__name {
  flex: 1;
  min-width: 0;
  font-weight: 500;
}
.agent-row__main .btn svg {
  margin-left: 2px;
}
.agent-row__setup {
  display: grid;
  gap: 8px;
  padding: 0 16px 16px 54px;
}
.agent-row__setup[hidden] {
  display: none;
}
.agent-row__label {
  margin: 4px 0 -2px;
  color: var(--muted);
  font-size: 12.5px;
}
.key-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  font-weight: 500;
}
.key-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.key-icon {
  flex: none;
  color: var(--muted);
}
.client-mark {
  display: inline-block;
  flex: none;
  vertical-align: middle;
}
/* A command, a key or a prompt to copy: wraps instead of hiding anything, with its Copy button. */
.cmd {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface);
}
.cmd[hidden] {
  display: none;
}
/* The prompt sign is not part of the command: selecting the line never takes it. */
.cmd__dollar {
  color: var(--muted);
  user-select: none;
}
.cmd--block {
  align-items: flex-start;
}
.cmd__text {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 5px 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere; /* wrap at spaces; a long key or URL breaks anywhere rather than hide or scroll */
}
.cmd__text code {
  font: inherit;
}
.cmd__copy {
  flex: none;
}
.setup-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--warning);
  font-size: 13px;
  font-weight: 500;
}
.setup-status__dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: waiting 1.6s ease-in-out infinite;
}
.setup-status.is-on {
  color: var(--success);
}
.setup-status.is-on .setup-status__dot {
  animation: none;
}
@keyframes waiting {
  50% {
    opacity: 0.3;
  }
}
.list__meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}
.list__meta code {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tool-row__name {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.list__main .tool-row__name > span {
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
}

.codeblock__copy {
  position: absolute;
  top: 10px;
  right: 10px;
}

/* ---------- Forms and dialogs ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field label {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
}
.field input,
.field select,
.filters select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.field input:hover,
.filters select:hover {
  border-color: color-mix(in srgb, var(--text) 30%, var(--line-strong));
}
.field input:focus-visible,
.field select:focus-visible,
.filters select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field [aria-invalid="true"] {
  border-color: var(--danger);
}
.field [aria-invalid="true"]:focus-visible {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}
.field__hint {
  color: var(--muted);
  font-size: 12.5px;
}
.field__hint.is-warning {
  color: var(--warning);
}
.field__error {
  color: var(--danger);
  font-size: 12.5px;
}
.field__optional {
  margin-left: 4px;
  color: var(--muted);
  font-weight: 400;
}
.form-error {
  padding: 10px 12px;
  border-radius: var(--radius-s);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}
.money {
  position: relative;
}
.money > span {
  position: absolute;
  top: 50%;
  left: 12px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}
.money input {
  padding-left: 24px;
  font-variant-numeric: tabular-nums;
}
.filters select {
  width: auto;
  min-width: 150px;
  max-width: 240px;
  height: 34px;
  padding: 0 10px;
  font-size: 13.5px;
}

.dialog {
  width: min(480px, calc(100% - 32px));
  padding: 24px;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-l);
}
.dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.dialog[open] {
  animation: pop 160ms ease-out;
}
.dialog[open]::backdrop {
  animation: fade-in 160ms ease-out;
}
.dialog,
.dialog form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.dialog:not([open]) {
  display: none;
}
.dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -6px -8px 0 0;
}
.dialog h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 4px -24px -24px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 14px 14px;
  background: var(--bg);
}
.secret {
  display: flex;
  align-items: center;
  gap: 8px;
}
.secret code {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--surface-2);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 -8px;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background-color 160ms ease;
}
.check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}
.cap-form {
  width: 100%;
}
.cap-form__row {
  display: flex;
  gap: 8px;
}
.cap-form__row .money {
  flex: 1;
  min-width: 0;
}
.cap-form__row input {
  height: 40px;
}

/* ---------- Docs, inside the dashboard ---------- */
.main--docs {
  max-width: 1120px;
}
.doc {
  display: grid;
  grid-template-columns: minmax(0, 720px) 200px;
  justify-content: space-between;
  gap: 48px;
}
.doc__body {
  min-width: 0;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-2);
}
.doc__crumb {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
}
.doc__body h1 {
  color: var(--text);
  font-size: 32px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.04em;
}
.doc__body h1 code {
  font-size: 0.85em;
  letter-spacing: -0.02em;
}
.doc__lead {
  margin: 10px 0 8px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}
.doc__body h2 {
  margin: 40px 0 12px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.025em;
  scroll-margin-top: 72px;
}
.doc__body h3,
.doc__body .docs__h3 {
  margin: 28px 0 8px;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}
.doc__body p {
  margin: 12px 0;
}
.doc__body a:not(.btn) {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent);
  text-underline-offset: 3px;
}
.doc__body a:not(.btn):hover {
  text-decoration-color: currentColor;
}
.doc__body strong {
  color: var(--text);
  font-weight: 600;
}
.doc__body :not(pre) > code {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.85em;
}
.doc__body h1 code,
.doc__body .param__head code,
.doc__body .param__enum code,
.doc__body .sidenav code {
  border: 0;
  background: none;
  padding: 0;
}
.doc__body .codeblock {
  position: relative;
  margin: 16px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--code-bg);
}
.doc__body .codeblock__label {
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}
.doc__body .codeblock pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
}
.doc__body .codeblock code {
  font: inherit;
}
.doc__body .codeblock .s {
  color: #0a7c55;
}
.doc__body .codeblock .k {
  color: var(--accent);
}
.doc__body .codeblock .d {
  color: var(--muted);
}
.codeblock__copy {
  top: 4px;
  right: 6px;
  height: 26px !important;
  opacity: 0;
  transition: opacity 120ms ease;
}
.codeblock:hover .codeblock__copy,
.codeblock__copy:focus-visible {
  opacity: 1;
}
/* Touch screens have no hover: the button is always there. */
@media (hover: none) {
  .codeblock__copy {
    opacity: 1;
  }
}
.doc__body .kv {
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.doc__body .kv__row {
  display: grid;
  grid-template-columns: minmax(0, 200px) minmax(0, 1fr);
  gap: 16px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.55;
}
.doc__body .kv__row + .kv__row {
  border-top: 1px solid var(--line);
}
.doc__body .kv dt {
  color: var(--text);
  font-weight: 500;
}
.doc__body .kv dd {
  margin: 0;
}
.doc__body .table-wrap {
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.doc__body .table {
  font-size: 13.5px;
}
.doc__body .table th {
  border-top: 0;
}
.doc__body .table td {
  white-space: normal;
  line-height: 1.5;
}
.doc__body .method {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
}
.doc__body .method--post {
  background: var(--accent-soft);
  color: var(--accent);
}
.doc__body .method--get {
  background: color-mix(in srgb, var(--success) 14%, transparent);
  color: var(--success);
}
.doc__body .doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 16px 0 0;
}
.doc__body .tag,
.doc__body .badge-cost {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 11.5px;
}
.doc__body .badge-cost {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
}
.doc__body .params {
  margin: 12px 0;
  border-top: 1px solid var(--line);
}
.doc__body .param {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 72px;
}
.doc__body .param__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  color: var(--muted);
  font-size: 12.5px;
}
.doc__body .param__name {
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
}
.doc__body .param__meta {
  color: var(--muted);
  font-size: 12px;
}
.doc__body .param p {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.6;
}
.doc__body .param__enum {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.doc__body details.param__enum {
  display: block;
}
.doc__body details.param__enum summary {
  margin-bottom: 6px;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
}
.doc__body .param__enum code {
  display: inline-block;
  margin: 0 4px 4px 0;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11.5px;
}
.doc__body .params--compact .param {
  padding: 10px 0;
}
.doc__body .search-card__rows--flat {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.doc__body .result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}
.doc__body .result__who {
  display: flex;
  flex-direction: column;
  line-height: 1.4;
}
.doc__body .result__name {
  color: var(--text);
  font-weight: 500;
}
.doc__body .result__sub {
  color: var(--muted);
  font-size: 13px;
}
.doc__body .result__score {
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--success) 14%, transparent);
  color: var(--success);
  font-family: var(--mono);
  font-size: 12px;
}
.doc__body .muted {
  color: var(--muted);
}
.pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 48px;
}
.doc__body .pager a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  transition: border-color 120ms ease, background-color 120ms ease;
}
.doc__body .pager a:last-child {
  text-align: right;
}
.doc__body .pager a:hover {
  border-color: var(--line-strong);
  background: var(--hover);
}
.pager small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}
.doc__toc {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  align-self: start;
  gap: 2px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}
.doc__toc-title {
  margin-bottom: 6px;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
}
.doc__toc a {
  padding: 3px 0;
  color: var(--muted);
  font-size: 13px;
  transition: color 100ms ease;
}
.doc__toc a:hover,
.doc__toc a.is-active {
  color: var(--text);
}
.doc__toc a.is-active {
  font-weight: 500;
}

/* ---------- Sign up / Log in ---------- */
/* Sign up, Log in and Connect an app fit the window. Scrolling past an edge (macOS trackpad) must not pull the page
   away: it cut off the logo and heading and showed a bare strip below the panel. */
.auth-page {
  overscroll-behavior: none;
}
.auth {
  display: grid;
  grid-template-columns: minmax(0, 620px) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
}
.auth__panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px 48px;
  background: url("../assets/hero-grain-1x.webp") center / cover, #50288c;
  color: #fff;
}
.auth__panel .logo {
  align-self: flex-start;
  color: #fff;
}
.auth__quote {
  max-width: 480px;
  font-family: var(--ds-font-serif);
  font-size: 40px;
  line-height: 1.15;
  letter-spacing: -0.05em;
}
.auth__main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px));
}
.auth__form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(380px, 100%);
}
.auth__form h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.04em;
}
.auth__form a:not(.btn) {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.auth__oauth {
  width: 100%;
  gap: 10px;
}
.auth__or {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}
.auth__or::before,
.auth__or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.auth__status {
  font-size: 14px;
}
.auth__status:empty {
  display: none;
}
.auth__status.is-error {
  color: var(--danger);
}

/* ---------- Consent: an app asks to connect ---------- */
.consent.is-loading [data-consent-title] {
  color: var(--muted);
}
.consent__body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.consent__return {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.consent__host {
  font-family: var(--mono);
  font-size: 15px;
  overflow-wrap: anywhere;
}
.consent__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.consent__who {
  overflow-wrap: anywhere;
}
.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* A key row that is an app signed in with OAuth (claude.ai, ChatGPT): no key to show. */
.app-chip {
  display: inline-block;
  padding: 3px 6px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  white-space: nowrap;
}

/* ---------- Motion ---------- */
@keyframes pulse {
  50% {
    opacity: 0.5;
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}
@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
}
@keyframes slide-in {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* ---------- Responsive ---------- */
/* Tables as one card per row, each value under its label: keys on phones, usage below 1400 px. */
.table td[data-label]::before {
  display: none;
}
@media (max-width: 1399px) {
  .table.table--usage thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .table.table--usage tr {
    display: grid;
    grid-template-columns: 1.3fr 1.6fr 1.6fr 0.7fr 0.8fr 0.8fr 1.3fr;
    gap: 10px 20px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
  }
  .table.table--usage tbody tr:first-child {
    border-top: 0;
  }
  .table.table--usage td {
    min-width: 0;
    max-width: none;
    padding: 0;
    border: 0;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .table.table--usage td.brief {
    grid-column: 1 / -1;
    order: -1;
    color: var(--text);
    font-weight: 500;
  }
  .table.table--usage td.list__empty,
  .table.table--usage .skeleton-row td {
    grid-column: 1 / -1;
  }
  .table.table--usage td[data-label]::before,
  .table.table--keys td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 500;
  }
  .table.table--usage td.brief::before {
    display: none;
  }
  .table.table--usage tr.call-detail-row {
    display: block;
    padding: 0 20px 14px;
    border-top: 0;
  }
  .table.table--usage tr.call-detail-row td {
    display: block;
    overflow: visible;
    white-space: normal;
  }
  .call-detail {
    flex-direction: column;
    gap: 12px;
    padding: 12px 0 0;
    border-top: 1px dashed var(--line-strong);
  }
}
@media (max-width: 1399px) and (min-width: 641px) {
  .table.table--keys td[data-label]::before {
    display: none;
  }
}
@media (max-width: 1100px) {
  .grid-2--wide {
    grid-template-columns: minmax(0, 1fr);
  }
  .doc {
    grid-template-columns: minmax(0, 1fr);
  }
  .doc__toc {
    display: none;
  }
}
@media (max-width: 900px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }
  /* The sidebar becomes a drawer, opened from the menu button in the top bar. */
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 86vw);
    transform: translateX(-100%);
    visibility: hidden;
    box-shadow: var(--shadow-l);
    transition: transform 200ms ease, visibility 0s linear 200ms;
  }
  .nav-open .sidebar {
    transform: none;
    visibility: visible;
    transition: transform 200ms ease;
  }
  .sidebar__close {
    display: inline-grid;
  }
  .scrim {
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgba(0, 0, 0, 0.4);
    animation: fade-in 160ms ease-out;
  }
  .topbar {
    display: flex;
    padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
  }
  .topbar__menu {
    display: inline-grid;
  }
  .main {
    gap: 20px;
    padding: 24px max(16px, env(safe-area-inset-right, 0px)) 56px max(16px, env(safe-area-inset-left, 0px));
  }
  .auth {
    grid-template-columns: minmax(0, 1fr);
  }
  .auth__panel {
    min-height: 220px;
    padding: 24px 16px;
  }
  .auth__quote {
    font-size: 26px;
  }
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 640px) {
  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .page-head h1 {
    font-size: 24px;
  }
  .tiles {
    grid-template-columns: minmax(0, 1fr);
  }
  .cap-form__row {
    flex-direction: column;
  }
  .secret {
    flex-direction: column;
    align-items: stretch;
  }
  .doc__body h1 {
    font-size: 26px;
  }
  .doc__body .kv__row {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }
  .table.table--usage tr {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px 12px;
    padding: 14px 16px;
  }
  .table.table--usage td.brief {
    white-space: normal;
  }
  /* The card already shows the whole brief at this width. */
  .call-detail__brief {
    display: none;
  }
  .table.table--usage code {
    overflow-wrap: anywhere;
    white-space: normal;
  }
  /* Brief, then time and status, tool, key, then the numbers. */
  .table.table--usage td[data-label="Time"] {
    grid-column: span 3;
    order: 0;
  }
  .table.table--usage td[data-label="Status"] {
    grid-column: span 3;
    order: 1;
  }
  .table.table--usage td[data-label="Tool"] {
    grid-column: 1 / -1;
    order: 2;
  }
  .table.table--usage td[data-label="Key"] {
    grid-column: 1 / -1;
    order: 3;
  }
  .table.table--usage td.num {
    grid-column: span 2;
    order: 4;
  }
  .table.table--keys thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .table.table--keys tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 12px;
    padding: 14px 16px;
    border-top: 1px solid var(--line);
  }
  .table.table--keys tbody tr:first-child {
    border-top: 0;
  }
  .table.table--keys td[data-label="Key"] {
    grid-column: 1 / -1;
  }
  .table.table--keys td {
    padding: 0;
    border: 0;
    white-space: normal;
  }
  .table.table--keys .cell-name,
  .table.table--keys .actions,
  .table.table--keys .list__empty,
  .table.table--keys .skeleton-row td {
    grid-column: 1 / -1;
  }
  .table.table--keys tr {
    position: relative;
  }
  .table.table--keys .actions {
    position: absolute;
    top: 10px;
    right: 10px;
  }
  .table.table--keys .cell-name {
    padding-right: 40px;
  }
  /* Filters: period and tool side by side, key below, then the total. */
  .filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .filters select,
  .filters .select,
  .filters .select__btn {
    width: 100%;
    max-width: none;
    min-width: 0;
  }
  .filters [data-filter="key"],
  .filters .select:has([data-filter="key"]) {
    grid-column: 1 / -1;
  }
  .filters__summary {
    grid-column: 1 / -1;
    text-align: left;
  }
}

@media (max-width: 1100px) {
  .connect {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 640px) {
  .agent-row__main {
    padding-left: 16px;
  }
  .agent-row__setup {
    padding-left: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
