:root {
  color-scheme: light;
  --white: #fff;
  --panel: #f6f6f8;
  --hover: #ececef;
  --ink: #1d1d20;
  --muted: #626267;
  --line: #e4e4e7;
  --input-line: #c6c6cb;
  --switch-on: #1b7467;
  --error: #9a3129;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--white); color: var(--ink); font: 15px/1.5 var(--font); }
h1, h2, p { margin: 0; }
a, button, input { color: inherit; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible { outline: 2px solid #626273; outline-offset: 3px; }

.workspace-header { border-bottom: 1px solid var(--line); }
.workspace-header-inner { display: flex; min-height: 56px; align-items: center; gap: 28px; padding: 5px clamp(18px, 3.5vw, 44px); }
.brand { display: flex; flex: none; align-items: center; gap: 8px; white-space: nowrap; }
.brand img { display: block; width: 104px; height: auto; }
.brand-label { color: var(--muted); font-size: 13px; font-weight: 550; }

h1 { font-size: clamp(29px, 4vw, 35px); font-weight: 660; line-height: 1.15; letter-spacing: -.045em; }
.auth-main { width: min(100% - 48px, 340px); margin-inline: auto; padding-block: clamp(64px, 15vh, 145px) 48px; }
.auth-main form { margin-top: 26px; }
fieldset { display: grid; min-width: 0; gap: 10px; margin: 0; padding: 0; border: 0; }
.field label { display: block; margin-bottom: 5px; font-size: 14px; font-weight: 560; }
.field input { display: block; width: 100%; min-height: 45px; padding: 9px 11px; border: 1px solid var(--input-line); border-radius: 8px; background: var(--white); font-size: 16px; }
.field input[aria-invalid="true"] { border-color: var(--error); }
.field-message { display: grid; margin-top: 4px; }
.field-message > p { grid-area: 1 / 1; font-size: 13px; }
.field-hint { visibility: hidden; color: var(--muted); }
.field:focus-within .field-hint { visibility: visible; }
@media (hover: hover) {
  .field:hover .field-hint { visibility: visible; }
}
.field:has(input[aria-invalid="true"]) .field-hint { visibility: hidden; }
.field-error { color: var(--error); }
.field-error:empty { display: none; }

.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: 8px 13px; border: 0; border-radius: 8px; font-weight: 570; }
.button-primary { margin-top: 3px; background: #262628; color: var(--white); }
.button-primary:hover { background: #3a3a3e; }
.quiet-link { display: inline-block; margin-top: 14px; text-underline-offset: 3px; }
.notice { margin-top: 14px; padding: 10px 12px; border-radius: 7px; background: #faf1ef; color: var(--error); font-size: 14px; }
.notice[data-tone="success"] { background: var(--panel); color: var(--ink); }

.workspace-header nav { display: flex; gap: 4px; }
.workspace-header nav a { display: grid; min-height: 44px; align-content: center; padding: 0 10px; border-radius: 7px; color: var(--muted); font-size: 14px; text-decoration: none; }
.workspace-header nav a:hover, .workspace-header nav a[aria-current="page"] { background: var(--panel); color: var(--ink); }
.workspace-header nav a[aria-current="page"] { font-weight: 600; }
.session-actions { display: flex; min-width: 0; align-items: center; gap: 10px; margin-inline-start: auto; }
.session-account { min-width: 0; overflow-wrap: anywhere; color: var(--muted); font-size: 13px; }
.button-quiet { flex: none; background: transparent; font-size: 14px; }
.button-quiet:hover { background: var(--panel); }

.access-main { width: min(100% - 40px, 680px); margin-inline: auto; padding-block: clamp(36px, 7vw, 76px); }
#access-loading { margin-top: 12px; color: var(--muted); }
.access-panel { margin-top: 26px; }
.access-panel h2 { margin-bottom: 8px; font-size: 15px; font-weight: 640; }
.permissions, .module-list { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.permission-table { width: 100%; border-collapse: collapse; table-layout: fixed; text-align: left; }
.permission-table th, .permission-table td { padding: 9px clamp(11px, 2.5vw, 18px); }
.permission-table thead { color: var(--muted); font-size: 13px; }
.permission-table thead th { font-weight: 560; }
.permission-table tbody tr { border-top: 1px solid var(--line); }
.permission-table :is(th, td):not(:first-child) { width: 119px; }
.permission-table tbody th { overflow-wrap: anywhere; font-size: 14px; font-weight: 560; }
.role { display: block; margin-top: 1px; color: var(--muted); font-size: 12px; font-weight: 450; }
.switch { display: inline-flex; min-height: 44px; align-items: center; gap: 7px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 13px; white-space: nowrap; }
.switch-track { position: relative; width: 34px; height: 20px; flex: none; border: 1px solid #77777f; border-radius: 20px; background: #77777f; }
.switch-track::after { position: absolute; inset: 2px auto auto 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--white); content: ""; }
.switch[aria-checked="true"] .switch-track { border-color: var(--switch-on); background: var(--switch-on); }
.switch[aria-checked="true"] .switch-track::after { inset-inline-start: 16px; }
.always-on { color: var(--muted); font-size: 13px; white-space: nowrap; }
.module-link { display: flex; min-height: 50px; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 15px; border-radius: inherit; text-decoration: none; }
.module-link:hover { background: var(--hover); }
.module-link strong { font-weight: 560; }
.module-link > span { color: var(--muted); font-size: 22px; line-height: 1; }
.module-empty, .empty-accounts { padding: 12px 15px; }
.module-empty strong, .module-empty span { display: block; }
.module-empty strong { font-weight: 580; }
.module-empty span, .empty-accounts { color: var(--muted); }
.save-status { margin-top: 8px; color: var(--muted); font-size: 13px; }
.save-status[data-tone="error"] { color: var(--error); }

@media (max-width: 630px) {
  .workspace-header-inner { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0 10px; }
  .workspace-header .brand { grid-area: 1 / 1; }
  .session-actions { display: contents; }
  .session-actions > .button-quiet { grid-area: 1 / 2; justify-self: end; padding-inline: 8px; }
  .workspace-header nav { grid-area: 2 / 1; }
  .workspace-header nav a { padding-inline: 7px; }
  .session-account { grid-area: 2 / 2; text-align: end; }
  .auth-main { padding-top: clamp(42px, 9vh, 74px); }
  .permission-table :is(th, td):not(:first-child) { width: 99px; }
}

.account-heading, .account-dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.account-heading { margin-bottom: 8px; }
.account-heading h2 { margin: 0; }
.account-heading .button { margin: 0; font-size: 13px; }
.permission-table :is(th, td).manage-column { width: 87px; padding-inline-start: 3px; text-align: end; }
.permission-table .manage-column .button { padding-inline: 6px; font-size: 13px; }
.account-dialog {
  width: min(100% - 32px, 420px);
  max-height: 85dvh;
  padding: 18px 20px 22px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--white);
  color: var(--ink);
}
.account-dialog::backdrop { background: #20202840; }
.account-dialog-heading h2 { overflow-wrap: anywhere; font-size: 19px; line-height: 1.25; }
.account-dialog-heading + :is(form, div) { margin-top: 12px; }
.account-dialog form, .invitation { display: grid; gap: 12px; }
.account-dialog select, .invitation input {
  width: 100%;
  min-height: 44px;
  padding: 8px 9px;
  border: 1px solid var(--input-line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
.account-options { display: grid; margin-top: 10px; }
.account-options .button { justify-content: flex-start; text-align: left; }
.account-options .button + .button { border-top: 1px solid var(--line); }
.account-options .danger { color: var(--error); }
.invitation { margin-top: 12px; }
.invitation p { color: var(--muted); font-size: 13px; }

@media (max-width: 630px) {
  .permission-table :is(th, td).manage-column { width: 66px; padding-inline-end: 5px; }
  .permission-table :is(th, td):not(:first-child, .manage-column) { width: 88px; }
}
