/* Portal style A: light SaaS look with a sidebar, soft cards and a dark set of the same colours. */
[data-theme=light] {
  color-scheme: light;
}

[data-theme=dark] {
  color-scheme: dark;
}

[data-theme=system] {
  color-scheme: light dark;
}

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

:root,
[data-theme=light] {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-alt: #eef1f7;
  --text: #1c2333;
  --muted: #5d6779;
  --border: #dde2ec;
  --accent: #3b5bdb;
  --accent-text: #ffffff;
  --shadow: 0 1px 3px rgba(20, 30, 60, 0.08), 0 4px 12px rgba(20, 30, 60, 0.05);
  --danger: #b00020;
  --notice-bg: #fff3cd;
  --notice-text: #5c4300;
  --ok-bg: #dcf5e4;
  --ok-text: #14632e;
  --bad-bg: #fde0e0;
  --bad-text: #8c1d1d;
  --neutral-bg: #e6e9f0;
  --neutral-text: #3d465a;
  --warn-bg: #fdf0cf;
  --warn-text: #7a5600;
}

[data-theme=dark] {
  --bg: #0f1420;
  --surface: #181f30;
  --surface-alt: #202a40;
  --text: #e6e9f2;
  --muted: #9aa5bd;
  --border: #2a3550;
  --accent: #7c97ff;
  --accent-text: #0f1420;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
  --danger: #ff8a9b;
  --notice-bg: #4a3b0c;
  --notice-text: #ffe9a8;
  --ok-bg: #153a24;
  --ok-text: #8be0a8;
  --bad-bg: #4a1c1c;
  --bad-text: #ffb3b3;
  --neutral-bg: #2a3350;
  --neutral-text: #c4cce0;
  --warn-bg: #4a3b0c;
  --warn-text: #ffe9a8;
}

@media (prefers-color-scheme: dark) {
  [data-theme=system] {
    --bg: #0f1420;
    --surface: #181f30;
    --surface-alt: #202a40;
    --text: #e6e9f2;
    --muted: #9aa5bd;
    --border: #2a3550;
    --accent: #7c97ff;
    --accent-text: #0f1420;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.3);
    --danger: #ff8a9b;
    --notice-bg: #4a3b0c;
    --notice-text: #ffe9a8;
    --ok-bg: #153a24;
    --ok-text: #8be0a8;
    --bad-bg: #4a1c1c;
    --bad-text: #ffb3b3;
    --neutral-bg: #2a3350;
    --neutral-text: #c4cce0;
    --warn-bg: #4a3b0c;
    --warn-text: #ffe9a8;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
.page-title { display: flex; align-items: center; gap: 0.6rem; margin: 0 0 1rem; }
.page-title h1 { margin: 0; }
.icon { width: 1.1em; height: 1.1em; flex: none; }
.page-title .icon { width: 1.6rem; height: 1.6rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.75rem; }
pre { overflow-x: auto; }
code { background: var(--surface-alt); padding: 0.1rem 0.3rem; border-radius: 4px; }

label { display: block; margin: 0.75rem 0 0.25rem; color: var(--muted); font-size: 0.9rem; }
input, select {
  padding: 0.5rem 0.6rem;
  min-width: 16rem;
  max-width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}
input[type="radio"] { min-width: 0; width: auto; padding: 0; border: 0; }
button {
  margin-top: 1rem;
  padding: 0.5rem 1.1rem;
  background: var(--accent);
  color: var(--accent-text);
  border: 0;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}
button.icon-button { display: inline-flex; align-items: center; justify-content: center; padding: 0.5rem 0.9rem; }
button.icon-button .icon { width: 1.4rem; height: 1.4rem; }
button.icon-button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Admin page: one card per developer with the name, icon actions and a fact list. */
.dev-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; }
.dev-head h2 { margin: 0; }
.dev-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.dev-actions form { margin: 0; }
.dev-actions button { margin: 0; }
.dev-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem 1.25rem; margin: 1rem 0 0; }
.dev-facts dt { color: var(--muted); font-size: 0.85rem; }
.dev-facts dd { margin: 0.2rem 0 0; }
.dev-facts select { min-width: 0; padding: 0.3rem 0.5rem; }
.filter-row { display: flex; flex-wrap: wrap; gap: 0 1rem; }
.filter-row .field { flex: 1 1 10rem; min-width: 0; }
.filter-row .field select, .filter-row .field input { width: 100%; min-width: 0; }

.error { color: var(--danger); }
.field-error { margin: 0.35rem 0 0; font-size: 0.9rem; }
.key { font-size: 1.1rem; letter-spacing: 0.1rem; }
.inline { display: inline; }
.inline button { margin-top: 0; margin-left: 0.5rem; padding: 0.2rem 0.7rem; }
/* The role save button joins its form from the card actions, so it matches the inline action buttons. */
.dev-actions > button { margin-left: 0.5rem; padding: 0.2rem 0.7rem; }
.notice { background: var(--notice-bg); color: var(--notice-text); padding: 0.6rem 0.9rem; border-radius: 6px; }
.notice a { color: inherit; }
.notice-closable { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 0 1rem; }
.notice-close { display: inline-flex; padding: 0.15rem; border-radius: 4px; text-decoration: none; }
.notice-close .icon { width: 1.1rem; height: 1.1rem; }
.notice-close:hover { background: rgba(0, 0, 0, 0.12); }

