/*
 * The dashboard's one stylesheet: a light theme. No scripts anywhere and no outside fonts or images: the content security
 * policy allows only this file and files from this site, so everything here is plain CSS.
 */
:root {
  color-scheme: light;

  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --line: #e6eaf1;
  --line-strong: #d0d8e4;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-text: #ffffff;
  --ring: rgba(79, 70, 229, 0.28);

  --ok: #047857;
  --ok-bg: #dcfce7;
  --ok-line: #a7e8c3;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --warn-line: #f6d77a;
  --bad: #be123c;
  --bad-bg: #ffe4e6;
  --bad-line: #fbb6c0;
  --info: #3730a3;
  --info-bg: #e0e7ff;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 28px -14px rgba(15, 23, 42, 0.14);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--text);
  background: radial-gradient(1100px 380px at 50% -220px, #dfe6ff 0%, rgba(223, 230, 255, 0) 72%) no-repeat, var(--bg);
  min-height: 100vh;
  font: 16px/1.55 Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
p a, li a, .hint a { text-decoration: underline; text-decoration-color: rgba(79, 70, 229, 0.35); text-decoration-thickness: 1px; }
p a:hover, li a:hover, .hint a:hover { text-decoration-color: currentColor; }
.actions > a, .subnav a, .mainnav a, .brand { text-decoration: none; }

h1 { font-size: 1.85rem; line-height: 1.2; letter-spacing: -0.022em; font-weight: 750; margin: 30px 0 8px; overflow-wrap: anywhere; }
h2 { font-size: 1.05rem; letter-spacing: -0.005em; font-weight: 650; margin: 0 0 14px; }
p { margin: 0 0 12px; }
code { font: 0.88em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }

/* --- the bar across the top --- */

.top {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: saturate(160%) blur(12px); backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; letter-spacing: -0.01em; text-decoration: none; color: var(--text); }
.brand:hover { color: var(--text); }
.brand img { width: 32px; height: 32px; border-radius: 9px; box-shadow: 0 4px 12px -4px rgba(79, 70, 229, 0.55); }
.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav a { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; color: var(--text-2); font-weight: 550; text-decoration: none; }
.mainnav a:hover { background: var(--surface-2); color: var(--text); }
.mainnav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-hover); }
.count { background: var(--bad); color: #fff; border-radius: 999px; padding: 0 8px; min-width: 22px; text-align: center; font-size: 0.76rem; font-weight: 700; line-height: 20px; }
.signout { display: flex; align-items: center; gap: 10px; margin: 0; }
.who { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-weight: 550; }
.who::before {
  content: attr(data-initial); display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-hover); font-size: 0.85rem; font-weight: 700; text-transform: uppercase;
}

/* --- headings and the links under them --- */

.subnav {
  display: flex; gap: 4px; margin: 0 0 22px; padding: 4px; width: fit-content; max-width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-sm);
  overflow-x: auto; scrollbar-width: none;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav a { padding: 7px 14px; border-radius: 999px; color: var(--text-2); font-weight: 550; font-size: 0.93rem; text-decoration: none; white-space: nowrap; }
.subnav a:hover { background: var(--surface-2); color: var(--text); }
.subnav a[aria-current="page"] { background: var(--accent); color: var(--accent-text); box-shadow: 0 2px 8px -2px rgba(79, 70, 229, 0.6); }

.crumb { margin: 0 0 18px; font-size: 0.93rem; }
.lead { color: var(--muted); max-width: 70ch; }
.lead + .tiles { margin-top: 18px; }
h1 + .lead { margin-top: 0; }

/* --- cards --- */

