:root {
  color-scheme: dark;
  --bg: #0b0d13;
  --bg-soft: #10131c;
  --panel: #151925;
  --panel-2: #1b2030;
  --border: #2a3042;
  --text: #e8ebf4;
  --muted: #98a1b6;
  --accent: #7c8cff;
  --accent-2: #a78bfa;
  --ok: #34d399;
  --off: #fb7185;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
  --radius: 16px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% -10%, rgba(124, 140, 255, 0.18), transparent 34rem),
    radial-gradient(circle at 90% 0%, rgba(167, 139, 250, 0.12), transparent 30rem),
    var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 56px;
}

main.narrow { max-width: 460px; margin-top: 10vh; }

h1 {
  font-size: 28px;
  line-height: 1.2;
  margin: 4px 0 22px;
  letter-spacing: -0.02em;
}
h2 {
  font-size: 18px;
  margin: 30px 0 12px;
  letter-spacing: -0.01em;
}
h3 { font-size: 15px; margin: 0 0 4px; }

header.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: rgba(11, 13, 19, 0.82);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

header.top .brand {
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
header.top nav { display: flex; gap: 18px; flex: 1; flex-wrap: wrap; }
header.top nav a { color: var(--muted); font-size: 14px; }
header.top nav a:hover { color: var(--text); }

form.inline { display: inline; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
button:hover, .button:hover {
  border-color: var(--accent);
  background: #22283a;
  text-decoration: none;
}
button:active, .button:active { transform: translateY(1px); }
button.primary, .button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(124, 140, 255, 0.25);
}
button.danger {
  color: #fecdd3;
  border-color: #7f1d2d;
  background: #2a141a;
}
.link-button {
  min-height: auto;
  background: none;
  border: none;
  color: var(--muted);
  padding: 0;
}
.link-button:hover { color: var(--text); background: none; }

.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.018), transparent), var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.stack { display: flex; flex-direction: column; gap: 15px; }

label {
  display: block;
  font-size: 12px;
  line-height: 1.3;
  color: var(--muted);
  letter-spacing: 0.02em;
}

input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
}
input:hover, select:hover, textarea:hover { border-color: #3a435a; }
input[type="checkbox"] { width: auto; min-height: auto; }
label.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 14px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(124, 140, 255, 0.55);
  outline-offset: 1px;
  border-color: var(--accent);
}
textarea {
  resize: vertical;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px 20px;
  align-items: end;
}
.grid > div {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}
.grid-heading {
  grid-column: 1 / -1;
  margin-top: 6px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.grid-heading:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.meta, .actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 18px;
}
.meta {
  padding: 12px 16px;
  background: rgba(21, 25, 37, 0.7);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-size: 13px;
}
.meta strong { color: var(--text); }
.actions-bar {
  padding: 14px;
  background: rgba(21, 25, 37, 0.6);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.actions-bar form { margin: 0; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
}
.badge.ok { color: #bbf7d0; border-color: #166534; background: #0f2417; }
.badge.off { color: #fecdd3; border-color: #7f1d2d; background: #2a141a; }
.badge.neutral { color: var(--muted); }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 700;
  background: rgba(255,255,255,0.02);
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(124, 140, 255, 0.045); }
td.actions { white-space: nowrap; }
td.actions > * { margin-right: 8px; }

table.history td { font-size: 13px; }

/* Thumbnail of an archived incoming attachment in the contact card. */
.media-thumb {
  display: block;
  max-width: 120px;
  max-height: 120px;
  border-radius: 6px;
  object-fit: cover;
}
.nowrap { white-space: nowrap; }

.flash {
  padding: 11px 14px;
  border-radius: 11px;
  border: 1px solid #365314;
  background: #14210d;
  color: #d9f99d;
  margin-bottom: 16px;
}
.flash.error { border-color: #7f1d2d; background: #2a141a; color: #fecdd3; }

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

pre.logs {
  background: #080a0f;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  max-height: 70vh;
}

.qr {
  width: min(320px, 100%);
  background: #fff;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
}
.qr svg { display: block; width: 100%; height: auto; }

details {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--bg-soft);
  margin-bottom: 14px;
}
details summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
}
details[open] summary { margin-bottom: 12px; }

@media (max-width: 820px) {
  header.top {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 10px 14px;
  }
  header.top nav {
    gap: 12px;
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }
  header.top nav a { white-space: nowrap; }

  main {
    padding: 18px 12px calc(40px + env(safe-area-inset-bottom));
  }
  h1 { font-size: 22px; margin-bottom: 16px; }
  h2 { font-size: 17px; margin-top: 22px; }

  .card { padding: 14px; border-radius: 14px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }

  /* 16px stops iOS from zooming the page on focus. */
  input, select, textarea { font-size: 16px; }

  /* Wide tables scroll instead of stretching the page. */
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  th, td { padding: 9px 10px; }

  .meta { font-size: 12px; gap: 8px 12px; padding: 10px 12px; }
  .actions-bar { align-items: stretch; padding: 12px; }
  .actions-bar form, .actions-bar button { width: 100%; }
  .actions-bar form { margin-bottom: 8px; }

  .qr { width: min(240px, 100%); }
  pre.logs { font-size: 11px; padding: 12px; }
}
