/* The platform's site.
 *
 * One stylesheet, no build step, no framework. The site is a few dozen
 * elements and a framework would be more to keep current than to write.
 *
 * Colour lives in custom properties and nowhere else, so the dark palette is a
 * block of overrides rather than a second set of rules that drifts.
 */

:root {
  --ink: #16191d;
  --ink-soft: #5b646e;
  --ink-faint: #8b949e;
  --page: #f6f7f9;
  --card: #ffffff;
  --side: #fbfbfc;
  --line: #e2e5e9;
  --line-soft: #eef0f3;
  --hover: #eef0f3;
  --accent: #1f5fa8;
  --accent-wash: #e8f0fa;
  --accent-ink: #ffffff;
  --danger: #b3261e;
  --danger-wash: #fdecea;
  --good: #1f7a4d;
  --good-wash: #e8f5ee;
  --warn-ink: #8a5a10;
  --warn-wash: #fdf3e0;
  --violet: #5b4bb7;
  --violet-wash: #efedfd;
  --radius: 8px;
  --shadow-pop: 0 8px 24px rgba(16, 20, 26, .12), 0 2px 6px rgba(16, 20, 26, .08);
  --backdrop: rgba(16, 20, 26, .4);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e8eaed;
    --ink-soft: #a2abb5;
    --ink-faint: #79828c;
    --page: #14171a;
    --card: #1c2024;
    --side: #181b1f;
    --line: #2c3237;
    --line-soft: #23282d;
    --hover: #262b31;
    --accent: #6ba4e8;
    --accent-wash: #1a2a3d;
    --accent-ink: #10141a;
    --danger: #ef8a82;
    --danger-wash: #3a201f;
    --good: #6cc48a;
    --good-wash: #17301f;
    --warn-ink: #e0b874;
    --warn-wash: #33291a;
    --violet: #b1a8f0;
    --violet-wash: #2a2547;
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, .5);
    --backdrop: rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14.5px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
}

code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

h1 { font-size: 1.45rem; letter-spacing: -.02em; margin: 0; font-weight: 600; }
h2 { font-size: 1rem; margin: 0; font-weight: 600; }

/* ── The shell ──────────────────────────────────────────────────────────── */

/* A sidebar on every signed-in page. Before it, the only way between areas was
 * back through the account page, and nothing said which organisation you were
 * in. */
.shell { display: grid; grid-template-columns: 15rem minmax(0, 1fr); min-height: 100vh; }
.content, .list-row .grow { overflow-wrap: anywhere; }

.sidebar {
  background: var(--side);
  border-right: 1px solid var(--line);
  padding: 1rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .15rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  font-weight: 650;
  letter-spacing: -.01em;
  color: var(--ink);
  padding: .25rem .6rem .9rem;
  display: block;
}
.brand:hover { text-decoration: none; }

.nav-label {
  font-size: .72rem;
  color: var(--ink-faint);
  padding: 1rem .6rem .3rem;
  letter-spacing: .02em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .42rem .6rem;
  border-radius: var(--radius);
  color: var(--ink-soft);
}
.nav-item:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--accent-wash); color: var(--accent); font-weight: 550; }
.nav-item svg { flex: 0 0 auto; }

.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: .75rem; }

/* The organisation switcher. A <details>, so it opens without script. */
.switcher { position: relative; margin-bottom: .25rem; }
.switcher > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem .6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  font-weight: 550;
}
.switcher > summary::-webkit-details-marker { display: none; }
.switcher > summary .muted { font-weight: 400; }
.switcher .menu-pop { left: 0; right: 0; top: calc(100% + .3rem); }

.content { padding: 2rem 2.5rem 4rem; max-width: 72rem; width: 100%; }

/* On a narrow screen the sidebar becomes a compact bar across the top, so the
 * page's own content is on the first screen rather than below the menu. */
@media (max-width: 52rem) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem;
    padding: .6rem .75rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand { padding: .25rem .5rem .25rem 0; }
  .switcher { flex: 1 1 10rem; margin: 0; }
  .nav-label { display: none; }
  .nav-item { padding: .35rem .5rem; font-size: .9rem; }
  .sidebar-foot { margin: 0; border: 0; padding: 0; display: flex; }
  .content { padding: 1.25rem 1rem 3rem; }
  .list-row { flex-wrap: wrap; }
  .list-row .grow { flex-basis: 12rem; }
}

/* Pages with nobody signed in: sign-in, invitation landings, refusals. */
.solo { max-width: 34rem; margin: 0 auto; padding: 4rem 1.25rem; }
.solo .brand { padding: 0 0 1.5rem; font-size: 1.05rem; }

/* ── Page head ──────────────────────────────────────────────────────────── */

.pagehead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.pagehead p { margin: .3rem 0 0; color: var(--ink-soft); max-width: 44rem; }
.pagehead .actions { display: flex; gap: .5rem; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 2rem 0 .6rem; }
.section-head p { margin: 0; color: var(--ink-soft); font-size: .9rem; }

/* ── Lists ──────────────────────────────────────────────────────────────── */

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel + .panel { margin-top: 1rem; }

.list-row {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--line-soft);
  min-height: 3.4rem;
}
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1 1 auto; min-width: 0; }
.list-row .title { font-weight: 550; }
.list-row .meta { color: var(--ink-soft); font-size: .85rem; }

