.workspace-shell {
  --workspace-nav: 224px;
  --workspace-bar: 0px;
  --workspace-gutter: clamp(18px, 3vw, 40px);
  --workspace-page-top: clamp(16px, 1.75vw, 24px);
  display: grid;
  grid-template-columns: var(--workspace-nav) minmax(0, 1fr);
  min-height: 100svh;
  background: var(--canvas);
}
.workspace-shell .workspace-sidebar {
  position: sticky;
  inset-block-start: 0;
  align-self: start;
  display: flex;
  gap: 20px;
  flex-direction: column;
  min-height: 100svh;
  max-height: 100dvh;
  overflow: auto;
  padding: 14px 15px;
  border: 0;
  border-inline-end: 1px solid var(--line);
  border-radius: 0;
  background: var(--subtle);
}
.workspace-mark, .workspace-mobile-mark {
  display: flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  color: var(--ink);
  font-size: 18px;
  font-weight: 740;
  letter-spacing: -.045em;
}
.workspace-mark { min-height: 42px; padding-inline: 3px; }
.workspace-mark small, .workspace-mobile-mark small {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .01em;
}
.workspace-sidebar nav {
  display: grid;
  gap: 3px;
  overflow: visible;
  padding: 0;
}
.workspace-sidebar nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 540;
}
.workspace-sidebar nav a:hover { background: var(--raised); color: var(--ink); }
.workspace-sidebar nav a[aria-current="page"] {
  background: var(--selected);
  border-color: transparent;
  color: var(--on-selected);
  font-weight: 650;
}
.workspace-sidebar nav a[aria-current="page"]::before {
  content: "";
  position: absolute;
  inset: 10px auto 10px -1px;
  width: 2px;
  border-radius: 2px;
  background: currentColor;
}
.workspace-nav-section { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.workspace-nav-section .workspace-external { width: 13px; height: 13px; margin-inline-start: auto; }
.workspace-sidebar .workspace-nav-count {
  display: inline-flex; align-items: center; gap: 2px; margin-inline-start: auto; padding: 2px 6px;
  border-radius: 5px; background: var(--subtle); color: var(--muted);
  font-size: 11px; font-weight: 660; font-variant-numeric: tabular-nums; line-height: 1.35; white-space: nowrap;
}
.workspace-count-positive { color: var(--mint); }
.workspace-count-negative { color: var(--error); }
.workspace-count-divider { color: var(--quiet); }
.workspace-footer { display: grid; gap: 12px; margin-top: auto; }
.workspace-sidebar nav svg, .workspace-header svg {
  flex: none;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}
.workspace-profile {
  display: grid;
  align-items: center;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 8px;
  padding: 12px 0 2px 5px;
  border-block-start: 1px solid var(--line);
}
.workspace-profile strong, .workspace-profile small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.workspace-profile strong { font-size: 13px; }
.workspace-profile small { color: var(--muted); font-size: 11px; }
.workspace-profile button {
  margin: 0;
  align-self: center;
}
.workspace-shell .workspace-icon-button,
.workspace-shell .workspace-profile .workspace-icon-button {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}
.workspace-shell .workspace-icon-button:hover {
  background: var(--subtle);
  border-color: var(--outline);
  color: var(--ink);
}
.workspace-icon-button svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.workspace-shell .workspace-menu-toggle, .workspace-mobile-mark, .workspace-menu-backdrop { display: none; }
.workspace-body { min-width: 0; min-height: 100svh; padding: 0; }
.workspace-header { display: none; }
.workspace-shell[data-loading] .workspace-body::after {
  position: fixed;
  z-index: 6;
  inset: var(--workspace-bar) 0 auto var(--workspace-nav);
  height: 2px;
  content: "";
  background: linear-gradient(90deg, transparent 16%, var(--accent) 49%, transparent 82%) left / 50% 100% no-repeat;
  animation: workspace-loading 1s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes workspace-loading { to { background-position: right; } }
.workspace-page {
  width: min(100%, 1440px);
  min-height: calc(100svh - var(--workspace-bar));
  margin: 0 auto;
  padding: var(--workspace-page-top) var(--workspace-gutter) 40px;
}
.workspace-panel { min-height: 310px; }
.workspace-page .page-heading, .workspace-page .panel-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px 20px;
  margin: 0 0 clamp(16px, 2vw, 26px);
}
.workspace-page .page-heading h1, .workspace-page .panel-heading h1 {
  font-size: clamp(28px, 3.5vw, 38px);
  font-weight: 710;
  letter-spacing: -.04em;
  line-height: 1.16;
}
.workspace-page .page-heading p, .workspace-page .panel-heading p { margin-top: 6px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.workspace-page .panel, .workspace-page .guide, .workspace-page .table-wrap { border-radius: 10px; }
.workspace-page .empty { padding: 30px 18px; }
.workspace-page .referral-masked { color: var(--muted); }
.workspace-loading-state {
  color: var(--muted);
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}
.workspace-page .heading-actions:empty { display: none; }
.workspace-page .button, .workspace-page button.primary {
  min-height: 38px;
  border-radius: 7px;
}
.workspace-page button.primary, .workspace-page .button.dark {
  box-shadow: 0 1px 2px #1017311f;
}
.workspace-page .button.dark:hover, .workspace-page button.primary:hover { filter: brightness(1.08); }
.connection-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.connection-surface {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.connection-surface h2 { font-size: 16px; font-weight: 680; }
.connection-surface > p { margin-top: 5px; color: var(--muted); }
.connection-surface .base-url-block, .connection-surface > .copy-block { margin-top: 14px; }
.connection-link { display: inline-flex; margin-top: 13px; font-size: 13px; font-weight: 620; }
.connection-builder { margin-top: 14px; }
.connection-builder .request-fields { grid-template-columns: minmax(0, 400px); }
.connection-builder .model-status:empty { display: none; }
.connection-builder .copy-block pre { max-height: 24rem; overflow: auto; white-space: pre; }
.credential-panel { container: credentials / inline-size; }
.credential-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 14px;
}
.credential-toolbar p, .credential-label { color: var(--muted); font-size: 12px; }
.credential-toolbar .table-tools { padding: 0; margin: 0; border: 0; background: transparent; }
.credential-panel table { table-layout: fixed; white-space: normal; }
.credential-panel th:first-child { width: 17%; }
.credential-panel th:nth-child(2) { width: 16%; }
.credential-panel th:last-child { width: 88px; }
.credential-panel td { overflow-wrap: anywhere; }
.credential-name strong, .credential-name code, .credential-label { display: block; }
.credential-name code { color: var(--muted); font-size: 11px; }
.credential-label { display: none; }
.credential-action { text-align: right; }
.credential-requests strong, .credential-tokens strong { font-variant-numeric: tabular-nums; font-weight: 650; }
.credential-action button { color: var(--error); }
@container credentials (max-width: 810px) {
  .credential-panel table, .credential-panel tbody { display: block; }
  .credential-panel thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .credential-panel tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas: "name status" "client client" "requests tokens" "expiry used" "action action";
    align-items: start;
    gap: 9px 12px;
    padding: 12px 14px;
    border-top: 1px solid var(--line);
  }
  .credential-panel td { padding: 0; border: 0; }
  .credential-label { display: block; }
  .credential-name { grid-area: name; }
  .credential-client { grid-area: client; }
  .credential-state { grid-area: status; text-align: right; }
  .credential-requests { grid-area: requests; }
  .credential-tokens { grid-area: tokens; }
  .credential-expiry { grid-area: expiry; }
  .credential-used { grid-area: used; }
  .credential-action { grid-area: action; justify-self: end; }
  .credential-action:empty { display: none; }
}
@media (max-width: 760px) {
  .workspace-shell {
    --workspace-bar: 56px;
    --workspace-nav: 0px;
    --workspace-gutter: clamp(16px, 5vw, 24px);
    grid-template-columns: minmax(0, 1fr);
  }
  .workspace-shell .workspace-sidebar {
    position: fixed;
    z-index: 8;
    top: var(--workspace-bar);
    left: 0;
    width: min(272px, calc(100vw - 44px));
    min-height: calc(100svh - var(--workspace-bar));
    max-height: calc(100dvh - var(--workspace-bar));
    padding-top: 14px;
    display: none;
  }
  .workspace-shell.menu-open .workspace-sidebar { display: flex; }
  .workspace-shell.menu-open .workspace-header { z-index: 9; }
  .workspace-shell.menu-open .workspace-menu-backdrop {
    display: block;
    position: fixed;
    z-index: 7;
    inset: var(--workspace-bar) 0 0;
    background: #0b122953;
  }
  .workspace-shell .workspace-menu-toggle { display: inline-grid; }
  .workspace-mobile-mark { display: flex; font-size: 16px; }
  .workspace-header {
    position: sticky;
    z-index: 5;
    top: 0;
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: var(--workspace-bar);
    padding: 8px var(--workspace-gutter);
    border-bottom: 1px solid var(--line);
    background: var(--canvas);
  }
  .workspace-page { padding-top: 16px; }
  .connection-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .workspace-shell[data-loading] .workspace-body::after { animation: none; background-size: 100%; }
}

.workspace-theme-choices {
  --theme-position: 2;
  flex: none;
  min-inline-size: 0;
  margin: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--canvas);
}
:root[data-theme-mode="light"] .workspace-theme-choices { --theme-position: 0; }
:root[data-theme-mode="dark"] .workspace-theme-choices { --theme-position: 1; }
.workspace-theme-track {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(var(--theme-segments, 3), minmax(0, 1fr));
}
.workspace-theme-track::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 auto 0 0;
  width: calc(100% / var(--theme-segments, 3));
  border-radius: 8px;
  background: var(--selected);
  transform: translateX(calc(var(--theme-position) * 100%));
  transition: transform 200ms cubic-bezier(.22, .8, .28, 1);
}
.workspace-theme-choices label { display: block; margin: 0; padding: 0; cursor: pointer; }
.workspace-theme-segment {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 30px;
  padding-inline: 8px;
  border-radius: 7px;
  color: var(--muted);
  font: 620 12px/1 var(--sans);
}
.workspace-theme-choices label:hover .workspace-theme-segment { color: var(--ink); }
.workspace-theme-choices input:checked + .workspace-theme-segment { color: var(--on-selected); }
.workspace-theme-choices input:focus-visible + .workspace-theme-segment::after {
  content: "";
  position: absolute;
  inset: auto 0 3px;
  width: 12px;
  height: 2px;
  margin-inline: auto;
  border-radius: 2px;
  background: currentColor;
}
.workspace-theme-choices svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@media (max-width: 520px) {
  .workspace-theme-segment { min-width: 34px; min-height: 34px; padding-inline: 5px; }
  .sign-in-tools .workspace-theme-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
@media (prefers-reduced-motion: reduce) {
  .workspace-theme-track::before { transition: none; }
}

.workspace-footer .workspace-theme-segment {
  flex-direction: column;
  gap: 4px;
  min-height: 42px;
  padding-inline: 2px;
  font-size: 11px;
}

/* Overview geometry for the console and administration workspace. */
.workspace-overview {
  --overview-pad: clamp(14px, 1.8vw, 21px);
  --plot-height: clamp(132px, 12vw, 170px);
  display: grid;
  gap: 16px;
}
.workspace-overview :is(.overview-metrics, .overview-columns) { display: grid; gap: 16px; }
.workspace-overview .overview-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.workspace-overview .overview-columns { grid-template-columns: minmax(0, 1.95fr) minmax(265px, 1fr); }
.workspace-overview :is(.overview-metric, .overview-panel, .panel) {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background-color: var(--surface);
}
.workspace-overview .overview-metric {
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 15px var(--overview-pad);
  background-image: linear-gradient(140deg, color-mix(in srgb, var(--overview-color) 8%, var(--surface)), var(--surface) 80%);
}
.workspace-overview a.overview-metric:hover { border-color: var(--overview-color); }
.overview-metric-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 620; }
.overview-metric-label::before { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--overview-color); content: ""; }
.overview-metric-label .overview-row-arrow { margin-inline-start: auto; }
.overview-spark { display: flex; flex: 0 1 88px; align-items: end; justify-content: end; gap: 2px; height: 24px; margin-bottom: 3px; }
.overview-spark i { flex: 1; max-width: 8px; height: max(2px, var(--height)); border-radius: 2px; background: color-mix(in srgb, var(--overview-color) 68%, var(--surface)); }
.workspace-overview .overview-metric-value { display: flex; justify-content: space-between; align-items: end; gap: 10px; }
.workspace-overview .overview-metric-value strong {
  font-size: clamp(23px, 3.1vw, 36px);
  font-weight: 710;
  line-height: 1.18;
  letter-spacing: -.05em;
  font-variant-numeric: tabular-nums;
}
.workspace-overview .overview-metric > p { margin: 0; color: var(--muted); font-size: 12px; }
.workspace-overview :is(.overview-panel-heading, .panel-header) h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 680;
  line-height: 1.3;
  letter-spacing: -.024em;
}
@media (max-width: 1020px) {
  .workspace-overview .overview-columns { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .workspace-overview { --plot-height: 133px; }
  .workspace-overview .overview-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .workspace-overview .overview-metric:first-child { grid-column: 1 / -1; }
}

/* Usage period control and date picker shared by the workspaces. */
.usage-period { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; max-width: 100%; }
.usage-period-edit { padding: 0; border: 0; background: none; color: var(--accent); font-size: 12px; font-weight: 630; }
.usage-period-edit:hover { text-decoration: underline; }
#usage-date-dialog { width: min(465px, calc(100% - 28px)); padding: clamp(16px, 5vw, 23px); border-radius: 14px; }
#usage-date-dialog h2 { margin: 0 0 6px; font-size: 22px; font-weight: 650; }
#usage-date-dialog > form > p:first-of-type { color: var(--muted); }
#usage-date-dialog [role="alert"] {
  padding: 10px 12px; margin: 12px 0 0; border-radius: 6px; color: var(--warn); background: var(--warn-bg);
}
.usage-date-fields { display: grid; gap: 12px; margin-top: 14px; }
.usage-date-fields label { display: block; margin: 0 0 4px; font-size: 13px; font-weight: 620; }
.usage-date-fields input {
  width: 100%; min-height: 40px; padding: 8px 40px 8px 12px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
}
.usage-date-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 10px; margin-top: 15px; }
.usage-date-actions button { padding: 9px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--raised); }
.usage-date-actions button:hover { border-color: var(--accent); }
.usage-date-actions .primary { background: var(--action); color: var(--on-action); font-weight: 680; }
.key-expiration-date { position: relative; min-width: 0; }
:is(#key-dialog, #usage-date-dialog, .issue-key-dialog) .key-expiration-date button {
  position: absolute; inset: 1px 1px 1px auto; display: grid; place-items: center;
  width: 34px; min-height: 0; padding: 0; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted);
}
:is(#key-dialog, #usage-date-dialog, .issue-key-dialog) .key-expiration-date button:hover, :is(#key-dialog, #usage-date-dialog, .issue-key-dialog) .key-expiration-date button[aria-expanded="true"] {
  color: var(--accent); background: var(--selected);
}
.key-expiration-date button span {
  display: block; position: relative; width: 14px; height: 13px; border: 1.5px solid currentColor; border-radius: 3px;
}
.key-expiration-date button span::before {
  content: ''; position: absolute; inset: 3px 0 auto; border-top: 1.5px solid currentColor;
}
.key-expiration-date button span::after {
  content: ''; position: absolute; inset: -3px 2px auto; height: 3px;
  border-inline: 1.5px solid currentColor;
}
.key-calendar {
  position: fixed; inset: auto; width: 310px; margin: 0; padding: 8px; overflow: auto;
  color: var(--ink); background: var(--surface); border: 1px solid var(--outline); border-radius: 10px;
  box-shadow: 0 12px 30px #080d2655;
}
.key-calendar-header { display: grid; grid-template-columns: 34px 1fr 34px; align-items: center; text-align: center; }
.key-calendar-header strong { font-size: 13px; font-weight: 650; }
.key-calendar-week, .key-calendar-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; text-align: center; }
.key-calendar-week { padding-block: 7px 3px; color: var(--muted); font-size: 11px; font-weight: 600; }
:is(#key-dialog, #usage-date-dialog, .issue-key-dialog) .key-calendar button {
  min-width: 0; min-height: 33px; padding: 0; text-align: center;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
}
:is(#key-dialog, #usage-date-dialog, .issue-key-dialog) .key-calendar-header button { font-size: 21px; line-height: 1; }
:is(#key-dialog, #usage-date-dialog, .issue-key-dialog) .key-calendar-days button { font-size: 12px; font-variant-numeric: tabular-nums; }
:is(#key-dialog, #usage-date-dialog, .issue-key-dialog) .key-calendar button:disabled { color: var(--quiet); }
:is(#key-dialog, #usage-date-dialog, .issue-key-dialog) .key-calendar button:hover:enabled { border-color: var(--outline); background: var(--raised); }
:is(#key-dialog, #usage-date-dialog, .issue-key-dialog) .key-calendar-days [aria-current="date"] { color: var(--accent); border-color: var(--outline); font-weight: 650; }
:is(#key-dialog, #usage-date-dialog, .issue-key-dialog) .key-calendar-days [aria-pressed="true"] { background: var(--action); color: var(--on-action); font-weight: 650; }
:is(#key-dialog, #usage-date-dialog, .issue-key-dialog) .key-calendar-days [aria-pressed="true"]:hover:enabled { background: var(--action); }
@media (max-width: 390px) {
  :is(#key-dialog, #usage-date-dialog, .issue-key-dialog) .key-expiration-date button { width: 26px; }
  :is(#key-dialog, #usage-date-dialog, .issue-key-dialog) .key-calendar button { min-height: 28px; }
}
