:root {
  color-scheme: light;
  --page: #f5f7fa;
  --sidebar: #101828;
  --sidebar-soft: #182235;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #d8e0ea;
  --line-strong: #b8c4d2;
  --ink: #172033;
  --ink-soft: #344054;
  --muted: #667085;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --primary-soft: #e7f7f3;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --amber: #a15c07;
  --amber-soft: #fff7df;
  --red: #b42318;
  --red-soft: #fff1f0;
  --green-soft: #e9f9ef;
  --shadow-sm: 0 1px 2px rgba(20, 31, 50, 0.05);
  --shadow-md: 0 18px 42px rgba(16, 24, 40, 0.14);
  --radius: 8px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Aptos, "PingFang SC", "Microsoft YaHei", ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
}

body.auth-pending .app-layout {
  visibility: hidden;
}

.login-page {
  min-height: 100vh;
  background: #ffffff;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(360px, 44%) minmax(0, 1fr);
  min-height: 100vh;
}

.login-brand {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  background: #111827;
  color: #ffffff;
  padding: 42px 48px;
}

.login-brand-lockup,
.login-mobile-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand-lockup {
  color: #d7dee9;
  font-size: 14px;
  font-weight: 700;
}

.login-brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #0f766e;
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
}

.login-brand-copy {
  align-self: center;
  max-width: 500px;
}

.login-kicker {
  margin: 0 0 16px;
  color: #0f766e;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.login-brand .login-kicker {
  color: #5eead4;
}

.login-brand h1 {
  margin: 0;
  font-size: 52px;
  font-weight: 760;
  line-height: 1.14;
  letter-spacing: 0;
}

.login-brand-copy > p:last-child {
  margin: 24px 0 0;
  color: #aeb9c9;
  font-size: 17px;
}

.login-domain {
  margin: 0;
  color: #7f8ca0;
  font-size: 12px;
}

.login-entry {
  display: grid;
  grid-template-rows: 1fr auto;
  min-width: 0;
  min-height: 100vh;
  padding: 48px clamp(32px, 8vw, 112px) 28px;
}

.login-form-wrap {
  align-self: center;
  width: min(100%, 420px);
}

.login-mobile-brand {
  display: none;
}

.login-entry h2 {
  margin: 0;
  color: #172033;
  font-size: 32px;
  line-height: 1.2;
  letter-spacing: 0;
}

.login-lead {
  margin: 12px 0 28px;
  color: #667085;
  font-size: 15px;
}

.dingtalk-login {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  width: 100%;
  min-height: 52px;
  border: 1px solid #1677ff;
  border-radius: 8px;
  background: #1677ff;
  color: #ffffff;
  padding: 8px 12px;
  font-weight: 760;
  text-align: center;
  text-decoration: none;
  transition: background 150ms ease, border-color 150ms ease;
}

.dingtalk-login::after {
  content: "›";
  font-size: 23px;
  font-weight: 400;
}

.dingtalk-login:hover {
  border-color: #0f65dc;
  background: #0f65dc;
}

.dingtalk-login.is-loading {
  pointer-events: none;
  border-color: #b9c4d2;
  background: #b9c4d2;
}

.dingtalk-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 13px;
}

.login-notice {
  margin: 0 0 16px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #344054;
  padding: 11px 12px;
  font-size: 13px;
  line-height: 1.5;
}

.login-notice.error {
  border-color: #f3b7b2;
  background: #fff1f0;
  color: #9f261c;
}

.login-notice.success {
  border-color: #addbc3;
  background: #ecf9f1;
  color: #166534;
}

.login-session-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  color: #667085;
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #98a2b3;
}

.status-dot.ready {
  background: #16a36a;
}

.status-dot.error {
  background: #d92d20;
}

.login-account-note {
  margin: 26px 0 0;
  border-top: 1px solid #e4e7ec;
  color: #98a2b3;
  padding-top: 18px;
  font-size: 12px;
}

.login-footer {
  color: #98a2b3;
  font-size: 12px;
}

