:root {
  /* MasterGo tokens: 中性色 / primary */
  --bg: #f9f9fa; /* color-bg-2 */
  --surface: #ffffff; /* color-bg-1 */
  --surface-2: #f9f9fa;
  --surface-3: #f1f3f5; /* color-bg-3 */
  --text: #1d2129; /* color-text-1 */
  --muted: #868f9c; /* color-text-3 */
  --text-2: #4d5562; /* color-text-2 */
  --line: #e5e6eb; /* color-border-3 */
  --line-soft: #f2f3f5; /* color-border-4 */
  --accent: #1d2129;
  --accent-strong: #000000;
  --primary: #1d2129;
  --nav-bg: #ffffff;
  --nav-bg-2: #f9f9fa;
  --nav-text: #1d2129;
  --nav-muted: #868f9c;
  --blue: #1d2129;
  --amber: #a45f13;
  --danger: #b42318;
  --mask: #dadada;
  --mask-stroke: #6a707b;
  --selected: #1d2129;
  --disabled: #cbcbcb;
  --shadow: 0 0 10px rgba(0, 0, 0, 0.04);
  font-family: "HarmonyOS Sans SC", "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  color: var(--text);
  background: var(--bg);
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

input,
select {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fbfcfc;
}

input:focus,
select:focus,
.custom-rules:focus {
  outline: 2px solid rgba(29, 33, 41, 0.18);
  border-color: var(--accent);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: #000;
}

.hidden {
  display: none !important;
}

.file-input-proxy {
  position: fixed;
  left: -9999px;
  top: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.auth-screen,
.pending-screen {
  height: 100%;
  min-height: 100%;
  display: grid;
  place-items: center;
  grid-template-columns: minmax(300px, 1fr) minmax(420px, 520px);
  gap: clamp(72px, 9vw, 180px);
  padding: 48px 64px;
  overflow: auto;
  overscroll-behavior: contain;
  background: linear-gradient(135deg, #f3f5f9 0%, #eef0f3 48%, #f8f8f8 100%);
}

html.sso-launch #authView {
  display: none !important;
}

html.sso-launch #pendingView,
html.sso-launch #appView {
  display: none !important;
}

html.sso-launch,
html.sso-launch body {
  background: #fff;
}

.auth-screen {
  background:
    linear-gradient(90deg, rgba(29, 33, 41, 0.08) 0%, rgba(241, 243, 245, 0.6) 100%),
    url("/static/login-background-20260717.jpg") center / cover no-repeat;
}

.pending-screen {
  grid-template-columns: minmax(320px, 480px);
}

.auth-brand,
.pending-panel {
  width: 100%;
}

.auth-brand {
  justify-self: start;
  max-width: 430px;
  margin-left: clamp(92px, 9vw, 180px);
}

.auth-brand .brand-mark,
.pending-panel .brand-mark {
  width: 56px;
  height: 56px;
  margin-bottom: 18px;
  font-size: 24px;
}

.auth-brand h1,
.pending-panel h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: 0;
}

.auth-screen .auth-brand h1 {
  color: #fff;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.24);
}

.auth-brand p,
.pending-panel p {
  margin: 10px 0 0;
  color: var(--muted);
}

.auth-panel,
.pending-panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.auth-panel {
  justify-self: end;
  width: min(100%, 460px);
  min-height: 360px;
  padding: 30px;
  border-color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.auth-tabs button,
.nav-btn,
.secondary-btn,
.text-btn {
  min-height: 38px;
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-2);
}

.auth-tabs button {
  min-height: 44px;
  font-size: 15px;
}

.auth-tabs button.active {
  color: #fff;
  background: var(--accent);
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.auth-form input {
  min-height: 46px;
  padding: 0 14px;
  font-size: 15px;
}

.password-field {
  position: relative;
  display: block;
  width: 100%;
}

.password-field input {
  padding-right: 62px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  min-height: 30px;
  border-radius: 7px;
  color: var(--accent);
  background: #f1f3f5;
  font-size: 12px;
  font-weight: 700;
  transform: translateY(-50%);
}

.password-toggle:hover {
  color: #fff;
  background: var(--accent);
}

.auth-form .primary-btn {
  min-height: 48px;
  margin-top: 2px;
  font-size: 16px;
}

.auth-status {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--danger);
  font-size: 13px;
  white-space: pre-wrap;
}

