:root {
    --ink: #202831;
    --muted: #596575;
    --accent: #354556;
    --line: #d7dde4;
    --surface: #fff;
    font: 15px/1.45 system-ui, sans-serif;
    color: var(--ink);
    background: #f2f3f5;
}

* { box-sizing: border-box; }
body, h1, h2, form { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }

.site-header, .brand, .account {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.site-header {
    min-height: 66px;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: .8rem 1.4rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.brand { font-size: 1.25rem; font-weight: 700; text-decoration: none; }
.account { min-width: 0; flex-wrap: wrap; overflow-wrap: anywhere; }
.account small { display: block; color: var(--muted); font-size: .73rem; text-transform: uppercase; }
.avatar {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    color: white;
    background: var(--accent);
    font-weight: 650;
}

.content { width: min(100% - 2rem, 1140px); margin: 2rem auto; }
h1 { margin-bottom: 1.3rem; font-size: 1.8rem; letter-spacing: -.025em; }
h2 { margin-bottom: 1rem; font-size: 1.15rem; }

.tabs {
    display: flex;
    gap: .25rem;
    overflow-x: auto;
    margin-bottom: 1.3rem;
    border-bottom: 1px solid var(--line);
}

.tabs a {
    padding: .6rem .9rem;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.tabs a:hover, .tabs a[aria-current] { color: var(--accent); }
.tabs a[aria-current] { border-bottom-color: var(--accent); }

.panel { border: 1px solid var(--line); border-radius: .55rem; background: var(--surface); }
.table-panel { overflow-x: auto; padding: .65rem 1rem; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: .6rem .5rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .8rem; font-weight: 650; text-transform: uppercase; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.empty { padding-block: 1rem; color: var(--muted); }
.timestamp-trigger {
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  white-space: nowrap;
}
.timestamp-popover {
  max-width: calc(100vw - 2rem);
  padding: .7rem .85rem;
  border: 1px solid var(--line);
  border-radius: .45rem;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 .35rem 1rem #2028311a;
  font-size: .85rem;
}
.timestamp-popover dl,
.timestamp-popover dd { margin: 0; }
.timestamp-popover dt { color: var(--muted); }
.timestamp-popover code { user-select: all; }
@supports (position-area: bottom span-right) {
  .timestamp-popover {
    inset: auto;
    margin: .25rem 0;
    position-area: bottom span-right;
    position-try-fallbacks: flip-inline, flip-block, flip-block flip-inline;
  }
}

.sign-in, .account-form { max-width: 30rem; padding: 1.4rem; }
.sign-in { margin: 3rem auto; }
.account-form { margin-top: 1.3rem; }
.account-form + .table-panel { margin-top: 1.3rem; }
.table-panel + .table-panel { margin-top: 1.3rem; }
.checkbox { display: flex; align-items: center; gap: .5rem; }
.checkbox input { width: auto; margin: 0; }
.notice { color: var(--muted); }
.token-result { margin-bottom: 1rem; }
.token-result p { margin: .75rem 0 0; color: var(--muted); }
.publish-token { display: block; overflow-x: auto; white-space: nowrap; user-select: all; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: .35rem; background: #f2f3f5; }
label { display: block; margin-bottom: .9rem; font-weight: 550; }
input, button, select, textarea { padding: .5rem .75rem; border: 1px solid var(--line); border-radius: .35rem; }
input, select, textarea { display: block; width: 100%; margin: .25rem 0 0; color: var(--ink); }
textarea { font-weight: 400; resize: vertical; }
button { color: var(--accent); background: var(--surface); cursor: pointer; }
button:hover { border-color: var(--muted); }
.primary { border-color: var(--accent); color: white; background: var(--accent); }
.primary:hover { background: #283748; }

.button-link { display: inline-flex; align-items: center; padding: .5rem .85rem; border: 1px solid var(--line); border-radius: .35rem; background: var(--surface); text-decoration: none; font-weight: 600; }
.button-link.primary { color: white; background: var(--accent); border-color: var(--accent); }
.button-link.primary:hover { background: #283748; }
.panel-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding: .4rem .5rem .65rem; }
.panel-heading h2 { margin: 0; }
.section-stack, .form-fields { display: grid; gap: 1rem; }
.section-stack > .table-panel, .form-fields > label, .form-fields p { margin: 0; }
.form-page { max-width: 50rem; }
.page-title { font-size: 1.65rem; letter-spacing: -.025em; }
.back-link { display: inline-block; margin-bottom: .65rem; color: var(--muted); }
.form-section { min-inline-size: 0; padding: clamp(1rem, 3vw, 1.35rem); }
.section-title { margin: 0 0 .85rem; font-size: 1.15rem; }
.form-fields > .section-title { margin: 0; }
.form-inline label { margin: 0; }
.form-inline { display: flex; flex-wrap: wrap; align-items: end; gap: .75rem; }
.form-inline label { flex: 0 1 24rem; max-width: 100%; }
.field-help { color: var(--muted); font-weight: 400; }
.form-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.form-error { padding: .65rem .8rem; border-inline-start: .2rem solid #a84235; background: #fff3ef; }

.token-description { display: block; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.permission-row { margin: 0; padding: .7rem .75rem; border: 1px solid var(--line); border-radius: .45rem; }
.permission-row small { display: block; color: var(--muted); font-weight: 400; }
.permission-row.form-fields { gap: .35rem; }
.project-picker { border: 1px solid var(--line); border-radius: .35rem; }
.project-picker summary { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .55rem .75rem; background: #f2f3f5; color: var(--accent); cursor: pointer; font-weight: 600; }
.project-picker summary::-webkit-details-marker { display: none; }
.project-picker summary::after { content: ''; width: .45rem; height: .45rem; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.project-picker[open] summary::after { transform: rotate(225deg); }
.project-count { margin-inline-start: auto; color: var(--muted); font-size: .85rem; font-weight: 500; }
.project-picker-body { padding: .65rem; }
.project-search { margin: 0 0 .45rem; }
.project-choices { max-height: 15rem; overflow: auto; }
.project-choice { margin: 0; padding: .45rem .35rem; border-radius: .3rem; overflow-wrap: anywhere; }
.project-choice:hover { background: #f2f3f5; }
.project-picker [hidden] { display: none; }

.project-icon { width: 28px; }
.project-icon img { display: block; object-fit: contain; }
.app-manager-project { background: #fdf1bf; }
.app-manager-project a { font-weight: 700; }