@media (max-width: 760px) {
  .login-shell {
    display: block;
  }

  .login-brand {
    display: none;
  }

  .login-entry {
    min-height: 100vh;
    padding: 28px 24px 22px;
  }

  .login-form-wrap {
    align-self: center;
    justify-self: center;
  }

  .login-mobile-brand {
    display: flex;
    margin-bottom: 64px;
    color: #344054;
  }

  .login-entry h2 {
    font-size: 28px;
  }

  .login-footer {
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dingtalk-login {
    transition: none;
  }
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.18);
  outline-offset: 2px;
}

code {
  border-radius: 4px;
  background: #eef3f8;
  color: #1e3a5f;
  padding: 2px 6px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  background: var(--sidebar);
  color: #ffffff;
  padding: 18px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 4px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  background: #0f766e;
  font-weight: 840;
  letter-spacing: 0.02em;
}

.brand p,
.brand h1 {
  margin: 0;
}

.brand p {
  color: #a7b3c5;
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.brand h1 {
  margin-top: 2px;
  font-size: 17px;
  line-height: 1.2;
  letter-spacing: 0;
}

.side-nav {
  display: grid;
  align-content: start;
  gap: 6px;
  padding-top: 18px;
}

.side-nav button {
  justify-content: flex-start;
  width: 100%;
  border-color: transparent;
  background: transparent;
  color: #cbd5e1;
  padding: 10px 11px;
}

.side-nav button:hover,
.side-nav button.active {
  background: var(--sidebar-soft);
  color: #ffffff;
}

.side-nav button.active {
  box-shadow: inset 3px 0 0 #2dd4bf;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 14px;
}

.main {
  min-width: 0;
  padding: 22px 24px 32px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 74px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary-strong);
  font-size: 11px;
  font-weight: 820;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-header h2 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

.page-header p:last-child {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.content-root {
  display: grid;
  gap: 14px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel-title,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.panel-title h3,
.panel-title p {
  margin: 0;
}

.panel-title h3 {
  font-size: 15px;
  line-height: 1.25;
}

.panel-title p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.metric-card strong {
  font-size: 24px;
  line-height: 1;
}

.admin-strip .metric-card {
  border-left-color: var(--primary);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tabs button {
  min-height: 34px;
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--ink-soft);
  padding: 7px 10px;
}

.tabs button.active {
  border-color: #9ee1d8;
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.search-box {
  display: grid;
  gap: 5px;
  min-width: min(360px, 100%);
}

.search-box span,
.field span,
.scope-box legend {
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 760;
  line-height: 1.25;
  white-space: nowrap;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field.compact span {
  color: #cbd5e1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

textarea {
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #98a6b5;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--line-strong);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.sidebar select {
  border-color: rgba(255, 255, 255, 0.14);
  background: #0f172a;
  color: #ffffff;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  color: inherit;
  font-size: 13px;
  font-weight: 760;
  line-height: 1.2;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, transform 120ms ease;
}

button:hover:not(:disabled),
.button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
  transform: none;
}

.primary {
  border-color: var(--primary-strong);
  background: var(--primary);
  color: #ffffff;
}

.primary:hover {
  background: var(--primary-strong);
}

.secondary {
  border-color: var(--line);
  background: #eef3f8;
  color: var(--ink-soft);
}

.secondary:hover {
  border-color: var(--line-strong);
  background: #e4ebf3;
}

.danger-button {
  border-color: #fecaca;
  background: #fff7f7;
  color: var(--red);
}

.full-width {
  width: 100%;
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 760;
  line-height: 1.2;
  white-space: nowrap;
}

.status-pill {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--amber-soft);
  color: var(--amber);
}

.status-pill.ok,
.badge.published {
  background: var(--green-soft);
  color: var(--primary-strong);
}

.badge.unpublished {
  background: var(--red-soft);
  color: var(--red);
}

.table-wrap {
  overflow: auto;
}

.data-table {
  width: 100%;
  min-width: 1060px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.data-table tbody tr:hover {
  background: #fbfdff;
}

.actions-col {
  width: 328px;
}

.data-table th:last-child,
.data-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 1;
  background: #ffffff;
  box-shadow: -10px 0 18px rgba(16, 24, 40, 0.06);
}

.data-table th:last-child {
  z-index: 2;
  background: #f8fafc;
}

.title-cell {
  display: grid;
  gap: 3px;
  min-width: 220px;
}

.title-link {
  justify-content: flex-start;
  width: fit-content;
  min-height: auto;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  font-size: 13px;
  font-weight: 820;
  text-align: left;
}

.title-link:hover {
  color: var(--primary-strong);
  text-decoration: underline;
  transform: none;
}

.title-cell strong {
  color: var(--ink);
  font-size: 13px;
}

.title-cell span,
.scope-text {
  color: var(--muted);
  font-size: 12px;
}

.row-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 5px;
  white-space: nowrap;
}

.row-actions button,
.version-card button {
  min-height: 34px;
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink-soft);
  padding: 7px 9px;
  font-size: 12px;
}

.row-actions button:hover,
.version-card button:hover {
  border-color: var(--primary);
  color: var(--primary-strong);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  line-height: 1.6;
  padding: 24px;
  text-align: center;
}

.empty-state strong {
  color: var(--ink-soft);
  font-size: 15px;
}

.empty-state span {
  font-size: 13px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.admin-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 15px;
}

.admin-card h3 {
  margin: 0 0 7px;
  font-size: 15px;
}

.admin-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.drawer-backdrop,
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15, 23, 42, 0.36);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 41;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
  width: min(760px, 100vw);
  height: 100vh;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow-md);
}