.empty-state { padding: 2.5rem 1rem; text-align: center; color: var(--ink-soft); }
.empty-state strong { display: block; color: var(--ink); font-size: 1rem; margin-bottom: .25rem; }
.empty-state p { margin: 0 0 1rem; }

table { border-collapse: collapse; width: 100%; }
th {
  text-align: left;
  font-size: .78rem;
  color: var(--ink-faint);
  font-weight: 550;
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: .7rem 1rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.right, th.right { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }

.avatar {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--accent-wash);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: .78rem;
  font-weight: 600;
}
.avatar.pending { background: var(--warn-wash); color: var(--warn-ink); }

/* ── Menus ──────────────────────────────────────────────────────────────── */

/* Row actions live behind "…". A destructive button beside every row, one
 * click from firing, is how a revoke happens by accident. */
.menu { position: relative; }
.menu > summary {
  list-style: none;
  cursor: pointer;
  padding: .3rem .45rem;
  border-radius: var(--radius);
  color: var(--ink-soft);
  line-height: 1;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover, .menu[open] > summary { background: var(--hover); color: var(--ink); }

.menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + .25rem);
  z-index: 20;
  min-width: 12rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  padding: .3rem;
}
.menu-pop form { margin: 0; }
.menu-pop a, .menu-pop button {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  text-align: left;
  padding: .45rem .6rem;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: none;
  color: var(--ink);
  font: inherit;
  font-weight: 400;
  cursor: pointer;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--hover); text-decoration: none; }
.menu-pop .danger { color: var(--danger); }
.menu-pop .current { font-weight: 600; }
.menu-pop hr { border: 0; border-top: 1px solid var(--line-soft); margin: .3rem 0; }
.menu-pop .menu-note { padding: .3rem .6rem; font-size: .78rem; color: var(--ink-faint); }

/* ── Dialogs ────────────────────────────────────────────────────────────── */

dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  width: min(32rem, calc(100vw - 2rem));
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
}
dialog.wide { width: min(44rem, calc(100vw - 2rem)); }
dialog::backdrop { background: var(--backdrop); }
.dialog-head { padding: 1.1rem 1.25rem 0; }
.dialog-head p { margin: .3rem 0 0; color: var(--ink-soft); font-size: .92rem; }
.dialog-body { padding: 1rem 1.25rem; }
.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  padding: .9rem 1.25rem;
  border-top: 1px solid var(--line-soft);
}

/* ── Forms ──────────────────────────────────────────────────────────────── */

.field { display: block; margin-bottom: .9rem; }
.field > span { display: block; font-size: .84rem; font-weight: 550; margin-bottom: .3rem; }
.field > .hint { display: block; font-size: .8rem; color: var(--ink-faint); font-weight: 400; margin: .3rem 0 0; }

input[type="text"], input[type="email"], input:not([type]), input[type="search"], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .5rem .65rem;
}
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .84rem; resize: vertical; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 .75rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 .75rem; }
@media (max-width: 40rem) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters select, .filters input { width: auto; min-width: 10rem; }

button, .button {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font: inherit;
  font-weight: 550;
  padding: .48rem .9rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
button:hover, .button:hover { background: var(--hover); text-decoration: none; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover, .button.primary:hover { filter: brightness(1.08); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.danger:hover { filter: brightness(1.08); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 400; }
button.link:hover { text-decoration: underline; }

/* ── Status ─────────────────────────────────────────────────────────────── */

.notice { border-radius: var(--radius); padding: .7rem 1rem; margin-bottom: 1.25rem; font-size: .93rem; }
.notice.bad { background: var(--danger-wash); color: var(--danger); border: 1px solid var(--danger); }
.notice.info { background: var(--accent-wash); color: var(--ink); border: 1px solid var(--line); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
  font-weight: 550;
  padding: .12rem .55rem;
  border-radius: 99px;
  background: var(--line-soft);
  color: var(--ink-soft);
  white-space: nowrap;
}
.pill.good { background: var(--good-wash); color: var(--good); }
.pill.warn { background: var(--warn-wash); color: var(--warn-ink); }
.pill.gone { background: var(--danger-wash); color: var(--danger); }
.pill.accent { background: var(--accent-wash); color: var(--accent); }
.pill.violet { background: var(--violet-wash); color: var(--violet); }

.chips { display: flex; gap: .35rem; flex-wrap: wrap; }

.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: .84rem; }

.keys { margin: .5rem 0 0; padding: 0; list-style: none; font-size: .86rem; }
.keys li { display: flex; gap: .75rem; align-items: center; padding: .3rem 0; color: var(--ink-soft); }
.keys .mono { color: var(--ink); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

[hidden] { display: none !important; }

.stack > * + * { margin-top: 1rem; }
.stack > * { margin-bottom: 0; }

/* After the button rules, so a destructive menu item reads as red text in a
 * list rather than a solid danger button. */
.menu-pop button.danger { background: none; border: 0; color: var(--danger); filter: none; }
.menu-pop button.danger:hover { background: var(--danger-wash); }

/* A menu or dialog opened from a right-aligned, no-wrap table cell must not
 * inherit either. */
.menu-pop, dialog { text-align: left; white-space: normal; }
