/* Design tokens. Every color, size and font used below comes from here. */
:root {
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;

  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.5rem;
  --text-2xl: 2rem;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;

  --radius: 4px;
  --content-width: 72rem;

  --color-bg: #f7f6f3;
  --color-surface: #ffffff;
  --color-text: #1d2125;
  --color-text-muted: #5b6168;
  --color-border: #dcd9d2;
  --color-accent: #2c5d7c;
  --color-accent-text: #ffffff;
  --color-danger: #a12f2f;
  --color-success: #2f6b45;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #16191c;
    --color-surface: #1e2226;
    --color-text: #e4e2dd;
    --color-text-muted: #9aa0a6;
    --color-border: #33383d;
    --color-accent: #7fb0cf;
    --color-accent-text: #10161b;
    --color-danger: #e08080;
    --color-success: #83c29b;
  }
}

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

html {
  font-family: var(--font-sans);
  font-size: 100%;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 var(--space-4);
}

h1 {
  font-size: var(--text-2xl);
  font-weight: 600;
}

p {
  margin: 0 0 var(--space-4);
}

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

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

/* Page frame */
.site-header,
.site-main,
.site-footer {
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding-inline: var(--space-4);
}

.site-header {
  padding-block: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.wordmark {
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: 0.01em;
  color: var(--color-text);
  text-decoration: none;
}

.site-main {
  flex: 1;
  padding-block: var(--space-12);
}

.site-footer {
  padding-block: var(--space-6);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
}

.site-nav form {
  margin: 0;
}

.nav-button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
  color: var(--color-text);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-1) var(--space-3);
  cursor: pointer;
}

.nav-button:hover {
  background: var(--color-surface);
  border-color: var(--color-text-muted);
}

/* Content */
.intro {
  max-width: 40rem;
}

.lead {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
}

h2 {
  font-size: var(--text-lg);
  font-weight: 600;
}

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

.hint {
  font-size: var(--text-sm);
  margin: var(--space-1) 0 0;
}

code {
  font-family: var(--font-mono);
  font-size: 0.95em;
}

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  max-width: 44rem;
}

.panel.narrow {
  max-width: 26rem;
  margin-inline: auto;
}

.panel > :last-child {
  margin-bottom: 0;
}

/* Elements with the hidden attribute stay hidden even when a class sets their display. */
[hidden] {
  display: none !important;
}

/* Forms */
.form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: 100%;
}

.field-check {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
}

label,
.label {
  font-size: var(--text-sm);
  font-weight: 600;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  width: 100%;
  font: inherit;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-3);
}

input[type="checkbox"],
input[type="radio"] {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  flex: none;
  accent-color: var(--color-accent);
}

.button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
  color: var(--color-accent-text);
  background: var(--color-accent);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
}

.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.button-secondary {
  color: var(--color-accent);
  background: transparent;
}

.button-small {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
}

.button-danger {
  color: var(--color-danger);
  background: transparent;
  border-color: var(--color-danger);
}

.link-button {
  font: inherit;
  color: var(--color-accent);
  background: none;
  border: 0;
  padding: 0;
  text-decoration: underline;
  cursor: pointer;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.actions form {
  margin: 0;
}

.divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--color-border);
}

.aside {
  font-size: var(--text-sm);
}

.disclosure {
  margin-top: var(--space-4);
  font-size: var(--text-sm);
}

.disclosure summary {
  cursor: pointer;
  color: var(--color-accent);
  margin-bottom: var(--space-3);
}

/* Notices */
.notice {
  border-left: 3px solid;
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  margin: 0 0 var(--space-4);
  background: var(--color-surface);
}

.notice ul,
.notice p {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.notice-success {
  border-color: var(--color-success);
}

.notice-error {
  border-color: var(--color-danger);
  color: var(--color-danger);
}

/* Lists */
.settings {
  margin: 0;
}

.settings > div {
  display: grid;
  grid-template-columns: 12rem 1fr;
  gap: var(--space-4);
  padding-block: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.settings dt {
  font-weight: 600;
}

.settings dd {
  margin: 0;
  display: flex;
  gap: var(--space-3);
}

.item-list {
  list-style: none;
  margin: 0 0 var(--space-4);
  padding: 0;
}

.item-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-3);
  padding-block: var(--space-2);
  border-top: 1px solid var(--color-border);
}

.item-list form {
  margin: 0 0 0 auto;
}

.code-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2) var(--space-6);
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-6);
}

.steps {
  padding-left: var(--space-6);
}

.qr-code svg {
  display: block;
  width: 12rem;
  height: auto;
  margin-bottom: var(--space-4);
  border-radius: var(--radius);
}

/* Application shell: sidebar with company and navigation next to the content */
.app-shell {
  flex: 1;
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
}

.sidebar {
  padding: var(--space-6) var(--space-4);
  border-right: 1px solid var(--color-border);
  font-size: var(--text-sm);
}

.app-main {
  padding: var(--space-8) var(--space-6);
  min-width: 0;
}

.company-switcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  margin: 0 0 var(--space-6);
  padding: var(--space-2) var(--space-3);
  font: inherit;
  text-align: left;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

button.company-switcher {
  cursor: pointer;
}

button.company-switcher:hover {
  border-color: var(--color-text-muted);
}

.company-switcher-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.company-switcher-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.company-switcher-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.chevron {
  flex: none;
  width: 1rem;
  height: 1rem;
  color: var(--color-text-muted);
}

.nav-list a {
  display: block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius);
  color: var(--color-text);
  text-decoration: none;
}

.nav-list a:hover {
  background: var(--color-surface);
}

/* Popovers: menus and info hints, positioned by popovers.js */
[popover][data-anchored] {
  position: fixed;
  inset: auto;
  margin: 0;
}

