/*
 * Design tokens. Every colour in the platform comes from here (one theme, light).
 *   primary:   --accent (buttons, links, marks) with --on-accent as the text on it
 *   secondary: --card/--bg surfaces, --border lines, --muted text, button.btn-sm (outlined)
 *   status:    --ok-*, --warn-*, --error-*, --off-* (background + text pairs)
 */
:root {
    color-scheme: light;
    --bg: #f6f7f9;
    --card: #fff;
    --text: #1d2330;
    --muted: #667085;
    --border: #e3e6eb;
    --accent: #2d57cb; /* the default; the user's pick (ACCENT_COLORS in lib.php) overrides it in <head> */
    --on-accent: #fff;
    --dev-bg: #fff4d6; --dev-text: #7a5300;
    --prod-bg: #ddf3e4; --prod-text: #1d6b3a;
    --error-bg: #fde4e4; --error-text: #9b1c1c;
    --ok-bg: var(--prod-bg); --ok-text: var(--prod-text);
    --warn-bg: var(--dev-bg); --warn-text: var(--dev-text);
    --off-bg: #eceef2; --off-text: #596172;
    --odoo: #7c4dbd; --shopify: #4f8a3b; --integ: #2f5bd3; --sd: #c76a12;
    --ev-exported: #2f5bd3; --ev-picked: #7c4dbd; --ev-slip: #c76a12;
    --ev-shipped: #1f8a4c; --ev-error: #c42b2b; --ev-warning: #c99a06;
    --ev-other: #98a2b3;
    --faint: #98a2b3;
    --env-dev: var(--warn-bg); --env-dev-text: var(--warn-text); /* the DEV flag: the same yellow as the "Du ser som" bar */
    --sidebar: 300px;
    --btn-h: 40px; --btn-h-sm: 32px; /* heights of buttons and fields: what sits side by side lines up */
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
main { flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 32px 16px 32px; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
/* Page title and section headings: clear size, air before the box below. A title with an intro text under it keeps that close. */
h1 { font-size: 26px; line-height: 1.25; margin: 0 0 24px; }
h1:has(+ .muted), h1:has(+ .lead), h1:has(+ .intro), h1:has(+ p:not(.notice)) { margin-bottom: 8px; }
h2 { font-size: 18px; line-height: 1.3; margin: 0 0 16px; }
.muted { color: var(--muted); }
a { color: var(--text); }
form { display: flex; gap: 8px; margin: 16px 0 24px; }
input[type=text] { flex: 1; padding: 9px 12px; font: inherit; color: inherit; background: var(--card); border: 1px solid var(--border); border-radius: 6px; }
/*
 * Buttons: .btn-sm (and a.btn-link) are the secondary, outlined style; modifiers .resume (green) and .danger (red).
 * A button is --btn-h tall. In a row of actions every button has that height, also .btn-sm; in tables .btn-sm is compact.
 */
button { display: inline-flex; align-items: center; justify-content: center; height: var(--btn-h); padding: 0 18px; font: inherit; line-height: 1; white-space: nowrap; color: var(--on-accent); background: var(--accent); border: 1px solid transparent; border-radius: 6px; cursor: pointer; }
button:hover { filter: brightness(1.08); }
button:disabled, button:disabled:hover { opacity: .45; cursor: not-allowed; filter: none; }
input[type=text], input[type=email], input[type=password], input[type=number], select { min-height: var(--btn-h); }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 16px; overflow-x: auto; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 12px; }
dt { color: var(--muted); }
dd { margin: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
.num { text-align: right; white-space: nowrap; }
.badge { display: inline-block; padding: 3px 10px; line-height: 1.4; border-radius: 12px; font-size: 12px; font-weight: 600; }
.dev { background: var(--dev-bg); color: var(--dev-text); }
.prod { background: var(--prod-bg); color: var(--prod-text); }
.this { background: var(--accent); color: var(--on-accent); }
.error { background: var(--error-bg); color: var(--error-text); padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
pre { margin: 4px 0 0; font-size: 12px; white-space: pre-wrap; color: var(--muted); }

/* Navigation: the menu is a column on the left, the page (content + footer) to the right of it */
.app { flex: 1; display: flex; }
.sidebar { flex: none; width: var(--sidebar); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 16px; padding: 20px 12px; background: var(--card); border-right: 1px solid var(--border); overflow-y: auto; }
.page { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.brandbox { display: flex; flex-direction: column; align-items: flex-start; gap: 18px; padding: 0 8px; }
.brand { font-weight: 700; font-size: 22px; line-height: 1.2; text-decoration: none; overflow-wrap: anywhere; }
.menu { display: flex; flex-direction: column; gap: 2px; }
.menu a { padding: 8px 12px; border-radius: 6px; color: var(--muted); text-decoration: none; }
.menu a:hover { color: var(--text); background: var(--bg); }
.menu a.on { color: var(--accent); font-weight: 600; background: color-mix(in srgb, var(--accent) 12%, transparent); }
/* Bottom of the menu: one divider, then who is logged in (with logout beside it), then the credit */
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding-top: 12px; border-top: 1px solid var(--border); }
.account { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 8px 0 12px; }
.account .user { flex: 1; min-width: 0; padding: 4px 10px 4px 4px; margin-left: -4px; overflow: hidden; text-overflow: ellipsis; font-weight: 600; border-radius: 999px; }
.account .user::after { content: "\203A"; margin-left: auto; font-size: 18px; line-height: 1; color: var(--muted); } /* a small arrow: this is a link */
.account .user:hover, .account .user.on { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.account .user.on, .account .user.on::after { color: var(--accent); } /* the current page: accent colour */
.account form { margin: 0; }
.account .logout { font: inherit; font-size: 13px; background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; }
.account .logout:hover { text-decoration: underline; }
@media (max-width: 1100px) { :root { --sidebar: 240px; } }
.topbar, .menu-toggle { display: none; }
/* Narrow screens: a slim top bar (name + menu button) that stays at the top; the menu opens under it */
@media (max-width: 800px) {
    .app { flex-direction: column; }
    .sidebar { position: sticky; top: 0; z-index: 50; width: auto; height: auto; max-height: 100vh; max-height: 100dvh; display: block; gap: 0; padding: 0; border-right: 0; border-bottom: 1px solid var(--border); overflow-y: auto; }
    .topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 6px 8px 6px 16px; }
    .topbrand { flex: 1; min-width: 0; font-weight: 700; font-size: 17px; line-height: 1.25; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .menu-toggle { display: inline-flex; flex: none; width: 44px; height: 44px; padding: 0; color: var(--text); background: transparent; border: 1px solid var(--border); border-radius: 8px; }
    .menu-toggle:hover { background: transparent; filter: none; }
    .sidebar.open .menu-toggle { background: var(--bg); }
    .menu-toggle .ic-close, .sidebar.open .menu-toggle .ic-menu { display: none; }
    .sidebar.open .menu-toggle .ic-close { display: inline; }
    /* Open: the menu fills the screen under the top bar, the page behind does not scroll, the account sits at the bottom */
    .sidebar.open { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
    html:has(.sidebar.open) { overflow: hidden; } /* html only: with body too, the menu stops following the screen */
    .brandbox, .menu, .side-foot { display: none; }
    .sidebar.open .menu { display: flex; flex-direction: column; gap: 2px; padding: 4px 8px 8px; border-top: 1px solid var(--border); }
    .sidebar.open .menu a { display: flex; align-items: center; min-height: 48px; padding: 8px 14px; font-size: 16px; }
    .sidebar.open .topbar { flex: none; }
    /* The logo is not in the top bar, but shown at the top of the open menu (the name is already in the bar) */
    .sidebar.open .brandbox { display: flex; flex: none; padding: 20px 16px 12px; border-top: 1px solid var(--border); }
    .sidebar.open .brandbox .brand { display: none; }
    .sidebar.open .brandbox .brand-logo img { max-height: 88px; max-width: 60vw; border-radius: 6px; }
    .sidebar.open .brandbox + .menu { border-top: 0; }
    .sidebar.open .menu { flex: none; }
    .sidebar.open .side-foot { display: flex; flex-direction: column; margin: auto 0 0; padding: 4px 8px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
    .account { margin: 0; padding: 4px 6px 4px 14px; border: 0; }
    .account .user { min-height: 44px; }
    .account .logout { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; font-size: 14px; }
    .credit { margin-top: 0; padding: 8px 14px 0; }
    html { scroll-padding-top: 72px; }
}

/* Flow page */
.lead { font-size: 16px; margin: 8px 0 24px; }
.diagram { width: 100%; height: auto; display: block; margin: 8px 0; }
.diagram .box { fill: var(--card); stroke-width: 2; }
.diagram .label { font: 600 16px system-ui, sans-serif; fill: var(--on-accent); text-anchor: middle; }
.diagram .sub { font: 12px system-ui, sans-serif; fill: var(--on-accent); opacity: .85; text-anchor: middle; }
.diagram .arrow { stroke: var(--muted); stroke-width: 1.5; fill: none; }
.diagram .arrowtext { font: 12px system-ui, sans-serif; fill: var(--text); text-anchor: middle; }
.steps { list-style: none; margin: 0; padding: 0; }
.step { position: relative; padding-left: 52px; padding-bottom: 16px; }
.step::before { content: ""; position: absolute; left: 15px; top: 50px; bottom: -18px; width: 2px; background: var(--border); }
.step:last-child::before { display: none; }
.step .num { position: absolute; left: 0; top: 18px; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--on-accent); }
.step h3 { font-size: 17px; margin: 14px 0 10px; }
.step p { margin: 0 0 10px; line-height: 1.65; }
.step p:last-child { margin-bottom: 0; }
.step .card { padding: 24px 28px; margin-bottom: 0; }
.step .badge { margin-right: 6px; padding: 4px 12px; }
@media (max-width: 600px) { .step { padding-left: 44px; } .step .card { padding: 18px; } }
.where { color: var(--on-accent); }
.odoo { background: var(--odoo); }
.shopify { background: var(--shopify); }
.integ { background: var(--integ); }
.sd { background: var(--sd); }
.status { background: var(--border); color: var(--text); }

/* Event timeline on the lookup page */
.events { position: relative; margin-top: 4px; }
.events::before { content: ""; position: absolute; left: 7px; top: 14px; bottom: 14px; width: 2px; background: var(--border); }
.event-line { position: relative; display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 0; border-radius: 8px; list-style: none; }
summary.event-line { cursor: pointer; }
summary.event-line::-webkit-details-marker { display: none; }
summary.event-line:hover { background: var(--bg); }
.dot { flex: none; position: relative; z-index: 1; width: 16px; height: 16px; border-radius: 50%; background: var(--card); border: 4px solid var(--ev-other); box-sizing: border-box; }
.event.exported .dot { border-color: var(--ev-exported); }
.event.picked .dot { border-color: var(--ev-picked); }
.event.slip .dot { border-color: var(--ev-slip); }
.event.shipped .dot { border-color: var(--ev-shipped); background: var(--ev-shipped); }
.event.error .dot { border-color: var(--ev-error); background: var(--ev-error); }
.event.warning .dot { border-color: var(--ev-warning); }
.event-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.event-text { font-weight: 500; overflow-wrap: anywhere; }
.event.error .event-text { color: var(--ev-error); }
.event-meta { font-size: 12px; color: var(--muted); }
.chevron { flex: none; width: 8px; height: 8px; margin-right: 6px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s; }
details[open] > summary .chevron { transform: rotate(-135deg); }
.event pre { margin: 0 0 8px 30px; padding: 10px 12px; background: var(--bg); border-radius: 6px; }

/* Flow page: clear sections with air between them */
.flow h1 { font-size: 26px; line-height: 1.25; margin: 4px 0 10px; }
.flow .lead { margin-bottom: 28px; }
.section-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 56px 0 20px; padding-top: 32px; border-top: 1px solid var(--border); }
.section-head h2 { margin: 0; font-size: 22px; }
.section-when { font-size: 13px; color: var(--muted); background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 3px 10px; }
.flow .info-card { padding: 24px 28px; }
.flow .info-card p { margin: 0 0 14px; line-height: 1.65; }
.flow .info-card p:last-child { margin-bottom: 0; }
@media (max-width: 600px) { .flow .info-card { padding: 18px; } .flow h1 { font-size: 22px; } }
@media (max-width: 600px) { main { padding-top: 32px; } }


/* Integrations page: status badges and tables */
.admin-table { margin-bottom: 8px; }
.admin-table td { vertical-align: middle; padding: 10px 8px; }
.admin-table td.act { text-align: right; white-space: nowrap; }
.admin-table .plan { min-width: 170px; }
.admin-table .plan small { display: block; color: var(--muted); }
.admin-table form { display: inline; margin: 0; }
.st { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; margin-right: 4px; white-space: nowrap; }
.st.ok { background: var(--ok-bg); color: var(--ok-text); }
.st.paused { background: var(--warn-bg); color: var(--warn-text); }
.st.off { background: var(--off-bg); color: var(--off-text); }
button.btn-sm { height: var(--btn-h-sm); padding: 0 12px; font-size: 13px; color: var(--text); background: transparent; border: 1px solid var(--border); }
button.btn-sm:hover { background: var(--bg); filter: none; }
.actions button.btn-sm { height: var(--btn-h); padding: 0 18px; font-size: inherit; }
button.btn-sm.resume { color: var(--ok-text); background: var(--ok-bg); border-color: transparent; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 0 32px; }
/* A description under a section heading belongs to it: close to the heading, a short step down to the box */
h2:has(+ .hint) { margin-bottom: 8px; }
h2 + .hint { margin-bottom: 16px; }
/* Setup boxes: the same padding on all sides (the first label's own margin used to add to the top) */
form.card.edit:not(:has(.fsec)) { padding: 20px; }
form.card.edit:not(:has(.fsec)) > label:first-of-type { margin-top: 0; }
.admin h2 { margin: 32px 0 16px; }
.notice { padding: 10px 16px; border-radius: 8px; margin-bottom: 16px; }
.notice.ok { background: var(--ok-bg); color: var(--ok-text); }
.notice.err { background: var(--error-bg); color: var(--error-text); }
form.edit { display: block; margin: 0 0 16px; }
form.edit label { display: block; margin: 14px 0; font-weight: 500; }
form.edit input:not([type=checkbox]):not([type=radio]) { display: block; width: 100%; max-width: 30rem; margin-top: 4px; padding: 8px 10px; font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; font-weight: 400; }
form.edit small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; }
form.edit .check { display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 8px 0; }
form.edit .check:has(> span) { align-items: flex-start; margin: 22px 0; }
form.edit .check:has(> span) small { line-height: 1.5; margin-top: 4px; }
form.edit label:not(.check) + .check:has(> span) { margin-top: 32px; }
form.edit .check:has(> span) input { margin-top: 6px; }
form.edit .check.inline { display: inline-flex; margin-right: 14px; }
form.edit fieldset { border: 1px solid var(--border); border-radius: 6px; margin: 14px 0; padding: 6px 12px 10px; max-width: 30rem; }
form.edit legend { font-weight: 500; padding: 0 6px; }
form.edit .section { margin: 22px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-top: 1px solid var(--border); padding-top: 14px; }
form.edit .actions { display: flex; gap: 16px; align-items: center; margin-top: 22px; }
details.new > summary { cursor: pointer; display: inline-flex; align-items: center; height: var(--btn-h-sm); padding: 0 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); }
details.new[open] > summary { margin-bottom: 12px; }
.empty { color: var(--muted); }
@media (max-width: 600px) {
    .admin-table th:nth-child(2), .admin-table tr:not(.group) td:nth-child(2) { display: none; }
    .admin-table .plan { min-width: 0; }
    .st { margin-bottom: 2px; }
}

/* Flow overview: one card per integration type */
a.type-card { display: block; text-decoration: none; color: inherit; padding: 24px 28px; }
a.type-card:hover { border-color: var(--accent); }
.type-card h2 { margin: 0 0 6px; font-size: 18px; }
.type-card p { margin: 0 0 12px; line-height: 1.6; }
.type-integrations { list-style: none; margin: 0 0 12px; padding: 0; }
.type-integrations li { padding: 4px 0; }
.type-card .more { color: var(--accent); font-weight: 600; }
.type-integrations-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 20px; }
.type-chip { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 3px 12px; }
.flow .hint { margin-top: 24px; }

.admin-table tr.group td { background: var(--bg); padding: 6px 8px; font-size: 13px; color: var(--muted); }
.admin-table tr.group td strong { color: var(--text); margin-right: 10px; }
button.btn-sm.danger { color: var(--error-text); border-color: var(--error-text); }
button.btn-sm.danger:hover { background: var(--error-bg); }
.new-links { margin: 8px 0 0; }
a.btn-link { display: inline-flex; align-items: center; height: var(--btn-h-sm); margin: 0 6px 6px 0; padding: 0 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); text-decoration: none; }
a.btn-link:hover { border-color: var(--accent); }
.actions a.btn-link { height: var(--btn-h); margin: 0; padding: 0 18px; }
form.edit textarea { display: block; width: 100%; max-width: 30rem; margin-top: 4px; padding: 8px 10px; font: inherit; color: inherit; background-color: var(--bg); border: 1px solid var(--border); border-radius: 6px; font-weight: 400; }
form.edit select { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-repeat: no-repeat; background-size: 6px 6px; background-position: calc(100% - 20px) center, calc(100% - 14px) center; display: block; width: 100%; max-width: 30rem; margin-top: 4px; padding-top: 8px; padding-bottom: 8px; padding-left: 10px; font: inherit; color: inherit; background-color: var(--bg); border: 1px solid var(--border); border-radius: 6px; font-weight: 400; }

