/* =========================================================================
   Ligo Regnskap application shell in the training-health minimalistic style
   (training-health/personal_os/web/minimalistic.css): theme surfaces, 1 px
   lines, 10 px corners and few frames. Only the outer panel, fields, buttons
   and the hover or active state get one. A state is a 7 px key and its words.
   Requires theme.css and colors_and_type.css. control-plane.css adds page
   specific rules only.
   ========================================================================= */

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

html {
  scroll-behavior: smooth;
}

body {
  min-width: 0;
  max-width: 100%;
  margin: 0;
}

button {
  cursor: pointer;
}

:is(a, button, summary, input, select, textarea, [tabindex]):focus-visible {
  outline: 1px solid var(--primary);
  outline-offset: 2px;
}

::selection {
  background: rgba(var(--primary-rgb), .28);
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 8px 14px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--bg-cream);
  color: var(--ink);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

/* ---------- Labels: section and field names, keys, badges and buttons ---------- */

.side-section-label,
.brand-copy small,
.login-brand small,
.page-eyebrow,
.section-label,
.section-kicker,
.page-date,
.field-label,
.metric-item > span,
.control-table th,
.quiet-badge,
.cadence-badge,
.text-link,
.development-notice {
  color: var(--muted);
  font: 400 var(--minimal-label)/1.5 var(--font-mono);
  letter-spacing: var(--minimal-tracking);
  text-transform: uppercase;
}

/* ---------- Shell grid ---------- */

.control-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.content-shell {
  min-width: 0;
}

:is(.page-heading, .surface-heading, .panel-body, .field-group, .metric-item) > *,
.control-main fieldset {
  min-width: 0;
  max-width: 100%;
}

.control-main fieldset {
  min-inline-size: 0;
}

:is(.page-heading, .surface-heading, .notice, .field-label, .field-help, .check-row) {
  overflow-wrap: anywhere;
}

.control-main {
  width: min(100%, 1320px);
  margin: 0 auto;
  padding: 44px 40px 64px;
}

.control-main p {
  margin-top: 0;
}

/* ---------- Sidebar ---------- */

.side-rail {
  position: sticky;
  z-index: 80;
  top: 0;
  display: flex;
  height: 100vh;
  height: 100dvh;
  flex-direction: column;
  gap: 20px;
  overflow: hidden auto;
  padding: 16px 14px 14px;
  border-right: 1px solid var(--border);
  background: var(--bg-cream);
  scrollbar-width: thin;
}

.brand-lockup,
.mobile-brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.brand-lockup {
  min-height: 48px;
  padding: 2px 6px 16px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  width: 50px;
  height: 30px;
  flex: none;
  object-fit: contain;
}

.brand-copy {
  display: grid;
  min-width: 0;
  line-height: 1.3;
}

.brand-copy strong {
  overflow: hidden;
  color: var(--ink);
  font: 500 var(--minimal-text)/1.4 var(--font-sans);
  text-overflow: ellipsis;
  white-space: nowrap;
}


