/* The dashboard.
 *
 * Sits on top of base.css, which owns the design tokens (--bg, --fg, --line,
 * --panel, --soft) and the vendored @font-face rules. Nothing here redeclares a
 * token: the landing page links the same base, and a palette duplicated in two
 * files drifts the moment one is edited.
 *
 * Deliberately plain — tables, panels, one accent — because the product UI is
 * CRUD plus an execution timeline. Every rule here is progressive enhancement
 * away from a page that already works without JavaScript.
 */

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.wrap {
  width: min(1100px, calc(100% - 40px));
  margin: auto;
}

/* --- chrome ---------------------------------------------------------------- */

.topbar {
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.03em;
  flex: none;
}

.mark {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
}

/* The tab bar fills the space between the brand and the account, so the
   navigation reads as the middle of the header rather than as a group of links
   that happens to be second. */
.tabs {
  display: flex;
  align-items: stretch;
  gap: 22px;
  flex: 1;
  height: 64px;
  font-size: 14px;
}

/* The underline sits on the header's own bottom border: same 1px, moved up by
   the border's width, so the active tab's mark looks continuous with the rule
   the header already draws. */
.tab {
  display: flex;
  align-items: center;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--fg);
}

.tab.active {
  color: var(--fg);
  border-bottom-color: var(--fg);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 14px;
  flex: none;
}

.who {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* The provider avatar. `object-fit` matters because these are square but not
   always the same size; the border keeps a light avatar from bleeding into the
   dark bar. */
.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--line);
  display: block;
}

/* Shown when the provider gave no picture, so the slot keeps its shape rather
   than the name jumping left. */
.avatar-fallback {
  display: grid;
  place-items: center;
  background: var(--soft);
  color: var(--muted);
  font: 11px 'DM Mono';
  border: 1px solid var(--line);
  border-radius: 50%;
}

main {
  flex: 1;
  padding: 44px 0 80px;
}

.pagefoot {
  padding: 18px 0 28px;
  color: #444;
  font-size: 11px;
}

/* --- typography ------------------------------------------------------------ */

h1 {
  font-size: 34px;
  letter-spacing: -0.04em;
  margin: 0 0 10px;
}

h2 {
  font-size: 22px;
  letter-spacing: -0.03em;
  margin: 0 0 8px;
}

h3 {
  font-size: 17px;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

.kicker {
  font: 11px 'DM Mono';
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin: 0 0 12px;
}

.lede {
  color: #929292;
  line-height: 1.6;
  max-width: 62ch;
  margin: 0 0 20px;
}

.dim {
  color: var(--muted);
}

.mono {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
}

.fineprint {
  color: #777;
  font-size: 13px;
  line-height: 1.6;
  margin: 16px 0 0;
}

.pagehead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin: 0 0 20px;
}

.pagehead h1 {
  margin-bottom: 4px;
}

/* --- panels --------------------------------------------------------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 24px;
  margin-bottom: 20px;
}

.panel.narrow {
  max-width: 520px;
  margin: 60px auto;
}

.panel.accent {
  border-color: #3a3a3a;
  background: var(--soft);
}

.panel.empty {
  color: var(--muted);
  text-align: center;
  padding: 40px 24px;
}

/* A panel whose heading and actions sit on one line: the account name on the
   left, what you can do with it on the right. */
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.panel-head h3 {
  margin: 0 0 6px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* The one next step on a first run: a panel that is a little louder than the
   rest, without being a different component. */
.panel.step {
  border-color: #3a3a3a;
  background: var(--soft);
}

.panel.step .row {
  margin-top: 4px;
}

/* --- overview -------------------------------------------------------------- */

/* Three counts across the top. Grid rather than flex so the columns stay equal
   however long the labels get. */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-bottom: 32px;
}

