/* ── Utility ─────────────────────────────────────────────────────────── */

.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;
}

/* ── Settings layout ─────────────────────────────────────────────────── */

body {
  min-height: 100dvh;
  background: var(--paper-soft);
  font-family: 'DM Sans', system-ui, sans-serif;
  color: var(--text-body);
}

/* Shell */
.settings-shell {
  display: flex;
  gap: 3rem;
  max-width: 1040px;
  margin: 0 auto;
  padding: 2.5rem 1.75rem 4rem;
  align-items: flex-start;
}

/* Sidebar */
.settings-sidebar {
  width: 168px;
  flex-shrink: 0;
  position: sticky;
  top: calc(60px + 2.5rem);
}

.sidebar-group-label {
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-subtle);
  padding: 0 .625rem;
  margin-bottom: .375rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4375rem .625rem;
  border-radius: var(--radius-md);
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: background var(--d-fast) var(--ease-out-quart), color var(--d-fast);
  cursor: pointer;
}
.sidebar-item:hover { background: var(--paper-deep); color: var(--ink-deep); }
.sidebar-item:focus-visible {
  outline: 2px solid var(--lavender-soft);
  outline-offset: 2px;
  background: var(--paper-deep);
  color: var(--ink-deep);
}
.sidebar-item.active { background: var(--paper-deep); color: var(--ink-deep); }
.sidebar-item.active .sidebar-icon { color: var(--lavender); }

.sidebar-icon { width: 16px; height: 16px; flex-shrink: 0; }

/* Main content */
.settings-main { flex: 1; min-width: 0; }

/* Section */
.section-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.section-desc {
  font-size: .8125rem;
  color: var(--text-muted);
  margin-top: .25rem;
}

/* ── Users table ─────────────────────────────────────────────────────── */

.users-wrap {
  background: var(--paper);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.users-table th {
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: .625rem 1.125rem;
  border-bottom: 1px solid var(--border-hairline);
  background: var(--paper-soft);
  white-space: nowrap;
}

.users-table th:first-child { width: 40%; }
.users-table th:nth-child(2) { width: 120px; }
.users-table th:nth-child(3) { width: 110px; }
.users-table th:last-child  { width: 96px; }

.users-table td {
  padding: .8125rem 1.125rem;
  border-bottom: 1px solid var(--border-hairline);
  vertical-align: middle;
}
.users-table tr:last-child td { border-bottom: none; }
.users-table tbody tr { transition: background var(--d-fast); }
.users-table tbody tr:hover td { background: var(--paper-soft); }
.users-table tbody tr.row-removing {
  opacity: 0;
  transform: translateX(8px);
  transition: opacity .25s, transform .25s;
}
.users-table tbody tr.row-highlight {
  background: color-mix(in srgb, var(--lavender) 7%, transparent);
  transition: background .6s;
}

/* Identity cell */
.user-identity {
  display: flex;
  align-items: center;
  gap: .625rem;
  min-width: 0;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--lavender);
  color: var(--paper);
  font-size: .625rem;
  font-weight: 700;
  letter-spacing: .03em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
}

.user-info { min-width: 0; }

.user-name-row {
  display: flex;
  align-items: center;
  gap: .375rem;
  min-width: 0;
}

.user-name {
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-you {
  font-size: .6875rem;
  color: var(--text-subtle);
  font-weight: 400;
  flex-shrink: 0;
}

.user-email {
  font-family: 'JetBrains Mono', monospace;
  font-size: .6875rem;
  color: var(--text-subtle);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Role pill */
.role-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .1875rem .5rem;
  border-radius: var(--radius-pill);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  background: var(--paper-deep);
  color: var(--ink-muted);
  transition: background var(--d-fast), color var(--d-fast);
  white-space: nowrap;
}
.role-pill-btn[data-role="admin"] {
  background: color-mix(in srgb, var(--lavender) 14%, transparent);
  color: var(--lavender-deep);
}
[data-theme="dark"] .role-pill-btn[data-role="admin"] {
  color: var(--lavender);
}
.role-pill-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--lavender) 18%, var(--paper-deep));
  color: var(--ink-deep);
}
.role-pill-btn:disabled { cursor: default; opacity: .65; }
.role-pill-btn svg { width: 10px; height: 10px; }

