:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #172033;
  --muted: #647086;
  --line: #dbe3ef;
  --line-soft: #edf1f7;
  --primary: #245bdb;
  --primary-dark: #163f9e;
  --good: #138a55;
  --warn: #b96800;
  --danger: #c53b4a;
  --rail: #111827;
  --rail-2: #1f2937;
  --rail-text: #dbeafe;
  --shadow: 0 14px 34px rgba(20, 33, 61, 0.08);
}

:root[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #111827;
  --surface-2: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --line: #334155;
  --line-soft: #243044;
  --primary: #4f7cff;
  --primary-dark: #86a5ff;
  --good: #34d399;
  --warn: #fbbf24;
  --danger: #fb7185;
  --rail: #020617;
  --rail-2: #172033;
  --rail-text: #dbeafe;
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

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

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

.sidebar {
  background: var(--rail);
  color: var(--rail-text);
  padding: 18px 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--primary);
  border-radius: 6px;
  font-weight: 600;
}

.brand-title {
  font-size: 16px;
  font-weight: 600;
}

.brand-subtitle {
  margin-top: 2px;
  color: rgba(219, 234, 254, 0.62);
  font-size: 12px;
}

.primary-nav {
  display: grid;
  gap: 5px;
  margin-top: 16px;
}

.primary-item {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  color: rgba(219, 234, 254, 0.78);
  background: transparent;
  border: 0;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
}

.primary-item:hover,
.primary-item.is-active {
  color: #fff;
  background: var(--rail-2);
}

.primary-item.is-active {
  box-shadow: inset 3px 0 0 var(--primary);
}

