/* Ads-Reporter base styles. Colors are tokens; dark mode redefines them. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-muted: #eef0f3;
  --border: #dfe2e7;
  --text: #1c2129;
  --text-muted: #5d6573;
  --accent: #2459d6;
  --accent-contrast: #ffffff;
  --accent-soft: #e6edfc;
  --sidebar-bg: #ffffff;
  --danger: #c0352b;
  --danger-soft: #fbe9e7;
  --warning: #a86400;
  --success: #1e7f4f;
  --focus: #2459d6;
  --radius: 8px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111418;
    --surface: #1a1e24;
    --surface-muted: #232830;
    --border: #2e343d;
    --text: #e6e8ec;
    --text-muted: #9aa3b0;
    --accent: #6d97ff;
    --accent-contrast: #0b1220;
    --accent-soft: #1e2a45;
    --sidebar-bg: #15191e;
    --danger: #ff7b70;
    --danger-soft: #3a1d1b;
    --warning: #f0a83c;
    --success: #4cc38a;
    --focus: #8fb0ff;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111418;
  --surface: #1a1e24;
  --surface-muted: #232830;
  --border: #2e343d;
  --text: #e6e8ec;
  --text-muted: #9aa3b0;
  --accent: #6d97ff;
  --accent-contrast: #0b1220;
  --accent-soft: #1e2a45;
  --sidebar-bg: #15191e;
  --danger: #ff7b70;
  --danger-soft: #3a1d1b;
  --warning: #f0a83c;
  --success: #4cc38a;
  --focus: #8fb0ff;
  --shadow: none;
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

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

h1 {
  font-size: 1.5rem;
  font-weight: 650;
}

h2 {
  font-size: 1.125rem;
  font-weight: 600;
}

p {
  margin: 0 0 1em;
}

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

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-muted);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* --- Layout ------------------------------------------------------------ */

.layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.25rem 0.875rem;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
}

.content {
  padding: 2rem 2.5rem;
  max-width: 1400px;
  width: 100%;
}

.page-header {
  margin-bottom: 1.5rem;
}

/* --- Brand ------------------------------------------------------------- */

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 0.5rem;
  font-weight: 650;
  font-size: 1.05rem;
}

.brand-large {
  font-size: 1.25rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background:
    linear-gradient(135deg, var(--accent) 0 50%, transparent 50%),
    linear-gradient(135deg, transparent 0 50%, var(--success) 50%);
  flex: none;
}

/* --- Navigation ---------------------------------------------------------- */

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

a.nav-item:hover {
  background: var(--surface-muted);
}

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-item.is-disabled {
  color: var(--text-muted);
  opacity: 0.6;
  cursor: default;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem 0.5rem 0;
  border-top: 1px solid var(--border);
}

.sidebar-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.sidebar-actions form {
  margin: 0;
}

.user {
  font-size: 0.85rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Theme toggle label shows the mode you switch to. */
.theme-label-dark {
  display: none;
}

:root[data-theme="dark"] .theme-label-light {
  display: none;
}

:root[data-theme="dark"] .theme-label-dark {
  display: inline;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-label-light {
    display: none;
  }

  :root:not([data-theme="light"]) .theme-label-dark {
    display: inline;
  }
}

/* --- Components ---------------------------------------------------------- */

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

.empty-state {
  max-width: 640px;
}

.empty-state p {
  color: var(--text-muted);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 36px;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--surface-muted);
}

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

.button-primary:hover {
  background: var(--accent);
  filter: brightness(1.08);
}