/* Inline role select */
.role-select-inline {
  appearance: none;
  padding: .1875rem .75rem .1875rem .5rem;
  border-radius: var(--radius-pill);
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  border: 1.5px solid var(--lavender);
  background: var(--paper);
  color: var(--ink-deep);
  cursor: pointer;
  outline: none;
  font-family: 'DM Sans', system-ui, sans-serif;
  transition: border-color var(--d-fast) var(--ease-out-quart), box-shadow var(--d-fast);
}
.role-select-inline:focus-visible { box-shadow: 0 0 0 2px var(--lavender-soft); }

/* Last seen */
.last-seen { font-size: .8125rem; color: var(--text-subtle); }

/* Actions */
.user-actions { display: flex; align-items: center; gap: .125rem; }

.action-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--d-fast), color var(--d-fast);
  flex-shrink: 0;
}
.action-btn svg { width: 15px; height: 15px; pointer-events: none; }
.action-btn:hover:not(:disabled) { background: var(--paper-deep); color: var(--ink-deep); }
.action-btn.danger:hover:not(:disabled) { background: var(--fail-bg); color: var(--fail); }
.action-btn:active:not(:disabled) { background: var(--paper-deep); }
.action-btn:disabled { opacity: .3; cursor: not-allowed; }
.action-btn:focus-visible { outline: 2px solid var(--lavender-soft); outline-offset: 1px; }

/* Inline delete confirm */
.delete-confirm-cell {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8125rem;
  color: var(--text-body);
  white-space: nowrap;
}
.delete-confirm-label { color: var(--text-muted); }
.delete-confirm-name { font-weight: 500; color: var(--text-primary); }

.btn-confirm-delete {
  padding: .25rem .625rem;
  border-radius: var(--radius-md);
  font-size: .75rem;
  font-weight: 600;
  border: none;
  background: var(--fail);
  color: var(--paper);
  cursor: pointer;
  transition: opacity var(--d-fast);
  font-family: 'DM Sans', system-ui, sans-serif;
}
.btn-confirm-delete:hover { opacity: .85; }
.btn-confirm-delete:focus-visible { outline: 2px solid var(--lavender-soft); outline-offset: 1px; }

.btn-cancel-delete {
  padding: .25rem .5rem;
  border-radius: var(--radius-md);
  font-size: .75rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--d-fast), background var(--d-fast);
  font-family: 'DM Sans', system-ui, sans-serif;
}
.btn-cancel-delete:hover { color: var(--ink-deep); background: var(--paper-deep); }
.btn-cancel-delete:focus-visible { outline: 2px solid var(--lavender-soft); outline-offset: 1px; }

/* Password reset inline */
.pwd-reset-row td {
  background: var(--paper-soft);
  padding: .75rem 1.125rem;
}

.pwd-reset-inner {
  display: flex;
  align-items: center;
  gap: .625rem;
  flex-wrap: wrap;
}

.pwd-reset-label {
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.pwd-reset-field {
  font-family: 'JetBrains Mono', monospace;
  font-size: .8125rem;
  padding: .3125rem .625rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--paper);
  color: var(--text-body);
  width: 200px;
  outline: none;
}
.pwd-reset-field:focus { border-color: var(--lavender); box-shadow: 0 0 0 2px var(--lavender-soft); }