.app-shell {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  width: 100%;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  background: var(--bg);
  transition: grid-template-columns 0.18s ease;
}

.app-shell.admin-mode {
  grid-template-columns: 256px minmax(0, 1fr);
}

.app-shell.nav-collapsed {
  grid-template-columns: 72px minmax(0, 1fr);
}

.app-shell.admin-mode.nav-collapsed {
  grid-template-columns: 72px minmax(0, 1fr);
}

.app-main {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr);
  overflow: hidden;
}

.app-content {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: 334px minmax(0, 1fr) 260px;
  overflow: hidden;
}

.app-shell.admin-mode .app-content {
  grid-template-columns: minmax(0, 1fr);
}

.app-shell.admin-mode .sidebar,
.app-shell.admin-mode .inspector {
  display: none;
}

.nav-sidebar {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0;
  padding: 0;
  overflow: hidden;
  color: var(--nav-text);
  background: var(--nav-bg);
  border-right: 1px solid var(--line);
}

.nav-brand {
  position: relative;
  display: block;
  height: 72px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.nav-title-block {
  min-width: 0;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.nav-title-copy {
  min-width: 0;
}

.nav-brand h1 {
  margin: 0;
  overflow: hidden;
  color: #000;
  font-family: "Archivo Black", "Arial Black", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.1;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-brand p {
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--nav-muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: #fff url("/static/veildoc-logo.svg?v=20260724-black") center / 26px 26px no-repeat;
  box-shadow: 0 0 0 1px var(--line);
}

.collapse-nav-btn {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-2);
  background: #fff;
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  box-shadow: var(--shadow);
  flex: 0 0 28px;
}

.nav-sidebar-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--line-soft);
}

.nav-sidebar .account-box {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px;
  align-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.account-profile-btn {
  min-width: 0;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: inherit;
  background: transparent;
  text-align: left;
}

.account-profile-btn:hover {
  background: var(--surface-2);
}

.account-profile-btn.active {
  background: var(--surface-2);
}

.account-icon-btn {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--text-2);
  background: transparent;
}

.account-icon-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.account-icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.collapse-nav-btn.account-icon-btn {
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
}

.collapse-nav-btn.account-icon-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.account-avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  user-select: none;
}