.drawer-header,
.modal-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.drawer-header p,
.modal-header p {
  margin: 0 0 4px;
  color: var(--primary-strong);
  font-size: 11px;
  font-weight: 820;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.drawer-header h3,
.modal-header h3 {
  margin: 0;
  font-size: 19px;
  line-height: 1.25;
}

.icon-close {
  min-height: 32px;
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--ink-soft);
  padding: 6px 9px;
}

.drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.info-grid div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px;
}

.info-grid dt {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
}

.info-grid dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
}

.drawer-section {
  display: grid;
  gap: 10px;
}

.external-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 12px;
}

.external-card strong,
.external-card p {
  margin: 0;
}

.external-card p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.external-url,
.password-note {
  overflow-wrap: anywhere;
}

.external-actions {
  display: flex;
  align-items: start;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.external-actions button {
  min-height: 32px;
}

.section-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-line h4 {
  margin: 0;
  font-size: 15px;
}

.section-line span {
  color: var(--muted);
  font-size: 12px;
}

.version-stack {
  display: grid;
  gap: 8px;
}

.version-card {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 10px;
}

.version-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.current-dot {
  display: inline-flex;
  margin-left: 6px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--primary-strong);
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 760;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 42;
  width: min(860px, calc(100vw - 32px));
  height: min(760px, calc(100vh - 24px));
  max-height: calc(100vh - 24px);
  overflow: hidden;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding-bottom: 10px;
}

.permission-modal {
  width: min(1120px, calc(100vw - 32px));
}

.modal-form {
  display: grid;
  flex: 1;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  padding-top: 10px;
}

.permission-form {
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}

.permission-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(540px, 1.28fr);
  gap: 16px;
  min-height: 0;
  overflow: hidden;
}