.btn-copy-pwd, .btn-set-pwd, .btn-cancel-pwd {
  padding: .3125rem .625rem;
  border-radius: var(--radius-md);
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: 'DM Sans', system-ui, sans-serif;
  transition: opacity var(--d-fast), background var(--d-fast), color var(--d-fast);
}
.btn-copy-pwd { background: var(--paper-deep); color: var(--ink-muted); }
.btn-copy-pwd:hover { color: var(--ink-deep); }
.btn-copy-pwd:focus-visible { outline: 2px solid var(--lavender-soft); outline-offset: 1px; }
.btn-set-pwd { background: var(--lavender); color: var(--paper); }
.btn-set-pwd:hover { background: var(--lavender-deep); }
.btn-set-pwd:disabled { opacity: .5; cursor: not-allowed; }
.btn-set-pwd:focus-visible { outline: 2px solid var(--lavender-soft); outline-offset: 2px; }
.btn-cancel-pwd { background: transparent; color: var(--text-muted); }
.btn-cancel-pwd:hover { color: var(--ink-deep); }
.btn-cancel-pwd:focus-visible { outline: 2px solid var(--lavender-soft); outline-offset: 1px; }

.pwd-reset-field[readonly] {
  background: var(--paper-soft);
  color: var(--text-primary);
  cursor: text;
}

/* Skeleton */
.skeleton-row td { padding: .8125rem 1.125rem; border-bottom: 1px solid var(--border-hairline); }
.skeleton-row:last-child td { border-bottom: none; }
.skel {
  border-radius: var(--radius-sm);
  background: var(--paper-deep);
  height: 12px;
  animation: skel-pulse 1.5s ease-in-out infinite;
}
.skel-circle { border-radius: 50%; width: 30px; height: 30px; flex-shrink: 0; }
.skel-stack-row { display: flex; align-items: center; gap: .625rem; }
.skel-stack { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.skel-w-55 { width: 55%; }
.skel-w-75 { width: 75%; }
.skel-w-54 { width: 54px; }
.skel-w-60 { width: 60px; }
.skel-w-70 { width: 70px; }
.skel-w-80 { width: 80px; }
.skel-h-10 { height: 10px; }
.skel-h-18 { height: 18px; }
.skel-h-20 { height: 20px; }
.skel-pill { border-radius: 999px; }
.skel-soft-radius { border-radius: var(--radius-sm); }
.skel-inline-actions { display: flex; gap: .25rem; }
@keyframes skel-pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* Empty state */
.users-empty {
  padding: 3rem 1.5rem;
  text-align: center;
}
.users-empty-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--paper-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
  margin-bottom: .875rem;
}
.users-empty-icon svg { width: 20px; height: 20px; }
.users-empty-title { font-size: .9375rem; font-weight: 600; color: var(--text-primary); margin-bottom: .3rem; }
.users-empty-body { font-size: .8125rem; color: var(--text-muted); }

/* ── Add member panel ────────────────────────────────────────────────── */

.member-panel {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  justify-content: flex-end;
}
.member-panel[hidden] { display: none; }

.panel-backdrop {
  position: absolute;
  inset: 0;
  background: oklch(18% .04 280 / .35);
  animation: backdrop-in var(--d-default) var(--ease-out-quart);
}
@keyframes backdrop-in { from{opacity:0} to{opacity:1} }

.panel-drawer {
  position: relative;
  width: 360px;
  background: var(--paper);
  border-left: 1px solid var(--border-hairline);
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: drawer-in var(--d-slow) var(--ease-out-expo);
}
@keyframes drawer-in { from{transform:translateX(100%)} to{transform:translateX(0)} }

/* Key panel has form/reveal wrapper divs between panel-drawer and
   panel-header/body/footer — they must join the flex chain. */
#key-panel-form,
#key-panel-reveal {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border-hairline);
  flex-shrink: 0;
}

.panel-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.panel-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--d-fast), color var(--d-fast);
}
.panel-close:hover { background: var(--paper-deep); color: var(--ink-deep); }
.panel-close:focus-visible { outline: 2px solid var(--lavender-soft); outline-offset: 1px; }
.panel-close svg { width: 16px; height: 16px; }

