/* Styles for the DNS control panel.
 *
 * The palette and the typography are the ones used across AS206208, so that
 * moving between the looking glass, the webmail and this panel does not feel
 * like moving between three different products. What differs is what the
 * pages are for: this one is edited rather than read, so it carries forms,
 * inline editors and confirmation states that a read-only site does not need.
 *
 * Colour is reserved for meaning -- a record that is disabled, a delegation
 * that has not been granted, a reverse record whose forward record disagrees
 * -- so that a coloured cell is always worth looking at.
 */

:root {
  /* Dark is the default rather than a preference: this is an operations tool,
   * read in the same context as a terminal. The light theme below exists for
   * people who have asked their system for one. */
  --bg: #0b0f16;
  --bg-raised: #121824;
  --bg-inset: #0e131d;
  --panel: #131a27;
  --border: #222d40;
  --border-strong: #31405a;

  --text: #dde3ec;
  --text-dim: #8d9aae;
  --text-faint: #5f6b7d;

  --accent: #5aa9f8;
  --accent-dim: #2d6cb5;
  --accent-bg: rgba(90, 169, 248, 0.12);

  --green: #46c05f;
  --green-bg: rgba(70, 192, 95, 0.13);
  --red: #f4655c;
  --red-bg: rgba(244, 101, 92, 0.13);
  --amber: #e0a32e;
  --amber-bg: rgba(224, 163, 46, 0.13);
  --violet: #a983f5;
  --violet-bg: rgba(169, 131, 245, 0.13);

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo,
          Consolas, "Liberation Mono", monospace;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --radius: 7px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);

  --wrap: 1400px;
  --gutter: 20px;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f7fa;
    --bg-raised: #ffffff;
    --bg-inset: #eef1f6;
    --panel: #ffffff;
    --border: #d8dee9;
    --border-strong: #b9c3d3;

    --text: #1a2231;
    --text-dim: #5b6779;
    --text-faint: #8b97a8;

    --accent: #1b62c4;
    --accent-dim: #4b8ada;
    --accent-bg: rgba(27, 98, 196, 0.09);

    --green: #1a7f37;
    --green-bg: rgba(26, 127, 55, 0.1);
    --red: #cf222e;
    --red-bg: rgba(207, 34, 46, 0.1);
    --amber: #9a6700;
    --amber-bg: rgba(154, 103, 0, 0.11);
    --violet: #6639ba;
    --violet-bg: rgba(102, 57, 186, 0.1);

    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px -14px rgba(16, 24, 40, 0.2);
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.55;
  /* A long TXT record would otherwise force a horizontal scrollbar across the
   * whole page. */
  overflow-wrap: break-word;
}

/* `hidden` has to win over every display rule that follows, or an element the
 * markup says is hidden stays on screen the moment something gives it a
 * display value. */
[hidden] { display: none !important; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 640; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.06rem; }
h3 { font-size: 0.95rem; }

p { margin: 0 0 0.75rem; }
p:last-child { margin-bottom: 0; }

.wrap {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 var(--gutter);
  /* Grid and flex children default to a minimum of their content, which lets
   * a wide table push the whole page wider than the screen. This is the fix,
   * and it has to be repeated on every container that holds a table. */
  min-width: 0;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: 10px 16px;
}
.skip:focus { left: 8px; top: 8px; }

/* ---------------------------------------------------------------- header */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 11px;
  padding-bottom: 11px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); flex: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  line-height: 1;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--mono); font-size: 0.95rem; letter-spacing: 0.02em; }
.brand-text span {
  font-size: 0.7rem; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.08em;
}

.site-nav { display: flex; gap: 4px; flex: 1 1 auto; flex-wrap: wrap; }
.site-nav a {
  font-size: 0.85rem;
  padding: 7px 11px;
  border-radius: var(--radius);
  color: var(--text-dim);
  white-space: nowrap;
}
.site-nav a:hover { color: var(--text); background: var(--bg-raised); text-decoration: none; }
.site-nav a.active { color: var(--accent); background: var(--accent-bg); }

.session { display: flex; align-items: center; gap: 10px; flex: none; font-size: 0.82rem; }
.session .who { color: var(--text-dim); font-family: var(--mono); font-size: 0.78rem; }

.nav-toggle {
  display: none;
  flex: none;
  width: 38px; height: 34px;
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
}
.nav-toggle .bars,
.nav-toggle .bars::before,
.nav-toggle .bars::after {
  position: absolute; left: 50%; transform: translateX(-50%);
  width: 16px; height: 2px; background: var(--text); border-radius: 2px;
}
.nav-toggle .bars { top: 50%; margin-top: -1px; }
.nav-toggle .bars::before { content: ""; top: -5px; }
.nav-toggle .bars::after { content: ""; top: 5px; }

/* ------------------------------------------------------------------ main */

