:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #5d6b78;
  --line: #d9dee3;
  --brand: #1565c0;
  --brand-text: #ffffff;
  --ok: #1b873f;
  --warn: #b85c00;
  --danger: #c62828;
  --soft: #eef2f6;
  --focus: #ffb300;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #11161b;
    --panel: #1a2128;
    --text: #e8edf2;
    --muted: #9aa8b5;
    --line: #2d3843;
    --brand: #4f9be8;
    --brand-text: #0b1520;
    --ok: #4cc276;
    --warn: #f0a04b;
    --danger: #ef6b6b;
    --soft: #222b34;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #11161b;
  --panel: #1a2128;
  --text: #e8edf2;
  --muted: #9aa8b5;
  --line: #2d3843;
  --brand: #4f9be8;
  --brand-text: #0b1520;
  --ok: #4cc276;
  --warn: #f0a04b;
  --danger: #ef6b6b;
  --soft: #222b34;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, sans-serif;
}
h1,
h2,
h3 {
  margin: 0 0 0.5em;
  line-height: 1.2;
}
h2 {
  font-size: 1.2rem;
}
h3 {
  font-size: 1rem;
}
a {
  color: var(--brand);
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.85rem;
}
.hidden {
  display: none !important;
}

button,
.btn {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 0.5em 0.9em;
  cursor: pointer;
  min-height: 40px;
}
button:hover {
  filter: brightness(0.97);
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}
button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-text);
  font-weight: 600;
}
button.ok {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
  font-weight: 600;
}
button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  font-weight: 600;
}
button.warn {
  background: var(--warn);
  border-color: var(--warn);
  color: #fff;
  font-weight: 600;
}
button.link {
  border: none;
  background: none;
  color: var(--brand);
  padding: 0.25em;
  min-height: 0;
  text-decoration: underline;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

input,
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5em 0.6em;
  min-height: 40px;
  max-width: 100%;
}
label {
  display: block;
  margin: 0.6em 0 0.25em;
  font-weight: 600;
  font-size: 0.9rem;
}
.field input,
.field select,
.field textarea {
  width: 100%;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.grow {
  flex: 1;
}
.dot {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  border-radius: 50%;
  vertical-align: -0.05em;
  margin-right: 0.35em;
  border: 1px solid rgba(0, 0, 0, 0.25);
}
.chip {
  display: inline-block;
  border-radius: 999px;
  padding: 0.1em 0.6em;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--soft);
  color: var(--muted);
  white-space: nowrap;
}
.chip.ok {
  background: color-mix(in srgb, var(--ok) 18%, transparent);
  color: var(--ok);
}
.chip.warn {
  background: color-mix(in srgb, var(--warn) 18%, transparent);
  color: var(--warn);
}
.chip.danger {
  background: color-mix(in srgb, var(--danger) 18%, transparent);
  color: var(--danger);
}
.chip.brand {
  background: color-mix(in srgb, var(--brand) 18%, transparent);
  color: var(--brand);
}

.modal {
  border: none;
  border-radius: var(--radius);
  padding: 1.25rem;
  width: min(520px, calc(100vw - 32px));
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.modal::backdrop {
  background: rgba(0, 0, 0, 0.45);
}
.modal-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.modal-body {
  max-height: 65vh;
  overflow: auto;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translate(-50%, 150%);
  background: #222;
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  display: flex;
  gap: 1rem;
  align-items: center;
  max-width: calc(100vw - 32px);
  transition: transform 0.2s;
  z-index: 3000;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.toast.show {
  transform: translate(-50%, 0);
}
.toast.error {
  background: #8e1c1c;
}
.toast-action {
  background: #fff;
  color: #111;
  font-weight: 700;
  border: none;
}

.auth-wrap {
  max-width: 420px;
  margin: 8vh auto;
  padding: 0 16px;
}
.auth-wrap h1 {
  font-size: 1.8rem;
  letter-spacing: 0.08em;
}
.auth-wrap .card button.primary {
  width: 100%;
  margin-top: 1rem;
}
.error-text {
  color: var(--danger);
  font-weight: 600;
  min-height: 1.4em;
  margin-top: 0.5rem;
}

/* ---------- AVA brand (sign-in screens and landing page) ---------- */
header.brand { text-align: center; margin: 0.5rem 0 1.5rem; }
.brand-mark { width: 88px; height: 88px; display: block; margin: 0 auto 0.6rem; }
.brand-name { margin: 0; font-size: 2.4rem; font-weight: 900; letter-spacing: 0.32em; text-indent: 0.32em; color: var(--text); }
.brand-full { margin: 0.2rem 0 0; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--brand); }
.brand-sub { margin: 0.9rem 0 0; }
