/*
 * The whole stylesheet for w-devs SSO. Hand written, no framework, no build
 * step: the CSP is `default-src 'none'; script-src 'none'; style-src 'self'`,
 * so this file is the only styling the app has and it is served fingerprinted
 * and immutable through MapStaticAssets().
 */

:root {
  --ink: #1c1f26;
  --ink-soft: #5a6270;
  --line: #d9dee6;
  --page: #f4f6f9;
  --surface: #ffffff;
  --accent: #2f5bd0;
  --ok: #1c7a4a;
  --warn: #96650a;
  --bad: #b3261e;
  --radius: 8px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}

/* ---- frame ------------------------------------------------------------- */

.site-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
}

.site-main {
  flex: 1 1 auto;
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

.site-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.site-footer p {
  margin: 0;
}

/* ---- containers -------------------------------------------------------- */

.card {
  max-width: 26rem;
  margin: 2rem auto;
  padding: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel {
  margin: 0 0 1.5rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

h1 {
  margin: 0 0 1rem;
  font-size: 1.35rem;
}

h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

p {
  margin: 0 0 1rem;
}

a {
  color: var(--accent);
}

code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em;
  word-break: break-all;
}

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

.field {
  margin: 0 0 1rem;
}

.field label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.field input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.field input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hint {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

button {
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  color: #ffffff;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}

button:hover {
  filter: brightness(1.08);
}

.card-links {
  margin: 1rem 0 0;
  font-size: 0.9rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.actions form {
  margin: 0;
}

/* ---- messages ---------------------------------------------------------- */

/* The one thing on /admin/stalwart that outranks the health panel: the mail
   server is rewriting a live DNS zone. Its own class rather than .flash, which
   is the one-shot post-redirect-get message and is read as such by the tests. */
.banner {
  margin: 0 0 1.5rem;
  padding: 1rem 1.15rem;
  border: 2px solid var(--bad);
  border-radius: var(--radius);
  background: var(--surface);
}

.banner h2 {
  color: var(--bad);
}

.banner p:last-child {
  margin-bottom: 0;
}

/* The per-subject drift list on a mailbox or mail-domain page. */
.drift {
  margin: 0;
  padding-left: 1.1rem;
}

.drift li {
  margin-bottom: 0.3rem;
}

.flash {
  margin: 0 0 1.25rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--surface);
}

.validation-summary {
  margin: 0 0 1rem;
  color: var(--bad);
  font-size: 0.9rem;
}

.validation-summary ul {
  margin: 0;
  padding-left: 1.1rem;
}

.validation-summary:empty,
.validation-summary-valid {
  /* The tag helper still emits an empty list when there is nothing to report,
     with an inline style the CSP refuses to apply. Hide the whole block. */
  display: none;
}

.tone-ok {
  color: var(--ok);
  border-left-color: var(--ok);
}

.tone-warn {
  color: var(--warn);
  border-left-color: var(--warn);
}

.tone-bad {
  color: var(--bad);
  border-left-color: var(--bad);
}

.tone-muted {
  color: var(--ink-soft);
  border-left-color: var(--line);
}

/* ---- data -------------------------------------------------------------- */

.facts {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 0.4rem 1rem;
  margin: 0 0 1rem;
}

.facts dt {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.facts dd {
  margin: 0;
}

.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.grid caption {
  margin-bottom: 0.5rem;
  color: var(--ink-soft);
  font-size: 0.8rem;
  text-align: left;
}

.grid th,
.grid td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.grid thead th {
  color: var(--ink-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.grid td.agent {
  max-width: 18rem;
  color: var(--ink-soft);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.grid tr.active-account {
  background: color-mix(in srgb, var(--ok) 9%, transparent);
}

.grid button {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

/* ==========================================================================
 * The /admin area. Same file, same variables, no framework: the CSP is
 * `style-src 'self'` and this is the only stylesheet the application has.
 * ========================================================================== */

/* ---- frame ------------------------------------------------------------- */

.admin-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.whoami {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.whoami form {
  margin: 0;
}

.whoami-email {
  color: var(--ink-soft);
}

button.quiet {
  padding: 0.3rem 0.7rem;
  color: var(--ink);
  background: transparent;
  border-color: var(--line);
  font-size: 0.8rem;
}

.admin-shell {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  gap: 1.5rem;
  width: 100%;
  max-width: 78rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

@media (max-width: 46rem) {
  .admin-shell {
    grid-template-columns: minmax(0, 1fr);
  }
}

.admin-nav ul {
  position: sticky;
  top: 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-nav a {
  display: block;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9rem;
}

.admin-nav a:hover {
  background: var(--surface);
}

.admin-nav a[aria-current="page"] {
  background: var(--surface);
  border-left: 3px solid var(--accent);
  font-weight: 600;
}

.admin-main {
  min-width: 0;
}

.crumbs {
  margin: -0.5rem 0 1rem;
  font-size: 0.85rem;
}

.panel-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
}

/* ---- badges ------------------------------------------------------------ */

.badge {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  vertical-align: baseline;
}

/* ---- filter bars ------------------------------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.filters .field {
  margin: 0;
  flex: 1 1 10rem;
}

.filters button {
  flex: 0 0 auto;
}

.field select,
.field textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.field textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

.field select:focus-visible,
.field textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

fieldset.field {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
}

fieldset.field legend {
  padding: 0 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.35rem;
  font-size: 0.9rem;
}

.checks label,
.field.check label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 400;
}

.checks input,
.field.check input {
  width: auto;
}

/* ---- tables and detail panels ------------------------------------------ */

.facts dd code,
.grid code {
  font-size: 0.85em;
}

.counts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.9rem;
  margin: 0;
}

.counts dt {
  text-align: left;
}

.counts dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.row-actions form {
  margin: 0;
}

.grid details summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.8rem;
}

.grid details pre {
  margin: 0.4rem 0 0;
  padding: 0.5rem;
  max-width: 26rem;
  overflow-x: auto;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.75rem;
}

/* ---- pager ------------------------------------------------------------- */

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.pager p {
  margin: 0;
}

.pager-count {
  color: var(--ink-soft);
}

.pager-links a {
  margin-left: 0.9rem;
}

/* ---- dangerous things -------------------------------------------------- */

button.danger {
  background: var(--bad);
}

.confirm {
  max-width: 42rem;
}

.consequences {
  margin: 0 0 1.25rem;
  padding-left: 1.1rem;
}

.consequences li {
  margin-bottom: 0.35rem;
}

/* ---- reveal-once ------------------------------------------------------- */

.reveal {
  max-width: 42rem;
}

.secret {
  margin: 0 0 1.25rem;
  padding: 0.9rem;
  background: var(--page);
  border: 1px solid var(--line);
  border-left: 4px solid var(--warn);
  border-radius: var(--radius);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* ---- machine text: zone files and job payloads ------------------------- */

pre.zone,
pre.payload {
  margin: 0 0 0.75rem;
  padding: 0.75rem;
  max-height: 28rem;
  overflow: auto;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---- front-channel logout notifiers ------------------------------------ */

/* One 0x0 iframe per client that has to be told the session ended. They are
   invisible on purpose and never interactive; `display: none` would be wrong,
   because the whole point is that the browser loads them. */
.logout-frames {
  height: 0;
  overflow: hidden;
}

.logout-frames iframe {
  width: 0;
  height: 0;
  border: 0;
}