.account-meta {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.nav-sidebar .account-box strong {
  overflow: hidden;
  color: #0a0a0a;
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-sidebar .account-box span,
.nav-sidebar .account-meta span {
  overflow: hidden;
  color: var(--nav-muted);
  font-size: 12px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-sidebar .text-btn {
  min-height: 24px;
  padding: 0;
  color: var(--text-2);
  font-size: 13px;
}

.nav-list {
  align-content: start;
  display: grid;
  gap: 8px;
  padding: 12px 16px;
}

.nav-btn {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-2);
  background: transparent;
  text-align: left;
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.nav-btn:hover {
  background: var(--surface-2);
}

.nav-btn.active {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  display: grid;
  place-items: center;
  color: inherit;
}

.nav-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-shell.nav-collapsed .nav-sidebar {
  display: flex;
  flex-direction: column;
  padding: 0;
}

.app-shell.nav-collapsed .nav-brand {
  display: flex;
  flex: 0 0 72px;
  align-items: center;
  justify-content: center;
  height: 72px;
  padding: 0;
  border-bottom: 0;
}

.app-shell.nav-collapsed .nav-title-block {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-right: 0;
}

.app-shell.nav-collapsed .nav-title-copy,
.app-shell.nav-collapsed .nav-sidebar-foot .account-box,
.app-shell.nav-collapsed .nav-label {
  display: none !important;
}

.app-shell.nav-collapsed .nav-list {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 0;
  gap: 8px;
}

.app-shell.nav-collapsed .nav-sidebar-foot {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: auto;
  padding: 0 0 16px;
  border-top: 0;
}

.app-shell.nav-collapsed .collapse-nav-btn {
  position: static;
  width: 40px;
  height: 32px;
  margin: 0;
  border-style: dashed;
  box-shadow: none;
}

.app-shell.nav-collapsed .nav-brand-mark {
  width: 32px;
  height: 32px;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  background-color: transparent;
  background-image: url("/static/veildoc-logo.svg?v=20260724-black");
  background-position: center;
  background-size: 32px 32px;
  background-repeat: no-repeat;
}

.app-shell.nav-collapsed .nav-btn {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  height: 40px;
  margin-inline: auto;
  justify-content: center;
  padding: 0;
  border-color: transparent;
}

.app-shell.nav-collapsed .nav-btn.active {
  border-color: transparent;
  background: var(--surface-2);
  color: var(--text);
}

.sidebar,
.inspector {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 16px;
  overflow: hidden;
}

.sidebar {
  background: var(--surface);
}

.sidebar > .workbench-only {
  min-height: 0;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar .rules-panel {
  min-height: 0;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 0;
}

.sidebar .rules-panel > .panel-head {
  flex: 0 0 auto;
  margin-bottom: 10px;
}

/* 仅「脱敏目标」芯片列表可滚动；白名单/方式/来源/一键脱敏固定在底部 */
.sidebar .rules-panel-body {
  min-height: 0;
  flex: 1 1 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: #d0d4db transparent;
}

.sidebar .rules-panel-body::-webkit-scrollbar {
  width: 4px;
}

.sidebar .rules-panel-body::-webkit-scrollbar-thumb {
  background: #d0d4db;
  border-radius: 999px;
}

.sidebar .rules-panel-body::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar .rules-panel-footer {
  flex: 0 0 auto;
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
  position: relative;
  z-index: 2;
}

.inspector {
  border-right: 0;
  border-left: 1px solid var(--line);
  background: var(--surface);
}

.inspector > .panel-head {
  flex: 0 0 auto;
  margin-bottom: 12px;
}

.inspector-head {
  min-height: 32px;
}

.inspector-icon-btn {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-2);
  background: var(--surface);
}

.inspector-icon-btn:not(:disabled):hover {
  color: var(--text);
  background: var(--surface-3);
}

.inspector-icon-btn svg {
  width: 16px;
  height: 16px;
}

.inspector .mask-list {
  min-height: 0;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.inspector .mask-list::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

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

.account-box {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
  margin-bottom: 12px;
}

.account-box strong {
  font-size: 14px;
}

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

.text-btn {
  justify-self: start;
  min-height: 28px;
  padding: 0 10px;
  color: var(--accent-strong);
  background: transparent;
}

/* nav-list / nav-btn styles defined above for MasterGo light sidebar */

.drop-zone {
  display: grid;
  gap: 8px;
  place-items: center;
  padding: 22px 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  margin-bottom: 14px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: var(--surface-3);
}

.drop-zone input {
  display: none;
}

.drop-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--accent);
  font-size: 24px;
}

.drop-zone small,
.section-head p {
  color: var(--muted);
}

.panel,
.panel-block {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  background: var(--surface);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.panel-head h2,
.panel-block h3 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
}

.panel-toggle-btn {
  color: var(--text-2) !important;
  background: var(--surface-2) !important;
}

.panel-toggle-btn:hover {
  background: #fff !important;
  box-shadow: inset 0 0 0 1px var(--line);
}

.panel-block h3 {
  margin-bottom: 12px;
}

.panel-toggle-btn {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-radius: 8px;
  color: var(--accent-strong);
  background: #f1f3f5;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.panel-toggle-btn:hover {
  background: #e5e6eb;
}

.rules-panel.collapsed {
  padding-bottom: 10px;
}

.rules-panel.collapsed .panel-head {
  margin-bottom: 0;
}

.rule-list {
  display: grid;
  gap: 16px;
}

.rule-group {
  display: grid;
  gap: 8px;
}

.rule-group-title {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
}

.rule-group-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  opacity: 0.75;
  background:
    linear-gradient(currentColor, currentColor) 2px 11px / 4px 3px no-repeat,
    linear-gradient(currentColor, currentColor) 7px 8px / 4px 6px no-repeat,
    linear-gradient(currentColor, currentColor) 12px 5px / 4px 9px no-repeat;
}

#customRuleGroup:has(#customRuleList:empty) {
  display: none;
}

