/* Follows files.teatea.uk (web-arpp-files/public/style.css): same tokens, fonts, header and controls. */
:root {
  color-scheme: light;
  --bg: #cfd6da;
  --bg-2: #dce2e5;
  --surface: #e6ebed;
  --surface-2: #d5dce0;
  --border: #a8b3ba;
  --text: #3a2618;
  --muted: #5f6a70;
  --accent: #a67b35;
  --accent-2: #875f28;
  --accent-soft: rgba(166, 123, 53, 0.18);
  --danger: #8b3a3a;
  --danger-soft: rgba(139, 58, 58, 0.12);
  --ok: #3f6b3a;
  --ok-soft: rgba(63, 107, 58, 0.14);
  --shadow: 0 8px 22px rgba(40, 28, 18, 0.1);
  --radius: 12px;
  --font-ui: "Outfit", system-ui, sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  overflow-y: scroll;
}

body {
  margin: 0;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  font-family: var(--font-ui);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 480px at 82% -8%, rgba(166, 123, 53, 0.1), transparent 58%),
    radial-gradient(700px 420px at 8% 0%, rgba(230, 235, 237, 0.55), transparent 55%),
    radial-gradient(circle at 20% 70%, rgba(62, 36, 22, 0.04), transparent 40%),
    repeating-radial-gradient(
      circle at 92% 88%,
      transparent 0 18px,
      rgba(166, 123, 53, 0.03) 18px 19px,
      transparent 19px 36px
    );
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

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

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.15;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
  font-weight: 650;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
}

h2 {
  font-size: 1.2rem;
  margin-top: 2.25rem;
}

.container {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 0 1.25rem;
}

.container.wide {
  width: min(1440px, 100%);
}

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

.small {
  font-size: 0.85rem;
}

.mono,
code,
pre {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  background: rgba(207, 214, 218, 0.88);
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 68px;
  height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  font-weight: 700;
  color: var(--text);
  font-size: 1.05rem;
  font-family: var(--font-display);
}

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

.brand-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--accent), var(--accent-2));
  color: #e6ebed;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  border: 2px solid rgba(230, 235, 237, 0.45);
  box-shadow: 0 2px 0 #c4ad7e inset, 0 3px 10px rgba(40, 28, 18, 0.14);
}