.stat {
  background: var(--panel);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-value {
  font-size: 26px;
  letter-spacing: -0.04em;
  line-height: 1;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

/* A list of recent events. Rows rather than a table: there are no columns to
   align, and a four-cell table for one sentence per line is harder to read at
   this width. */
.activity {
  list-style: none;
  margin: 0;
  padding: 0;
}

.activity li {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.activity li:last-child {
  border-bottom: 0;
}

.activity-what {
  flex: none;
}

.activity-source {
  color: var(--muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-when {
  color: #555;
  font-size: 13px;
  flex: none;
}

.plain-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.plain-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.plain-list li:last-child {
  border-bottom: 0;
}

/* --- forms ---------------------------------------------------------------- */

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type='text'],
input[type='search'],
input:not([type]) {
  width: 100%;
  background: #0b0b0b;
  border: 1px solid #333;
  color: var(--fg);
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
}

input[readonly] {
  color: #ccc;
  background: #101010;
}

input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid #6a6a6a;
  outline-offset: 2px;
}

.inline-form {
  display: flex;
  align-items: flex-end;
  gap: 14px;
}

.field.grow {
  flex: 1;
  margin-bottom: 0;
}

.button {
  display: inline-block;
  border: 1px solid #414141;
  background: transparent;
  color: #bbb;
  padding: 11px 18px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}

.button.primary {
  background: #eee;
  border-color: #eee;
  color: #080808;
  font-weight: 600;
}

/* The provider button: the mark and the label on one line, centred. */
.button.github {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.github-mark {
  flex: none;
  /* Sit the mark on the text baseline rather than the box centre: the label's
     descenders otherwise push it visually high. */
  margin-top: -1px;
}

.linkish {
  background: none;
  border: 0;
  padding: 0;
  color: #9a9a9a;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
}

.linkish:hover {
  color: #fff;
}

.linkish.danger {
  color: #c0664f;
}

/* --- tables --------------------------------------------------------------- */

.table {
  width: 100%;
  border-collapse: collapse;
  /* Fixed layout so the column widths below are honoured. Without it a long
     value — a webhook URL — expands its column past the panel and pushes the
     last column (Delete) out of view, which is exactly what happened. */
  table-layout: fixed;
}

.table th,
.table td {
  text-align: left;
  padding: 11px 14px 11px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table th {
  font: 11px 'DM Mono';
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 400;
}

.table tr:last-child td {
  border-bottom: 0;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A block of prose the user wrote, or a document we are about to store.
   Wrapped, never truncated: instructions are the content of a page, and a long
   line must not push the panel sideways. */
.prose {
  background: #0b0b0b;
  border: 1px solid #333;
  padding: 14px 16px;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
  font-size: 14px;
  line-height: 1.6;
}

/* The spec JSON, behind a disclosure. Monospaced and scrollable: it is the
   machine's view, and wrapping it would make it harder to read, not easier. */
.spec {
  padding: 14px 16px;
  margin: 10px 0 0;
  background: #0b0b0b;
  border: 1px solid #333;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.6;
}

/* The message beside a field that was refused. The same red as `.notice.bad`
   because it is the same kind of thing, at the scale of one input. */
.field-error {
  color: #d08a72;
  font-size: 13px;
  margin: -6px 0 16px;
}

.actions {
  text-align: right;
}

.nowrap {
  white-space: nowrap;
}

/* A fixed layout means every cell can overflow; truncate by default and let
   the few that should wrap opt out. */
.table td,
.table th {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- status --------------------------------------------------------------- */

.tag {
  font: 11px 'DM Mono';
  border: 1px solid #3a3a3a;
  padding: 3px 8px;
  color: #b9b9b9;
  white-space: nowrap;
}

.tag.active,
.tag.accepted,
.tag.connected,
.tag.ok {
  border-color: #2f5a38;
  color: #7fb98d;
}

.tag.disabled,
.tag.error,
.tag.revoked,
.tag.invalid_signature,
.tag.malformed,
.tag.bad {
  border-color: #6a3a2c;
  color: #d08a72;
}

.notice {
  border-left: 2px solid #555;
  background: #121212;
  padding: 12px 14px;
  margin: 0 0 18px;
  color: #bbb;
  font-size: 14px;
  line-height: 1.5;
}

.notice.bad {
  border-left-color: #a8492f;
  color: #e0a190;
}

.notice.good {
  border-left-color: #2f5a38;
  color: #9fc9a8;
}

details.fineprint summary {
  cursor: pointer;
  color: #9a9a9a;
}

details.fineprint p {
  margin: 8px 0 0;
}

@media (max-width: 720px) {
  .inline-form {
    flex-direction: column;
    align-items: stretch;
  }

  /* The header cannot hold a brand, three tabs and an account on a phone, so
     the tabs move to their own row and the account stays on the first one. */
  .topbar-inner {
    height: auto;
    padding: 14px 0 0;
    flex-wrap: wrap;
    gap: 12px;
  }

  .tabs {
    order: 3;
    flex-basis: 100%;
    height: auto;
    gap: 18px;
  }

  .tab {
    padding-bottom: 10px;
  }

  .table th:nth-child(2),
  .table td:nth-child(2) {
    display: none; /* the URL is the widest column; it stays available on the row's title */
  }

  /* An activity row's right-hand columns wrap under the text instead of being
     squeezed into nothing. */
  .activity li {
    flex-wrap: wrap;
    gap: 8px 14px;
  }

  .activity-source {
    flex-basis: 100%;
    order: 3;
  }
}
