:root {
  color-scheme: light;
  --paper: #faf9f6;
  --surface: #fff;
  --ink: #262c27;
  --muted: #596359;
  --line: #d9ded4;
  --green: #345c41;
  --green-dark: #264832;
  --soft: #eaf0e7;
  --danger: #943b30;
  --warning: #795310;
  --radius: 8px;
  font-family:
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}
button,
input,
select {
  font: inherit;
}
button,
a,
input,
select {
  touch-action: manipulation;
}
a {
  color: var(--green);
  text-underline-offset: 4px;
}
button {
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--green);
  color: white;
  padding: 10px 16px;
  font-weight: 600;
  min-height: 44px;
}
button:hover {
  background: var(--green-dark);
}
button:disabled {
  cursor: wait;
  opacity: 0.55;
}
.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.secondary:hover {
  background: var(--soft);
}
.text-button {
  background: transparent;
  color: var(--muted);
  padding: 8px 0;
  text-align: left;
}
.text-button:hover {
  background: transparent;
  color: var(--green);
}
.danger {
  color: var(--danger);
}
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
pre:focus-visible {
  outline: 3px solid #779b6d;
  outline-offset: 3px;
}
input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #9fa99e;
  border-radius: 5px;
  background: white;
  color: var(--ink);
  padding: 9px 11px;
}
input::placeholder {
  color: #626d64;
}
label {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 2.4rem;
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1.18;
  text-wrap: balance;
}
h2 {
  font-size: 1.16rem;
  letter-spacing: -0.015em;
  font-weight: 650;
}
h3 {
  font-size: 1.05rem;
}
p {
  max-width: 75ch;
}
.helper,
.footnote {
  font-size: 0.87rem;
  color: var(--muted);
  line-height: 1.6;
}
.helper {
  margin-top: 12px;
}
.app-shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: 100dvh;
}
.sidebar {
  padding: 38px 24px 28px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  background: #f1f3ed;
}
.wordmark {
  color: var(--ink);
  text-decoration: none;
  font-size: 1.06rem;
  font-weight: 720;
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}
.mark {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--green);
  border-radius: 3px;
  transform: rotate(45deg);
}
nav {
  display: grid;
  gap: 8px;
  margin-top: 52px;
}
nav a {
  padding: 12px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 550;
}
nav a:hover {
  background: #e6ebe1;
}
nav a[aria-current="page"] {
  background: #dce7d6;
  color: #264c30;
}
.sidebar-bottom {
  margin-top: auto;
  padding-top: 100px;
  font-size: 0.82rem;
  color: var(--muted);
}
.sidebar-bottom p {
  display: flex;
  align-items: center;
  gap: 7px;
}
.status-dot {
  width: 7px;
  height: 7px;
  background: var(--muted);
  border-radius: 50%;
  flex-shrink: 0;
}
.connected .status-dot {
  background: var(--green);
}
main {
  padding: 52px 42px 24px;
  min-width: 0;
  max-width: 1640px;
  width: 100%;
  margin: 0 auto;
}
.page {
  min-height: calc(100dvh - 160px);
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 36px;
}
.page-header p {
  margin-top: 12px;
  color: var(--muted);
}
.page-header button {
  flex-shrink: 0;
}
.filter-bar {
  display: flex;
  align-items: end;
  gap: 16px;
  flex-wrap: wrap;
  padding: 24px 0;
  border-block: 1px solid var(--line);
  margin-bottom: 36px;
}
.filter-bar label {
  min-width: 145px;
}
.report-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  margin: 0 0 16px;
}
.report-heading p {
  font-size: 0.87rem;
  color: var(--muted);
}
.table-wrap {
  overflow: auto;
  border-block: 1px solid var(--line);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
th,
td {
  text-align: right;
  padding: 16px 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
th:first-child,
td:first-child {
  text-align: left;
  padding-left: 0;
}
th:last-child,
td:last-child {
  padding-right: 0;
}
th {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}
td {
  border-top: 1px solid var(--line);
}
td:first-child {
  font-weight: 600;
}
.usage-table tbody tr:hover {
  background: #f0f3eb;
}
.usage-table td:nth-child(6) {
  font-weight: 700;
  color: var(--green);
}
.status {
  font-size: 0.76rem;
  display: inline-block;
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--soft);
  color: var(--green);
}
.status.warning {
  background: #f6edd9;
  color: var(--warning);
}
.status.revoked {
  background: #f2e6e3;
  color: var(--danger);
}
.status-detail {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}
.report-notes {
  display: grid;
  gap: 7px;
  margin-top: 20px;
  font-size: 0.82rem;
  color: var(--muted);
}
.empty-state {
  padding: 50px 20px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}
.empty-state p {
  margin: 10px auto 16px;
  color: var(--muted);
  max-width: 48ch;
}
.setup-forms {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 36px;
  margin-bottom: 46px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--line);
}
.setup-forms form + form {
  padding-left: 36px;
  border-left: 1px solid var(--line);
}
form h2 {
  margin-bottom: 18px;
}
.input-action {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.input-action button {
  white-space: nowrap;
}
.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}
.form-row label {
  flex: 1;
  min-width: 0;
}
.friend {
  padding: 22px 0;
  border-top: 1px solid var(--line);
}
.friend-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.friend-heading .text-button {
  font-size: 0.84rem;
}
.key-row {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) minmax(100px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}
.friend-heading + .key-row {
  margin-top: 14px;
}
.key-row strong {
  display: block;
  font-size: 0.95rem;
}
.key-row code {
  color: var(--muted);
  font-size: 0.8rem;
}
.key-meta {
  font-size: 0.82rem;
  color: var(--muted);
}
.key-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.key-actions button {
  font-size: 0.8rem;
  padding: 7px 10px;
}
.grant-form {
  background: var(--soft);
  padding: 20px;
  margin-bottom: 16px;
  border-radius: var(--radius);
}
.grant-options {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  margin-bottom: 18px;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}
.check-label input {
  min-height: 20px;
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}
.connection-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  border-block: 1px solid var(--line);
  padding: 28px 0;
}
.connection-panel p {
  margin-top: 6px;
  color: var(--muted);
}
.oauth-flow {
  padding: 28px 0;
  border-bottom: 1px solid var(--line);
  max-width: 760px;
}
.oauth-flow p {
  margin-bottom: 18px;
  color: var(--muted);
}
.oauth-flow button {
  margin-top: 16px;
}
.model-heading {
  margin-top: 40px;
  align-items: center;
}
.model-heading p {
  margin-top: 8px;
}
.model-list {
  border-top: 1px solid var(--line);
}
.model-row {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.model-row code {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
  overflow-wrap: anywhere;
}
.model-row button {
  font-size: 0.85rem;
  flex-shrink: 0;
}
.notice {
  padding: 14px 18px;
  background: var(--soft);
  border-radius: 6px;
  margin-bottom: 24px;
  color: var(--green);
}
.notice.error,
.error {
  color: var(--danger);
}
.notice.error {
  background: #f5e8e4;
}
.error {
  font-size: 0.9rem;
  min-height: 1.5em;
}
footer {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 48px;
  color: var(--muted);
  font-size: 0.77rem;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  width: min(760px, calc(100vw - 32px));
  color: var(--ink);
  background: var(--paper);
}
dialog::backdrop {
  background: #1e2c2566;
}
.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 18px;
}
dialog p {
  color: var(--muted);
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #edf0e8;
  padding: 20px;
  border-radius: 6px;
  font-size: 0.85rem;
  max-height: 50vh;
  overflow: auto;
}
#copy-status {
  font-size: 0.85rem;
  margin-top: 10px;
}
.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  background: #f1f3ed;
}
.login-shell {
  max-width: 550px;
  padding: 60px 36px;
}
.login-shell .wordmark {
  margin-bottom: 64px;
}
.login-shell h1 {
  font-size: 2.7rem;
}
.lede {
  margin-top: 20px;
  color: var(--muted);
  font-size: 1.05rem;
}
.login-form {
  display: grid;
  gap: 12px;
  margin: 36px 0 24px;
}
.login-form button {
  margin-top: 8px;
}
.skip-link {
  position: fixed;
  top: -60px;
  left: 16px;
  padding: 12px;
  background: white;
  z-index: 10;
}
.skip-link:focus {
  top: 16px;
}
[hidden] {
  display: none !important;
}
@media (prefers-reduced-motion: no-preference) {
  .notice {
    animation: notice-in 0.2s ease-out;
  }
  @keyframes notice-in {
    from {
      clip-path: inset(0 0 90% 0);
    }
    to {
      clip-path: inset(0);
    }
  }
}
@media (min-width: 1500px) {
  main {
    padding-inline: 64px;
  }
}
@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 200px minmax(0, 1fr);
  }
  .sidebar {
    padding-inline: 18px;
  }
  main {
    padding: 36px 24px;
  }
  .setup-forms {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .setup-forms form + form {
    padding-left: 0;
    border-left: 0;
  }
  .key-row {
    grid-template-columns: 1fr 1fr;
  }
  .key-actions {
    grid-column: 1/-1;
  }
}
@media (max-width: 700px) {
  .app-shell {
    display: block;
  }
  .sidebar {
    padding: 20px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  nav {
    display: flex;
    gap: 4px;
    margin-top: 20px;
    overflow: auto;
  }
  nav a {
    white-space: nowrap;
    padding: 9px;
    font-size: 0.85rem;
  }
  .sidebar-bottom {
    padding-top: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .sidebar-bottom .text-button {
    min-height: 36px;
  }
  main {
    padding: 30px 20px 20px;
  }
  .page-header {
    display: block;
    margin-bottom: 24px;
  }
  .page-header button {
    margin-top: 20px;
  }
  h1 {
    font-size: 2rem;
  }
  .filter-bar {
    gap: 12px;
  }
  .filter-bar label {
    flex: 1;
    min-width: 130px;
  }
  .report-heading {
    align-items: start;
    flex-direction: column;
    gap: 8px;
  }
  .connection-panel {
    align-items: start;
    flex-direction: column;
  }
  .model-row {
    gap: 10px;
  }
  .model-row strong {
    font-size: 0.9rem;
  }
  .model-row code {
    font-size: 0.7rem;
  }
  .model-row button {
    padding: 8px;
  }
  .model-heading {
    gap: 16px;
  }
  .key-row {
    gap: 10px;
  }
  .form-row {
    flex-direction: column;
  }
  .input-action {
    flex-wrap: wrap;
  }
  .input-action input {
    flex: 1;
    min-width: 130px;
  }
  .page {
    min-height: 50dvh;
  }
  footer {
    gap: 16px;
    font-size: 0.72rem;
  }
  .login-shell {
    padding: 32px 24px;
  }
  .login-shell .wordmark {
    margin-bottom: 44px;
  }
  .login-shell h1 {
    font-size: 2.35rem;
  }
  dialog {
    padding: 20px;
  }
}

/* Usage analytics extends the existing paper, green and ruled-ledger system. */
.scope-heading { margin-top: 28px; }
.scope-heading p { overflow-wrap: anywhere; }
.date-presets { display: flex; gap: 20px; }
.filter-bar select { max-width: 260px; }
.usage-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 24px 0 0; border-block: 1px solid var(--line); }
.usage-summary > div { padding: 18px 16px 18px 0; }
.usage-summary dt { font-size: .85rem; color: var(--muted); }
.usage-summary dd { margin: 6px 0 0; font-size: 1.7rem; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.trend-section { margin: 40px 0; }
.trend-section .report-heading p { margin-top: 6px; }
.time-chart svg { display: block; width: 100%; min-height: 180px; }
.chart-axis { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart-gridline { stroke: var(--line); stroke-width: 1; }
.chart-line { fill: none; stroke: var(--green); stroke-width: 2; stroke-linejoin: round; }
.chart-point { fill: var(--green); }
.chart-point.incomplete { fill: var(--warning); }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; margin: 40px 0 48px; }
.chart-grid > section { padding-top: 22px; border-top: 1px solid var(--line); min-width: 0; }
.share-chart { display: flex; align-items: center; gap: 20px; margin-top: 20px; }
.share-chart svg { width: 132px; flex: 0 0 132px; }
.chart-legend { list-style: none; padding: 0; margin: 0; min-width: 0; flex: 1; max-height: 280px; overflow: auto; }
.chart-legend li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: .85rem; border-bottom: 1px solid var(--line); }
.legend-label { display: flex; gap: 8px; align-items: center; min-width: 0; }
.legend-label > span:last-child, .legend-label button { overflow-wrap: anywhere; min-width: 0; font-size: inherit; }
.legend-value { font-variant-numeric: tabular-nums; text-align: right; flex-shrink: 0; }
.chart-swatch { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.chart-color-0 { fill: #345c41; background: #345c41; }
.chart-color-1 { fill: #527f99; background: #527f99; }
.chart-color-2 { fill: #b0863f; background: #b0863f; }
.chart-color-3 { fill: #966768; background: #966768; }
.chart-color-4 { fill: #7d769f; background: #7d769f; }
.chart-color-5 { fill: #8b9588; background: #8b9588; }
.chart-empty { padding: 24px 0; color: var(--muted); font-size: .9rem; }
.total-row { font-weight: 700; background: var(--soft); }
.history-section { margin-top: 40px; }
.history-section .table-wrap { max-height: 560px; }
.history-section th { position: sticky; top: 0; z-index: 1; background: var(--paper); }
.history-pagination { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 16px; }
.history-pagination p { color: var(--muted); font-size: .85rem; }
summary { cursor: pointer; color: var(--green); padding: 12px 0; font-size: .9rem; }
summary:focus-visible, .table-wrap:focus-visible { outline: 3px solid #779b6d; outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-width: 1200px) {
  .share-chart { flex-direction: column; align-items: stretch; }
  .share-chart svg { align-self: center; flex-basis: auto; }
}
@media (max-width: 700px) {
  .chart-grid { grid-template-columns: minmax(0, 1fr); }
  .share-chart { flex-direction: row; align-items: center; }
  .share-chart svg { width: 96px; flex: 0 0 96px; }
  .usage-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .usage-summary dd { font-size: 1.4rem; }
  .filter-bar label { flex: 1 1 140px; min-width: 0; }
  .filter-bar select { max-width: 100%; }
  .trend-section .report-heading { align-items: start; }
  .trend-section .report-heading label { max-width: 160px; }
  .legend-value { flex-shrink: 1; }
}