/* App layout: sidebar and content. */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 14rem;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.25rem 1rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.15rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 0.25rem; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}
.sidebar nav a:hover { background: var(--surface-alt); }
.sidebar nav a.active { background: var(--accent); color: var(--accent-text); }
.switch { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; color: var(--muted); }
.switch a { color: var(--muted); text-decoration: none; padding: 0.1rem 0.4rem; border-radius: 4px; }
.theme-switch { display: inline-flex; gap: 0.15rem; padding: 0.2rem; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 999px; }
.theme-switch a { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 1.6rem; padding: 0; border-radius: 999px; }
.switch .theme-switch a.active { background: var(--accent); color: var(--accent-text); }
.theme-switch .icon { width: 1rem; height: 1rem; }
.lang-switch label { display: inline; margin: 0; font-size: inherit; }
.lang-switch select { min-width: 0; padding: 0.2rem 0.4rem; }
.lang-switch button { margin: 0; padding: 0.25rem 0.5rem; }
.lang-switch button .icon { width: 1.1rem; height: 1.1rem; }
.switch a.active { background: var(--surface-alt); color: var(--text); font-weight: 600; }
.logout button { margin: 0; }
main.content { flex: 1; min-width: 0; padding: 2rem; max-width: 70rem; }
/* The page title and the tool bar share the first row; the tool bar stays right-aligned when it wraps. */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; margin: 0 0 1rem; }
.page-head > .page-title, .page-head > h1 { margin: 0; }
.page-head > .page-tools { margin-left: auto; }
.page-tools { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }
.page-tools .switch > span:first-child, .page-tools .lang-switch label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.page-tools .logout button { padding: 0.3rem 0.5rem; }
.page-tools .logout .icon { width: 1.1rem; height: 1.1rem; }

/* Card layout: login, TOTP, enrolment and setup. */
.card-page { min-height: 100vh; display: flex; flex-direction: column; padding: 2rem; }
.card-page-body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.25rem; }
.card-page .card { width: 100%; max-width: 26rem; }
.help-link { display: inline-flex; padding: 0.3rem; border-radius: 4px; color: var(--muted); }
.help-link:hover { background: var(--surface-alt); color: var(--text); }
.help-link .icon { width: 1.3rem; height: 1.3rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}
.card h2:first-child { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.cards .card { margin-bottom: 0; }
.stat-label { display: block; color: var(--muted); font-size: 0.85rem; }
.stat-value { display: block; font-size: 1.8rem; font-weight: 700; }
.card p { margin: 0.4rem 0; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }
th a { color: inherit; text-decoration: none; }
th a:hover, th a:focus-visible { text-decoration: underline; }
.table-wrap { overflow-x: auto; }

/* Dashboard lists: a bordered table with a tinted header and a footer row with total, page size and pager. */
.list-table { margin-top: 1rem; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.list-table table { font-size: 0.9rem; }
.list-table th { background: var(--surface-alt); padding: 0.75rem 1rem; white-space: nowrap; }
.list-table td { padding: 0.8rem 1rem; }
.list-table tr:last-child td { border-bottom: 0; }
.list-table tr:hover td { background: var(--surface-alt); }
.table-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--muted);
}
.table-foot .total { margin-right: auto; }
.table-foot form { display: flex; align-items: center; gap: 0.5rem; margin: 0; }
.table-foot select, .table-foot input { min-width: 0; padding: 0.35rem 0.5rem; }
.table-foot input[type="number"] { width: 4.5rem; }
.table-foot label { display: inline; margin: 0; font-size: inherit; }
.table-foot button { margin: 0; padding: 0.35rem 0.6rem; }
.pager { display: flex; align-items: center; gap: 0.25rem; }
.pager a, .pager span { min-width: 2rem; height: 2rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; padding: 0 0.4rem; }
.pager a { color: var(--text); text-decoration: none; }
.pager a:hover, .pager a:focus-visible { background: var(--surface-alt); }
.pager .current { background: var(--surface-alt); color: var(--text); font-weight: 600; }
.pager .disabled { opacity: 0.4; }

.badge {
  display: inline-block;
  padding: 0.05rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: var(--neutral-bg);
  color: var(--neutral-text);
}
.badge-done { background: var(--ok-bg); color: var(--ok-text); }
.badge-failed { background: var(--bad-bg); color: var(--bad-text); }
.badge-cancelled, .badge-skipped-draft, .badge-skipped-inactive { background: var(--warn-bg); color: var(--warn-text); }

/* The auto-submit notice: read by assistive technology, shown while its form has focus. */
.auto-hint {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
form[data-auto-submit]:focus-within .auto-hint {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip-path: none;
  white-space: normal;
  flex-basis: 100%;
  color: var(--muted);
  font-size: 0.85em;
}

@media (max-width: 40rem) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  main.content { padding: 1rem; }
  input, select { min-width: 0; width: 100%; }
  input[type="radio"] { width: auto; }
}