main { padding: 24px 0 56px; }

.page-head { margin-bottom: 20px; display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.page-head > div:first-child { min-width: 0; flex: 1 1 auto; }
.page-head h1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; word-break: break-word; }
.page-head .lede { color: var(--text-dim); margin-top: 6px; font-size: 0.92rem; }
.page-head .head-actions { display: flex; gap: 8px; flex-wrap: wrap; flex: none; }

.breadcrumb { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 8px; }
.breadcrumb a { color: var(--text-dim); }
.breadcrumb a:hover { color: var(--accent); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
  overflow: hidden;
  min-width: 0;
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  flex-wrap: wrap;
}
.panel-head h2 { font-size: 0.95rem; }
.panel-head .subtitle { font-size: 0.8rem; color: var(--text-dim); margin: 3px 0 0; }
.panel-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel > .empty { padding: 22px 16px; color: var(--text-dim); text-align: center; margin: 0; }
.panel-body { padding: 16px; min-width: 0; }
.panel-body > p:first-child { margin-top: 0; }

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

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--bg-raised);
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--bg-raised); }
tbody tr.editing { background: var(--accent-bg); }
tbody tr.is-disabled td { opacity: 0.55; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); white-space: nowrap; }
td.nowrap, th.nowrap { white-space: nowrap; }
td.actions, th.actions { text-align: right; white-space: nowrap; width: 1%; }

.mono, td .mono { font-family: var(--mono); font-size: 0.83rem; }
.dim { color: var(--text-faint); }
.value { font-family: var(--mono); font-size: 0.82rem; word-break: break-word; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--ui);
  font-size: 0.82rem;
  font-weight: 550;
  padding: 7px 13px;
  color: var(--text);
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.3;
}
.btn:hover { border-color: var(--accent-dim); color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent-dim); border-color: var(--accent-dim); color: #fff; }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--red); border-color: var(--border-strong); }
.btn.danger:hover { border-color: var(--red); background: var(--red-bg); color: var(--red); }
.btn.small { font-size: 0.76rem; padding: 4px 9px; }
.btn[disabled], .btn:disabled { opacity: 0.5; cursor: not-allowed; }

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

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

form.inline { display: inline; }

.field { margin-bottom: 14px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim); margin-bottom: 5px; font-weight: 600;
}
.field .help { font-size: 0.78rem; color: var(--text-faint); margin-top: 5px; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], select, textarea {
  width: 100%;
  font-family: var(--mono);
  font-size: 0.84rem;
  padding: 8px 11px;
  color: var(--text);
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  min-width: 0;
}
select { font-family: var(--ui); }
textarea { font-size: 0.8rem; line-height: 1.5; resize: vertical; min-height: 120px; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

.checkbox { display: flex; align-items: flex-start; gap: 8px; font-size: 0.85rem; }
.checkbox input { width: auto; margin-top: 3px; flex: none; }
.checkbox label {
  text-transform: none; letter-spacing: 0; font-size: 0.85rem;
  color: var(--text); margin: 0; font-weight: 450;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  align-items: start;
}
.form-grid > * { min-width: 0; }
.form-grid .wide { grid-column: 1 / -1; }

/* The row that appears under a record when it is being edited. */
.row-form td { background: var(--bg-inset); padding: 14px 12px; }
.row-form .form-grid { margin-bottom: 12px; }

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

.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1.5;
}
.badge.type { color: var(--accent); background: var(--accent-bg); border-color: var(--accent-dim); }
.badge.ok, .badge.status-ok { color: var(--green); background: var(--green-bg); border-color: var(--green); }
.badge.warn, .badge.status-warn { color: var(--amber); background: var(--amber-bg); border-color: var(--amber); }
.badge.bad, .badge.status-fail { color: var(--red); background: var(--red-bg); border-color: var(--red); }
.badge.neutral { color: var(--text-dim); background: var(--bg-inset); border-color: var(--border-strong); }
.badge.signed { color: var(--violet); background: var(--violet-bg); border-color: var(--violet); }
.badge.source-manual { color: var(--text-dim); background: var(--bg-inset); border-color: var(--border-strong); }
.badge.source-vmmanager { color: var(--violet); background: var(--violet-bg); border-color: var(--violet); }
.badge.source-template { color: var(--accent); background: var(--accent-bg); border-color: var(--accent-dim); }
.badge.source-system { color: var(--amber); background: var(--amber-bg); border-color: var(--amber); }
.badge.source-import { color: var(--green); background: var(--green-bg); border-color: var(--green); }

/* --------------------------------------------------------------- numbers */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 0;
}
.stat .label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim);
}
.stat .value {
  font-family: var(--mono); font-size: 1.5rem; font-weight: 600;
  margin-top: 4px; font-variant-numeric: tabular-nums; line-height: 1.1;
}
.stat .note { font-size: 0.76rem; color: var(--text-faint); margin-top: 3px; }
.stat.good .value { color: var(--green); }
.stat.bad .value { color: var(--red); }
.stat.warn .value { color: var(--amber); }
.stat.info .value { color: var(--accent); }

