:root {
    --ui-font: "Segoe UI", system-ui, sans-serif;
    --ui-accent: #6061de;
    --ui-accent-hover: #5051c5;
    --ui-accent-soft: #eeedff;
    --ui-text: #303644;
    --ui-muted: #737d90;
    --ui-border: #dfe2e8;
    --ui-surface: #fff;
    --ui-subtle: #f7f8fa;
    --ui-radius: 6px;
    --ui-control-height: 36px;
    --ui-focus: 0 0 0 3px #6061de24;
    --ui-speed: 140ms;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--ui-surface); color: #2a2f3a; font: 13px/1.5 var(--ui-font); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; color: inherit; }
button:disabled, select:disabled { cursor: default; opacity: .5; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 2px solid #6669e8; outline-offset: 3px; }
a { color: inherit; }
input, select { background: var(--ui-surface); color: var(--ui-text); border: 1px solid var(--ui-border); border-radius: var(--ui-radius); padding: 8px 10px; min-width: 0; }
input:disabled { background: #f6f7f9; color: #737b88; }
.primary { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; background: var(--ui-accent); color: var(--ui-surface); border: 1px solid var(--ui-accent); border-radius: var(--ui-radius); font-size: 12px; text-decoration: none; white-space: nowrap; }
.primary:hover { background: var(--ui-accent-hover); }
.primary>span { font-size: 17px; line-height: 1; }
.secondary { padding: 9px 14px; border: 1px solid var(--ui-border); background: var(--ui-surface); border-radius: var(--ui-radius); font-size: 12px; }
.table-region { position: relative; overflow-x: auto; border: 1px solid #e5e7ed; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12px; }
th { background: #f8f9fb; color: #818997; font-size: 11px; font-weight: 500; border-bottom: 1px solid #e5e7ed; padding: 13px 15px; white-space: nowrap; }
td { padding: 17px 15px; border-bottom: 1px solid #eceef2; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfe; }
.role-badge { display: inline-block; background: #f2f4f7; color: #657083; border-radius: 4px; padding: 4px 7px; font-size: 10px; white-space: nowrap; }
.role-badge.super { background: var(--ui-accent-soft); color: #6962bc; }
.state { color: #479068; white-space: nowrap; font-size: 11px; }
.state:before { content: ""; width: 5px; height: 5px; background: currentColor; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: middle; }
.state.paused { color: #9298a4; }
.icon-button { border: 0; background: transparent; color: #757d8c; font-size: 11px; padding: 6px 7px; border-radius: 4px; }
.icon-button:hover { background: #eeedf9; color: #605dba; }
.entity-link { border: 0; background: transparent; padding: 0; color: #5f61c4; font-size: 12px; font-weight: 500; }
.empty { text-align: center; padding: 55px 20px; color: #8c94a3; }
.notice, .error-notice { padding: 10px 13px; margin-bottom: 14px; border-radius: var(--ui-radius); font-size: 12px; }
.notice { background: #f0f7f3; color: #4e7b62; }
.error-notice { background: #fdf0ed; color: #a2503f; }
.editor-drawer>header { padding: 20px 24px; border-bottom: 1px solid #e7e9ee; display: flex; align-items: center; justify-content: space-between; }
.editor-drawer h2 { font-size: 16px; font-weight: 600; margin: 0; }
.close { font-size: 25px; line-height: 1; padding: 4px 8px; }
.editor-drawer form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.editor-body { overflow-y: auto; flex: 1; min-height: 0; padding: 24px; }
.editor-body>label, .assignment>label { display: grid; gap: 7px; margin-bottom: 18px; font-size: 12px; color: #767d89; }
.editor-body label input, .editor-body label select { width: 100%; color: #373e4b; }
.editor-body .check-line { display: flex; gap: 9px; align-items: center; color: #505967; font-size: 12px; }
.check-line input { width: 15px !important; height: 15px; accent-color: #6365df; flex-shrink: 0; }
.text-button { border: 0; background: transparent; color: #6865c5; font-size: 12px; padding: 3px; }
.text-button.remove { color: #a87872; font-size: 11px; margin-top: 13px; }
.hint { color: #949ba8; font-size: 11px; margin: 10px 0 0; line-height: 1.6; }
.editor-drawer form>footer { display: flex; justify-content: end; gap: 10px; padding: 18px 24px; border-top: 1px solid #e7e9ee; background: var(--ui-surface); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.ui-icon { width: 18px; height: 18px; display: inline-block; vertical-align: middle; flex: 0 0 auto; }
.ui-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: var(--ui-control-height); transition: background-color var(--ui-speed), border-color var(--ui-speed), box-shadow var(--ui-speed); }
.ui-button:disabled { pointer-events: none; opacity: .45; }
.ui-button:active:not(:disabled) { filter: brightness(.96); }
.ui-button.icon-button { min-width: 32px; min-height: 32px; }
.ui-button.close { width: 32px; padding: 6px; }
input:not([type=checkbox]), select { height: var(--ui-control-height); transition: border-color var(--ui-speed), box-shadow var(--ui-speed); }
input:not([type=checkbox]):hover:not(:disabled), select:hover:not(:disabled) { border-color: #b7bfcd; }
input:not([type=checkbox]):focus, select:focus { border-color: var(--ui-accent); outline: none; box-shadow: var(--ui-focus); }
input:user-invalid, select:user-invalid, input[aria-invalid=true], select[aria-invalid=true] { border-color: #c85c50; }
input:disabled, select:disabled { background-color: var(--ui-subtle); color: var(--ui-muted); opacity: .65; }
select { appearance: none; background-image: url('/icons/chevron-down.svg'); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 34px !important; cursor: pointer; }
input[type=checkbox] { appearance: none; width: 16px; height: 16px; padding: 0; margin: 0; border: 1px solid #b7bfcd; border-radius: 4px; background: var(--ui-surface); cursor: pointer; display: inline-grid; place-content: center; }
input[type=checkbox]:checked { background: var(--ui-accent); border-color: var(--ui-accent); }
input[type=checkbox]:checked::after { content: ""; width: 8px; height: 4px; border-left: 1.7px solid white; border-bottom: 1.7px solid white; transform: translateY(-1px) rotate(-45deg); }
input[type=checkbox]:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 3px; }
.secondary:hover { background: var(--ui-subtle); border-color: #b7bfcd; }
.editor-drawer:not([open]) { display: none; }
.editor-drawer::backdrop { background: #18203240; }
body:has(dialog[open]) { overflow: hidden; }
.ui-spinner { display: inline-flex; animation: ui-spin .8s linear infinite; }
@keyframes ui-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
@media (forced-colors: active) { select { appearance: auto; background-image: none; } input[type=checkbox] { appearance: auto; } }

@media (max-width: 760px) { .editor-body { padding: 20px; } .editor-drawer>header { padding: 18px 20px; } }

/* Shared office-style grid and column controls. */
.table-region { border-radius: 4px; }
th:not(:last-child), td:not(:last-child) { border-right: 1px solid #e1e5eb; }
th { background: #f0f2f6; color: #525e70; }
th.ui-column { padding: 0; }
.ui-column-trigger { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 44px; padding: 12px 14px; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; }
.ui-column-trigger .ui-icon { width: 14px; height: 14px; color: #8994a6; }
.ui-column-trigger:hover { background: #e6eaf1; }
th[aria-sort=ascending], th[aria-sort=descending], .ui-column-trigger.filtered { color: var(--ui-accent); background: #eeedff; }
.ui-column-menu { position: fixed; inset: auto; margin: 0; width: 248px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow-y: auto; border: 1px solid var(--ui-border); border-radius: 8px; padding: 12px; background: var(--ui-surface); color: var(--ui-text); box-shadow: 0 8px 28px #192b4526; font: 12px/1.5 var(--ui-font); text-align: left; white-space: normal; }
.ui-column-menu:popover-open { display: grid; gap: 4px; }
.ui-column-menu>strong { padding: 3px 6px 8px; font-weight: 600; }
.ui-column-menu .text-button { justify-content: flex-start; padding: 7px; color: var(--ui-text); border-radius: 4px; }
.ui-column-menu .text-button:hover, .ui-column-menu [aria-pressed=true] { background: var(--ui-accent-soft); color: var(--ui-accent); }
.ui-column-menu label { display: grid; gap: 6px; margin: 9px 0; padding-top: 12px; border-top: 1px solid var(--ui-border); color: var(--ui-muted); }
.ui-column-menu input { width: 100%; }

/* Shared centered editor: height follows the form, long content scrolls inside. */
.editor-drawer { position: fixed; inset: 0; margin: auto; padding: 0; width: 560px; max-width: calc(100vw - 32px); height: fit-content; max-height: calc(100dvh - 48px); overflow: hidden; background: var(--ui-surface); color: var(--ui-text); border: 1px solid var(--ui-border); border-radius: 14px; box-shadow: 0 24px 80px #17223833; display: flex; flex-direction: column; }
.editor-drawer>header, .editor-drawer form>footer { flex-shrink: 0; }
@media (max-width: 760px) { .editor-drawer { max-width: calc(100vw - 20px); max-height: calc(100dvh - 24px); border-radius: 12px; } }

/* Editable table rows share pointer and hover treatment. */
tr.editable-row { cursor: pointer; }
tr.editable-row:hover, tr.editable-row:focus-within { background: var(--ui-accent-soft); }
