/* Shared with files.teatea.uk: web-arpp-files/public/base.css is a symlink to this file, so both sites
   have the same header and nav. Its own page styles are in web-arpp-files/public/style.css. */
:root {
  color-scheme: dark;
  --bg: #0b080b;
  --bg-2: #110c11;
  --surface: #181118;
  --surface-2: #221822;
  --border: #382638;
  --text: #f3eaf0;
  --muted: #a8949f;
  --accent: #f02d8a;
  --accent-2: #ff6fb1;
  --teal: #2fd6bb;
  --gold: #f2c14e;
  --on-accent: #1a0611;
  --accent-soft: rgba(240, 45, 138, 0.16);
  --danger: #ff6b6b;
  --danger-soft: rgba(255, 107, 107, 0.12);
  --ok: #2fd6bb;
  --ok-soft: rgba(47, 214, 187, 0.14);
  --shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  --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(1000px 520px at 0% -8%, rgba(240, 45, 138, 0.13), transparent 58%),
    radial-gradient(900px 480px at 100% 100%, rgba(47, 214, 187, 0.09), transparent 55%),
    radial-gradient(circle at 20% 70%, rgba(240, 45, 138, 0.03), transparent 40%),
    repeating-radial-gradient(
      circle at 92% 88%,
      transparent 0 18px,
      rgba(47, 214, 187, 0.025) 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(11, 8, 11, 0.85);
  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: var(--on-accent);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  border: 2px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 2px 0 rgba(255, 255, 255, 0.25) inset, 0 3px 12px rgba(240, 45, 138, 0.35);
}

/* The Tea Plugins cup (tea-plugins-mark.png, transparent) on a rounded tile, same as teatea.uk's brand mark. */
.brand-cup {
  display: block;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  object-fit: contain;
  background: linear-gradient(135deg, #2a1424, #0f2421);
  box-shadow: 0 6px 16px rgba(240, 45, 138, 0.25);
}

.brand-cup-lg {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  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;
  align-self: stretch;
  justify-content: flex-end;
  gap: 0.35rem;
  font-weight: 600;
  min-width: 0;
}

/* Tabs run the full height of the header, so the selected one is a solid block from top to bottom. */
.nav-tabs {
  display: flex;
  align-items: stretch;
  align-self: stretch;
  gap: 0;
  min-width: 0;
}

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

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

.nav-tabs a {
  display: flex;
  align-items: center;
  padding: 0 1rem;
  border: 0;
  border-radius: 0;
  line-height: 1.2;
  white-space: nowrap;
}

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

/* The tab you're on stays as it is; the others light up on hover. */
.nav-tabs a.nav-cta:hover {
  color: var(--accent-2);
}

.nav-tabs a:not(.nav-cta):hover {
  background: var(--accent);
  color: var(--on-accent);
  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: var(--on-accent);
}

.btn-primary:hover {
  color: var(--on-accent);
  border-color: transparent;
}

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

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

input[type="text"],
input[type="date"] {
  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"] {
  flex: 1;
  min-width: 160px;
}

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

input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* A short label beside its input, e.g. "From [date]". */
.field-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.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;
}

.card-actions {
  margin: 1rem 0 0;
}

.grid2 {
  display: grid;
  /* 480px fits a 4-column table (IP, location, sessions, last seen) without scrolling. */
  grid-template-columns: repeat(auto-fit, minmax(min(480px, 100%), 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;
}

/* Narrow side-by-side tables: cells wrap at spaces so they fit instead of scrolling sideways.
   Headers never wrap. */
.grid2 td {
  white-space: normal;
}

/* Secondary details under a cell's main value (e.g. PC name / OS under the player). */
.cell-sub {
  display: block;
  max-width: 22rem;
  white-space: normal;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

/* Sortable column headers (Customers). */
th a.sort {
  color: inherit;
}

th a.sort:hover,
th a.sort.on {
  color: var(--accent-2);
}

/* Keep headings full size when they use the code font (account IDs, IPs). */
h1.mono {
  font-size: clamp(1.4rem, 3vw, 2rem);
  letter-spacing: 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;
}

button.small {
  padding: 0.2rem 0.55rem;
  font-size: 0.78rem;
}

/* 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;
  align-items: start;
}

.log-side {
  min-width: 0;
}

.log-side h1 {
  overflow-wrap: anywhere;
}

.log-side .files {
  margin-top: 1.25rem;
}

.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;
}

/* Header: brand and Log out on one row, tabs as a full-width bar under them.
   1360px is where the owner's 10-tab nav (dashboard, Loadouts and file host, see partials/header.ejs) stops fitting on one line. */
@media (max-width: 1360px) {
  .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-auto-flow: column;
    grid-auto-columns: 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;
  }
}

@media (max-width: 720px) {
  /* Rows of three: 6 dashboard tabs = two rows, 10 with Loadouts and the files tabs (.all) = four rows. */
  .nav-tabs {
    grid-auto-flow: row;
    grid-template-columns: repeat(3, 1fr);
  }

  .nav-tabs a:nth-child(3n) {
    border-right: 0;
  }

  .nav-tabs a:nth-child(-n+3),
  .nav-tabs.all a:nth-child(-n+9) {
    border-bottom: 1px solid var(--border);
  }

  .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(0, 0, 0, 0.5);
  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);
}

/* Kills page: "Kill log" / "Totals" switch, and the period picker on Totals. */
.subtabs,
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem;
  margin: 0 0 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.subtabs a,
.seg a {
  padding: 0.45rem 0.9rem;
  border-radius: calc(var(--radius) - 4px);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.subtabs a:hover,
.seg a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.subtabs a.active,
.seg a.active {
  background: var(--accent-soft);
  color: var(--accent-2);
}

.subtabs {
  display: flex;
  width: fit-content;
}

.seg a {
  font-size: 0.82rem;
  padding: 0.35rem 0.75rem;
}

/* Kill totals: built to be shown to customers ("Export image" draws the same figures, public/kills-export.js). */
.totals-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.totals-export {
  font-size: 0.82rem;
  padding: 0.5rem 0.9rem;
}

.totals-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem 1.5rem;
  padding: 1.4rem 1.5rem;
  margin: 0 0 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(150deg, var(--accent-soft), transparent 60%), var(--surface);
  box-shadow: var(--shadow);
}

.totals-figure {
  display: flex;
  flex-direction: column;
  color: var(--muted);
  font-weight: 600;
}

.totals-num {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 6vw, 3.2rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.totals-figure:first-child .totals-num {
  color: var(--accent-2);
}

.totals-note {
  grid-column: 1 / -1;
  margin: 0;
}

.boss-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: 0.9rem;
}

.boss-tile {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.boss-tile h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--muted);
}

.boss-num {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.bar {
  display: block;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
}

.bar-track {
  fill: var(--surface-2);
}

.bar-normal {
  fill: var(--teal);
}

.bar-awakened {
  fill: var(--accent);
}

.boss-split {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0.15rem 0 0;
  color: var(--muted);
}

.dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
}

.dot-normal {
  background: var(--teal);
}

.dot-awakened {
  background: var(--accent);
}

.dot-quest,
.bar-quest {
  background: var(--gold);
  fill: var(--gold);
}

.split-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-right: 0.6rem;
}

/* Variant label in kill tables. */
.variant-quest {
  color: var(--gold);
  font-weight: 600;
}

.variant-awakened {
  color: var(--accent-2);
  font-weight: 600;
}

/* Loadouts tab: the loadout app from mk3-tea-simulations, framed under the nav (src/loadouts.js). */
/* The Loadouts page uses the whole window width, not the 1440px column. */
.container.wide:has(> .loadout-frame) {
  width: 100%;
}

.loadout-frame {
  display: block;
  width: 100%;
  height: calc(100vh - 68px - 10rem);
  min-height: 640px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #0f1512;
}