.panel-body { padding: 1.25rem 1.5rem; flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 1.125rem; }

/* Form fields */
.form-field { display: flex; flex-direction: column; gap: .375rem; }
.form-label {
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  padding: 9px 12px;
  background: var(--paper);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: .875rem;
  color: var(--text-body);
  outline: none;
  transition: border-color var(--d-fast) var(--ease-out-quart), box-shadow var(--d-fast);
  box-sizing: border-box;
}
.form-input::placeholder { color: var(--text-subtle); }
.form-input:focus { border-color: var(--lavender); box-shadow: 0 0 0 2px var(--lavender-soft); }
.form-input:disabled { opacity: .62; cursor: not-allowed; }
.form-input[aria-invalid="true"] { border-color: var(--fail); }

.form-error {
  font-size: .75rem;
  color: var(--fail);
  display: none;
}
.form-error.visible { display: block; }

/* Password row with generate button */
.pwd-row { display: flex; gap: .5rem; }
.pwd-row .form-input { flex: 1; min-width: 0; }

.btn-generate {
  padding: 0 .75rem;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--paper-soft);
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: 'DM Sans', system-ui, sans-serif;
  transition: background var(--d-fast), color var(--d-fast);
  flex-shrink: 0;
}
.btn-generate:hover { background: var(--paper-deep); color: var(--ink-deep); }
.btn-generate:focus-visible { outline: 2px solid var(--lavender-soft); outline-offset: 1px; }

/* Role radio group */
.role-fieldset { border: none; padding: 0; margin: 0; }
.role-fieldset legend {
  display: block;
  width: 100%;
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .5rem;
  padding: 0;
}

.role-options { display: flex; flex-direction: column; gap: .375rem; }

.role-option {
  display: flex;
  align-items: flex-start;
  gap: .625rem;
  padding: .625rem .75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-hairline);
  cursor: pointer;
  transition: border-color var(--d-fast), background var(--d-fast);
}
.role-option:hover { border-color: var(--border-strong); background: var(--paper-soft); }
.role-option:focus-within { border-color: var(--lavender); background: color-mix(in srgb, var(--lavender) 4%, transparent); }
.role-option:has(input:checked) { border-color: var(--lavender); background: color-mix(in srgb, var(--lavender) 6%, transparent); }
.role-option input[type="radio"] { margin-top: 2px; accent-color: var(--lavender); flex-shrink: 0; }
.role-option-name { font-size: .875rem; font-weight: 600; color: var(--text-primary); }
.role-option-desc { font-size: .75rem; color: var(--text-muted); margin-top: .0625rem; }

/* Panel footer */
.panel-footer {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-hairline);
  flex-shrink: 0;
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .5625rem .875rem;
  background: var(--lavender);
  color: var(--paper);
  border: none;
  border-radius: var(--radius-md);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background var(--d-fast) var(--ease-out-quart),
    transform   var(--d-fast) var(--ease-out-quart);
}
.btn-primary:hover:not(:disabled) { background: var(--lavender-deep); }
.btn-primary:active:not(:disabled) { transform: scale(0.985); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary:focus-visible { outline: 2px solid var(--lavender-soft); outline-offset: 2px; }
.btn-primary svg { width: 14px; height: 14px; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  padding: .5625rem .875rem;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-md);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--d-fast), color var(--d-fast);
}
.btn-ghost:hover:not(:disabled) { background: var(--paper-deep); color: var(--ink-deep); }
.btn-ghost:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost:focus-visible { outline: 2px solid var(--lavender-soft); outline-offset: 2px; }

/* ── API Keys ────────────────────────────────────────────────────────── */