section {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 24px; margin: 0 0 20px;
}
section > h2:first-child::before {
  content: ""; display: inline-block; width: 4px; height: 1em; margin-right: 10px; vertical-align: -2px; border-radius: 2px;
  background: linear-gradient(180deg, #6366f1, #8b5cf6);
}
section > p:last-child, section > form:last-child { margin-bottom: 0; }

/* --- buttons --- */

button, .link { font: inherit; cursor: pointer; }
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 9px 18px; border: 1px solid transparent; border-radius: var(--radius-sm); font-weight: 600; line-height: 1.25; color: var(--accent-text);
  background: linear-gradient(180deg, #6366f1, #4f46e5);
  box-shadow: 0 1px 2px rgba(49, 46, 129, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  transition: transform 0.06s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
button:hover { filter: brightness(1.06); box-shadow: 0 4px 14px -4px rgba(79, 70, 229, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.16); }
button:active { transform: translateY(1px); }
button.link { background: transparent; box-shadow: none; filter: none; color: var(--text-2); min-height: 38px; padding: 7px 14px; border: 1px solid var(--line-strong); font-weight: 550; }
button.link:hover { background: var(--surface-2); color: var(--text); box-shadow: none; }
button.approve { border-color: rgba(4, 120, 87, 0.5); background: linear-gradient(180deg, #10b981, #059669); box-shadow: 0 1px 2px rgba(4, 120, 87, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
button.approve:hover { box-shadow: 0 4px 14px -4px rgba(5, 150, 105, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
button.reject { background: var(--surface); color: var(--bad); border: 1px solid var(--bad-line); box-shadow: none; }
button.reject:hover { background: var(--bad-bg); box-shadow: none; filter: none; }
button:disabled, input:disabled { opacity: 0.5; cursor: not-allowed; filter: none; box-shadow: none; transform: none; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

.actions { margin: 0 0 20px; }
.actions > a {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px; border-radius: var(--radius-sm); font-weight: 600; text-decoration: none;
  color: var(--accent-text); background: linear-gradient(180deg, #6366f1, #4f46e5);
  box-shadow: 0 1px 2px rgba(49, 46, 129, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.actions > a::before { content: "+"; font-size: 1.2em; font-weight: 500; line-height: 1; }
.actions > a:hover { color: #fff; filter: brightness(1.06); }

/* --- forms --- */

input[type=text], input[type=password], input[type=email], select, textarea {
  font: inherit; color: var(--text); background: var(--surface); max-width: 100%;
  min-height: 44px; padding: 9px 12px; line-height: 1.4; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder { color: #9aa6b8; }
input[type=text]:hover, input[type=password]:hover, input[type=email]:hover, select:hover, textarea:hover { border-color: #b7c2d3; }
input[type=text]:focus, input[type=password]:focus, input[type=email]:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
input:disabled { background: var(--surface-2); }
input[type=text], input[type=password], input[type=email], select { height: 44px; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
label { display: block; margin: 0 0 12px; font-weight: 600; font-size: 0.93rem; color: var(--text-2); }
label input, label select { display: block; margin-top: 6px; font-weight: 400; font-size: 1rem; color: var(--text); }
.stack { display: grid; gap: 4px; }
.narrow { max-width: 380px; }
.inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 0 0 12px; }
.inline label { margin: 0; }
.inline input[type=email] { min-width: 300px; }
/* A form's fields sit in as many columns as fit, so a long form is not a long thin strip. */
.form { display: grid; gap: 0; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); column-gap: 28px; }
.form > section, .form > div:last-child, .form > input[type=hidden], .field.wide { grid-column: 1 / -1; }
.form section { display: grid; gap: 0; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); column-gap: 28px; align-content: start; }
.form section > h2, .form section > p, .form section > .check, .form section > .flash, .form section > ul { grid-column: 1 / -1; }
.form section { padding-bottom: 8px; }
@supports (grid-template-rows: subgrid) {
  .form section > .field, .form > .field { display: grid; grid-row: span 4; grid-template-rows: subgrid; row-gap: 0; align-content: start; }
  .form section > .field > label, .form > .field > label { align-self: end; } /* a one-line label sits on its box, not at the top of a two-line gap */
}
section > p + .form { margin-top: 16px; }
.field { margin: 0 0 18px; min-width: 0; }
.field label { display: block; margin: 0 0 6px; font-weight: 600; }
.field input[type=text], .field input[type=password], .field input[type=email], .field select, .field textarea { width: 100%; max-width: none; }
textarea.paste { width: 100%; max-width: 920px; font: 0.88rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
.hint { color: var(--muted); font-size: 0.87rem; margin: 6px 0 0; max-width: 62ch; }
.error { color: var(--bad); font-size: 0.9rem; margin: 6px 0 0; font-weight: 600; }
.check, .field .check { display: flex; align-items: flex-start; gap: 10px; margin: 10px 0 0; font-weight: 400; max-width: 580px; color: var(--text-2); }
.check input, .field .check input { margin: 3px 0 0; flex: none; }
.check + p { margin-top: 16px; }
.todo { margin: 0 0 12px; padding-left: 20px; color: var(--text-2); }
.todo li { margin: 3px 0; }
.form > div:last-child { margin: 0 0 6px; }

/* --- tables --- */

.scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: var(--surface-2); color: var(--muted); font-size: 0.73rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
table.r2on th:nth-child(n+2), table.r2on td:nth-child(n+2), table.r4 th:nth-child(4), table.r4 td:nth-child(4), table.r34 th:nth-child(3), table.r34 td:nth-child(3), table.r34 th:nth-child(4), table.r34 td:nth-child(4) { text-align: right; }
tbody tr:hover td { background: #fafbff; }
td a { font-weight: 550; }
.list td:not(:first-child) { white-space: nowrap; }
td button { min-height: 0; padding: 6px 12px; font-size: 0.85rem; }
td .inline { margin: 0; align-items: center; flex-wrap: nowrap; gap: 10px; }
td .muted { white-space: nowrap; }

.muted { color: var(--muted); font-size: 0.92em; }
.nowrap { white-space: nowrap; }
.empty { color: var(--muted); padding: 18px; text-align: center; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 12px; margin: 0; }

/* --- small things --- */

.badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 650; letter-spacing: 0.005em;
  background: var(--info-bg); color: var(--info); vertical-align: middle;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge-live, .badge-ready, .badge-applied, .badge-active, .badge-ok, .badge-approved { background: var(--ok-bg); color: var(--ok); }
.badge-dry, .badge-dry_run, .badge-awaiting_approval, .badge-onboarding, .badge-paused { background: var(--warn-bg); color: var(--warn); }
.badge-saved, .badge-none { background: var(--surface-2); color: var(--muted); }
.badge-connected { background: var(--ok-bg); color: var(--ok); }
.badge-failed, .badge-blocked, .badge-auth_rejected, .badge-error, .badge-alert, .badge-rejected, .badge-stale { background: var(--bad-bg); color: var(--bad); }

.flash { display: flex; gap: 10px; padding: 12px 16px; border-radius: 12px; margin: 16px 0; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-sm); }
.flash::before { flex: none; font-weight: 800; }
.flash-success { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.flash-success::before { content: "\2713"; }
.flash-error { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.flash-error::before { content: "!"; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--bad); color: #fff; font-size: 0.8rem; }
div.flash { display: block; }
div.flash::before { content: none; }
div.flash p { margin: 0 0 6px; font-weight: 600; }
div.flash ul { margin: 0; padding-left: 20px; }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin: 0 0 18px; }
.facts div { margin: 0; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.facts dt { color: var(--muted); font-size: 0.74rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 4px; }
.facts dd { margin: 0; display: flex; align-items: center; min-height: 28px; font-weight: 600; font-size: 1.02rem; }
.facts dd .badge { white-space: normal; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin: 0 0 22px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.tile .n { display: block; font-size: 1.9rem; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; }
.tile .l { display: block; margin-top: 4px; color: var(--muted); font-size: 0.82rem; font-weight: 600; letter-spacing: 0.02em; }
.tile-alert .n { color: var(--bad); }
.tile-live .n { color: var(--ok); }
.tile-dry .n { color: var(--warn); }

.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.cards li { border: 1px solid var(--line); border-left: 4px solid #f59e0b; border-radius: 12px; padding: 14px 18px; background: var(--surface); box-shadow: var(--shadow-sm); }
.cards p { margin: 0 0 8px; }
.what { font-weight: 600; font-size: 1.02rem; }
.decision { display: flex; gap: 10px; margin-top: 4px; }
.decision form { margin: 0; }

.log { list-style: none; padding: 0; margin: 0; display: grid; gap: 0; }
.log li { padding: 10px 2px; border-bottom: 1px solid var(--line); }
.log li:last-child { border-bottom: 0; }
.log-cols li { display: flex; align-items: baseline; gap: 2px 14px; }
.log-cols li > .muted:first-child { flex: none; min-width: 11.2rem; white-space: nowrap; }
.log-cols li > a:first-child { flex: none; min-width: 12.5rem; }
.log-cols li > .badge { flex: none; min-width: 9.6rem; justify-content: center; }
.log-cols li > .muted:last-child:not(:first-child) { margin-left: auto; white-space: nowrap; }

details summary { cursor: pointer; color: var(--accent); font-size: 0.9em; font-weight: 550; margin-top: 4px; }
pre.report {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px; box-shadow: var(--shadow);
  padding: 22px 26px; overflow-x: auto; white-space: pre-wrap; margin: 0 0 20px;
  font: 0.93rem/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-2);
}
td pre.report, details pre.report { box-shadow: none; margin: 8px 0 0; padding: 14px 16px; }

/* --- signing in, and pages with nothing else on them --- */

.auth { min-height: 70vh; display: grid; place-items: center; padding: 28px 0; }
.auth-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 24px 60px -28px rgba(49, 46, 129, 0.35), var(--shadow); padding: 34px 32px 30px;
}
.auth-card { text-align: center; }
.auth-card .mark { display: block; width: 56px; height: 56px; border-radius: 15px; margin: 0 auto 18px; box-shadow: 0 8px 20px -6px rgba(79, 70, 229, 0.6); }
.auth-card h1 { margin: 0 0 4px; font-size: 1.6rem; }
.auth-card .lead { margin: 0 auto 24px; }
.auth-card form, .auth-card label { text-align: left; }
.auth-card .flash { text-align: left; }
.auth-card .narrow { max-width: none; }
.auth-card button { width: 100%; padding: 12px 18px; margin-top: 6px; }
.auth-card input[type=text], .auth-card input[type=password] { width: 100%; }
.auth-card .flash { margin: 0 0 16px; }

.foot { color: var(--muted); font-size: 0.84rem; padding: 12px 20px 40px; text-align: center; }

@media (max-width: 720px) {
  .wrap { padding: 0 14px; }
  h1 { font-size: 1.5rem; margin-top: 22px; }
  section { padding: 18px 16px; border-radius: 14px; }
  .bar { gap: 6px 12px; padding-top: 8px; padding-bottom: 8px; }
  .mainnav { order: 3; flex: 1 0 100%; }
  .signout { margin-left: auto; }
  .who { display: none; }
  .inline input[type=email] { min-width: 0; width: 100%; }
  .subnav { border-radius: 14px; }
  th, td { padding: 10px 12px; }
  .log-cols li { flex-wrap: wrap; }
  .log-cols li > .badge { min-width: 0; }
  .log-cols li > .muted:last-child:not(:first-child) { margin-left: 0; }
  .list td:first-child { min-width: 170px; }
  .scroll td:first-child { min-width: 128px; }
  .tile .n { font-size: 1.5rem; }
}

/* Setup pages: a copyable block, a link that looks like a button, a tick-box line */
pre.copy { margin: 8px 0 14px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm, 10px); overflow-x: auto; font-size: 0.85rem; line-height: 1.55; user-select: all; white-space: pre-wrap; overflow-wrap: anywhere; }
a.button { display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: 10px; background: linear-gradient(180deg, #6366f1, #4f46e5); color: #fff; font-weight: 600; text-decoration: none; box-shadow: 0 1px 2px rgba(49, 46, 129, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.16); }
a.button:hover { filter: brightness(1.06); }
a.button.quiet { background: var(--surface); color: var(--text-2); border: 1px solid var(--line-strong); box-shadow: none; }
label.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; }
label.check input { margin-top: 4px; }
button[disabled] { opacity: 0.5; cursor: not-allowed; }
input.copy { width: 100%; max-width: 40rem; margin-top: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; background: var(--surface-2); user-select: all; }

/* A status tile with a line of detail under its badge (System, Connections) */
.facts dd.stack { flex-direction: column; align-items: flex-start; justify-content: center; gap: 6px; }
.facts dd.stack .badge { white-space: nowrap; }
.sub { color: var(--muted); font-size: 0.86rem; font-weight: 500; }

/* A list of settings: what it is, its value, and a note under it. Room for sentences, unlike the tiles. */
.settings { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 10px; }
.settings li { display: grid; grid-template-columns: minmax(180px, 15rem) 1fr; gap: 4px 20px; align-items: baseline; padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; }
.settings .name { font-weight: 650; }
.settings .val { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.settings .note { grid-column: 2; margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

/* A readiness checklist: a badge, then the sentence */
.checklist { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 10px; }
.checklist li { display: grid; grid-template-columns: 6.5rem 1fr; gap: 14px; align-items: baseline; }
.checklist .badge { justify-content: center; }

/* A form whose parts stack: a confirmation line, then its button */
form.stack { display: grid; gap: 12px; justify-items: start; margin: 16px 0 6px; }
form.stack label.check { margin: 0; }

@media (max-width: 640px) {
  .settings li { grid-template-columns: 1fr; }
  .settings .note { grid-column: 1; }
  .checklist li { grid-template-columns: 1fr; gap: 4px; }
  .checklist .badge { justify-self: start; }
}

/* Buttons that belong together, with their one line of explanation after them */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin: 6px 0 16px; }
.actions form { margin: 0; }
.actions .muted { flex-basis: 100%; margin: 2px 0 0; font-size: 0.88rem; }