/* Profile page */
form.profile .whoami { margin: 0 0 8px; color: var(--muted); }
form.profile .whoami strong { color: var(--text); }
form.profile input:not([type=checkbox]):not([type=radio]) { max-width: none; }
form.profile .source { padding: 12px 0; border-bottom: 1px solid var(--border); }
form.profile .source:last-of-type { border-bottom: 0; }
form.profile .source .check { margin: 0; }
form.profile .source small { margin: 2px 0 0 26px; }
form.profile .source.off { opacity: .55; }
form.profile .actions { margin-top: 20px; }
form.profile .source.off { border-bottom: 0; }

/* Clickable toggles */
form.edit .check, form.edit .check input { cursor: pointer; }
form.edit .check input[type=radio] { width: auto; }
form.edit .check:has(input:disabled), form.edit .check input:disabled { cursor: not-allowed; }

/* Login page */
main.login { max-width: 380px; padding-top: 12vh; }
main.login h1 { text-align: center; margin-bottom: 20px; }
main.login form.edit input:not([type=checkbox]):not([type=radio]):not([type=radio]) { max-width: none; }
main.login .actions { margin-top: 20px; }
form.profile .source:has(input[type=radio]) { border-bottom: 0; padding-bottom: 0; }
form.profile .provider { margin: 0 0 8px 26px; padding-left: 14px; border-left: 2px solid var(--border); }