/* ----------------------------------------------------------- definitions */

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1px;
  /* Separators are drawn by each cell rather than by showing a background
   * through the gaps: a row whose last cells are empty would otherwise render
   * them as stray coloured blocks. */
  background: transparent;
  margin: 0;
}
.fact {
  background: var(--panel);
  box-shadow: 0 0 0 1px var(--border);
  padding: 12px 16px;
  min-width: 0;
}
.fact dt {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-dim); margin-bottom: 4px;
}
.fact dd { margin: 0; font-family: var(--mono); font-size: 0.86rem; word-break: break-word; }
.fact dd.plain { font-family: var(--ui); }

/* --------------------------------------------------------------- notices */

.notice {
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-inset);
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.notice strong { color: var(--text); }
.notice.good { border-color: var(--green); background: var(--green-bg); color: var(--text); }
.notice.warn { border-color: var(--amber); background: var(--amber-bg); color: var(--text); }
.notice.bad { border-color: var(--red); background: var(--red-bg); color: var(--text); }
.notice p:last-child { margin-bottom: 0; }
.notice ul { margin: 8px 0 0; padding-left: 20px; }
.notice li { margin-bottom: 4px; }

/* ------------------------------------------------------------------ pre */

pre.code {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.55;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  margin: 0;
  overflow-x: auto;
  white-space: pre;
  color: var(--text-dim);
  max-height: 560px;
}
pre.code.tall { max-height: none; }

code.inline {
  font-family: var(--mono); font-size: 0.82rem;
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 1px 5px;
  word-break: break-all;
}

/* --------------------------------------------------------------- filters */

.filters {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.filters input, .filters select { width: auto; min-width: 120px; }

/* ------------------------------------------------------------ checklist */

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  font-size: 0.86rem;
}
.checklist li:last-child { border-bottom: 0; }
.checklist .mark { flex: none; margin-top: 1px; }
.checklist .what { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-dim); display: block; margin-bottom: 2px; }

/* ---------------------------------------------------------------- login */

.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px var(--gutter);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}
.login-card .brand { justify-content: center; margin-bottom: 4px; }
.login-card h1 { font-size: 1.15rem; text-align: center; margin-bottom: 4px; }
.login-card .lede { text-align: center; color: var(--text-dim); font-size: 0.85rem; margin-bottom: 22px; }
.login-card input { font-family: var(--ui); }
.login-card .btn { width: 100%; justify-content: center; }
.login-foot { text-align: center; margin-top: 18px; font-size: 0.78rem; color: var(--text-faint); }

/* ---------------------------------------------------------------- misc */

.cols-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  align-items: start;
}
.cols-2 > * { min-width: 0; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 13px; flex-wrap: wrap; }
.pager a, .pager span {
  font-size: 0.82rem; padding: 6px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  color: var(--text-dim);
}
.pager a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pager .current { background: var(--accent-bg); color: var(--accent); border-color: var(--accent-dim); }

details.disclosure { border-top: 1px solid var(--border); }
details.disclosure > summary {
  cursor: pointer; padding: 11px 16px; font-size: 0.85rem; color: var(--text-dim);
  list-style: none; display: flex; align-items: center; gap: 8px;
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::before { content: "▸"; font-size: 0.7rem; }
details.disclosure[open] > summary::before { content: "▾"; }
details.disclosure > summary:hover { color: var(--text); }
details.disclosure .disclosure-body { padding: 0 16px 16px; }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 22px 0 36px;
  font-size: 0.82rem;
  color: var(--text-dim);
}
.site-footer p { margin-bottom: 6px; }

/* --------------------------------------------------------- narrow screens */

@media (max-width: 900px) {
  .header-inner { gap: 10px; }
  .nav-toggle { display: block; margin-left: auto; order: 2; }
  .session { order: 3; }
  .site-nav {
    order: 4; flex-basis: 100%;
    flex-direction: column; gap: 2px;
    display: none;
    padding-bottom: 6px;
  }
  .site-nav.open { display: flex; }
}

@media (max-width: 640px) {
  :root { --gutter: 14px; }
  body { font-size: 14px; }
  main { padding: 16px 0 40px; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .stat .value { font-size: 1.25rem; }
  .facts { grid-template-columns: 1fr 1fr; }
  table { font-size: 0.8rem; }
  thead th, tbody td { padding: 7px 9px; }
  .panel-head { padding: 11px 13px; }
  .panel-body { padding: 13px; }
  .page-head h1 { font-size: 1.25rem; }
}

@media (max-width: 420px) {
  .facts { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