.keys-wrap {
  background: var(--paper);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.keys-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.keys-table th {
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: .625rem 1.125rem;
  border-bottom: 1px solid var(--border-hairline);
  background: var(--paper-soft);
  white-space: nowrap;
}

.keys-table th:first-child { width: 30%; }
.keys-table th:nth-child(2) { width: 110px; }
.keys-table th:nth-child(3) { }
.keys-table th:nth-child(4) { width: 110px; }
.keys-table th:last-child   { width: 80px; }

.keys-table td {
  padding: .8125rem 1.125rem;
  border-bottom: 1px solid var(--border-hairline);
  vertical-align: middle;
}
.keys-table tr:last-child td { border-bottom: none; }
.keys-table tbody tr { transition: background var(--d-fast); }
.keys-table tbody tr:hover td { background: var(--paper-soft); }

.key-name { font-weight: 500; color: var(--text-primary); }
.key-none,
.key-last-used,
.proxy-credential-user {
  color: var(--text-muted);
  font-size: .8125rem;
}
.proxy-credential-password {
  color: var(--text-subtle);
  font-size: .8125rem;
}
.sync-failure-detail { opacity: .7; }
.key-prefix {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .75rem;
  color: var(--text-muted);
  background: var(--paper-deep);
  padding: .125rem .375rem;
  border-radius: 4px;
}

.perm-badges {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
}
.perm-badge {
  font-size: .625rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: .125rem .4375rem;
  border-radius: 999px;
  background: var(--paper-deep);
  color: var(--ink-muted);
  border: 1px solid var(--border-hairline);
}
.perm-badge.group-sites       { background: oklch(93% 0.04 270); color: oklch(35% 0.12 270); border-color: oklch(80% 0.06 270); }
.perm-badge.group-reports     { background: oklch(93% 0.04 155); color: oklch(35% 0.12 155); border-color: oklch(80% 0.06 155); }
.perm-badge.group-spellcheck  { background: oklch(93% 0.04 55);  color: oklch(38% 0.12 55);  border-color: oklch(80% 0.06 55);  }
.perm-badge.group-media       { background: oklch(93% 0.04 20);  color: oklch(38% 0.12 20);  border-color: oklch(80% 0.06 20);  }

.keys-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  padding: 3rem 1.5rem;
  text-align: center;
}
.keys-empty-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--paper-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
  margin-bottom: .875rem;
}
.keys-empty-icon svg { width: 20px; height: 20px; }
.keys-empty-title { font-size: .9375rem; font-weight: 600; color: var(--text-primary); }
.keys-empty-body  { font-size: .8125rem; color: var(--text-muted); }

.api-docs-hint {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  margin-top: 1rem;
  font-size: .8125rem;
  color: var(--text-muted);
  line-height: 1.55;
}
.api-docs-hint > svg { flex-shrink: 0; margin-top: .125rem; }
.api-docs-hint code {
  font-family: 'JetBrains Mono', monospace;
  font-size: .75rem;
  background: var(--paper-deep);
  padding: .0625rem .3125rem;
  border-radius: 3px;
}
.api-docs-hint a { color: var(--lavender); text-decoration: none; }
.api-docs-hint a:hover { text-decoration: underline; }

/* Permission fieldset in create panel */
.perm-fieldset { border: none; padding: 0; margin: 0; }

.perm-groups { display: flex; flex-direction: column; gap: 1.125rem; margin-top: .5rem; }

.perm-group-label {
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-bottom: .375rem;
}

.perm-check-list { display: flex; flex-direction: column; gap: .25rem; }

.perm-check {
  display: flex;
  align-items: flex-start;
  gap: .625rem;
  padding: .5rem .625rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--d-fast);
}
.perm-check:hover { background: var(--paper-deep); }
.perm-check input[type="checkbox"] {
  width: 15px; height: 15px;
  flex-shrink: 0;
  margin-top: .1rem;
  accent-color: var(--lavender);
  cursor: pointer;
}
.perm-check-name  { font-size: .875rem; font-weight: 500; color: var(--text-primary); }
.perm-check-desc  { font-size: .75rem; color: var(--text-muted); margin-top: .125rem; }

