/* Access admin. Product UI: restrained palette (tinted neutrals + one moss-green accent for primary actions and the current selection), one system sans family,
   a tight type scale, dense tables, inline forms. Dialogs only for destructive confirmations. */
:root {
  color-scheme: light dark;
  --bg: oklch(0.985 0.004 140);
  --panel: oklch(1 0 0);
  --side: oklch(0.962 0.008 140);
  --hover: oklch(0.975 0.008 140);
  --ink: oklch(0.24 0.014 150);
  --muted: oklch(0.46 0.016 150);
  --line: oklch(0.9 0.008 140);
  --line-strong: oklch(0.76 0.012 140);
  --accent: oklch(0.5 0.11 145);
  --accent-hover: oklch(0.44 0.11 145);
  --accent-ink: oklch(0.99 0 0);
  --accent-soft: oklch(0.935 0.04 145);
  --accent-text: oklch(0.38 0.1 148);
  --danger: oklch(0.5 0.17 28);
  --danger-soft: oklch(0.955 0.03 28);
  --warn-text: oklch(0.42 0.09 70);
  --warn-soft: oklch(0.955 0.045 88);
  --info-text: oklch(0.38 0.07 245);
  --info-soft: oklch(0.955 0.02 245);
  --ok-text: oklch(0.4 0.11 150);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --z-sticky: 10; --z-toast: 40;
  --ease: cubic-bezier(0.25, 1, 0.5, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(0.19 0.012 150); --panel: oklch(0.235 0.014 150); --side: oklch(0.215 0.013 150); --hover: oklch(0.26 0.014 150);
    --ink: oklch(0.93 0.01 140); --muted: oklch(0.74 0.015 140); --line: oklch(0.34 0.015 150); --line-strong: oklch(0.5 0.02 150);
    --accent: oklch(0.7 0.12 145); --accent-hover: oklch(0.76 0.12 145); --accent-ink: oklch(0.18 0.02 150); --accent-soft: oklch(0.3 0.05 148); --accent-text: oklch(0.85 0.1 145);
    --danger: oklch(0.7 0.16 28); --danger-soft: oklch(0.3 0.06 28); --warn-text: oklch(0.86 0.1 85); --warn-soft: oklch(0.31 0.05 85);
    --info-text: oklch(0.85 0.06 245); --info-soft: oklch(0.29 0.03 245); --ok-text: oklch(0.82 0.11 150);
  }
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 1rem/1.5 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { line-height: 1.25; margin: 0; text-wrap: balance; }
h1 { font-size: 1.6rem; font-weight: 650; }
h1:focus { outline: none; }
h2 { font-size: 1.1rem; font-weight: 650; }
p { margin: 0 0 0.75rem; max-width: 70ch; text-wrap: pretty; }
a { color: var(--accent-text); text-underline-offset: 0.18em; }
a:hover { color: var(--accent); }
code, .mono { font-family: var(--mono); font-size: 0.875em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.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; }
.skip { position: absolute; left: 8px; top: -48px; background: var(--panel); padding: 8px 12px; border-radius: 8px; z-index: var(--z-toast); }
.skip:focus { top: 8px; }
.sub { color: var(--muted); font-size: 0.875rem; }
.hint { color: var(--muted); font-size: 0.875rem; margin: 0.4rem 0 0; }
.lede { color: var(--muted); margin: 0.25rem 0 1.25rem; }
.nowrap { white-space: nowrap; }
.foot { margin-top: 2rem; }

/* shell */
.top { position: sticky; top: 0; z-index: var(--z-sticky); display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; }
.env { font-size: 0.8125rem; padding: 1px 9px; border-radius: 999px; background: var(--warn-soft); color: var(--warn-text); border: 1px solid var(--line); }
.env-prod { background: var(--danger-soft); color: var(--danger); }
.spacer { flex: 1; }
.who { color: var(--muted); font-size: 0.875rem; max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layout { display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: calc(100vh - 52px); }
.side { background: var(--side); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; }
.side a { padding: 8px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; transition: background-color 150ms var(--ease); }
.side a:hover { background: var(--hover); }
.side a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.content { padding: 28px 32px 72px; max-width: 1160px; width: 100%; }
.content:focus { outline: none; }
.fatal { max-width: 34rem; margin: 14vh auto 0; padding: 0 24px; }
.fatal h1 { margin-bottom: 0.75rem; }
@media (max-width: 760px) {
  /* minmax(0, 1fr), not 1fr: a bare 1fr column grows to its widest content (a table) and the whole page scrolls sideways */
  .layout { grid-template-columns: minmax(0, 1fr); grid-auto-rows: min-content; align-content: start; }
  .side { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; overflow-x: auto; }
  .side a { white-space: nowrap; }
  .page-head h1 { font-size: 1.35rem; }
  .content { padding: 20px 16px 56px; }
  .who { display: none; }
}

/* page structure */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 1rem; flex-wrap: wrap; }
.page-actions { display: flex; gap: 8px; }
.crumbs { display: flex; gap: 8px; font-size: 0.875rem; color: var(--muted); margin-bottom: 0.5rem; }
.crumbs a { color: var(--muted); }
.block { margin-top: 2rem; }
.block.first { margin-top: 1.25rem; }
details.settings { margin-top: 2rem; }
details.settings > summary { cursor: pointer; font-weight: 650; font-size: 1.1rem; list-style-position: outside; }
details.settings[open] > summary { margin-bottom: 1rem; }
details.settings summary .sub { font-weight: 400; }
.block > h2 { margin-bottom: 0.75rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 1.5rem; }
.form-grid { display: grid; gap: 16px; max-width: 640px; }
.form-grid > h2 { margin-bottom: 0; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field.check { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: start; }
.field.check label { margin: 0; }
.field.check .hint { grid-column: 2; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.add-form { display: grid; gap: 14px; max-width: 640px; margin-bottom: 1.5rem; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel); color: var(--ink); font: inherit; transition: border-color 150ms var(--ease); }
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; margin-top: 0.2rem; accent-color: var(--accent); }
textarea { resize: vertical; min-height: 5rem; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--muted); }
.filter { max-width: 22rem; margin-bottom: 0.75rem; }
.filter.wide { max-width: 30rem; margin-bottom: 1rem; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
table.data { width: 100%; border-collapse: collapse; }
.data th, .data td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.data tbody tr:last-child > * { border-bottom: 0; }
.data thead th { background: var(--side); color: var(--muted); font-size: 0.8125rem; font-weight: 600; }
.data tbody th { font-weight: 500; }
.data a { text-decoration: none; }
.data a:hover, .data a:focus-visible { text-decoration: underline; }
.data tbody tr:hover { background: var(--hover); }
.data .num { text-align: right; font-variant-numeric: tabular-nums; }
.data .actions { text-align: right; white-space: nowrap; }
.row-muted { color: var(--muted); }
.chip { display: inline-block; padding: 1px 8px; margin: 0 6px 4px 0; border: 1px solid var(--line); border-radius: 6px; background: var(--side); color: var(--ink); font-size: 0.875rem; text-decoration: none; }
.chip:hover { border-color: var(--line-strong); }
.status-on { color: var(--ok-text); }
.status-off { color: var(--muted); }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.plain-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* badges, notices, empty, skeleton */
.badge { display: inline-block; font-size: 0.8125rem; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--panel); white-space: nowrap; }
.badge-all_employees { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.badge-self_service { background: var(--info-soft); color: var(--info-text); border-color: transparent; }
.notice { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); margin: 0.75rem 0; }
.notice p { margin: 0; }
.notice p + button { margin-top: 10px; }
.notice-info { background: var(--info-soft); color: var(--info-text); }
.notice-warn { background: var(--warn-soft); color: var(--warn-text); }
.notice-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.status:empty { display: none; }
.empty { background: var(--panel); border: 1px dashed var(--line-strong); border-radius: 12px; padding: 32px 24px; max-width: 36rem; }
.empty h2 { margin-bottom: 0.5rem; }
.empty.compact { padding: 16px 20px; }
.empty.compact p { margin: 0; color: var(--muted); }
.skeleton-row { height: 42px; margin-bottom: 8px; border-radius: 8px; background: linear-gradient(90deg, var(--side), var(--line), var(--side)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.facts { display: grid; grid-template-columns: 9rem 1fr; gap: 6px 16px; margin: 0.5rem 0 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.danger-zone .action-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding: 14px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.danger-zone .action-row:first-of-type { border-top: 0; }
.danger-zone .action-row .hint { max-width: 60ch; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border: 1px solid transparent; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--panel); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { background: var(--hover); }
.btn-quiet { background: transparent; color: var(--ink); }
.btn-quiet:hover:not(:disabled) { background: var(--hover); }
.btn-danger { background: var(--danger); color: oklch(0.99 0 0); }
@media (prefers-color-scheme: dark) { .btn-danger { color: oklch(0.18 0.02 28); } }
.btn-danger:hover:not(:disabled) { filter: brightness(0.92); }
.btn-quiet-danger { background: transparent; color: var(--danger); }
.btn-quiet-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-small { height: 30px; padding: 0 10px; font-size: 0.875rem; }

/* feedback */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: var(--z-toast); display: grid; gap: 8px; max-width: min(26rem, calc(100vw - 40px)); }
.toast { padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--panel); box-shadow: 0 4px 16px oklch(0.2 0.02 150 / 0.18); animation: toast-in 180ms var(--ease); }
.toast-warn { background: var(--warn-soft); color: var(--warn-text); }
.toast-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
dialog.confirm { max-width: 28rem; width: calc(100vw - 32px); padding: 22px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--panel); color: var(--ink); }
dialog.confirm::backdrop { background: oklch(0.2 0.02 150 / 0.5); }
dialog.confirm h2 { margin-bottom: 0.5rem; }
dialog.confirm .form-actions { margin-top: 1.25rem; justify-content: flex-end; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
}
