/* The admin panel's only stylesheet. Mobile first (390 px), then wider screens; no JavaScript anywhere. */

:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --text: #16191d;
  --muted: #555d6b;
  --line: #dde0e5;
  --input-line: #858d9b;
  --accent: #1d5bbf;
  --accent-dark: #164a9c;
  --accent-soft: #e7effb;
  --bar: #17202d;
  --bar-text: #d5dbe5;
  --focus: #1d5bbf;
  --bar-focus: #9cc2ff;
  --ok: #05603a;
  --ok-soft: #ecfdf3;
  --ok-line: #a6e9c3;
  --danger: #b42318;
  --danger-dark: #912018;
  --danger-soft: #fef3f2;
  --danger-line: #fbc9c4;
  --warn: #8a330c;
  --warn-soft: #fffaeb;
  --warn-line: #fbd98a;
  --radius: 12px;
}

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

[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Noto Sans Khmer", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: break-word;
}

h1,
h2 {
  line-height: 1.25;
  margin: 0;
}

h1 {
  font-size: 26px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

h2 {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 16px;
}

p {
  margin: 0;
}

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

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

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/*
 * The top bar. Phones: the name with your own links (password, sign out) on one row, the pages on the next, in one
 * row of pills. Wide screens: all on one row, your own links at the far end.
 */

.bar {
  background: var(--bar);
  color: #ffffff;
}

.bar-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 8px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "brand you"
    "nav nav";
  align-items: center;
  column-gap: 8px;
  row-gap: 4px;
}

.brand {
  grid-area: brand;
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-height: 44px;
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.nav {
  grid-area: nav;
  min-width: 0;
  /* Only on the narrowest phones do the pages not fit; then the row scrolls rather than wraps. */
  overflow-x: auto;
  scrollbar-width: none;
}

.nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 4px;
}

.nav li {
  flex: 1 0 auto;
}

.you {
  grid-area: you;
  display: flex;
  align-items: center;
  gap: 2px;
}

.you form {
  margin: 0;
}

.nav a,
.you a,
.nav-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 4px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--bar-text);
  font: inherit;
  font-size: 15px;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.nav a {
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.07);
}

.nav a:hover,
.you a:hover,
.nav-button:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.nav a[aria-current="page"],
.you a[aria-current="page"] {
  background: #ffffff;
  color: var(--bar);
}

.bar a:focus-visible,
.bar button:focus-visible {
  outline-color: var(--bar-focus);
}

/* The page */

.main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 16px 56px;
}

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

.page-head {
  margin-bottom: 24px;
}

.page-head .lead {
  margin-top: 6px;
}

.card {
  margin-top: 24px;
  padding: 20px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card > h1 {
  font-size: 22px;
  margin-bottom: 12px;
}

.card > p + p,
.card > p + .warning {
  margin-top: 12px;
}

.confirm {
  max-width: 560px;
  margin-top: 0;
}

.note {
  color: var(--muted);
  font-size: 15px;
}

.tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 600;
  vertical-align: 2px;
}

.name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Messages */

.flash,
.alert,
.warning {
  padding: 12px 16px;
  border: 1px solid;
  border-radius: 10px;
  font-weight: 600;
}

.flash {
  margin-bottom: 20px;
  background: var(--ok-soft);
  border-color: var(--ok-line);
  color: var(--ok);
}

.alert {
  margin-bottom: 20px;
  background: var(--danger-soft);
  border-color: var(--danger-line);
  color: var(--danger);
}

.warning {
  background: var(--warn-soft);
  border-color: var(--warn-line);
  color: var(--warn);
}

/* Forms */

.stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 0;
}

.field label {
  display: block;
  font-weight: 600;
}

.help {
  color: var(--muted);
  font-size: 15px;
}

.field-error {
  margin-top: 2px;
  color: var(--danger);
  font-size: 15px;
  font-weight: 600;
}