.permission-basics {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.permission-layout > .permission-panel {
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.permission-layout .contact-picker {
  height: 100%;
  min-height: 0;
  max-height: none;
}

.form-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

#versionForm .form-two-balanced:has(input[type="file"] + small) > .field:first-child::after {
  content: "";
  display: block;
  min-height: 16px;
}

.field small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  min-height: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

input[type="file"] {
  height: 40px;
  min-height: 40px;
  margin: 0;
  padding: 7px 10px;
}

.permission-panel {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdff;
  padding: 8px;
}

.permission-panel section {
  display: grid;
  gap: 6px;
}

.permission-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.permission-heading h4 {
  margin: 0;
  font-size: 14px;
}

.permission-heading span {
  color: var(--muted);
  font-size: 12px;
}

.policy-options {
  display: grid;
  gap: 4px;
}

.contact-picker {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(250px, 0.92fr);
  min-height: 184px;
  max-height: 216px;
  overflow: hidden;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.contact-directory,
.selected-directory {
  display: grid;
  min-width: 0;
}

.contact-directory {
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 8px;
  padding-right: 12px;
}

.selected-directory {
  grid-template-rows: auto minmax(0, 1fr);
  border-left: 1px solid var(--line);
  background: #ffffff;
  padding-left: 12px;
}

.contact-search {
  position: relative;
  display: block;
}

.contact-search span {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: transparent;
}

.contact-search span::before,
.contact-search span::after {
  content: "";
  position: absolute;
  display: block;
}

.contact-search span::before {
  width: 9px;
  height: 9px;
  border: 1.5px solid #9aa8b5;
  border-radius: 999px;
}

.contact-search span::after {
  left: 10px;
  top: 11px;
  width: 6px;
  height: 1.5px;
  transform: rotate(45deg);
  border-radius: 999px;
  background: #9aa8b5;
}

.contact-search input {
  height: 34px;
  min-height: 34px;
  padding-left: 34px;
  border-radius: var(--radius-sm);
}

.picker-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.picker-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--muted);
  padding: 0 8px;
}

.picker-actions button span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #f1f5f8;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 820;
}

.picker-actions button strong {
  color: inherit;
  font-size: 12px;
  font-weight: 680;
}

.picker-actions button.active {
  border-color: #9ee1d8;
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.picker-actions button.active span,
.picker-actions button.active strong {
  color: var(--primary-strong);
}

.picker-context {
  display: flex;
  align-items: center;
  min-height: 26px;
  gap: 8px;
}

.picker-context strong {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-context span {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.picker-back {
  min-height: 26px;
  border: 0;
  background: transparent;
  color: var(--primary-strong);
  padding: 0;
  font-size: 12px;
  font-weight: 760;
}

.directory-list,
.selected-list {
  display: grid;
  align-content: start;
  gap: 4px;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.directory-row,
.selected-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  border: 0;
  background: #ffffff;
  color: var(--ink);
  padding: 5px 8px;
  text-align: left;
}

.directory-row:hover,
.directory-row:focus-visible {
  background: #f5f9fb;
}

.directory-row.selected {
  background: #f1fbf9;
}

.directory-row strong,
.selected-row strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.directory-row small,
.selected-row small {
  color: var(--muted);
  font-size: 11px;
}

.check-box {
  width: 16px;
  height: 16px;
  border: 1px solid #c9d3df;
  border-radius: 4px;
  background: #ffffff;
}

.check-box.checked {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: inset 0 0 0 3px #ffffff;
}

.scope-avatar {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 6px;
  background: #eaf1f7;
  color: #415368;
  font-size: 11px;
  font-weight: 820;
}

.scope-avatar.department {
  background: #eaf8f4;
  color: var(--primary-strong);
}

.directory-department-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 0;
  min-height: 42px;
  border-radius: var(--radius-sm);
  background: #ffffff;
}

.directory-department-row:hover,
.directory-department-row:focus-within {
  background: #f5f9fb;
}

.directory-department-row.selected {
  background: #f1fbf9;
}

.department-select {
  display: grid;
  place-items: center;
  width: 34px;
  min-height: 42px;
  border: 0;
  background: transparent;
  padding: 0;
}

.department-open {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 5px 8px 5px 0;
  text-align: left;
}

.department-open > span:nth-child(2),
.current-department-choice > span:last-child {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.department-open strong,
.current-department-choice strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.department-open small,
.current-department-choice small {
  color: var(--muted);
  font-size: 11px;
}

.current-department-choice {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid #cfe7e2;
  border-radius: var(--radius-sm);
  background: #f6fbfa;
  color: var(--ink);
  padding: 5px 8px;
  text-align: left;
}

.current-department-choice.selected {
  border-color: #9ee1d8;
  background: var(--primary-soft);
}

.row-chevron {
  color: #93a3b3;
  font-size: 20px;
  line-height: 1;
}

.selected-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  margin-bottom: 10px;
}

.selected-head strong {
  color: var(--ink);
  font-size: 14px;
}

.selected-head span {
  color: var(--muted);
  font-size: 13px;
}

.selected-list {
  max-height: none;
}

.selected-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
  border-radius: var(--radius-sm);
  background: #f8fafc;
}

.selected-row div {
  display: grid;
  min-width: 0;
}

.selected-row button {
  min-height: 28px;
  border: 0;
  background: transparent;
  color: var(--red);
  padding: 0 4px;
  font-size: 12px;
}

.scope-empty,
.selected-empty {
  margin: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  color: var(--muted);
  padding: 10px;
  font-size: 12px;
  line-height: 1.5;
}

.policy-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  padding: 6px 8px;
}