.brand-product {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-product svg {
  width: 14px;
  height: 14px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.side-section {
  min-width: 0;
}

.side-section-label {
  display: block;
  margin: 0 10px 8px;
}

.side-nav {
  display: grid;
  gap: 2px;
}

.side-nav a,
.theme-picker > summary {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: 400 var(--minimal-label)/1.5 var(--font-mono);
  overflow-wrap: anywhere;
}

.side-nav a:is(.is-active, [aria-current="page"], :hover, :focus-visible),
.theme-picker > summary:is(:hover, :focus-visible),
.theme-picker[open] > summary {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--ink);
  outline: none;
}

:is(.side-nav, .theme-picker, .side-icon-button, .sidebar-mobile-toggle) svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.side-footer {
  display: grid;
  gap: 2px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* The theme picker: the six training-health themes, a 7 px key per theme. */
.theme-picker > summary {
  cursor: pointer;
  list-style: none;
}

.theme-picker > summary::-webkit-details-marker {
  display: none;
}

.theme-picker-current {
  margin-left: auto;
  color: var(--muted);
}

.theme-picker-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 6px 0 8px;
}

.theme-option {
  display: flex;
  min-width: 0;
  min-height: 32px;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font: 400 var(--minimal-label)/1.4 var(--font-sans);
  text-align: left;
}

.theme-option i {
  flex: 0 0 var(--marker);
  width: var(--marker);
  height: var(--marker);
  background: var(--swatch);
}

.theme-option[data-theme-option="dark"] { --swatch: #3fb2c9; }
.theme-option[data-theme-option="light"] { --swatch: #9a5800; }
.theme-option[data-theme-option="light-green"] { --swatch: #1f6b5c; }
.theme-option[data-theme-option="light-pink"] { --swatch: #8e3563; }
.theme-option[data-theme-option="paper"] { --swatch: #9b9b9b; }
.theme-option[data-theme-option="paper-light"] { --swatch: #5f5f5d; }

.theme-option:is(:hover, :focus-visible, [aria-pressed="true"]) {
  border-color: var(--primary);
  background: var(--primary-soft);
  outline: none;
}

.side-account {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  padding: 10px 0 0 10px;
}

.account-copy {
  display: grid;
  min-width: 0;
  flex: 1;
}

.account-copy strong {
  overflow: hidden;
  color: var(--ink);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-copy small {
  overflow: hidden;
  color: var(--muted);
  font: 400 var(--minimal-label)/1.5 var(--font-mono);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-icon-button,
.sidebar-mobile-toggle {
  display: grid;
  width: 36px;
  height: 36px;
  flex: none;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-cream);
  color: var(--ink);
}

:is(.side-icon-button, .sidebar-mobile-toggle):is(:hover, :focus-visible, [aria-expanded="true"]) {
  border-color: var(--primary);
  background: var(--primary-soft);
  outline: none;
}

.mobile-header,
.sidebar-backdrop {
  display: none;
}

/* ---------- Collapsed rail ---------- */

/* The logo is the button that folds the rail to its icons on wide screens
   and closes the drawer on phones. The layout script keeps the choice per
   browser and sets it on <html> before the first paint. */
button.brand-lockup {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

@media (min-width: 961px) {
  html[data-sidebar="collapsed"] .control-shell {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  html[data-sidebar="collapsed"] .side-rail {
    padding-inline: 8px;
  }

  html[data-sidebar="collapsed"] .brand-lockup {
    justify-content: center;
    padding-inline: 0;
  }

  html[data-sidebar="collapsed"] .brand-mark {
    width: 40px;
  }

  html[data-sidebar="collapsed"] :is(.brand-copy, .side-section-label, .account-copy, .theme-picker > summary > span, .theme-picker-options) {
    display: none;
  }

  html[data-sidebar="collapsed"] :is(.side-nav a, .theme-picker > summary) {
    justify-content: center;
    gap: 0;
    padding-inline: 0;
    font-size: 0;
  }

  html[data-sidebar="collapsed"] .side-account {
    justify-content: center;
    padding-left: 0;
  }
}

/* ---------- Page heading ---------- */

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: 32px;
  scroll-margin-top: 20px;
}

/* The display face is the page title, also on the sign-in pages. Tailwind's
   preflight loads after this file and resets bare headings, hence the classes. */
.page-heading h1,
.login-form-wrap h1,
.auth-heading h1 {
  margin: 0;
  color: var(--ink);
  font: var(--heading-weight) clamp(24px, 3vw, 32px)/1.15 var(--font-display);
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
}

.page-eyebrow {
  display: block;
  margin: 0 0 10px;
}

.section-label,
.section-kicker {
  display: block;
  margin: 0;
}

.page-description {
  max-width: 40rem;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 16px;
}

/* ---------- Key figures: one frame, cells split by lines ---------- */

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.metric-item {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 4px;
  padding: 18px 20px;
  border-right: 1px solid var(--border);
}

.metric-item:last-child {
  border-right: 0;
}

.metric-item > span {
  overflow-wrap: anywhere;
}

.metric-item strong {
  color: var(--ink);
  font: var(--heading-weight) var(--minimal-title)/1.35 var(--font-sans);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.metric-item small {
  color: var(--muted);
  font-size: var(--minimal-text);
}

/* ---------- Panels: the outer frame; nothing inside gets another ---------- */

.control-surface {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  scroll-margin-top: 20px;
}

.surface-spaced {
  margin-top: 20px;
}

.surface-heading {
  display: flex;
  min-height: 56px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin: 0;
  padding: 16px 24px;
}

.surface-heading h2 {
  margin: 0;
  color: var(--ink);
  font: var(--heading-weight) var(--minimal-title)/1.35 var(--font-sans);
  letter-spacing: -.015em;
  text-transform: none;
}

.surface-heading :is(.section-label, .section-kicker) + h2 {
  margin-top: 4px;
  color: var(--ink);
  font: var(--heading-weight) var(--minimal-title)/1.35 var(--font-sans);
  letter-spacing: 0;
  text-transform: none;
}

.surface-heading p {
  margin: 4px 0 0;
  color: var(--muted);
}

.panel-body {
  padding: 20px 24px;
}

.surface-heading + .panel-body {
  padding-top: 4px;
}

.panel-body > :first-child {
  margin-top: 0;
}

/* ---------- States and badges ---------- */

.status-badge {
  max-width: 100%;
  overflow-wrap: anywhere;
  --status-tone: var(--muted-2);
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font: 400 var(--minimal-text)/1.4 var(--font-sans);
  white-space: normal;
}

.status-badge::before {
  flex: 0 0 var(--marker);
  width: var(--marker);
  height: var(--marker);
  background: var(--status-tone);
  content: "";
}

.status-dot {
  display: none;
}

:is(.status-active, .status-reviewed, .status-completed, .status-succeeded, .status-approved, .status-accepted, .status-done, .status-ok) {
  --status-tone: var(--success);
}

:is(.status-running, .status-queued, .status-sending) {
  --status-tone: var(--primary);
}

:is(.status-awaiting_approval, .status-needs_review, .status-pending, .status-unreviewed, .status-unknown, .status-warning) {
  --status-tone: var(--warning);
}

:is(.status-failed, .status-rejected, .status-stale, .status-error, .status-blocked, .status-disabled) {
  --status-tone: var(--danger);
}

.quiet-badge,
.cadence-badge {
  display: inline-block;
  white-space: nowrap;
}

.level-badge {
  display: inline-block;
  color: var(--ink);
  font: 400 var(--minimal-text)/1.4 var(--font-mono);
}

/* ---------- Tables ---------- */

.table-scroll {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}

.control-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.control-table th {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.control-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  vertical-align: middle;
}

.control-table :is(th, td):first-child {
  padding-left: 24px;
}

.control-table :is(th, td):last-child {
  padding-right: 24px;
}

.control-table .is-numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.control-table tbody tr:last-child td {
  border-bottom: 0;
}

.control-table tbody tr:hover td {
  background: var(--primary-soft);
}

.table-primary,
.table-link {
  color: var(--ink);
  font-weight: 500;
}

.table-link:is(:hover, :focus-visible) {
  text-decoration: underline;
  text-decoration-color: var(--primary);
  text-underline-offset: .3em;
}

.table-secondary {
  margin-top: 2px;
  color: var(--muted);
}

.empty-table {
  padding: 32px 24px !important;
  color: var(--muted) !important;
}

@media (max-width: 760px) {
  .stacked-table,
  .stacked-table tbody {
    display: block;
    width: 100%;
  }

  .stacked-table thead {
    display: none;
  }

  .stacked-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 16px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
  }

  .stacked-table tbody tr:last-child {
    border-bottom: 0;
  }

  .control-table.stacked-table tbody td {
    display: block;
    min-width: 0;
    max-width: none;
    padding: 0;
    border: 0;
  }

  .stacked-table td:not([data-label]) {
    grid-column: 1 / -1;
  }

  .stacked-table td[data-label]::before {
    display: block;
    color: var(--muted);
    font: 400 var(--minimal-label)/1.5 var(--font-mono);
    letter-spacing: var(--minimal-tracking);
    text-transform: uppercase;
    content: attr(data-label);
  }

  .stacked-table tbody tr:hover td {
    background: transparent;
  }

  .stacked-table .run-progress-block {
    margin: 0;
  }
}

/* ---------- Links in their own place: mono capitals, underlined ---------- */

.text-link {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 5px;
  cursor: pointer;
}

.text-link:is(:hover, :focus-visible) {
  color: var(--ink);
  text-decoration-color: var(--primary);
  outline: none;
}

/* ---------- Empty states and messages: one muted line ---------- */

.empty-state-inline {
  display: flex;
  min-height: 0;
  align-items: center;
  gap: 10px;
  padding: 8px 24px 24px;
  color: var(--muted);
}

.empty-state-inline strong {
  color: inherit;
  font-weight: 400;
}

.control-surface > .empty-state-inline:first-child {
  padding-top: 24px;
}

.notice,
.flash-message,
.form-error {
  position: relative;
  margin: 0 0 20px;
  padding: 0 0 0 17px;
  border: 0;
  background: none;
  color: var(--ink);
  line-height: 1.6;
}

.notice::before,
.flash-message::before,
.form-error::before {
  position: absolute;
  top: .6em;
  left: 0;
  width: var(--marker);
  height: var(--marker);
  background: var(--primary);
  content: "";
}

.notice-success::before {
  background: var(--success);
}

.notice-error::before,
.flash-message.is-error::before,
.form-error::before {
  background: var(--danger);
}

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

.notice ul,
.form-error-list {
  margin: 4px 0 0;
  padding-left: 0;
  list-style: none;
}

.create-bar-error {
  grid-column: 1 / -1;
  margin: 0;
}

/* ---------- Fields ---------- */

.filter-bar,
.create-bar {
  display: grid;
  align-items: end;
  gap: 12px;
  margin-bottom: 20px;
}

.filter-bar {
  grid-template-columns: minmax(230px, 2fr) repeat(3, minmax(140px, 1fr)) auto;
}

.create-bar {
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
}

.field-group {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 6px;
}

.field-label {
  display: block;
}

.control-input,
.control-select,
.control-textarea,
.control-main input:not([type="hidden"], [type="checkbox"], [type="radio"], [type="range"]),
.control-main select,
.control-main textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 38px;
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  caret-color: var(--ink);
  font: 400 var(--minimal-text)/1.4 var(--font-sans);
  box-shadow: none;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}

:is(.control-select, .control-main select) option {
  background: var(--bg-cream);
  color: var(--ink);
}

:is(.control-textarea, .control-main textarea) {
  min-height: 84px;
  line-height: 1.6;
  resize: vertical;
}

:is(.control-input, .control-textarea, .control-main input, .control-main textarea)::placeholder {
  color: var(--muted);
  opacity: 1;
}

:is(.control-input, .control-select, .control-textarea, .control-main input:not([type="hidden"], [type="checkbox"], [type="radio"], [type="range"]), .control-main select, .control-main textarea):is(:hover, :focus) {
  border-color: var(--primary);
}

:is(.control-input, .control-select, .control-textarea, .control-main input:not([type="hidden"], [type="checkbox"], [type="radio"], [type="range"]), .control-main select, .control-main textarea):focus {
  outline: none;
  background: var(--primary-soft);
}

:is(.control-input, .control-main input)[readonly] {
  color: var(--muted);
}

:is(.control-input, .control-main input):-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--bg-cream) inset;
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--primary);
}

.check-row {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  cursor: pointer;
}

.field-help,
.field-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.6;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.inline-form > :is(input, select) {
  flex: 1 1 160px;
  width: auto;
}

/* ---------- Buttons: mono capitals in a 1 px frame ---------- */

.primary-button,
.secondary-button,
.danger-button,
.ghost-button {
  display: inline-flex;
  min-width: 0;
  min-height: 38px;
  max-width: 100%;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font: 400 var(--minimal-control)/1.5 var(--font-mono);
  letter-spacing: var(--minimal-tracking);
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  white-space: normal;
  overflow-wrap: anywhere;
  box-shadow: none;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}

.secondary-button,
.ghost-button {
  border-color: var(--border);
}

.danger-button {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--bg-cream));
  color: var(--danger);
}

:is(.primary-button, .secondary-button, .ghost-button):is(:hover, :focus-visible, .is-active):not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--ink);
  outline: none;
}

.danger-button:is(:hover, :focus-visible):not(:disabled) {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, var(--bg-cream));
  color: var(--danger);
  outline: none;
}