/* Key reveal */
.key-reveal-warning {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: oklch(94% 0.06 55);
  color: oklch(38% 0.14 55);
  border: 1px solid oklch(82% 0.1 55);
  border-radius: var(--radius-md);
  padding: .625rem .875rem;
  font-size: .8125rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

.key-reveal-box {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--paper-deep);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: .625rem .875rem;
  margin-bottom: .75rem;
}

.key-reveal-code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .8125rem;
  color: var(--text-primary);
  word-break: break-all;
  flex: 1;
}

.btn-copy-key {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: .3125rem .5rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: background var(--d-fast), color var(--d-fast);
}
.btn-copy-key:hover { background: var(--paper); color: var(--ink-deep); }
.btn-copy-key:focus-visible { outline: 2px solid var(--lavender-soft); outline-offset: 2px; }

.key-reveal-hint {
  font-size: .8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.key-reveal-hint code {
  font-family: 'JetBrains Mono', monospace;
  font-size: .75rem;
  background: var(--paper-deep);
  padding: .0625rem .3125rem;
  border-radius: 3px;
}

/* Dark mode: warning callout uses hard OKLCH light-mode values — remap */
[data-theme="dark"] .key-reveal-warning {
  background: oklch(22% 0.06 55);
  color: oklch(82% 0.12 55);
  border-color: oklch(34% 0.09 55);
}

/* Dark mode: permission badges use hard OKLCH light values */
[data-theme="dark"] .perm-badge.group-sites      { background: oklch(22% 0.05 270); color: oklch(78% 0.12 270); border-color: oklch(32% 0.08 270); }
[data-theme="dark"] .perm-badge.group-reports    { background: oklch(22% 0.05 155); color: oklch(78% 0.12 155); border-color: oklch(32% 0.08 155); }
[data-theme="dark"] .perm-badge.group-spellcheck { background: oklch(22% 0.05 55);  color: oklch(80% 0.12 55);  border-color: oklch(32% 0.08 55);  }
[data-theme="dark"] .perm-badge.group-media      { background: oklch(22% 0.05 20);  color: oklch(80% 0.12 20);  border-color: oklch(32% 0.08 20);  }

/* ── Proxy Pool ──────────────────────────────────────────────────────── */

.proxy-toggle-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}
.proxy-toggle-wrap input[type="checkbox"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

.proxy-toggle-track {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--paper-deep);
  border: 1px solid var(--border-strong);
  position: relative;
  transition: background var(--d-fast), border-color var(--d-fast);
}
.proxy-toggle-wrap input:focus-visible + .proxy-toggle-track {
  outline: 2px solid var(--lavender-soft);
  outline-offset: 2px;
}
.proxy-toggle-wrap input:checked + .proxy-toggle-track {
  background: var(--lavender);
  border-color: var(--lavender);
}
.proxy-toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text-subtle);
  transition: transform var(--d-fast), background var(--d-fast);
}
.proxy-toggle-wrap input:checked + .proxy-toggle-track .proxy-toggle-thumb {
  transform: translateX(16px);
  background: var(--paper);
}
.proxy-toggle-label {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text-muted);
  min-width: 2rem;
}

.proxy-status,
.proxy-degraded {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  padding: .625rem .875rem;
  border-radius: var(--radius-md);
  font-size: .8125rem;
  line-height: 1.5;
  margin-bottom: .75rem;
}
/* The default `[hidden] { display: none }` loses on cascade against the
   rule above (same specificity, source order wins). Re-assert it with
   class+attribute specificity so JS-toggled hiding actually works. */