.button-ghost {
  background: transparent;
  min-height: 32px;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

.button-block {
  width: 100%;
}

.alert {
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.alert p:last-child {
  margin-bottom: 0;
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
}

.messages {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
}

.message {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  background: var(--accent-soft);
  margin-bottom: 0.5rem;
}

.message-error {
  background: var(--danger-soft);
  color: var(--danger);
}

/* --- Forms --------------------------------------------------------------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.field label {
  font-weight: 550;
  font-size: 0.9rem;
}

.field input {
  min-height: 40px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

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

/* --- Auth pages ---------------------------------------------------------- */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem 1rem;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem;
}

.auth-title {
  font-size: 1.25rem;
  text-align: center;
  margin-bottom: 1.25rem;
}

/* --- Small screens ------------------------------------------------------- */

@media (max-width: 760px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    /* Extra height goes to the content, not to the stacked sidebar. */
    grid-template-rows: auto 1fr;
  }

  .hide-narrow {
    display: none;
  }

  .sidebar {
    position: static;
    height: auto;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar-footer {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border-top: 0;
    padding: 0;
  }

  .sidebar-footer .user {
    flex: 1 1 auto;
    min-width: 0;
  }

  .sidebar-actions {
    flex-wrap: nowrap;
    flex-shrink: 0;
  }

  .content {
    padding: 1.25rem 1rem;
  }
}

/* --- Page structure ---------------------------------------------------- */

.page-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header h1 {
  margin-bottom: 0.25rem;
}

.page-subtitle {
  color: var(--text-muted);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.section {
  margin-top: 2rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.card-flush {
  padding: 0;
  overflow: hidden;
}

.notice {
  background: var(--accent-soft);
  border-color: transparent;
  box-shadow: none;
  padding: 1rem 1.25rem;
}

.notice p {
  margin: 0;
}

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

.small {
  font-size: 0.85rem;
  font-weight: 400;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.pre-line {
  white-space: pre-line;
  margin: 0;
}

.strong-link {
  font-weight: 600;
  text-decoration: none;
}

.strong-link:hover {
  text-decoration: underline;
}

/* --- Badges ------------------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface-muted);
  color: var(--text-muted);
  vertical-align: middle;
}

.badge-success {
  background: color-mix(in srgb, var(--success) 15%, transparent);
  color: var(--success);
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

/* --- Tables ------------------------------------------------------------- */

.table-scroll {
  /* Containing block, so absolutely positioned content (e.g. .visually-hidden)
     is clipped too instead of widening the page. */
  position: relative;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 0.7rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table th {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-muted);
}

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

.table tbody tr:hover {
  background: color-mix(in srgb, var(--surface-muted) 50%, transparent);
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table .wrap {
  white-space: normal;
  min-width: 10rem;
}

/* --- Segmented filter ---------------------------------------------------- */

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface);
}

.segmented-item {
  padding: 0.4rem 0.8rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
}

.segmented-item + .segmented-item {
  border-left: 1px solid var(--border);
}

.segmented-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

/* --- Lists ----------------------------------------------------------------- */

.account-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.account-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 1rem;
  margin: 0;
}

.facts dt {
  color: var(--text-muted);
}

.facts dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

/* --- Status colors, sections, filters (sync status, raw data) --------------- */

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

.alert-warning {
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent);
}

.alert-success {
  background: color-mix(in srgb, var(--success) 12%, transparent);
  color: var(--text);
  border: 1px solid color-mix(in srgb, var(--success) 35%, transparent);
}

.message-success {
  background: color-mix(in srgb, var(--success) 14%, transparent);
}

.message-warning {
  background: color-mix(in srgb, var(--warning) 16%, transparent);
}

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

.badge-warning {
  background: color-mix(in srgb, var(--warning) 16%, transparent);
  color: var(--warning);
}

/* Table cells with an error message get room instead of a narrow column. */
.table td.cell-message {
  min-width: 14rem;
}

.error-text {
  color: var(--danger);
  white-space: normal;
  max-width: 42rem;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.section-header h2 {
  margin: 0;
}

.section-header form,
.table td.actions form {
  margin: 0;
}

.section-title {
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1rem;
}

.button-small {
  min-height: 30px;
  padding: 0.2rem 0.7rem;
  font-size: 0.85rem;
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.table td.actions {
  text-align: right;
}

.table tfoot th,
.table tfoot td {
  font-weight: 650;
  border-top: 2px solid var(--border);
  border-bottom: 0;
  background: var(--surface-muted);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.filter-bar .field input {
  min-height: 38px;
}

/* --- Login steps: two-factor login, legal links ----------------------------- */

.auth {
  align-content: center;
  gap: 1rem;
}

.auth-card-wide {
  max-width: 480px;
}

.auth-text {
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.auth-secondary {
  margin-top: 0.75rem;
}

.auth-footer {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
}

.auth-footer a,
.legal-links a {
  color: var(--text-muted);
}

.steps {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
}

.steps li + li {
  margin-top: 1.25rem;
}

.qr-code {
  display: block;
  width: 220px;
  max-width: 100%;
  height: auto;
  margin: 0.75rem auto;
  border-radius: var(--radius);
  /* Scanners need dark on light, also in dark mode. */
  background: #ffffff;
}

.secret {
  word-break: break-all;
  user-select: all;
}

.backup-codes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  gap: 0.5rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 1.05rem;
}

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

.legal-links {
  display: flex;
  gap: 1rem;
}

.content-footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.legal {
  display: grid;
  justify-items: center;
  gap: 1rem;
  padding: 2rem 1rem;
}

.legal-card {
  width: 100%;
  max-width: 760px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1.75rem;
  overflow-wrap: anywhere;
}

.legal-card .brand {
  color: var(--text);
  text-decoration: none;
  margin-bottom: 1.5rem;
}

.legal-text h2 {
  margin-top: 1.75rem;
}

.legal-text h3 {
  font-size: 1rem;
  margin: 1.25rem 0 0.5rem;
}

.legal-text ul {
  padding-left: 1.25rem;
}
