/*
 * The panel's appearance.
 *
 * Hand-written CSS, no framework, no fonts fetched from anywhere. The
 * content security policy this service sets refuses every external origin,
 * and that is not an inconvenience to work around: a control plane that
 * cannot be reached without a CDN is a control plane that is unavailable
 * exactly when a CDN is.
 *
 * The palette follows the operating system's, because somebody switching
 * advertising off at two in the morning should not be handed a white page.
 */

:root {
  color-scheme: light dark;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dcdfe4;
  --text: #14171c;
  --muted: #5d6570;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --danger: #c8342b;
  --ok: #1c7a4a;
  --warn: #9a6100;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1c2027;
    --surface-2: #23282f;
    --border: #333a44;
    --text: #e7eaee;
    --muted: #98a1ad;
    --accent: #5b8dff;
    --accent-text: #0d1117;
    --danger: #ff6b60;
    --ok: #57d295;
    --warn: #e0a33a;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 {
  font-size: 17px;
  margin: 0;
}

h2 {
  font-size: 15px;
  margin: 0;
}

p {
  margin: 0;
}

.sub {
  color: var(--muted);
  font-size: 13px;
}

/* --- sign in ----------------------------------------------------------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  display: grid;
  gap: 14px;
}

.login-card label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.login-card .sub {
  margin-bottom: 6px;
}

.login-steps {
  display: flex;
  gap: 12px;
  list-style: none;
  padding: 0;
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--muted);
}

.login-steps li.active {
  color: var(--text);
  font-weight: 600;
}

.login-card button.primary {
  width: 100%;
  padding: 10px 14px;
}

.totp-input {
  font-size: 22px;
  letter-spacing: 0.28em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* --- chrome ------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  flex: none;
  position: relative;
}

.mark::before,
.mark::after {
  content: "";
  position: absolute;
  background: var(--accent-text);
  border-radius: 2px;
}

.mark::before {
  left: 7px;
  right: 7px;
  top: 14px;
  height: 2px;
}

.mark::after {
  top: 7px;
  bottom: 7px;
  left: 14px;
  width: 2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.who {
  color: var(--muted);
  font-size: 13px;
}

.tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tabs button {
  border: 0;
  background: none;
  color: var(--muted);
  padding: 11px 13px;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tabs button:hover {
  color: var(--text);
}

.tabs button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

.foot {
  margin-top: 28px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.6;
}

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

.banner {
  margin: 12px 16px 0;
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13.5px;
}

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

.banner.error {
  border-color: var(--danger);
  color: var(--danger);
}

.problems {
  margin: 8px 0 0;
  padding-left: 18px;
  font-family: var(--mono);
  font-size: 12px;
}

.error {
  color: var(--danger);
  font-size: 13px;
}

.note {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 11px 14px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}

/* --- cards ------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.card-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 3px;
}

.card-body {
  padding: 16px;
  display: grid;
  gap: 14px;
}

/* --- fields ------------------------------------------------------------ */

.field {
  display: grid;
  gap: 5px;
}

.field .label {
  font-size: 13px;
  color: var(--muted);
}

.hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
  min-width: 0;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.toggle {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
}

.toggle input {
  margin: 2px 0 0;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex: none;
}

.toggle-body {
  display: grid;
  gap: 2px;
}

.toggle-label {
  font-size: 14px;
}

.inline-group {
  display: flex;
  gap: 16px;
}

.inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
}

.inline input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.add-inline {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.flag {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}

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

button {
  font: inherit;
  font-size: 13.5px;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

button.ghost {
  background: transparent;
}

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

button.danger:hover:not(:disabled) {
  border-color: var(--danger);
}

button.small {
  padding: 3px 9px;
  font-size: 12px;
}

.actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 2px;
}

/* --- rows -------------------------------------------------------------- */

.rows {
  display: grid;
  gap: 10px;
}

.row {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--surface-2);
}

.row.block {
  display: grid;
  gap: 12px;
}

.row-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

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

.row-sub {
  font-size: 12.5px;
  color: var(--muted);
}

.row-msg {
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex: none;
}

.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 6px 0;
}

.pill {
  font-size: 11px;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

.pill.live {
  color: var(--ok);
  border-color: var(--ok);
}

.pill.soon {
  color: var(--warn);
  border-color: var(--warn);
}

.pill.muted {
  opacity: 0.75;
}

.pill.scope {
  font-family: var(--mono);
}

.pill.type-error {
  color: var(--danger);
  border-color: var(--danger);
}

.pill.type-warning,
.pill.type-maintenance {
  color: var(--warn);
  border-color: var(--warn);
}

.pill.type-success {
  color: var(--ok);
  border-color: var(--ok);
}

.pill.type-promotion {
  color: var(--accent);
  border-color: var(--accent);
}

.document {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  max-height: 420px;
  overflow: auto;
  white-space: pre;
}

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

@media (max-width: 640px) {
  .row {
    flex-direction: column;
    align-items: stretch;
  }

  .row-actions {
    justify-content: flex-end;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 12px 14px;
  }
}

/* A destructive button that has been armed by a first click. It has four
   seconds to be confirmed, and it should be impossible to miss. */
button.armed {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  font-weight: 600;
}

/* --- two-step sign in ----------------------------------------------------- */

/* The QR sits on white whatever the theme is: a scanner needs the quiet
   zone and the contrast the symbol was drawn with, and a dark-mode panel
   that tints it is a symbol that reads on some phones and not others. */
.qr {
  display: block;
  width: 240px;
  height: 240px;
  padding: 8px;
  background: #fff;
  border-radius: 8px;
  image-rendering: pixelated;
}

/* The secret and the recovery codes. Monospace and selectable, because the
   whole job of this block is to be copied correctly. */
.secret {
  margin: 12px 0;
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  line-height: 1.8;
  letter-spacing: 0.08em;
  white-space: pre;
  overflow-x: auto;
  background: rgba(127, 127, 127, 0.12);
  border-radius: 8px;
  user-select: all;
}

/* "Start again" under the code field: a way back, not a second call to
   action competing with Verify. */
button.link {
  margin-top: 10px;
  padding: 0;
  background: none;
  border: 0;
  color: inherit;
  opacity: 0.7;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}
button.link:hover { opacity: 1; }