.custom-rule-wrap {
  grid-template-columns: minmax(0, 1fr) !important;
}

.custom-rule-wrap .add-rule-btn.hidden,
.panel-toggle-btn.hidden {
  display: none !important;
}

.exclude-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
}

.sidebar .status-box {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.rule-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rule-list label {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.rule-list label:has(input:checked) {
  border-color: #000;
  background: var(--surface-2);
  color: #000;
  font-weight: 500;
}

.rule-list label[data-custom-label="true"] {
  padding-right: 28px;
}

.rule-list span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.rule-list input {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  min-height: 1px;
  margin: 0;
  pointer-events: none;
}

.rule-list input:checked {
  border-color: transparent;
  background: transparent;
}

.rule-list input:checked::after {
  content: none;
}

.method-block {
  margin-top: 14px;
}

.method-title {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
}

.rule-delete-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  min-height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 7px;
  color: var(--danger);
  background: #fbecea;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.rule-delete-btn:hover {
  color: #fff;
  background: var(--danger);
}

.custom-rule-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 8px;
  margin-top: 10px;
}

.exclude-targets {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.exclude-title {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.exclude-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
}

.exclude-list.empty {
  display: none;
}

.exclude-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid #e3c7a4;
  border-radius: 8px;
  color: #6f410e;
  background: #fff8ed;
  font-size: 12px;
  font-weight: 700;
}

.exclude-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exclude-chip strong {
  margin-left: 6px;
  font-size: 13px;
  line-height: 1;
}

.exclude-rule-wrap {
  margin-top: 8px;
}

.custom-rules {
  min-height: 38px;
  height: 38px;
  resize: none;
  border-radius: 8px;
  background: #fbfcfc;
  font-size: 13px;
}