.field input {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--input-line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

.field input:focus-visible {
  outline-offset: 1px;
  border-color: var(--focus);
}

.field.invalid input {
  border: 2px solid var(--danger);
  padding: 9px 11px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.button.wide {
  width: 100%;
}

.button.secondary {
  background: var(--surface);
  border-color: var(--input-line);
  color: var(--text);
}

.button.secondary:hover {
  background: var(--bg);
}

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

.button.danger:hover {
  background: var(--danger-dark);
  border-color: var(--danger-dark);
}

.button.small {
  min-height: 44px;
  padding: 0 16px;
  font-size: 15px;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 20px 0 0;
}

.buttons .button {
  flex: 1 1 140px;
}

/* A lone button keeps its own width, like every other single button; only pairs share the row. */
.buttons .button:only-child {
  flex: 0 0 auto;
}

/* Lists: stacked rows on phones, a table from 640 px */

.list,
.list tbody,
.list tr,
.list td {
  display: block;
}

.list thead {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.list tr {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.list td {
  grid-column: 1;
  overflow-wrap: anywhere;
}

.list td[data-label] {
  color: var(--muted);
  font-size: 15px;
}

.list td[data-label]::before {
  content: attr(data-label) " ";
}

.list td.actions {
  grid-column: 2;
  grid-row: 1 / span 4;
}

.list td.actions:empty {
  display: none;
}

/* Lists of operators and groups: a card each, the name first, details under it */

.page-head.with-action {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.page-head.with-action > .button {
  width: 100%;
}

.back {
  margin: -8px 0 8px;
}

.back a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
  text-decoration: none;
}

.back a::before {
  content: "\2039";
  margin-right: 8px;
  font-size: 22px;
  line-height: 1;
}

.back a:hover {
  text-decoration: underline;
}

.items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.item {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.item-head .button {
  flex: none;
  margin: -4px -4px 0 0;
}

.item-title {
  margin: 0;
  padding-top: 4px;
  font-size: 19px;
  overflow-wrap: anywhere;
}

.facts {
  margin-top: 6px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.facts > p + p {
  margin-top: 2px;
}

.summary .facts {
  margin-top: 0;
  font-size: 16px;
}

/* How the last 5D check went: words first, and a warning box when it failed */

.facts > .status {
  margin: 6px 0;
  color: var(--text);
  font-weight: 600;
}

/* A plain line like the facts around it; only the boxed outcomes below get room around them. */
.facts > .status.ok {
  margin: 2px 0 0;
}

.status.ok {
  color: var(--ok);
}

.status.ok .when::before {
  content: "\00b7";
  margin-right: 6px;
}

.status .when {
  color: var(--muted);
  font-weight: 400;
}

.status.problem,
.status.gone {
  padding: 8px 12px;
  border-radius: 8px;
}

.status.problem {
  background: var(--warn-soft);
  border: 1px solid var(--warn-line);
  color: var(--warn);
}

.status.problem .when,
.status.gone .when {
  display: block;
  font-size: 14px;
}

.status.gone {
  background: var(--bg);
  border: 1px dashed var(--input-line);
  color: var(--text);
}

/* A second ring outside the border: it follows the rounded corners, unlike a stripe on one side. */
.item.needs-attention,
.card.needs-attention {
  border-color: var(--warn-line);
  box-shadow: 0 0 0 1px var(--warn-line);
}

.item.left .item-title {
  color: var(--muted);
}

.empty {
  padding: 20px 16px;
  background: var(--surface);
  border: 1px dashed var(--input-line);
  border-radius: var(--radius);
  color: var(--muted);
}

/* Pages and cards with forms: as wide as their fields, which fill them */

.narrow {
  max-width: 560px;
}

.card > h2 + .lead {
  margin: -8px 0 16px;
}

.group-fields {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
  margin: 0;
  padding: 20px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.group-fields legend {
  float: left;
  width: 100%;
  padding: 0;
  font-size: 17px;
  font-weight: 700;
}

.group-fields legend + .help {
  clear: both;
  margin-top: -16px;
}

.check-again {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin: 24px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.check-again .help {
  flex: 1 1 200px;
}

.button.danger-outline {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
}

.button.danger-outline:hover {
  background: var(--danger-soft);
}

.card .buttons:first-child,
.card > .lead + .buttons {
  margin-top: 0;
}

/* The activity list */

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.log li {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}

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

.log time {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* The sign-in page */

.signin {
  display: flex;
  justify-content: center;
  padding: 40px 16px;
}

.signin-card {
  width: 100%;
  max-width: 420px;
  padding: 28px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.signin-brand {
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.signin-card .lead {
  margin: 6px 0 24px;
}

.signin .stack .button {
  margin-top: 4px;
}

/* Wider screens */

@media (min-width: 640px) {
  .main {
    padding: 32px 24px 64px;
  }

  h1 {
    font-size: 30px;
  }

  .card {
    padding: 24px;
  }

  .card > h1 {
    font-size: 24px;
  }

  .buttons .button {
    flex: 0 0 auto;
  }

  .signin {
    padding-top: 12vh;
  }

  .signin-card {
    padding: 36px 32px;
  }

  .list {
    display: table;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
  }

  .list thead {
    display: table-header-group;
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
  }

  .list tbody {
    display: table-row-group;
  }

  .list tr {
    display: table-row;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
  }

  .list th,
  .list td,
  .list td.actions:empty {
    display: table-cell;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
  }

  .list th {
    background: #f8f9fb;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
  }

  .list tbody tr:last-child td,
  .list tbody tr:last-child td.actions:empty {
    border-bottom: 0;
  }

  .list td[data-label] {
    color: var(--text);
    font-size: 16px;
  }

  .list td[data-label]::before {
    content: none;
  }

  .page-head.with-action > .button {
    width: auto;
  }

  .item {
    padding: 18px 20px;
  }

  .log li {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 16px;
  }

  .log time {
    font-size: 15px;
    line-height: 1.6;
  }

  .list td.actions {
    width: 1%;
    padding-top: 6px;
    padding-bottom: 6px;
    text-align: right;
    white-space: nowrap;
  }
}

@media (min-width: 900px) {
  .items {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .bar-inner {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "brand nav you";
    column-gap: 32px;
    padding: 10px 24px;
  }

  .nav li {
    flex: none;
  }

  .nav a,
  .you a,
  .nav-button {
    padding: 4px 14px;
  }

  .nav a {
    background: transparent;
  }

  /* Your own links, set apart from the pages by a thin line. */
  .you {
    padding-left: 16px;
    border-left: 1px solid rgba(255, 255, 255, 0.16);
  }
}

/* The narrowest phones (360 px): the pages still fit on their row. */
@media (max-width: 374px) {
  .nav a,
  .you a,
  .nav-button {
    font-size: 14px;
  }
}