:is(.primary-button, .secondary-button, .danger-button, .ghost-button):disabled {
  opacity: .5;
  cursor: not-allowed;
}

:is(.primary-button, .secondary-button, .danger-button, .ghost-button) svg {
  width: 14px;
  height: 14px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-button-wide {
  width: 100%;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

@media (pointer: coarse) {
  .primary-button,
  .secondary-button,
  .danger-button,
  .ghost-button,
  .sidebar-mobile-toggle,
  .side-icon-button,
  .side-nav a,
  .theme-option,
  .theme-picker > summary,
  .control-input,
  .control-select,
  .control-textarea,
  .control-main input:not([type="hidden"], [type="checkbox"], [type="radio"], [type="range"]),
  .control-main select,
  .control-main textarea {
    min-height: 44px;
  }

  .sidebar-mobile-toggle,
  .side-icon-button {
    width: 44px;
    height: 44px;
  }
}

/* ---------- Disclosures: a labelled row with + and – ---------- */

.disclosure-summary,
:is(.technical-details, .schedule-editor, .recovery-option, .manual-secret, .work-create, .run-technical) > summary {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font: 400 var(--minimal-label)/1.5 var(--font-mono);
  letter-spacing: var(--minimal-tracking);
  text-transform: uppercase;
  cursor: pointer;
  list-style: none;
}

:is(.technical-details, .schedule-editor, .recovery-option, .manual-secret, .work-create, .run-technical) > summary::-webkit-details-marker {
  display: none;
}

:is(.technical-details, .schedule-editor, .recovery-option, .manual-secret, .work-create, .run-technical) > summary::after {
  margin-left: auto;
  color: var(--muted);
  font: 400 16px/1 var(--font-sans);
  content: "+";
}

:is(.technical-details, .schedule-editor, .recovery-option, .manual-secret, .work-create, .run-technical)[open] > summary::after {
  content: "–";
}

/* ---------- Pagination ---------- */

.pagination-footer {
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.pagination-footer nav {
  width: 100%;
}

.pagination-footer:not(:has(*)) {
  display: none;
}

/* ---------- Sign-in pages ---------- */

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 48px 20px 64px;
}

.login-shell,
.auth-card {
  width: min(100%, 420px);
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
}

.login-brand {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 12px;
  color: var(--ink);
}

.login-brand > span {
  display: grid;
  line-height: 1.3;
}

.login-brand strong {
  color: var(--ink);
  font: 500 var(--minimal-text)/1.4 var(--font-sans);
}

.brand-mark-large {
  width: 58px;
  height: 35px;
}

.login-form-panel {
  margin-top: 32px;
}

.auth-heading h1 {
  margin: 32px 0 16px;
}

.microsoft-login-button {
  margin-top: 24px;
}

.microsoft-login-button img {
  width: 18px;
  height: 18px;
}

.login-error {
  margin: 20px 0 0;
}

.login-form {
  display: grid;
  gap: 6px;
  margin-top: 24px;
}

.login-form .control-input {
  min-height: 40px;
}

.login-form .control-input + .field-label {
  margin-top: 12px;
}

.login-form button {
  margin-top: 20px;
}

.body-copy {
  margin: 12px 0 20px;
  color: var(--muted);
  line-height: 1.7;
}

.stack-form {
  display: grid;
  gap: 10px;
}

.otp-input {
  font-family: var(--font-mono) !important;
  font-size: 20px !important;
  font-variant-numeric: tabular-nums;
  letter-spacing: .3em;
}

.totp-qr {
  width: min(220px, 100%);
  margin: 20px auto;
  overflow: hidden;
  border-radius: var(--radius);
  background: #ffffff;
}

.totp-qr svg {
  max-width: 100%;
  height: auto;
}

.manual-secret {
  margin-bottom: 20px;
}

.manual-secret code {
  display: block;
  padding-top: 8px;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.recovery-option {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.recovery-option[open] > summary {
  margin-bottom: 12px;
}

.auth-exit {
  margin-top: 24px;
  text-align: center;
}

.development-notice {
  margin: 0;
  padding: 8px 54px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

/* ---------- Responsive ---------- */

@media (max-width: 1280px) {
  .control-main {
    padding: 32px 24px 48px;
  }

  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-item:nth-child(2n) {
    border-right: 0;
  }

  .metric-item:nth-child(-n + 2) {
    border-bottom: 1px solid var(--border);
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .page-actions {
    justify-content: flex-start;
  }

  .filter-bar,
  .create-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .control-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .mobile-header {
    position: sticky;
    z-index: 70;
    top: 0;
    display: flex;
    min-height: 64px;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-cream);
  }

  .mobile-brand .brand-mark {
    width: 40px;
    height: 24px;
  }

  .side-rail {
    position: fixed;
    left: 0;
    width: min(280px, calc(100vw - 48px));
    transform: translateX(-105%);
    transition: transform 200ms var(--ease);
  }

  .side-rail.is-open {
    transform: translateX(0);
  }

  .sidebar-backdrop:not([hidden]) {
    position: fixed;
    z-index: 75;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: color-mix(in srgb, var(--bg-cream) 30%, rgba(0, 0, 0, .6));
  }

  body.sidebar-is-open {
    overflow: hidden;
  }

  .control-main {
    padding: 28px 20px 48px;
  }

  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-item:nth-child(2n) {
    border-right: 0;
  }

  .metric-item:nth-child(-n + 2) {
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 760px) {
  .control-input,
  .control-select,
  .control-textarea,
  .control-main input:not([type="hidden"], [type="checkbox"], [type="radio"], [type="range"]),
  .control-main select,
  .control-main textarea {
    min-height: 44px;
    font-size: 16px;
  }
}

@media (max-width: 620px) {
  .control-main {
    padding: 24px 16px 40px;
  }

  .page-heading {
    gap: 16px;
    margin-bottom: 24px;
  }

  .filter-bar,
  .create-bar {
    grid-template-columns: minmax(0, 1fr);
  }

  .metric-item {
    padding: 12px 14px;
  }

  .surface-heading {
    min-height: 0;
    padding: 14px 16px;
  }

  .panel-body {
    padding: 16px;
  }

  .empty-state-inline {
    padding-inline: 16px;
  }

  .control-table :is(th, td) {
    padding-inline: 12px;
  }

  .control-table :is(th, td):first-child {
    padding-left: 16px;
  }

  .control-table :is(th, td):last-child {
    padding-right: 16px;
  }

  .pagination-footer {
    padding-inline: 16px;
  }

  .login-page {
    align-items: start;
    padding: 24px 16px 40px;
  }

  .login-shell,
  .auth-card {
    padding: 24px 20px;
  }
}

@media (max-width: 359px) {
  .metric-strip {
    grid-template-columns: minmax(0, 1fr);
  }

  .metric-item,
  .metric-item:nth-child(-n + 2) {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .metric-item:last-child {
    border-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Shared category language: a named square or a thin line, never a colour-only state. */
[data-category="bank"] { --category-tone: var(--category-bank); }
[data-category="documents"] { --category-tone: var(--category-documents); }
[data-category="payroll"] { --category-tone: var(--category-payroll); }
[data-category="data"] { --category-tone: var(--category-data); }
[data-category="access"] { --category-tone: var(--category-access); }
[data-category="general"] { --category-tone: var(--category-general); }

.category-label {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  color: var(--ink);
  font: 500 var(--minimal-label)/1.5 var(--font-mono);
  letter-spacing: .025em;
  text-transform: none;
  overflow-wrap: anywhere;
}
.category-label::before {
  content: '';
  width: var(--marker);
  height: var(--marker);
  flex: 0 0 var(--marker);
  background: var(--category-tone, var(--muted));
}
.category-key {
  margin: -8px 0 22px;
  color: var(--muted);
  font-size: 12px;
}
.category-key > summary { width: fit-content; padding: 5px 0; cursor: pointer; }
.category-key > summary > span { color: var(--ink); font-weight: 600; }
.category-key > summary > small { margin-left: 12px; font-size: inherit; }
.category-key-groups { display: flex; flex-wrap: wrap; gap: 18px 28px; padding: 14px 0 4px; }
.category-key-groups > .legend-group { flex: 1 1 220px; margin: 0; }
.category-key-groups > .legend-group:first-child { flex-basis: 360px; }
.category-key-items { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.category-key-items .category-label { font: 400 12px/1.5 var(--font-sans); letter-spacing: 0; }
.legend-group { min-width: 0; margin: 0 0 18px; }
.legend-group-title { display: block; margin-bottom: 8px; color: var(--ink); font: 600 12px/1.5 var(--font-sans); }
.legend-group-items { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 20px; min-width: 0; }
.legend-item, .legend-icon { display: inline-flex; align-items: center; gap: 8px; min-width: 0; color: var(--ink); font: 400 12px/1.5 var(--font-sans); }
.legend-item { --legend-tone: var(--muted); }
.legend-item[data-legend-tone="primary"] { --legend-tone: var(--primary); }
.legend-item[data-legend-tone="success"] { --legend-tone: var(--success); }
.legend-item[data-legend-tone="warning"] { --legend-tone: var(--warning); }
.legend-item[data-legend-tone="danger"] { --legend-tone: var(--danger); }
.legend-item::before { content: ''; width: 7px; height: 7px; flex: 0 0 7px; background: var(--legend-tone); }
.legend-item[data-legend-shape]::before { width: 18px; height: 1px; flex-basis: 18px; }
.legend-item[data-legend-shape="dashed"]::before { height: 0; background: transparent; border-top: 1px dashed var(--legend-tone); }
.legend-item[data-legend-shape="progress"]::before { height: 7px; background: linear-gradient(var(--legend-tone), var(--legend-tone)) left center / 100% 1px no-repeat, linear-gradient(var(--legend-tone), var(--legend-tone)) right center / 7px 7px no-repeat; }
.legend-item[data-legend-shape="history"]::before { width: 5px; height: 5px; flex-basis: 5px; background: var(--bg-cream); border: 1px solid var(--legend-tone); }
.legend-icon svg { width: 17px; height: 17px; flex: 0 0 17px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 700px) {
  .category-key > summary > small { display: block; margin: 3px 0 0 16px; }
  .category-key-groups > .legend-group { flex-basis: 100%; }
}
.side-section-label { color: var(--ink); font-weight: 500; }
.side-nav a:is(.is-active, [aria-current="page"]) { font-weight: 600; }
.table-primary, .table-link { font-weight: 600; }