.policy-option:has(input:checked) {
  border-color: #9ee1d8;
  background: var(--primary-soft);
}

.policy-option input {
  width: 16px;
  min-height: 16px;
  margin-top: 2px;
  accent-color: var(--primary);
}

.policy-option span {
  display: grid;
  gap: 3px;
}

.policy-option strong {
  color: var(--ink);
  font-size: 13px;
}

.external-config {
  border: 1px solid #9ee1d8;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  padding: 9px 10px;
}

.scope-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 10px;
}

.scope-box legend {
  padding: 0 4px;
}

.scope-box label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--ink-soft);
  padding: 7px 9px;
  font-size: 13px;
  font-weight: 680;
}

.scope-box label span {
  border-radius: 999px;
  background: #eef3f8;
  color: var(--muted);
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 760;
}

.scope-box label:has(input:checked) {
  border-color: #9ee1d8;
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.scope-box input {
  width: 15px;
  height: 15px;
  min-height: auto;
  accent-color: var(--primary);
}

.precheck-box {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1.45;
}

.precheck-box strong {
  color: var(--ink-soft);
  font-size: 13px;
}

.precheck-box span {
  color: var(--muted);
}

.precheck-box.ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.precheck-box.ok strong {
  color: var(--primary-strong);
}

.precheck-box.danger {
  border-color: #fecaca;
  background: #fff1f2;
}

.precheck-box.danger strong {
  color: var(--red);
}

.modal-footer {
  position: sticky;
  bottom: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding-top: 10px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  max-width: min(520px, calc(100vw - 44px));
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  background: #f0fdf4;
  color: var(--primary-strong);
  padding: 12px 14px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 760;
}

.toast.danger {
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--red);
}

@media (max-width: 1080px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    grid-template-rows: auto auto auto;
  }

  .side-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sidebar-footer {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: end;
  }

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

  .permission-modal {
    width: min(860px, calc(100vw - 32px));
  }

  .permission-form {
    overflow-y: auto;
  }

  .permission-layout {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .permission-basics,
  .permission-layout > .permission-panel {
    overflow: visible;
  }

  .permission-layout .contact-picker {
    min-height: 260px;
    max-height: 320px;
  }
}

@media (max-width: 720px) {
  .modal {
    height: auto;
    max-height: calc(100vh - 24px);
    overflow: auto;
  }

  .modal-header .icon-close {
    flex: 0 0 auto;
    width: auto;
  }

  .main {
    padding: 16px;
  }

  .page-header,
  .toolbar,
  .modal-footer {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .side-nav,
  .sidebar-footer,
  .metric-strip,
  .admin-grid,
  .form-two,
  .permission-panel,
  .external-card,
  .info-grid,
  .scope-box {
    grid-template-columns: 1fr;
  }

  .contact-picker {
    display: grid;
    grid-template-columns: 1fr;
    max-height: none;
  }

  .contact-directory {
    min-height: 206px;
    padding-right: 0;
  }

  .selected-directory {
    min-height: 124px;
    border-top: 1px solid var(--line);
    border-left: 0;
    padding-top: 12px;
    padding-left: 0;
  }

  .header-actions,
  .drawer-actions,
  .external-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  #modalRoot .modal-footer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  button,
  .button {
    width: 100%;
  }
}