/* Profile (avatar) and logout in the top bar */
.user { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; text-decoration: none; white-space: nowrap; }
.user:hover, .user.on { background: var(--bg); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.logout { color: var(--muted); text-decoration: none; white-space: nowrap; }
.logout:hover { color: var(--text); text-decoration: underline; }

/* Section navigation beside the profile page */
html { scroll-behavior: smooth; }
main.has-side { position: relative; }
main.has-side [id] { scroll-margin-top: 24px; }
.sidenav { position: absolute; left: -226px; top: 32px; bottom: 0; width: 210px; }
.sidenav nav { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 2px; }
.sidenav a { padding: 8px 12px; border-radius: 6px; color: var(--muted); text-decoration: none; }
.sidenav a:hover { color: var(--text); }
.sidenav a.on { color: var(--text); font-weight: 600; background: var(--card); }
@media (max-width: 1650px) {
    .sidenav { position: static; width: auto; margin-bottom: 16px; }
    .sidenav nav { position: static; flex-direction: row; flex-wrap: wrap; gap: 6px; }
    .sidenav a { border: 1px solid var(--border); background: var(--card); }
}

/* Address lists with add and remove */
form.edit .field { margin: 14px 0; }
form.edit .field .lbl { display: block; font-weight: 500; margin-bottom: 6px; }
.chips { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chips:empty { display: none; }
.chips li { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 16px; }
.chips li button { all: unset; cursor: pointer; width: 22px; height: 22px; line-height: 20px; text-align: center; border-radius: 50%; color: var(--muted); font-size: 16px; }
.chips li button:hover { background: var(--border); color: var(--text); }
.recips .add { display: flex; gap: 8px; max-width: 30rem; }
.recips .add input { margin-top: 0; }
.recips .add button { white-space: nowrap; }

.autosave-status { margin: 16px 0 0; font-size: 13px; color: var(--muted); }
.autosave-status.bad { color: var(--error-text); }
.dirty { align-self: center; font-size: 13px; color: var(--dev-text); background: var(--dev-bg); padding: 2px 10px; border-radius: 12px; }
.dirty[hidden] { display: none; }
.autosave-status.ok { color: var(--prod-text); font-weight: 600; }

.site { width: 100%; max-width: 860px; margin: auto auto 0; padding: 2.5rem 16px 1.5rem; text-align: center; font-size: .8rem; color: var(--faint); }
.site a, .credit a { color: inherit; text-decoration: none; }
.site a:hover, .credit a:hover { text-decoration: underline; }
.site span + span::before { content: " · "; }
/* The credit at the bottom of the menu */
.credit { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; padding: 12px 12px 0; border-top: 1px solid var(--border); font-size: 12px; color: var(--faint); overflow-wrap: anywhere; }

/* Shown in dev only, always in the bottom right corner */
.env-flag { position: fixed; right: 16px; bottom: 16px; z-index: 100; padding: 6px 14px; border-radius: 8px; font-weight: 700; letter-spacing: .06em; background: var(--env-dev); color: var(--env-dev-text); border: 1px solid color-mix(in srgb, var(--env-dev-text) 35%, transparent); box-shadow: 0 2px 8px rgba(0, 0, 0, .15); pointer-events: none; }
.intro { margin: 0 0 20px; color: var(--muted); }
.intro a { color: var(--accent); }

/* DEV machine with an integration in Live: it writes for real, so the flag is red */
.env-flag.live { background: var(--error-text); color: #fff; border-color: transparent; }

/* Switches (on/off) that ask for a confirmation: Integrasjoner page */
.switch-form { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
button.switch { all: unset; box-sizing: border-box; position: relative; flex: none; width: 38px; height: 22px; border-radius: 11px; background: var(--border); cursor: pointer; transition: background .15s; }
button.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--card); box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s; }
button.switch.on { background: var(--accent); }
button.switch.on::after { transform: translateX(16px); background: var(--on-accent); }
button.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-label { min-width: 3.5em; font-size: 14px; }
.switch-label.off { color: var(--muted); }
.source-card { margin-bottom: 16px; }
.source-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 2px; }
.source-card > small { display: block; color: var(--muted); }
.integration-list { list-style: none; margin: 16px 0 0; padding: 0; border-top: 1px solid var(--border); }
.integration-list.off { opacity: .5; }
.integration-list li { display: flex; align-items: center; gap: 24px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.integration-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.integration-list .name { flex: 1; min-width: 0; }
.integration-list .name small { display: block; color: var(--muted); }
@media (max-width: 600px) { .integration-list li { flex-wrap: wrap; gap: 8px 20px; } .integration-list .name { flex-basis: 100%; } }
p.back { margin: 0 0 12px; font-size: 14px; }
.integration-list li .run-form { margin: 0; display: block; }
.integration-list .name { display: flex; align-items: baseline; gap: 16px; } /* name and type as two fixed columns: the types line up */
.integration-list .name > :first-child { flex: 0 0 min(11rem, 48%); min-width: 0; overflow-wrap: anywhere; }
.integration-list .name small { display: block; flex: 1; min-width: 0; margin: 0; font-size: 13px; }
.integration-list .name small.last-run { display: block; margin: 10px 0 0; }
.integration-list .name small.last-run a { color: var(--accent); margin-left: .45em; }

/* Logg page: the saved runs */
.runs details { border-bottom: 1px solid var(--border); }
.runs details:last-child { border-bottom: 0; }
.runs summary { cursor: pointer; padding: 8px 0; display: grid; grid-template-columns: 1.4rem 10rem 9rem auto; align-items: center; gap: 0 8px; list-style: none; }
.runs summary::-webkit-details-marker { display: none; }
.runs summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; justify-self: center; }
.runs details[open] > summary::before { transform: rotate(45deg); }
.runs summary .st { justify-self: start; margin: 0; }
.runs pre { margin: 0 0 12px; padding: 10px 12px; background: var(--bg); border-radius: 6px; overflow-x: auto; }

/* Logo: above the name in the menu, and its preview on the profile page */
.brand-logo { display: block; }
.brand-logo img { display: block; max-width: 100%; max-height: 150px; object-fit: contain; }
form.edit label.logo-preview { display: inline-block; margin: 8px 0 12px; padding: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
form.edit label.logo-preview:hover { border-color: var(--accent); }
.logo-preview img { display: block; max-width: 240px; max-height: 150px; }
form.edit label.plain { font-weight: 400; }

.login-logo { margin: 0 0 16px; text-align: center; }
.login-logo img { max-width: 100%; max-height: 150px; }
form.edit .actions + small { margin-top: 16px; }

/* The integration form in sections */
.fsec { border: 1px solid var(--border); border-radius: 8px; padding: 18px 20px 8px; margin: 0 0 20px; }
.fsec h3 { margin: 0 0 4px; font-size: 16px; }
.fsec-help { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.fsec > label:first-of-type, .fsec > .fsec-help + label { margin-top: 12px; }
form.edit .fsec fieldset { max-width: none; }
/* The sections are the cards themselves: no outer box around them */
form.card:has(.fsec) { background: transparent; border: 0; padding: 0; }
form.card:has(.fsec) .fsec { background: var(--card); padding: 20px 24px 10px; }
form.card:has(.fsec) .actions { margin-top: 4px; }
form.card:has(.fsec) .danger-zone { margin-top: 28px; }
.danger-zone .btn-sm.danger { height: var(--btn-h); padding: 0 18px; font-size: inherit; }

/* E-postoppsett: compact cards */
form.edit.profile h2 { margin: 0 0 4px; }
.tabs { display: inline-flex; margin: 14px 0 4px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.tabs .tab { display: flex; align-items: center; margin: 0; padding: 0 20px; height: var(--btn-h-sm); font-weight: 500; cursor: pointer; color: var(--muted); }
.tabs .tab + .tab { border-left: 1px solid var(--border); }
.tabs .tab input { position: absolute; opacity: 0; pointer-events: none; }
.tabs .tab:has(input:checked) { background: var(--accent); color: var(--on-accent); }
.tabs .tab:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
form.edit .row2, form.edit .row3 { display: grid; gap: 0 16px; }
form.edit .row2 { grid-template-columns: 1fr 1fr; }
form.edit .row3 { grid-template-columns: 1fr 110px 200px; }
form.edit .row2 input:not([type=checkbox]):not([type=radio]), form.edit .row3 input:not([type=checkbox]):not([type=radio]), form.edit .row3 select { max-width: none; width: 100%; }
.actions.with-test { justify-content: space-between; flex-wrap: wrap; }
.test-group { display: flex; gap: 8px; align-items: center; }
form.edit .test-group input { margin: 0; width: 20rem; max-width: 100%; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
@media (max-width: 800px) { .cols2, form.edit .row2, form.edit .row3 { grid-template-columns: 1fr; } }
form.edit .test-group input { width: 24rem; min-width: 14rem; flex: 1 1 auto; }
.recips .add button.btn-sm { height: var(--btn-h); padding: 0 16px; font-size: inherit; }
/* Under the provider tabs the fields need no indent or side line */
form.profile .tabs ~ .provider { margin: 0; padding: 0; border-left: 0; }
/* E-postoppsett: the fields keep a fixed width instead of stretching over the whole card */
#emailform > label, #emailform .provider { max-width: 38rem; }

/* Notification addresses: one row per address, a tick per notification */
.matrix-table { width: 100%; max-width: 44rem; border-collapse: collapse; margin: 8px 0 12px; }
.matrix-table th { font-weight: 500; color: var(--muted); font-size: 13px; padding: 4px 8px; text-align: center; white-space: nowrap; }
.matrix-table th:first-child { text-align: left; padding-left: 0; }
.matrix-table td { padding: 8px; border-top: 1px solid var(--border); vertical-align: middle; }
.matrix-table td.addr { padding-left: 0; overflow-wrap: anywhere; }
.matrix-table td.addr small { display: block; color: var(--warn-text); }
.matrix-table td.tick { text-align: center; width: 5.5rem; }
.matrix-table td.tick label { display: flex; justify-content: center; margin: 0; cursor: pointer; }
.matrix-table td.tick label span { display: none; } /* the name is only shown on a phone, where the headings are hidden */
.matrix-table td.tick input { width: 18px; height: 18px; cursor: pointer; }
.matrix-table .remove { all: unset; cursor: pointer; width: 24px; height: 24px; line-height: 22px; text-align: center; border-radius: 50%; color: var(--muted); font-size: 18px; }
.matrix-table .remove:hover { background: var(--border); color: var(--text); }
.matrix-add { display: flex; align-items: center; gap: 8px; max-width: 30rem; }
form.edit .matrix-add input { margin-top: 0; }
.matrix-add button { white-space: nowrap; height: var(--btn-h); padding: 0 16px; font-size: inherit; }

/* A short explanation when pointing at (or tabbing to) a column heading */
.matrix-table th[data-tip] { position: relative; cursor: help; text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }
.matrix-table th[data-tip]::after { content: attr(data-tip); position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 10; width: 16rem; padding: 8px 10px; border-radius: 6px; background: var(--text); color: var(--card); font-size: 13px; font-weight: 400; line-height: 1.4; text-align: left; white-space: normal; text-decoration: none; box-shadow: 0 4px 12px rgba(0, 0, 0, .2); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .12s; }
.matrix-table th[data-tip]:hover::after, .matrix-table th[data-tip]:focus::after { opacity: 1; visibility: visible; }
.matrix-table th[data-tip]:focus { outline: none; }

.events-table tr.bad td { color: var(--error-text); }
.events-table td { font-size: 14px; }
/* A field that cannot be edited looks like it: grey, no focus ring, "not allowed" pointer */
form.edit input[readonly] { background: var(--off-bg); color: var(--muted); cursor: not-allowed; }
form.edit input[readonly]:focus { outline: none; border-color: var(--border); }
/* The label is only as wide as its field, so a click beside the field does not focus it */
.fsec > label, .fsec .provider > label { max-width: 30rem; }
/* Checkboxes with an explanation are running text, not fields: a little wider than the inputs */
.fsec > label.check:has(> span), .fsec .provider > label.check:has(> span) { max-width: 44rem; }
form.edit input[readonly]:not([type=checkbox]):not([type=radio]) { background: var(--off-bg); color: var(--faint); cursor: not-allowed; -webkit-text-fill-color: var(--faint); }
form.edit input[readonly]:not([type=checkbox]):not([type=radio]):focus { outline: none; border-color: var(--border); }

/* The logo of an order source in front of its name */
.source-title { display: inline-flex; align-items: center; gap: 10px; font-size: 17px; }
.source-title img { width: 28px; height: 28px; object-fit: contain; border-radius: 6px; }

/* The explanation of an order source sits to the right, next to its switch */
.source-help { flex: 1; text-align: right; color: var(--muted); font-size: 11px; line-height: 1.4; }
.source-head { gap: 20px; margin-bottom: 4px; }
@media (max-width: 800px) { .source-head { flex-wrap: wrap; } .source-help { order: 3; flex-basis: 100%; text-align: left; } }

h2.source-heading { margin: 40px 0 16px; font-size: 20px; }

/* Flow page: a tab per order source, big enough to be seen */
.flow-tabs { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 28px; }
.flow-tab { box-sizing: border-box; text-decoration: none; display: inline-flex; align-items: center; gap: 10px; padding: 12px 22px; cursor: pointer; font-size: 17px; font-weight: 600; color: var(--muted); background: var(--bg); border: 2px solid var(--border); border-radius: 10px; }
.flow-tab img { width: 26px; height: 26px; object-fit: contain; border-radius: 5px; }
.flow-tab:hover { color: var(--text); border-color: var(--muted); }
.flow-tab.on { color: var(--text); background: var(--card); border-color: var(--accent); box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 18%, transparent); }
.flow-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.flow-tabs + .lead { margin-top: 0; }
h2.with-logo { display: flex; align-items: center; gap: 10px; }
h2.with-logo img { width: 24px; height: 24px; object-fit: contain; border-radius: 5px; }
.flow .about { margin: 16px 0 12px; color: var(--muted); }

/* Lookup page before a search: the search box in the middle of the page, both ways */
main.lookup-start { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding-bottom: 12vh; }
main.lookup-start h1 { margin-bottom: 8px; }
main.lookup-start form { width: 100%; max-width: 36rem; }

/*
 * Mobile and touch (iPhone). Desktop is unchanged: everything here is inside a media query, except two safe defaults.
 *   - max-width: 800px  narrow screen: fields at 16px (iOS zooms into smaller ones), layouts stack
 *   - pointer: coarse   fingers: every control is 44px (the --btn-h tokens drive the heights of buttons and fields)
 */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { min-height: 100dvh; }

@media (pointer: coarse) {
    :root { --btn-h: 44px; --btn-h-sm: 44px; }
    input[type=checkbox], input[type=radio] { flex: none; width: 22px; height: 22px; }
    form.edit .check:has(> span) input { margin-top: 0; }
    form.edit .check { gap: 12px; min-height: 44px; }
    form.edit .check.inline { margin-right: 18px; }
    form.edit .check input[type=radio] { width: 22px; }
    button.switch { width: 48px; height: 28px; border-radius: 14px; }
    button.switch::after { top: 3px; left: 3px; width: 22px; height: 22px; }
    button.switch.on::after { transform: translateX(20px); }
    .switch-form { min-height: 44px; }
    .menu a, .sidenav a { min-height: 44px; display: flex; align-items: center; }
    .flow-tab { min-height: 48px; }
    .tabs .tab { min-width: 44px; }
    .chips li button { width: 32px; height: 32px; line-height: 30px; }
    .matrix-table .remove { width: 40px; height: 40px; line-height: 38px; }
    .matrix-table td.tick input { width: 24px; height: 24px; }
    .matrix-table td { padding-top: 4px; padding-bottom: 4px; }
    .runs summary { min-height: 44px; }
    .integration-list .name a, .type-card .more { display: inline-block; padding: 8px 0; margin: -4px 0; }
    .topbrand { padding: 11px 0; }
    /* Hover that sticks after a tap is worse than none */
    button:hover, button.btn-sm:hover { filter: none; }
    summary.event-line:hover { background: transparent; }
}

@media (max-width: 800px) {
    /* Fields: 16px stops iOS from zooming the page when one is tapped */
    input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=url],
    form.edit input:not([type=checkbox]):not([type=radio]), form.edit select, form.edit textarea { font-size: 16px; }
    form.edit input:not([type=checkbox]):not([type=radio]), form.edit select, form.edit textarea { padding-top: 10px; padding-bottom: 10px; }
}

@media (max-width: 600px) {
    main { padding-left: 16px; padding-right: 16px; }
    h1 { font-size: 24px; }
    .source-help { font-size: 12px; }
    dl { grid-template-columns: 1fr; gap: 0; }
    dt { margin-top: 10px; font-size: 13px; }
    dt:first-child { margin-top: 0; }
    .card { padding: 14px; }
    form.card:has(.fsec) .fsec { padding: 16px 16px 6px; }
    form.edit .actions { flex-wrap: wrap; gap: 10px 12px; }
    form.edit .actions button, form.edit .actions a.btn-link { flex: 1 1 auto; }
    .test-group { flex-wrap: wrap; }
    form.edit .test-group input { width: 100%; min-width: 0; flex-basis: 100%; }

    /* Logg: a saved run is name + Live/Test on the first line, the time under the name */
    .runs summary { grid-template-columns: 1.4rem 1fr auto; row-gap: 0; padding: 10px 0; }
    .runs summary strong { grid-column: 2; grid-row: 1; }
    .runs summary .muted { grid-column: 2; grid-row: 2; font-size: 13px; }
    .runs summary .st { grid-column: 3; grid-row: 1; }
    .runs summary::before { grid-row: 1; }

    /* Logg: the events and changes are lists of small cards instead of tables: time, who and what on one line, the text under it */
    table.log-table, table.log-table tbody { display: block; }
    table.log-table tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
    table.log-table tr:first-child { padding-top: 0; }
    table.log-table tr:last-child { padding-bottom: 0; border-bottom: 0; }
    table.log-table td { display: block; padding: 0; border: 0; min-width: 0; overflow-wrap: anywhere; }
    table.log-table td:empty { display: none; }
    table.log-table td:first-child { font-size: 13px; color: var(--muted); }
    table.log-table td:nth-child(2) { font-weight: 600; }
    table.log-table td:last-child { flex-basis: 100%; }
    table.log-table tr.bad td:first-child { color: inherit; }

    /* Notification addresses: one small card per address, the four ticks as labelled choices in two columns,
       the remove button in the corner. The column headings (with their explanations) stay as a row on top. */
    .matrix-table, .matrix-table thead, .matrix-table tbody { display: block; }
    .matrix-table thead { display: none; }
    .matrix-table tbody tr { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; margin: 0 0 10px; padding: 12px 14px; background: var(--bg); border-radius: 8px; }
    .matrix-table td { border: 0; padding: 0; }
    .matrix-table td.addr { grid-column: 1 / -1; padding: 0 40px 6px 0; font-weight: 600; }
    .matrix-table td.tick { width: auto; }
    .matrix-table td.tick label { display: flex; align-items: center; justify-content: flex-start; gap: 10px; min-height: 40px; margin: 0; cursor: pointer; }
    .matrix-table td.tick input { flex: none; }
    .matrix-table td.tick label span { display: inline; font-size: 14px; font-weight: 400; color: var(--text); }
    .matrix-table td:last-child { position: absolute; top: 6px; right: 6px; }
    /* A short explanation on a column heading: kept inside the screen */
    .matrix-table th[data-tip]::after { left: auto; right: 0; transform: none; width: min(14rem, 75vw); }
    .matrix-table th[data-tip]:nth-child(-n+3)::after { left: 0; right: auto; }

    /* The flow diagram is drawn for a wide screen: kept at a readable size and swiped sideways inside its card */
    .card:has(> .diagram) { -webkit-overflow-scrolling: touch; }
    .diagram { min-width: 600px; }


    /* Dev flag: small, in the corner, away from the buttons */
    .env-flag { right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); padding: 3px 10px; font-size: 12px; opacity: .85; }
}

/* Logg: status line, jump links, filter chips, "Viser X av Y" under the lists */
.notice.warn { background: var(--warn-bg); color: var(--warn-text); }
.notice a { color: inherit; font-weight: 600; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.pills a { display: inline-flex; align-items: center; min-height: 34px; padding: 0 14px; border: 1px solid var(--border); border-radius: 17px; background: var(--card); color: var(--text); font-size: 14px; text-decoration: none; }
.pills a:hover { border-color: var(--accent); }
.pills a.on { color: var(--accent); font-weight: 600; background: color-mix(in srgb, var(--accent) 12%, var(--card)); border-color: var(--accent); }
form.log-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 16px; }
form.log-filter .pills { margin: 0; }
form.log-filter select { appearance: none; -webkit-appearance: none; min-height: 34px; padding: 4px 36px 4px 12px; font: inherit; font-size: 14px; color: inherit; background-color: var(--card); background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-repeat: no-repeat; background-size: 6px 6px; background-position: calc(100% - 20px) center, calc(100% - 14px) center; border: 1px solid var(--border); border-radius: 17px; }
.events-table tr.warn td { color: var(--warn-text); }
.list-foot { margin: 8px 0 28px; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.list-foot a.btn-link { margin: 0; color: var(--text); font-size: 14px; }
@media (pointer: coarse) { .pills a, form.log-filter select { min-height: 44px; } }
@media (max-width: 800px) { form.log-filter select { font-size: 16px; } }
@media (max-width: 600px) { table.log-table tr.warn td:first-child { color: inherit; } }
.notice.status { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.notice.status form { display: inline-flex; margin: 0; }
.notice.status button.btn-sm { color: inherit; border-color: currentColor; background: transparent; white-space: nowrap; }
.notice.status button.btn-sm:hover { background: rgba(255, 255, 255, .45); }

/* Accent colour picker on the profile page: a dropdown whose rows show the colour as a dot */
.colorpick { position: relative; display: inline-block; margin: 6px 0 10px; }
.colorpick summary { display: inline-flex; align-items: center; gap: 8px; height: var(--btn-h-sm); padding: 0 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); cursor: pointer; list-style: none; min-width: 160px; }
.colorpick summary::-webkit-details-marker { display: none; }
.colorpick summary::after { content: "\25BE"; margin-left: auto; color: var(--muted); }
.colorpick[open] summary, .colorpick summary:focus-visible { border-color: var(--accent); }
.colorpick i { width: 14px; height: 14px; border-radius: 50%; background: var(--c); flex: none; }
.colorpick .opts { position: absolute; z-index: 5; left: 0; top: calc(100% + 4px); min-width: 100%; padding: 4px; background: var(--card); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, .12); }
.colorpick .opts label { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.colorpick .opts label:hover, .colorpick .opts label:has(input:checked) { background: var(--bg); }
.colorpick .opts label:has(input:checked) { font-weight: 600; }
.colorpick .opts input { position: absolute; opacity: 0; pointer-events: none; }
.colorpick .opts label:has(input:focus-visible) { outline: 2px solid var(--accent); }
.card:has(.colorpick) { overflow: visible; } /* the open list must not be cut off by the card */
form.edit .colorpick .opts label { margin: 0; font-weight: 400; }
form.edit .colorpick .opts label:has(input:checked) { font-weight: 600; }

/* Menu: thin lines between the groups, and a red dot on "Logg" when there are new errors */
hr.menu-sep { border: 0; border-top: 1px solid var(--border); margin: 8px 12px; }
.menu a { display: flex; align-items: center; }
.menu-badge { flex: none; width: 8px; height: 8px; margin-left: 8px; border-radius: 50%; background: var(--ev-error); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Brukere */
.user-list { list-style: none; margin: 0; padding: 0; }
.user-list li { padding: 14px 0; border-bottom: 1px solid var(--border); }
.user-list li:first-child { padding-top: 0; }
.user-list li:last-child { padding-bottom: 0; border-bottom: 0; }
.user-list .who { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.user-list .who small { flex-basis: 100%; color: var(--muted); }
details.edit-user { margin-top: 8px; }
details.edit-user > summary { cursor: pointer; display: inline-flex; align-items: center; min-height: var(--btn-h-sm); padding: 0 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); font-size: 14px; }
details.edit-user[open] > summary { margin-bottom: 8px; }
details.edit-user form { margin: 0; max-width: 30rem; }
code.newpass { display: inline-block; padding: 2px 8px; border-radius: 4px; background: rgba(255, 255, 255, .6); font-size: 1.05em; user-select: all; }

/* The title of a profile card (Logo, Aksentfarge, Bytt passord): bolder than the field labels, with air before the first one */
form.edit.profile > .lbl { font-weight: 600 !important; margin-bottom: 14px; }

/* Vis som: the developer's switch in the menu, and the bar that says what role the pages are shown as */
form.viewas { display: block; margin: 0; padding: 8px 8px 4px; }
.viewas-label { display: block; margin: 0 0 4px 4px; font-size: 12px; color: var(--muted); }
.viewas-opts { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.viewas-opts button { flex: 1; height: 30px; padding: 0 6px; font-size: 13px; color: var(--muted); background: transparent; border: 0; border-radius: 0; }
.viewas-opts button + button { border-left: 1px solid var(--border); }
.viewas-opts button:hover { background: var(--bg); filter: none; }
.viewas-opts button.on { color: var(--on-accent); background: var(--accent); font-weight: 600; }
form.viewas-bar { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 8px 16px; background: var(--warn-bg); color: var(--warn-text); border-bottom: 1px solid var(--border); font-size: 14px; position: sticky; top: 0; z-index: 40; }
form.viewas-bar button { height: 28px; padding: 0 12px; font-size: 13px; color: inherit; background: transparent; border: 1px solid currentColor; }
form.viewas-bar button:hover { background: rgba(255, 255, 255, .5); filter: none; }
@media (max-width: 800px) { form.viewas-bar { top: 57px; } }
@media (pointer: coarse) { .viewas-opts button { height: 44px; } form.viewas-bar button { height: 36px; } }

/* Role cards on the Brukere page: one card per role with what it gets, the chosen one highlighted */
form.edit .lbl { display: block; margin: 14px 0 6px; font-weight: 500; }
.role-cards { display: grid; gap: 8px; max-width: 30rem; margin: 0 0 14px; }
form.edit label.role-card { display: flex; align-items: flex-start; gap: 12px; margin: 0; padding: 12px 14px; font-weight: 400; background: var(--card); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.role-card:hover { border-color: var(--muted); }
.role-card:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card)); box-shadow: 0 0 0 1px var(--accent); }
.role-card:has(input:disabled) { opacity: .65; cursor: not-allowed; }
.role-card input { flex: none; margin: 3px 0 0; }
.role-card .rc-body { display: block; min-width: 0; }
.role-card strong { display: block; margin-bottom: 4px; }
.role-card .rc-lead { display: block; margin-bottom: 4px; color: var(--muted); font-size: 14px; }
.role-card ul { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.role-card li { position: relative; padding: 1px 0 1px 20px; }
.role-card li::before { position: absolute; left: 0; top: 1px; font-weight: 700; }
.role-card li.yes::before { content: "✓"; color: var(--ok-text); }
.role-card li.no { color: var(--muted); }
.role-card li.no::before { content: "✗"; color: var(--muted); }

/* Brukere: the badges sit evenly (the gap does the spacing), and the role takes the accent colour instead of the status green */
.user-list .who .st { margin: 0; }
.st.role-admin { background: color-mix(in srgb, var(--accent) 14%, var(--card)); color: var(--accent); }
.st.role-superadmin { background: var(--env-dev); color: var(--env-dev-text); } /* the developer: the same yellow as the DEV flag */
.st.role-user { background: var(--off-bg); color: var(--off-text); }
.st.you { padding: 1px 9px; background: transparent; border: 1px solid var(--border); color: var(--muted); }
.state-ro { margin: 0; }

/* Login: the other way in, under the button */
.login-alt { margin: 16px 0 0; font-size: 14px; text-align: center; }
.login-alt a { color: var(--muted); }

/* A run started by hand, in the event list: a "Manuell" mark, the printout opens under it */
.manual-run summary { cursor: pointer; }
.manual-run pre { margin: 8px 0 4px; padding: 10px 12px; background: var(--bg); border-radius: 6px; overflow-x: auto; font-size: 13px; }
.st.on-hand { background: color-mix(in srgb, var(--accent) 12%, var(--card)); color: var(--accent); }
tr:has(.manual-run) { cursor: pointer; }
tr:has(.manual-run):hover td { background: var(--bg); }

/* A long user name (an email address): the avatar keeps its round shape, the name is cut with "...", the arrow stays */
.account .avatar { flex: none; }
.account .user .uname { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account .user::after { flex: none; }
.account .logout { flex: none; white-space: nowrap; }

/* Users: "Rediger" as a small button at the right of the row, so each user takes less height. The form opens under the row. */
.user-list li { position: relative; }
.user-list .who { padding-right: 6.5rem; min-height: var(--btn-h-sm); }
details.edit-user { margin-top: 0; }
details.edit-user > summary { position: absolute; top: 14px; right: 0; }
.user-list li:first-child details.edit-user > summary { top: 0; }
details.edit-user[open] > summary { margin-bottom: 0; }
details.edit-user form { margin-top: 12px; }

/* Brukere: the rows line up. Name and details to the left, the badges in a column of their own with the same width for every
   role, the Rediger button at the right edge. On a narrow screen the badges go under the name. */
.user-list .who { display: grid; grid-template-columns: minmax(0, 1fr) 13rem; column-gap: 16px; row-gap: 2px; align-items: center; padding-right: 6.5rem; }
/* The row is as tall as name + details (3rem) and the Rediger button sits in the middle of that, level with the badges */
.user-list .who { min-height: 3rem; }
details.edit-user > summary { top: calc(14px + (3rem - var(--btn-h-sm)) / 2); }
.user-list li:first-child details.edit-user > summary { top: calc((3rem - var(--btn-h-sm)) / 2); }
.user-list .who strong { grid-column: 1; grid-row: 1; overflow-wrap: anywhere; }
.user-list .who small { grid-column: 1; grid-row: 2; flex-basis: auto; }
.user-list .who .badges { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.user-list .who .st.role { min-width: 6.5rem; text-align: center; }
@media (max-width: 800px) {
    .user-list .who { grid-template-columns: minmax(0, 1fr); }
    .user-list .who .badges { grid-column: 1; grid-row: 2; margin: 4px 0; }
    .user-list .who small { grid-row: 3; }
}

/* Avatars: a picture (uploaded, or made from the username) in a circle */
img.avatar { display: block; flex: none; object-fit: cover; background: var(--card); }
.avatar-lg { width: 96px; height: 96px; }
.avatar-edit { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px; margin: 8px 0 4px; }
.avatar-edit .avatar-actions { flex: 1 1 18rem; min-width: 0; }
.avatar-edit label.plain { margin: 0 0 8px; }
.user-list .who strong { display: flex; align-items: center; gap: 10px; }