/* Telemetry uses the cup of tea image (same as the favicon) in place of the files site's lettered disc. */
.brand-cup {
  display: block;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.brand-cup-lg {
  width: 72px;
  height: 72px;
  margin: 0 auto 1.25rem;
}

.brand-mark-lg {
  width: 64px;
  height: 64px;
  font-size: 2rem;
  margin: 0 auto 1.25rem;
}

.nav {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  font-weight: 600;
  min-width: 0;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.nav a {
  color: var(--muted);
}

.nav a:hover {
  color: var(--text);
}

.nav-tabs a {
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  line-height: 1.2;
  white-space: nowrap;
}

.nav-tabs a.nav-cta {
  background: var(--accent-soft);
  color: var(--accent-2);
  border-color: var(--border);
}

.nav-tabs a.nav-cta:hover {
  background: var(--accent);
  color: #e6ebed;
  border-color: var(--accent);
}

.refresh-status {
  min-width: 7.5rem;
  text-align: right;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.nav-logout-form {
  margin: 0;
  flex-shrink: 0;
}

.nav-logout {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
}

.nav-logout:hover {
  color: var(--text);
}

/* Page */
body > main {
  flex: 1 1 auto;
}

.form-page {
  padding: 3rem 0 5rem;
}

.form-wrap {
  max-width: 520px;
}

.login-wrap {
  margin: 4rem auto 0;
  text-align: center;
}

.eyebrow {
  display: inline-block;
  margin: 0 0 1rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-2);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.form-lede {
  margin: 0.5rem 0 1.75rem;
}

.form-error {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 600;
}

.error-page {
  text-align: center;
  padding: 3rem 0;
}

.error-page .btn {
  margin-top: 1.5rem;
}

/* Buttons and inputs */
.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover,
button:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  color: var(--accent-2);
}

.btn-primary {
  padding: 0.8rem 1.4rem;
  font-size: 0.98rem;
  background: linear-gradient(160deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #e6ebed;
}

.btn-primary:hover {
  color: #e6ebed;
  border-color: transparent;
}

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

button.danger:hover {
  background: rgba(139, 58, 58, 0.2);
  color: var(--danger);
  border-color: var(--danger);
}

input[type="text"] {
  flex: 1;
  min-width: 160px;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}

input[type="text"]:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

/* Cards and stats */
.card {
  padding: 1rem 1.15rem;
  margin: 0 0 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card h2 {
  margin-top: 0;
}

.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 0 1rem;
}

/* Grid cells may shrink below their table's width; the table then scrolls in its own box. */
.grid2 > * {
  min-width: 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.9rem;
  margin: 0 0 2rem;
}

.stat {
  display: flex;
  flex-direction: column;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.stat .num {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.stat.alert {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.stat.alert .num {
  color: var(--danger);
}

/* Tables */
.scroll {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.scroll table {
  box-shadow: none;
}

th,
td {
  text-align: left;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--surface-2);
  white-space: nowrap;
  vertical-align: top;
}

th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: var(--bg-2);
}

tr.flag td {
  background: var(--accent-soft);
}

tr.live td {
  background: var(--ok-soft);
}

td form {
  margin: 0;
}

/* Pills (same shape as files' .file-type) */
.pill {
  display: inline-flex;
  width: fit-content;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pill.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Definition lists */
dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 1rem;
  margin: 0;
}

dt {
  color: var(--muted);
  font-weight: 600;
}

dd {
  margin: 0;
}

dl.inline {
  margin: 0.5rem 0 1.25rem;
}

/* Log viewer */
.logview {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 1rem;
  margin-top: 1.5rem;
}

.files {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.files a {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  color: var(--text);
  word-break: break-all;
  font-weight: 600;
  font-size: 0.9rem;
}

.files a:hover {
  border-color: var(--border);
  background: var(--surface);
}

.files a.on {
  background: var(--accent-soft);
  color: var(--accent-2);
  border-color: var(--border);
}

.file h2 {
  margin-top: 0;
  font-family: var(--font-mono);
  font-size: 1rem;
  letter-spacing: 0;
}

pre {
  margin: 0;
  padding: 1rem 1.15rem;
  max-height: 75vh;
  overflow: auto;
  white-space: pre;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--text);
  line-height: 1.5;
}

@media (max-width: 720px) {
  .header-row {
    height: auto;
    min-height: 0;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand logout"
      "tabs tabs";
    gap: 0.75rem 0.85rem;
    align-items: center;
  }

  .brand {
    grid-area: brand;
  }

  .nav {
    display: contents;
  }

  .nav-logout-form {
    grid-area: logout;
    justify-self: end;
  }

  .nav-logout {
    padding: 0.35rem 0.15rem;
    font-size: 0.9rem;
  }

  .refresh-status {
    display: none;
  }

  .nav-tabs {
    grid-area: tabs;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
  }

  .nav-tabs a {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 0.2rem;
    border: 0;
    border-radius: 0;
    border-right: 1px solid var(--border);
    font-size: 0.85rem;
  }

  .nav-tabs a:last-child {
    border-right: 0;
  }

  .form-page {
    padding-top: 2rem;
    padding-bottom: 3.5rem;
  }

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

/* Customers: "Show tester" switch. A form POST (the CSP allows no scripts), saved in dashboard_prefs. */
.toggle-form {
  margin: 0 0 0.9rem;
}

.toggle,
.toggle:hover {
  gap: 0.6rem;
  padding: 0.35rem 0.2rem;
  border: 0;
  background: none;
  color: var(--text);
  transform: none;
  font-weight: 600;
}

.toggle-track {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(40, 28, 18, 0.25);
  transition: transform 0.15s ease;
}

.toggle[aria-checked="true"] .toggle-track {
  background: linear-gradient(160deg, var(--accent), var(--accent-2));
  border-color: transparent;
}

.toggle[aria-checked="true"] .toggle-thumb {
  transform: translateX(18px);
}

.toggle:focus-visible .toggle-track {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}

/* User page: sync button and the grouped products table. */
.sync-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--surface-2);
}

button:disabled {
  opacity: 0.6;
  cursor: progress;
  transform: none;
}

/* Products, laid out like /keycheck's embed: one field per provider, side by side. */
.keycheck {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.9rem;
}

.keycheck-field {
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.keycheck-field h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}

.keycheck-field ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.keycheck-field li {
  padding: 0.3rem 0;
}

.keycheck-field li + li {
  border-top: 1px solid var(--surface-2);
}

.kc-name::before {
  content: "• ";
  color: var(--muted);
}

.kc-time {
  display: block;
  padding-left: 0.85rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.warn-text {
  color: var(--danger);
}