.menu {
  padding: var(--space-1);
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.15);
  font-size: var(--text-sm);
}

.menu a {
  display: block;
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-6);
  border-radius: var(--radius);
  color: var(--color-text);
  text-decoration: none;
}

.menu a:hover {
  background: var(--color-bg);
}

.menu a[aria-current="true"] {
  font-weight: 600;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5l3 3 7-7' fill='none' stroke='%23888' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: var(--space-2) center;
  background-size: 0.85rem;
}

.label-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.info-hint {
  display: inline-grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  font: italic 600 0.75rem/1 Georgia, "Times New Roman", serif;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid var(--color-text-muted);
  border-radius: 50%;
  cursor: help;
}

.info-hint:hover,
.info-hint:focus-visible {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.info-popover {
  max-width: min(22rem, calc(100vw - 2rem));
  padding: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 400;
  line-height: 1.45;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.15);
}

.nav-list {
  list-style: none;
  margin: 0 0 var(--space-6);
  padding: 0;
}

.nav-list a[aria-current="page"] {
  background: var(--color-surface);
  box-shadow: inset 3px 0 0 var(--color-accent);
  font-weight: 600;
}

.nav-heading {
  margin: 0 0 var(--space-2);
  padding-inline: var(--space-2);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.page-header h1 {
  margin: 0;
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: var(--text-sm);
}

.table th,
.table td {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.table th {
  font-weight: 600;
  color: var(--color-text-muted);
}

/* Form layout */
.fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 var(--space-2);
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.fieldset legend {
  font-weight: 600;
  margin-bottom: var(--space-3);
}

.field-row {
  display: flex;
  gap: var(--space-4);
  width: 100%;
}

/* Groups fields without a frame, for example to disable them together or show them only for some choices. */
.form-fields {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-6);
}

/* A checkbox in a field row, aligned with the inputs next to it. */
.field-check-cell {
  flex: 0 0 9rem;
  justify-content: flex-end;
  min-height: 2.6rem;
}

.search-form {
  margin-bottom: var(--space-4);
}

.table-scroll {
  overflow-x: auto;
  margin-bottom: var(--space-4);
}

.table .number {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table a {
  font-weight: 600;
}

.field-short {
  flex: 0 0 9rem;
}

.field-medium {
  flex: 0 0 14rem;
}

.input-group {
  display: flex;
}

.input-prefix {
  display: grid;
  place-items: center;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius);
}

.input-prefix:not([hidden]) + input {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

[hidden] {
  display: none !important;
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
}

.form-inline .field {
  flex: 1 1 14rem;
  width: auto;
}

.form-inline .field-short {
  flex: 0 0 11rem;
}

.choice-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.choice-list a {
  display: block;
  padding: var(--space-3) 0;
  border-top: 1px solid var(--color-border);
  font-weight: 600;
}

/* Members */
.member-list {
  list-style: none;
  margin: 0 0 var(--space-6);
  padding: 0;
}

.member-list > li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-6);
  padding-block: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.member-name {
  display: flex;
  flex-direction: column;
  min-width: 14rem;
}

.role-checks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  flex: 1;
  font-size: var(--text-sm);
}

.role-checks label {
  font-weight: 400;
}

.member-list form {
  margin: 0;
}

.danger-zone {
  max-width: 44rem;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

@media (max-width: 48rem) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
    padding-block: var(--space-4);
  }

  .app-main {
    padding: var(--space-6) var(--space-4);
  }

  .field-row {
    flex-direction: column;
  }

  .field-short,
  .field-medium,
  .field-check-cell {
    flex-basis: auto;
  }

  .field-check-cell {
    min-height: 0;
  }
}

@media (max-width: 40rem) {
  .settings > div {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }
}

/* Modules */
.module-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.module-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.module-head h2 {
  margin: 0;
}

.badge {
  display: inline-block;
  padding: 0 var(--space-2);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.6;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}

.badge-success {
  color: var(--color-success);
  border-color: var(--color-success);
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}

.inline-form label {
  font-weight: 400;
}

input.input-small {
  width: auto;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-sm);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Audit log */
.audit-table td {
  vertical-align: top;
}

.nowrap {
  white-space: nowrap;
}

.audit-details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0 var(--space-3);
  margin: 0;
}

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

.audit-details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.title-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.title-row h1 {
  margin: 0;
}

/* Notifications */
.count {
  display: inline-grid;
  place-items: center;
  min-width: 1.25rem;
  height: 1.25rem;
  margin-left: var(--space-1);
  padding: 0 var(--space-1);
  font-size: 0.75rem;
  color: var(--color-accent-text);
  background: var(--color-accent);
  border-radius: 999px;
}

.notification-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.notification-list li {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3) var(--space-2);
  border-top: 1px solid var(--color-border);
}

.notification-list li.is-unread {
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--color-accent);
}

/* Compact header on narrow screens */
.menu-toggle {
  display: none;
}

.site-menu {
  min-width: 14rem;
}

.site-menu .nav-button {
  display: block;
  width: 100%;
  margin-bottom: var(--space-1);
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-color: transparent;
}

.site-menu form {
  margin: 0;
}

@media (max-width: 40rem) {
  .site-nav {
    display: none;
  }

  .menu-toggle {
    display: inline-flex;
    align-items: center;
  }
}

/* Footer and legal pages */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2) var(--space-6);
}

.footer-nav {
  display: flex;
  gap: var(--space-4);
}

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

.legal {
  max-width: 44rem;
}

.legal h2 {
  margin-top: var(--space-8);
}

.placeholder {
  padding: 0 var(--space-1);
  color: var(--color-danger);
  background: transparent;
  border: 1px dashed var(--color-danger);
  border-radius: var(--radius);
}
