/* AppWave brand tokens (appwave.dev) */
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("../fonts/inter/inter-latin-ext-400.0a6ff1a7c1e4.woff2") format("woff2"); unicode-range: U+0100-024F, U+1E00-1EFF; }
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("../fonts/inter/inter-latin-400.da03732a27e1.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url("../fonts/inter/inter-latin-ext-500.90ff4f7e8bcb.woff2") format("woff2"); unicode-range: U+0100-024F, U+1E00-1EFF; }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url("../fonts/inter/inter-latin-500.51205681a1ba.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("../fonts/inter/inter-latin-ext-600.65aed4e1ef63.woff2") format("woff2"); unicode-range: U+0100-024F, U+1E00-1EFF; }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("../fonts/inter/inter-latin-600.2ede57db1a3a.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url("../fonts/inter/inter-latin-ext-700.aa4c26661f64.woff2") format("woff2"); unicode-range: U+0100-024F, U+1E00-1EFF; }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url("../fonts/inter/inter-latin-700.8ca0a5155296.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }

/* Wave from the AppWave logo: the only ornament (under page headings and the active menu item). */
:root {
  --bg: #0b0b10;
  --surface: #111116;
  --surface-2: #1a1a20;
  --border: #3f3f46;
  --text: #c5c2c2;
  --heading: #ffffff;
  --muted: #a1a1aa;          /* 7.6:1 on --bg; #71717b only for large decorative bits */
  --accent: #f2603c;
  --accent-soft: rgb(242 96 60 / 40%);
  --success: #6ee7b7;
  --error: #ff6568;
  --radius-sm: .375rem;
  --radius: .5rem;
  --radius-lg: .75rem;
  --fs-xs: .8125rem; --fs-sm: .875rem; --fs-md: 1rem; --fs-lg: 1.25rem; --fs-xl: 1.75rem; --fs-2xl: 2.25rem;
  --wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='8' viewBox='0 0 48 8'%3E%3Cpath d='M0 4c6 0 6-3 12-3s6 6 12 6 6-6 12-6 6 3 12 3' fill='none' stroke='%23f2603c' stroke-width='2'/%3E%3C/svg%3E");
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 400 var(--fs-md)/1.6 "Inter", system-ui, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--heading); font-weight: 600; line-height: 1.25; margin: 0 0 .75rem; text-wrap: balance; }
h1 { font-size: var(--fs-xl); letter-spacing: -.01em; }
h2 { font-size: var(--fs-lg); margin-top: 1.75rem; }
h3 { font-size: var(--fs-md); }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
p { margin: 0 0 1rem; }
small, .muted { color: var(--muted); }
small { font-size: var(--fs-sm); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.page-head { margin-bottom: 2rem; }
.page-head h1 { padding-bottom: .9rem; margin-bottom: .6rem; background: var(--wave) left bottom / 48px 8px no-repeat; }
.page-head p { margin: 0; }

/* Top bar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1.5rem; border-bottom: 1px solid var(--surface-2); }
.topbar-left { display: flex; align-items: center; gap: 1rem; min-width: 0; }
.topbar img { height: 26px; display: block; }
.topbar nav { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; align-items: center; font-size: var(--fs-sm); }
.topbar nav a, .topbar nav button.link { color: var(--text); font-size: var(--fs-sm); }
.topbar nav a:hover, .topbar nav button.link:hover { color: var(--heading); }
.topbar form { margin: 0; }
.org-switch { display: inline-flex; align-items: center; gap: .5rem; padding: .3rem .7rem; border: 1px solid var(--border); border-radius: 999px; color: var(--heading); font-size: var(--fs-sm); font-weight: 500; white-space: nowrap; max-width: 16rem; }
.org-switch span { overflow: hidden; text-overflow: ellipsis; }
a.org-switch:hover { border-color: var(--accent); text-decoration: none; }
.org-switch small { color: var(--muted); font-size: var(--fs-xs); font-weight: 400; }

main { max-width: 1040px; margin: 0 auto; padding: 2.5rem 1rem 4rem; }
main.narrow { max-width: 440px; padding-top: 5vh; }

.card { background: var(--surface); border: 1px solid var(--surface-2); border-radius: var(--radius-lg); padding: 1.75rem; }
.card + .card { margin-top: 1.25rem; }
.lang-switch { text-align: center; padding: 1rem 0 1.5rem; font-size: var(--fs-sm); }
.lang-switch button.link { color: var(--muted); margin: 0 .25rem; }
.lang-switch button[aria-current] { color: var(--heading); font-weight: 600; }
.tagline { color: var(--muted); font-size: var(--fs-sm); text-align: center; margin-top: 1.5rem; }

/* App tiles on the start page */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; padding: 0; margin: 0; list-style: none; }
.tile { position: relative; display: flex; flex-direction: column; gap: .75rem; background: var(--surface); border: 1px solid var(--surface-2); border-radius: var(--radius-lg); padding: 1.25rem 1.35rem; }
.tile:has(a:hover), .tile:focus-within { border-color: var(--border); }
.tile h3 { margin: 0; font-size: var(--fs-lg); }
.tile .roles { display: flex; flex-wrap: wrap; gap: .35rem; }
.tile .open { margin-top: auto; font-weight: 500; }
.tile .open::after { content: " →"; }
.tile .no-url { margin-top: auto; color: var(--muted); font-size: var(--fs-sm); }
.section-title { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin: 2.25rem 0 1rem; }
.section-title h2 { margin: 0; }