.nav-icon {
  width: 20px;
  text-align: center;
  color: currentColor;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.topbar {
  min-height: 76px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.breadcrumb {
  color: var(--muted);
  font-size: 13px;
}

h1 {
  margin: 4px 0 0;
  font-size: 24px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.icon-button {
  height: 36px;
  padding: 0 13px;
  border-radius: 6px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.primary-button {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.ghost-button {
  color: var(--text);
  background: var(--surface);
}

.icon-button {
  width: 36px;
  padding: 0;
  color: var(--text);
  background: var(--surface-2);
}

.icon-button:hover,
.ghost-button:hover {
  border-color: var(--primary);
}

.global-sync {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 420px;
  padding: 0 11px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}

.global-sync strong {
  color: var(--muted);
  font-weight: 500;
}

.global-sync em {
  max-width: 150px;
  overflow: hidden;
  color: var(--danger);
  font-style: normal;
  text-overflow: ellipsis;
}

.sync-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--muted);
}

.sync-dot.success {
  background: var(--good);
}

.sync-dot.warn {
  background: var(--warn);
}

.sync-dot.danger {
  background: var(--danger);
}

.text-button {
  padding: 0;
  color: var(--primary);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.account-area {
  min-height: 36px;
  display: flex;
  align-items: center;
}

.account-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
}

.account-avatar {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--primary);
  font-size: 12px;
}

.account-role {
  color: var(--muted);
}

.secondary-wrap {
  padding: 10px 24px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.secondary-nav,
.tertiary-nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.secondary-item,
.tertiary-item {
  min-height: 38px;
  white-space: nowrap;
  padding: 0 14px;
  border: 0;
  border-radius: 6px 6px 0 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.secondary-item.is-active,
.tertiary-item.is-active {
  color: var(--primary);
  background: #eef4ff;
  font-weight: 600;
}

.page-body {
  padding: 20px 24px 32px;
  min-width: 0;
}

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

.section-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.section-note {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.section-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.field {
  min-width: 0;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.field select,
.field input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

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

.metric-card,
.panel,
.rule-card,
.config-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 110px;
  padding: 16px;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
}

.metric-value {
  margin-top: 10px;
  font-size: 25px;
  font-weight: 600;
  letter-spacing: 0;
}

.metric-foot {
  margin-top: 10px;
  color: var(--good);
  font-size: 12px;
}

.metric-foot.warn {
  color: var(--warn);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.9fr);
  gap: 14px;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  font-weight: 600;
}

.panel-subtitle {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.bars {
  display: grid;
  gap: 13px;
}

.bar-row {
  display: grid;
  grid-template-columns: 96px 1fr 56px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.track {
  height: 10px;
  background: #edf2f9;
  overflow: hidden;
  border-radius: 99px;
}

.fill {
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

.data-table th {
  color: var(--muted);
  font-weight: 600;
  background: var(--surface-2);
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--primary);
  font-size: 12px;
}

.tag.warn {
  color: var(--warn);
  background: #fff5e7;
}

.tag.danger {
  color: var(--danger);
  background: #fff0f2;
}

.rule-grid,
.config-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
  gap: 14px;
}

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

.rule-card,
.config-card {
  padding: 16px;
}

.card-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
}

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

.workflow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.workflow-step {
  padding: 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.step-num {
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
}

.step-title {
  margin-top: 8px;
  font-weight: 600;
}

.step-desc {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.placeholder {
  padding: 30px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.inline-action {
  margin-top: 12px;
}

.muted-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
}

.muted-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}

.form-mock {
  display: grid;
  gap: 10px;
}

.form-mock textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  padding: 10px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.product-thumb {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.sync-log-list {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
}

.sync-log-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: 7px;
  background: var(--surface-2);
}

.sync-log-item.success {
  border-left-color: var(--good);
}

.sync-log-item.error {
  border-left-color: var(--danger);
}

.sync-log-item.warn {
  border-left-color: var(--warn);
}

.sync-log-item div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.sync-log-item span,
.sync-log-item p {
  color: var(--muted);
}

.sync-log-item p {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.5;
  word-break: break-word;
}

.archive-search-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.realtime-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 16px;
  margin-bottom: 14px;
  padding: 20px;
  color: #fff;
  background: linear-gradient(135deg, #172033, #245bdb);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.hero-eyebrow {
  margin-bottom: 8px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.realtime-hero h3 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
}

.realtime-hero p {
  max-width: 680px;
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.7;
}

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

.sync-pill {
  min-height: 72px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
}

.sync-pill span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.sync-pill strong {
  font-size: 18px;
}

.sync-pill.warn {
  background: rgba(255, 174, 85, 0.18);
}

.sync-pill.info {
  background: rgba(118, 154, 255, 0.18);
}

.mini-chart {
  height: 150px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  align-items: end;
  gap: 8px;
  margin-top: 18px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mini-chart span {
  display: block;
  min-height: 16px;
  background: linear-gradient(180deg, var(--primary), #8fb0ff);
  border-radius: 6px 6px 0 0;
}

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

.quick-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 88px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.quick-entry-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--primary);
  border-radius: 8px;
  font-weight: 600;
}

.quick-entry strong,
.quick-entry span {
  display: block;
}

.quick-entry span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.period-tabs {
  margin-bottom: 12px;
}

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

.modal-backdrop[hidden] {
  display: none;
}

.auth-modal {
  width: min(460px, 100%);
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(17, 24, 39, 0.22);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 16px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-tab {
  min-height: 34px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.auth-tab.is-active {
  color: var(--primary);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-panel h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.auth-message {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

.auth-message.success {
  color: var(--good);
}

.auth-message.error {
  color: var(--danger);
}

.login-gate {
  display: grid;
  min-height: calc(100vh - 210px);
  place-items: center;
  padding: 40px 16px;
}

.login-gate-panel {
  width: min(560px, 100%);
  padding: 34px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-gate-mark {
  display: inline-grid;
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  place-items: center;
  color: #fff;
  background: var(--primary);
  border-radius: 8px;
  font-weight: 800;
}

.login-gate-panel h2 {
  margin: 0 0 10px;
  font-size: 26px;
}

.login-gate-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.login-gate-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.is-locked .sidebar {
  min-height: 100vh;
}

.diagnostics-filters {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.task-progress-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px 16px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-left: 4px solid var(--primary);
  border-radius: 8px;
}

.task-progress-banner strong {
  display: block;
  color: var(--text);
}

.task-progress-banner p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.task-progress-banner.running {
  background: #fffbeb;
  border-color: #fde68a;
  border-left-color: #f59e0b;
}

.task-progress-banner.done {
  background: #ecfdf5;
  border-color: #bbf7d0;
  border-left-color: var(--good);
}

.task-progress-banner.error {
  background: #fef2f2;
  border-color: #fecaca;
  border-left-color: var(--danger);
}

.task-progress-dot {
  width: 10px;
  height: 10px;
  margin-top: 7px;
  flex: 0 0 auto;
  background: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

.task-progress-banner.running .task-progress-dot {
  background: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.16);
}

.task-progress-banner.done .task-progress-dot {
  background: var(--good);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.16);
}

.task-progress-banner.error .task-progress-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.16);
}

.diagnostics-field {
  margin-top: 12px;
}

.diagnostics-grid {
  margin-top: 14px;
}

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

.diagnostics-list {
  display: grid;
  gap: 10px;
}

.diagnostics-item {
  padding: 12px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.65;
}

.json-box {
  max-height: 460px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.diagnostics-probe-panel {
  margin-top: 14px;
}

.probe-recommendations {
  margin-bottom: 14px;
}

.diagnostics-probe-table {
  min-width: 980px;
}

#diagProbeResults {
  overflow-x: auto;
}

@media (max-width: 1100px) {
  .diagnostics-filters,
  .diagnostics-raw-grid {
    grid-template-columns: 1fr;
  }
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.app-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 14px;
  color: #fff;
  background: #172033;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(17, 24, 39, 0.24);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  font-size: 13px;
}

.app-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.app-toast.success {
  background: var(--good);
}

.app-toast.warn {
  background: var(--warn);
  color: #172033;
}

.app-toast.error {
  background: var(--danger);
}

.permission-shell {
  min-height: 680px;
  display: grid;
  grid-template-columns: 260px minmax(280px, 390px) minmax(420px, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.permission-sidebar,
.permission-tree,
.permission-detail {
  min-width: 0;
  padding: 18px;
}

.permission-sidebar,
.permission-tree {
  border-right: 1px solid var(--line);
}

.permission-title {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.role-list,
.data-tree,
.permission-tabs,
.permission-options {
  display: grid;
  gap: 8px;
}

.role-item,
.data-node,
.permission-tab,
.permission-row,
.permission-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 7px;
  color: var(--text);
}

.role-item.is-active,
.data-node.is-active,
.permission-tab.is-active {
  color: var(--primary);
  background: #eef4ff;
  font-weight: 600;
}

.role-icon,
.data-icon {
  width: 22px;
  text-align: center;
  color: var(--muted);
}

.role-actions {
  margin-left: auto;
  color: var(--muted);
}

.permission-search {
  width: 100%;
  height: 38px;
  margin-bottom: 14px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.tree-group {
  margin: 14px 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.permission-tabs {
  grid-template-columns: repeat(4, max-content);
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.permission-tab {
  min-height: 42px;
  padding: 0;
  border-radius: 0;
  border-bottom: 2px solid transparent;
}

.permission-tab.is-active {
  background: transparent;
  border-bottom-color: var(--primary);
}

.permission-card {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
}

.permission-card-head,
.permission-row {
  min-height: 62px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line-soft);
}

.permission-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-2);
}

.permission-options {
  padding: 16px 18px;
}

.permission-option input {
  width: 16px;
  height: 16px;
}

.permission-row {
  justify-content: space-between;
}

.permission-savebar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.access-shell {
  grid-template-columns: 300px minmax(430px, 0.95fr) minmax(440px, 1.05fr);
}

.role-item small,
.approval-card span,
.account-table small,
.permission-card-head small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.approval-list {
  display: grid;
  gap: 10px;
}

.approval-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.approval-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

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

.employee-panel {
  overflow: auto;
}

.account-table td {
  vertical-align: middle;
}

.account-table tr.is-selected td {
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.account-table select {
  width: 136px;
  height: 32px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.mini-button {
  height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.danger-text {
  color: var(--danger);
}

.trial-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.trial-row input {
  width: 108px;
  height: 30px;
  padding: 0 8px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.permission-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--text);
  font-size: 13px;
}

.permission-check input {
  accent-color: var(--primary);
}

.all-check {
  min-height: 40px;
  padding: 0 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.permission-scope-grid,
.agent-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.permission-scope-grid h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.agent-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.agent-prompt {
  width: 100%;
  min-height: 122px;
  resize: vertical;
  padding: 12px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.7;
}

.subject-tabs {
  margin-bottom: 14px;
}

.subject-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.subject-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
}

.subject-item:hover,
.subject-item.is-selected {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--line));
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
}

.subject-item span:first-child {
  min-width: 0;
}

.subject-item strong,
.subject-item small {
  display: block;
}

.subject-item small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.management-table {
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.management-table .data-table {
  margin: 0;
  border: 0;
}

.management-table .data-table th,
.management-table .data-table td {
  white-space: nowrap;
}

.permission-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.permission-detail-head h3 {
  margin: 0;
  font-size: 18px;
}

.permission-detail-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.ai-config-card {
  margin-top: 20px;
}

.ai-config-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.compact-placeholder {
  min-height: 88px;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .brand {
    border-bottom: 0;
  }

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

  .filter-row,
  .metric-grid,
  .rule-grid,
  .config-grid,
  .workflow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .split-grid,
  .two-col-grid,
  .permission-shell {
    grid-template-columns: 1fr;
  }

  .realtime-hero,
  .quick-entry-grid {
    grid-template-columns: 1fr;
  }

  .permission-sidebar,
  .permission-tree {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .permission-tabs {
    grid-template-columns: repeat(2, max-content);
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .global-sync {
    max-width: none;
    width: 100%;
    justify-content: flex-start;
  }

  .primary-button,
  .ghost-button {
    flex: 1;
  }

  .filter-row,
  .metric-grid,
  .rule-grid,
  .config-grid,
  .workflow {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 80px 1fr 44px;
  }

  .archive-search-row {
    grid-template-columns: 1fr;
  }
}