.proxy-status[hidden],
.proxy-degraded[hidden] {
  display: none;
}
.proxy-status {
  background: color-mix(in srgb, var(--lavender) 6%, transparent);
  border: 1px solid color-mix(in srgb, var(--lavender) 22%, transparent);
  color: var(--text-body);
}
.proxy-status strong { color: var(--text-primary); font-weight: 600; }
.proxy-status-text { min-width: 0; }
[data-theme="dark"] .proxy-status {
  background: color-mix(in srgb, var(--lavender-night) 10%, transparent);
  border-color: color-mix(in srgb, var(--lavender-night) 28%, transparent);
  color: var(--text-night-body);
}
[data-theme="dark"] .proxy-status strong { color: var(--text-night-primary); }

.proxy-degraded {
  background: oklch(94% 0.06 55);
  border: 1px solid oklch(82% 0.1 55);
  color: oklch(38% 0.14 55);
}
[data-theme="dark"] .proxy-degraded {
  background: oklch(22% 0.06 55);
  border-color: oklch(34% 0.09 55);
  color: oklch(82% 0.12 55);
}
.proxy-degraded-text strong { font-weight: 600; }

.proxy-retry-btn {
  flex-shrink: 0;
  padding: .25rem .625rem;
  border-radius: var(--radius-md);
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--d-fast);
}
.proxy-retry-btn:hover:not(:disabled) {
  background: color-mix(in srgb, currentColor 12%, transparent);
}
.proxy-retry-btn:disabled { opacity: .5; cursor: not-allowed; }

.proxy-import-bar {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .375rem;
}
.proxy-import-key { flex: 1; }
.proxy-import-btn { white-space: nowrap; flex-shrink: 0; }
.proxy-import-hint {
  font-size: .75rem;
  color: var(--text-subtle);
  margin-bottom: 1rem;
}
.proxy-import-hint a { color: var(--lavender); text-decoration: none; }
.proxy-import-hint a:hover { text-decoration: underline; }

.proxy-table-wrap {
  background: var(--paper);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1rem;
}

.proxy-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.proxy-table th {
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  padding: .625rem 1rem;
  border-bottom: 1px solid var(--border-hairline);
  background: var(--paper-soft);
}
.proxy-table th:first-child  { width: 22%; }
.proxy-table th:nth-child(2) { width: 28%; }
.proxy-table th:nth-child(3) { width: 18%; }
.proxy-table th:nth-child(4) { width: 18%; }

.proxy-table td {
  padding: .5rem 1rem;
  border-bottom: 1px solid var(--border-hairline);
  vertical-align: middle;
}
.proxy-table tfoot td { padding: .625rem 1rem; background: var(--paper-soft); }
.proxy-table tfoot tr td:first-child { border-bottom: none; }
.proxy-table tbody tr:last-child td { border-bottom: none; }
.proxy-table tbody tr:hover td { background: var(--paper-soft); }

.proxy-cell-input {
  padding: 5px 9px;
  font-size: .8125rem;
  width: 100%;
  box-sizing: border-box;
}

.proxy-row-label  { font-size: .875rem; color: var(--text-primary); font-weight: 500; }
.proxy-row-server { font-family: 'JetBrains Mono', monospace; font-size: .75rem; color: var(--text-muted); }

.proxy-row-actions { display: flex; align-items: center; gap: .25rem; }

.proxy-add-btn { padding: .3125rem .75rem; font-size: .8125rem; }

.proxy-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .625rem;
  padding: 2.5rem 1.5rem;
  color: var(--text-subtle);
  font-size: .875rem;
  text-align: center;
}

.proxy-test-result {
  font-size: .75rem;
  font-family: 'JetBrains Mono', monospace;
  padding: .125rem .375rem;
  border-radius: var(--radius-sm);
}
.proxy-test-result.ok   { background: var(--pass-bg); color: var(--pass); }
.proxy-test-result.fail { background: var(--fail-bg); color: var(--fail); }

.proxy-footer {
  display: flex;
  justify-content: flex-end;
}