/* Organisation portal: side menu + content */
.portal { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: 2.5rem; align-items: start; }
.side-nav { position: sticky; top: 1.5rem; }
.side-nav .org { color: var(--muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 .75rem .75rem; }
.side-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .15rem; }
.side-nav a { display: block; padding: .55rem .75rem; border-radius: var(--radius); color: var(--text); font-size: var(--fs-sm); font-weight: 500; }
.side-nav a:hover { background: var(--surface); color: var(--heading); text-decoration: none; }
.side-nav a[aria-current="page"] { background: var(--surface); color: var(--heading); padding-bottom: .9rem; background-image: var(--wave); background-position: .75rem calc(100% - .3rem); background-size: 32px 6px; background-repeat: no-repeat; }

label { display: block; color: var(--heading); font-weight: 500; font-size: var(--fs-sm); margin-bottom: .35rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; padding: .7rem .85rem; background: var(--bg); color: var(--heading);
  border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--accent); outline: 2px solid var(--accent-soft); outline-offset: 0; }
input[type=checkbox] { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; vertical-align: -.15rem; }
form p, form .field { margin-bottom: 1.1rem; }
.helptext, form ul.helptext, .field small { display: block; color: var(--muted); font-size: var(--fs-sm); margin-top: .35rem; }
.errorlist { list-style: none; padding: 0; margin: .3rem 0; color: var(--error); font-size: var(--fs-sm); }
ul#id_roles, div#id_roles { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
#id_roles label { font-weight: 400; color: var(--text); display: flex; gap: .5rem; align-items: center; font-size: var(--fs-md); }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; cursor: pointer;
  padding: .65rem 1.15rem; border-radius: var(--radius-sm); font: 600 var(--fs-sm)/1.2 "Inter", sans-serif;
  background: var(--heading); color: var(--bg); border: 1px solid var(--heading); touch-action: manipulation;
}
button:hover, .button:hover { background: var(--text); text-decoration: none; }
button.secondary, .button.secondary { background: transparent; color: var(--heading); border-color: var(--border); }
button.secondary:hover, .button.secondary:hover { border-color: var(--accent); background: transparent; }
button.danger { background: transparent; color: var(--error); border-color: rgb(255 101 104 / 45%); }
button.danger:hover { background: rgb(255 101 104 / 10%); }
button.link { background: none; border: 0; padding: 0; color: var(--text); font-weight: 400; }
button.link:hover { color: var(--heading); background: none; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-top: 1.25rem; }
.actions form { margin: 0; }
.actions.tight { margin: 0; gap: .5rem; flex-wrap: nowrap; }

.messages { list-style: none; padding: 0; margin: 0 0 1.5rem; display: grid; gap: .5rem; }
.messages li, .alert { padding: .75rem 1rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.messages .success { border-color: rgb(110 231 183 / 40%); color: var(--success); }
.messages .error, .alert.error { border-color: rgb(255 101 104 / 45%); color: var(--error); }
.messages .warning, .messages .info { border-color: var(--accent-soft); }

table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: var(--fs-xs); }
th, td { padding: .8rem .6rem; border-bottom: 1px solid var(--surface-2); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td .sub { display: block; color: var(--muted); font-size: var(--fs-xs); }
td.person strong { color: var(--heading); font-weight: 500; }
td.person { position: relative; padding-left: calc(.6rem + 36px + .75rem); }  /* text column never wraps under the avatar */
td.person .avatar { position: absolute; left: .6rem; top: .8rem; }
.avatar { display: inline-block; flex: none; width: 36px; height: 36px; border-radius: 50%; overflow: hidden; background: var(--surface-2); vertical-align: middle; }
.avatar-sm { width: 28px; height: 28px; }
.avatar svg { display: block; width: 100%; height: 100%; }
.topbar .me { display: inline-flex; }
.nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; position: relative; }  /* contains .visually-hidden spans */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: var(--fs-xs); border: 1px solid var(--border); color: var(--text); white-space: nowrap; }
.badge.accent { border-color: var(--accent-soft); color: var(--accent); }
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.org-choice { width: 100%; justify-content: space-between; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .875em; color: var(--heading); }
img.qr { background: #fff; padding: .5rem; border-radius: var(--radius); }
input[type=checkbox] + label { display: inline; margin-left: .45rem; font-weight: 400; color: var(--text); font-size: var(--fs-md); }
form button[type=submit]:only-of-type:not(.link) { min-width: 8rem; }
form + p { margin-top: 1.25rem; }

@media (max-width: 760px) {
  .portal { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
  .side-nav { position: static; }
  .side-nav ul { display: flex; overflow-x: auto; gap: .25rem; }
  .side-nav a { white-space: nowrap; }
  .side-nav .org { display: none; }
}
@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; padding: .75rem 1rem; }
  .topbar nav { width: 100%; gap: .25rem 1rem; }
  main { padding-top: 1.75rem; }
  .card { padding: 1.25rem; }
  h1 { font-size: 1.5rem; }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 1rem; top: -3rem; z-index: 10; padding: .5rem .9rem; border-radius: var(--radius-sm); background: var(--heading); color: var(--bg); font-weight: 600; }
.skip-link:focus { top: .75rem; }