.add-rule-btn {
  min-height: 38px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.add-rule-btn:hover,
.primary-btn:hover:not(:disabled) {
  background: var(--accent-strong);
}

.toggle-row {
  display: flex;
  gap: 12px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 13px;
}

.toggle-row label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.toggle-row input {
  width: 15px;
  min-height: 15px;
}

.ocr-source,
.llm-source {
  margin: 10px 0 12px;
}

.ocr-source-title,
.llm-source-title {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.ocr-provider-row,
.llm-provider-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.llm-provider-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ocr-provider-row.is-muted,
.llm-provider-row.is-muted {
  opacity: 0.64;
}

.ocr-provider-btn,
.llm-provider-btn {
  min-height: 32px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
}

.ocr-provider-row,
.llm-provider-row {
  gap: 0;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ocr-provider-btn,
.llm-provider-btn {
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-2);
  background: transparent;
  font-size: 14px;
  font-weight: 400;
  box-shadow: none;
}

.ocr-provider-btn.active,
.llm-provider-btn.active {
  color: #000;
  background: #fff;
  border-color: #000;
  font-weight: 500;
  box-shadow: none;
}

.primary-btn,
.ghost-btn,
.tool-btn,
.mini-btn,
.secondary-btn {
  border-radius: 8px;
  min-height: 38px;
  padding: 0 12px;
}

.primary-btn {
  width: 100%;
  min-height: 40px;
  border-radius: 12px;
  color: #fff;
  background: var(--disabled);
  font-weight: 400;
}

.primary-btn:not(:disabled) {
  background: #000;
}

.primary-btn:hover:not(:disabled) {
  background: #222;
}

.secondary-btn {
  color: #fff;
  background: #000;
  white-space: nowrap;
}

.secondary-btn:hover:not(:disabled) {
  background: #222;
}

.ghost-btn {
  width: 100%;
  margin: 10px 0;
  color: var(--text);
  background: #edf1f0;
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.tool-btn {
  color: var(--text);
  background: #edf1f0;
}

.tool-btn.active {
  color: #fff;
  background: var(--accent);
}

.mini-btn {
  min-height: 30px;
  color: #fff;
  background: var(--danger);
}

.mini-btn.neutral {
  background: var(--accent);
}

.inspector-actions {
  display: flex;
  gap: 7px;
  align-items: center;
}

.status-box {
  padding: 12px;
  border-radius: 8px;
  background: #eef2f1;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.status-text {
  white-space: pre-wrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(18, 24, 32, 0.48);
}

.suggestion-dialog {
  width: min(520px, calc(100vw - 36px));
  max-height: min(620px, calc(100vh - 36px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.confirm-dialog {
  width: min(420px, calc(100vw - 36px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.confirm-head {
  padding: 18px 18px 10px;
}

.confirm-head h2 {
  margin: 0;
  font-size: 18px;
}

.confirm-body {
  padding: 0 18px 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.confirm-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--line);
}

.confirm-foot .ghost-btn,
.confirm-foot .primary-btn {
  width: auto;
  min-width: 82px;
  margin: 0;
}

.primary-btn.danger {
  background: var(--danger);
}

.suggestion-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.suggestion-head h2 {
  margin: 0;
  font-size: 20px;
}

.suggestion-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.suggestion-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding: 14px 18px;
}

.suggestion-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(29, 33, 41, 0.28);
  border-radius: 8px;
  background: #f9f9fa;
}

.suggestion-item strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 18px;
}

.suggestion-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.suggestion-item button {
  min-height: 36px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.suggestion-foot {
  display: flex;
  justify-content: flex-end;
  padding: 12px 18px 18px;
  border-top: 1px solid var(--line);
}

.suggestion-foot .ghost-btn {
  width: auto;
  min-width: 96px;
  margin: 0;
}

.pdf-compose-dialog {
  width: min(var(--pdf-compose-dialog-width, 980px), calc(100vw - 36px));
  height: min(780px, calc(100vh - 36px));
  min-height: 560px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.pdf-compose-head,
.pdf-compose-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.pdf-compose-foot {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.pdf-compose-head h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.pdf-compose-head p,
.pdf-compose-foot span,
.compose-name-field span,
.pdf-compose-preview-meta {
  color: var(--muted);
  font-size: 13px;
}

.pdf-compose-head p {
  margin: 4px 0 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-2);
  font-weight: 800;
}

.pdf-compose-body {
  min-height: 0;
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr);
}

.pdf-compose-list-pane {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  padding: 16px;
  border-right: 1px solid var(--line);
  background: var(--surface-3);
}

.compose-name-field {
  display: grid;
  gap: 6px;
}

.compose-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.compose-actions .ghost-btn,
.pdf-compose-foot .ghost-btn,
.pdf-compose-foot .primary-btn {
  width: auto;
  margin: 0;
}

.pdf-compose-page-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.pdf-compose-page {
  display: grid;
  grid-template-columns: 24px 18px 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 78px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
}

.pdf-compose-page.active {
  border-color: var(--accent);
  background: #f1f3f5;
}

.pdf-compose-page.excluded {
  opacity: 0.58;
}

.pdf-compose-page.dragging {
  outline: 2px solid rgba(29, 33, 41, 0.28);
}

.pdf-compose-drag {
  width: 24px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-2);
  cursor: grab;
  font-size: 18px;
  line-height: 1;
}

.pdf-compose-page input {
  width: 16px;
  min-height: 16px;
}

.pdf-compose-thumb {
  width: 58px;
  height: 62px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.pdf-compose-thumb-wrap {
  position: relative;
  width: 58px;
  height: 62px;
  flex: 0 0 58px;
}

.pdf-compose-thumb-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  line-height: 1.2;
  padding: 4px;
}

.pdf-compose-page.loading {
  opacity: 0.82;
}

.pdf-compose-thumb.hidden {
  display: none;
}

.pdf-compose-page-text {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.pdf-compose-page-text strong,
.pdf-compose-page-text span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-compose-page-text strong {
  font-size: 13px;
}

.pdf-compose-page-text span {
  color: var(--muted);
  font-size: 12px;
}

.pdf-compose-move {
  display: grid;
  grid-template-columns: 28px 28px;
  gap: 5px;
}

.pdf-compose-move button {
  min-height: 28px;
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-2);
}

.pdf-compose-preview-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
  padding: 0;
  background: #eef1f5;
}

.pdf-compose-preview-meta {
  padding: 12px 0 8px;
}

.pdf-compose-preview-frame {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.pdf-compose-preview-frame img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  filter: drop-shadow(0 8px 26px rgba(29, 35, 43, 0.14));
}

.pdf-compose-preview-empty {
  color: var(--muted);
  font-size: 13px;
}

.pdf-compose-preview-frame img[src=""] {
  display: none;
}

.pdf-compose-foot > div {
  display: flex;
  gap: 8px;
}

.workspace {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
  background: var(--bg);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(240px, 1fr);
  align-items: center;
  gap: 16px;
  min-height: 72px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-soft);
}

.topbar-left {
  min-width: 0;
  display: flex;
  align-items: center;
}

.page-title {
  color: var(--text);
  font-size: 28px;
  font-weight: 700;
  line-height: 60px;
}

.topbar strong:not(.page-title) {
  display: block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.topbar-tools {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.tool-chip {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
}

.tool-chip.active {
  border-color: var(--text);
  color: #fff;
  background: var(--text);
}

.tool-chip .tool-chip-icon {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 20px;
}

.tool-chip .tool-chip-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.document-context-bar {
  min-width: 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 16px 0;
  background: transparent;
}

.document-context-meta {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.document-context-meta .doc-title {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-context-meta span {
  color: var(--muted);
  font-size: 14px;
  line-height: 20px;
}

.document-context-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 12px;
}

.document-context-btn {
  min-width: 80px;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text-2);
  background: var(--surface-2);
  font-size: 14px;
  line-height: 20px;
  white-space: nowrap;
}

.document-context-btn:hover:not(:disabled) {
  border-color: var(--text-2);
  background: #fff;
}

.document-context-btn:disabled {
  color: var(--disabled);
}

.topbar-icon-btn {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text-2);
  background: var(--surface-2);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.topbar-icon-btn:hover:not(:disabled) {
  border-color: #000;
  background: #fff;
}

.topbar-btn,
.topbar-add-btn {
  min-height: 40px;
  padding: 8px 24px;
  border-radius: 12px;
  color: #fff;
  background: var(--disabled);
  font-size: 16px;
  font-weight: 400;
  white-space: nowrap;
}

.topbar-btn:not(:disabled),
.topbar-btn.primary:not(:disabled),
.topbar-add-btn:not(:disabled) {
  background: #000;
}

.topbar-btn:hover:not(:disabled),
.topbar-add-btn:hover:not(:disabled) {
  background: #222;
}

.counter {
  min-width: 48px;
  text-align: center;
}

.counter span {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
}

.counter small {
  color: var(--muted);
  display: block;
  margin-top: -2px;
}

.view-panel {
  display: none;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.view-panel.active {
  display: block;
}

.view-panel.admin-content.active {
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

#workbenchView.active {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  padding: 16px;
  overflow: hidden;
}

.workbench-canvas {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.workbench-stage {
  min-width: 0;
  min-height: 0;
  display: grid;
  margin: 16px;
  overflow: hidden;
  border-radius: 16px;
  background: var(--surface-2);
}

.empty-state {
  display: grid;
  place-items: center;
  height: 100%;
  padding: 24px;
  background: transparent;
}

.empty-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(100%, 420px);
  padding: 40px 32px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.empty-card strong {
  font-size: 18px;
  font-weight: 500;
  line-height: 28px;
}

.empty-card:hover,
.empty-state.dragging .empty-card {
  border-color: var(--text-2);
  background: var(--surface-2);
  box-shadow: var(--shadow);
}

.empty-card span {
  color: var(--muted);
  font-size: 14px;
}

.empty-upload-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 168px;
  min-height: 40px;
  margin-top: 16px;
  padding: 8px 24px;
  border-radius: 12px;
  color: #fff;
  background: #000;
  font-style: normal;
  font-size: 16px;
  font-weight: 400;
}

.document-scroll {
  display: none;
  min-height: 0;
  height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 22px;
  scrollbar-width: thin;
}

.document-scroll.open {
  display: block;
}

.pages {
  display: grid;
  gap: 22px;
  width: 100%;
  justify-items: center;
  transform-origin: top center;
}

.page-shell {
  position: relative;
  width: min(100%, var(--page-width));
  max-width: var(--page-width);
  margin-inline: auto;
  aspect-ratio: var(--page-ratio);
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.page-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--surface-2);
  user-select: none;
  -webkit-user-drag: none;
}

.overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.mask-rect {
  fill: var(--mask);
  fill-opacity: 1;
  stroke: var(--mask-stroke);
  stroke-width: 1.4;
  cursor: move;
}

.mask-rect.selected {
  stroke: var(--selected);
  stroke-width: 2.2;
}

.draft-rect {
  fill: rgba(29, 33, 41, 0.12);
  stroke: var(--selected);
  stroke-width: 1.8;
  stroke-dasharray: 7 5;
}

.resize-handle {
  fill: #fff;
  stroke: var(--selected);
  stroke-width: 2;
}

.mask-toolbar {
  position: absolute;
  display: none;
  gap: 6px;
  transform: translate(-50%, calc(-100% - 8px));
  z-index: 5;
}

.mask-toolbar.show {
  display: flex;
}

.mask-toolbar button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  color: #fff;
  background: var(--danger);
  box-shadow: 0 6px 18px rgba(24, 34, 32, 0.18);
}

.page-label {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 4;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(24, 34, 32, 0.78);
  color: #fff;
  font-size: 12px;
}

.mask-list,
.data-list {
  display: grid;
  gap: 8px;
  align-content: start;
}

.mask-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 6px 8px;
  align-self: start;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.mask-item-title {
  grid-column: 1;
  grid-row: 1;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  color: var(--text);
}

.mask-item-reason {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  font-size: 12px;
  line-height: 20px;
  color: var(--muted);
}

.mask-item-size {
  grid-column: 1 / -1;
  grid-row: 2;
  font-size: 12px;
  line-height: 16px;
  color: var(--muted);
}

.mask-item.selected {
  border-color: #000;
  background: var(--surface);
}

.mask-list-empty {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 24px 12px;
  color: var(--disabled);
  font-size: 14px;
  text-align: center;
}

.data-item {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  text-align: left;
}

.data-item.selected {
  border-color: var(--accent);
  background: var(--surface-3);
}

.mask-item strong,
.data-item strong {
  font-size: 13px;
}

.mask-item span,
.data-item span,
.meta-line {
  color: var(--muted);
  font-size: 12px;
}

.history-item {
  grid-template-columns: minmax(280px, 1.3fr) minmax(300px, 0.9fr) auto;
  align-items: center;
  gap: 18px;
  min-height: 92px;
  padding: 12px 14px;
}

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

.history-title-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-title-row strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-status {
  flex: 0 0 auto;
}

.history-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  align-items: center;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.history-metrics span {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 0 16px;
  color: var(--text);
}

.history-metrics span + span {
  border-left: 1px solid var(--line);
}

.history-metrics strong {
  font-size: 18px;
  line-height: 1.1;
  color: var(--accent-strong);
}

.history-metrics small {
  color: var(--muted);
  font-size: 12px;
}

.history-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.admin-content {
  padding: 20px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.section-head p {
  margin: 4px 0 0;
  font-size: 13px;
}

.toolbar-row,
.form-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-row {
  margin-bottom: 12px;
}

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

.profile-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(360px, 1.1fr);
  gap: 14px;
  max-width: 980px;
}

.panel-block {
  margin: 0;
  min-width: 0;
}

.panel-block.wide {
  grid-column: 1 / -1;
}

.settings-note {
  margin: -3px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.brand-settings-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-settings-actions input {
  max-width: 420px;
}

.brand-settings-actions .primary-btn {
  min-height: 38px;
  padding: 0 18px;
}

#organizationBrandStatus {
  color: var(--muted);
  font-size: 12px;
}

.compact .data-item {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.data-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.data-actions button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
}

.data-actions button.danger {
  background: var(--danger);
}

.data-actions button.secondary {
  background: #000;
}

.data-actions button.secondary:hover:not(:disabled) {
  background: #222;
}

.data-actions button.secondary:disabled {
  opacity: 1;
  color: var(--muted);
  background: var(--surface-3);
  border: 1px solid var(--line);
  cursor: not-allowed;
}

.dept-manager-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 8px;
  margin-top: 8px;
  max-width: 460px;
}

.dept-manager-row select {
  min-height: 32px;
}

.dept-manager-row button {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
}

.copy-code-btn {
  min-height: 22px;
  padding: 0 6px;
  border-radius: 6px;
  color: var(--accent-strong);
  background: #f1f3f5;
  font-size: 12px;
  vertical-align: baseline;
}

.copy-code-btn:hover {
  background: #e5e6eb;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--text-2);
  background: var(--surface-3);
  font-size: 12px;
  font-weight: 700;
}

.status-pill.pending {
  color: var(--amber);
  background: #fbf1dc;
}

.status-pill.disabled,
.status-pill.rejected {
  color: var(--danger);
  background: #fbecea;
}

.profile-fields,
.profile-form {
  display: grid;
  gap: 10px;
}

.profile-field {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
}

.profile-field span,
.profile-form label {
  color: var(--muted);
  font-size: 13px;
}

.profile-field strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-form label {
  display: grid;
  gap: 6px;
}

.profile-form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 38px;
}

.profile-form-actions .primary-btn {
  width: auto;
  min-width: 110px;
}

.profile-form-actions span {
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: var(--surface-3);
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

td select {
  min-width: 120px;
}

.cost-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.metric strong {
  font-size: 22px;
  letter-spacing: 0;
}

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

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .app-shell.nav-collapsed {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .app-shell.admin-mode {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .app-shell.admin-mode.nav-collapsed {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .app-content {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .inspector {
    display: none;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .topbar-tools {
    display: none;
  }

  .admin-grid,
  .profile-grid,
  .cost-grid {
    grid-template-columns: 1fr;
  }

  .brand-settings-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .history-item {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .history-metrics {
    grid-column: 1 / -1;
    border-left: 0;
    border-right: 0;
    border-top: 1px solid var(--line);
    padding-top: 10px;
  }
}

@media (max-width: 860px) {
  .auth-screen {
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 24px;
  }

  .auth-brand {
    margin-left: 0;
  }

  .auth-panel {
    justify-self: stretch;
    width: 100%;
    min-height: 0;
    padding: 24px;
  }

  .modal-backdrop {
    padding: 8px;
  }

  .pdf-compose-dialog {
    height: calc(100vh - 16px);
    min-height: 0;
  }

  .pdf-compose-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(260px, 44vh) minmax(0, 1fr);
  }

  .pdf-compose-list-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .pdf-compose-page {
    grid-template-columns: 24px 18px 52px minmax(0, 1fr);
  }

  .pdf-compose-move {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
  }

  .pdf-compose-head,
  .pdf-compose-foot {
    align-items: stretch;
    flex-direction: column;
  }

  .pdf-compose-foot > div {
    width: 100%;
  }

  .pdf-compose-foot button {
    flex: 1;
  }

  .app-shell,
  .app-shell.admin-mode,
  .app-shell.nav-collapsed,
  .app-shell.admin-mode.nav-collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .nav-sidebar {
    grid-template-rows: auto auto;
    gap: 10px;
    max-height: 220px;
    padding: 12px;
    overflow: auto;
  }

  .nav-brand {
    grid-template-columns: minmax(0, 1fr) 34px;
  }

  .nav-list {
    grid-template-columns: repeat(5, minmax(84px, 1fr));
    overflow-x: auto;
  }

  .app-shell.nav-collapsed .nav-sidebar {
    display: flex;
    flex-direction: column;
    max-height: none;
    padding: 0;
    overflow: hidden;
  }

  .app-shell.nav-collapsed .nav-list {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .sidebar {
    max-height: 48vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    height: 52vh;
  }

  .document-scroll,
  .admin-content {
    padding: 12px;
  }

  .section-head,
  .form-row,
  .toolbar-row,
  .profile-form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .profile-form-actions .primary-btn {
    width: 100%;
  }

  .history-item {
    grid-template-columns: 1fr;
  }

  .history-actions {
    justify-content: flex-start;
  }

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

  .history-metrics span {
    padding: 0 10px;
  }
}