/* ── Zammad ───────────────────────────────────────────────────────── */
.zammad-card {
  background: var(--paper);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.zammad-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.zammad-grid .form-field:first-child,
.zammad-grid .form-field:nth-child(2),
.zammad-grid .form-field:nth-child(3) {
  grid-column: 1 / -1;
}
.zammad-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-hairline);
}
.zammad-callback-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--paper-soft);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: .5rem;
  min-width: 0;
}
.zammad-callback-row .btn-ghost { flex-shrink: 0; }
.zammad-callback-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: .75rem;
}
.zammad-status-text {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  min-width: 0;
}
.zammad-status-line {
  color: var(--text-body);
}
.zammad-status-meta {
  color: var(--text-subtle);
  font-size: .75rem;
}
.zammad-status-error {
  color: var(--fail);
  font-size: .75rem;
  font-weight: 500;
}
@media (max-width: 760px) {
  .zammad-grid { grid-template-columns: 1fr; }
  .zammad-actions { align-items: stretch; flex-direction: column; }
  .zammad-actions .btn-primary,
  .zammad-actions .btn-ghost { width: 100%; justify-content: center; }
}
[data-theme="dark"] .zammad-card {
  background: var(--night-card);
  border-color: var(--night-border-hairline);
}
[data-theme="dark"] .zammad-callback-row {
  background: var(--night-soft);
  border-color: var(--night-border-hairline);
}
[data-theme="dark"] .zammad-callback-value { color: var(--text-night-muted); }
[data-theme="dark"] .zammad-actions { border-color: var(--night-border-hairline); }
[data-theme="dark"] .zammad-status-line { color: var(--text-night-body); }
[data-theme="dark"] .zammad-status-meta { color: var(--text-night-subtle); }

/* ── Language & spelling ──────────────────────────────────────────── */
.settings-card {
  background: var(--paper);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.settings-card + .settings-card { margin-top: 1rem; }
.settings-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.settings-card-title {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
}
.settings-card-copy {
  margin-top: .2rem;
  font-size: .8125rem;
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 68ch;
}
.language-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}
.language-grid .form-field:first-child,
.language-grid .form-field:nth-child(3) {
  grid-column: 1 / -1;
}
.language-dictionary-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, auto) auto;
  gap: .625rem;
  align-items: end;
  padding-top: 1rem;
  border-top: 1px solid var(--border-hairline);
}
.language-site-row { margin-bottom: 1rem; }
.language-feedback {
  margin-right: auto;
  color: var(--text-muted);
  font-size: .8125rem;
}
.language-feedback.ok { color: var(--pass); }
.language-feedback.err { color: var(--fail); }
.language-field-hint {
  color: var(--text-subtle);
  font-size: .75rem;
  line-height: 1.45;
}
.language-dictionary-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.language-dictionary-panels .spell-dictionary-panel {
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: .875rem;
  background: var(--paper-soft);
}
.language-dictionary-panels .spell-word-list {
  min-height: 44px;
  padding-top: .5rem;
}
@media (max-width: 760px) {
  .language-grid,
  .language-dictionary-panels,
  .language-dictionary-tools,
  .language-site-row { grid-template-columns: 1fr; }
  .language-dictionary-tools .btn-primary { width: 100%; justify-content: center; }
}
[data-theme="dark"] .language-dictionary-tools,
[data-theme="dark"] .language-site-row { border-color: var(--night-border-hairline); }
[data-theme="dark"] .language-dictionary-panels .spell-dictionary-panel {
  background: var(--night-soft);
  border-color: var(--night-border-hairline);
}
[data-theme="dark"] .settings-card {
  background: var(--night-card);
  border-color: var(--night-border-hairline);
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 700px) {
  .settings-shell { gap: 0; padding: 1.25rem 1rem 3rem; flex-direction: column; }
  .settings-sidebar { width: 100%; position: static; display: flex; gap: .25rem; margin-bottom: 1.5rem; }
  .sidebar-group-label { display: none; }
  .panel-drawer { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .panel-backdrop, .panel-drawer, .toast { animation: none; }
  .btn-primary, .action-btn { transition: none; }
}
