:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --line: #d8e0e7;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --danger: #b42318;
  --sidebar: #0d2b2f;
  --sidebar-soft: #ffffff;
  --sidebar-ink: #101827;
  --nav-accent: #38bdf8;
  --shadow: 0 18px 44px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--text);
  background: linear-gradient(135deg, #eefdf9 0, #f6f8fb 42%, #f1f5f9 100%);
  font: 14px/1.5 "Segoe UI", "Microsoft YaHei", sans-serif;
}
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button {
  border: 0;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease;
}
button:disabled { cursor: not-allowed; opacity: 0.5; }
button:hover:not(:disabled) { transform: translateY(-1px); }
button.primary { background: var(--primary); color: #fff; }
button.primary:hover:not(:disabled) { background: var(--primary-dark); }
button.ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.24); }
button.danger { background: #fee4e2; color: var(--danger); }
button.danger.solid { background: var(--danger); color: #fff; }
button.danger.solid:hover:not(:disabled) { background: #8a1f15; }
button.icon, .top-icon { width: 34px; height: 34px; padding: 0; }
.muted { color: var(--muted); }
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 58px;
  justify-content: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  border: 1px solid transparent;
}
.status-pill.enabled {
  color: #027a48;
  background: #ecfdf3;
  border-color: #abefc6;
}
.status-pill.disabled {
  color: #b42318;
  background: #fef3f2;
  border-color: #fecdca;
}
.status-pill i { font-size: 12px; }

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(460px, 100%);
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(217,224,234,0.9);
  border-radius: 10px;
  padding: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.auth-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
.auth-card h1 { margin: 0 0 6px; font-size: 26px; }
.auth-links { margin: 16px 0; }
.lang-switch { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.lang-switch select {
  min-width: 110px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  background: #fff;
}
.lang-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
}
.lang-actions.compact {
  background: #f3f7fb;
  border: 1px solid var(--line);
}
.lang-option {
  min-width: 68px;
  border-radius: 999px;
  padding: 6px 10px;
  background: transparent;
  color: inherit;
}
.lang-option.active {
  background: var(--primary);
  color: #fff;
}
.form { display: grid; gap: 14px; }
.form label, .check-field {
  display: grid;
  gap: 6px;
  color: #344054;
}
.check-field {
  grid-template-columns: 1fr auto;
  align-items: center;
}
.check-field.readonly {
  color: var(--muted);
}
.check-field.readonly input {
  cursor: not-allowed;
  opacity: 0.65;
}
.form input, .form select, .form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
}
.password-field {
  position: relative;
  display: block;
}
.password-field input {
  padding-right: 42px;
}
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 6px;
  background: transparent;
  color: #667085;
}
.password-toggle:hover:not(:disabled) {
  transform: translateY(-50%);
  background: #f1f5f9;
  color: var(--primary);
}
.form textarea { min-height: 110px; resize: vertical; }
.notice-list { display: grid; gap: 10px; margin-top: 18px; }
.notice {
  border-left: 3px solid var(--primary);
  background: #ecfdf3;
  padding: 10px 12px;
  border-radius: 4px;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  transition: grid-template-columns 0.18s ease;
}
.layout.sidebar-collapsed { grid-template-columns: 64px minmax(0, 1fr); }
.sidebar {
  background:
    linear-gradient(180deg, rgba(20, 184, 166, 0.14) 0, rgba(56, 189, 248, 0.08) 36%, rgba(16, 24, 39, 0) 72%),
    linear-gradient(180deg, var(--sidebar) 0, #12253d 52%, var(--sidebar-ink) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  min-width: 0;
  z-index: 8;
  box-shadow: 10px 0 30px rgba(15, 23, 42, 0.16);
}
.brand {
  height: 60px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px 0 16px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255,255,255,0.035);
}
.brand::before {
  content: "";
  width: 10px;
  height: 28px;
  border-radius: 999px;
  background: linear-gradient(180deg, #5eead4, var(--nav-accent));
  box-shadow: 0 0 18px rgba(45, 212, 191, 0.42);
}
.layout.sidebar-collapsed .brand { justify-content: center; padding: 0; }
.layout.sidebar-collapsed .brand span { display: none; }
.layout.sidebar-collapsed .brand::before { width: 28px; height: 28px; border-radius: 8px; }
.menu { padding: 12px 10px; overflow: auto; }
.menu ul { list-style: none; padding: 0; margin: 0; }
.menu li { margin: 3px 0; }
.menu-node {
  position: relative;
  display: grid;
  grid-template-columns: 16px 20px 1fr;
  align-items: center;
  gap: 9px;
  width: 100%;
  color: #d8e4ee;
  padding: 10px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  overflow: hidden;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.menu-node::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 999px;
  background: transparent;
}
.menu-node:hover {
  background: rgba(45, 212, 191, 0.10);
  border-color: rgba(94, 234, 212, 0.14);
  color: #fff;
}
.menu-node.active {
  background: linear-gradient(90deg, rgba(20, 184, 166, 0.28), rgba(56, 189, 248, 0.14));
  border-color: rgba(94, 234, 212, 0.30);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.07), 0 10px 22px rgba(8, 145, 178, 0.16);
}
.menu-node.active::before {
  background: linear-gradient(180deg, #5eead4, var(--nav-accent));
}
.menu-arrow { width: 16px; color: #8fb0c0; text-align: center; }
.menu-arrow i { transition: transform 0.16s ease; }
.menu-item.expanded > .menu-node .menu-arrow i { transform: rotate(90deg); }
.menu-icon { width: 20px; text-align: center; font-size: 15px; color: #8fd7cf; }
.menu-node.active .menu-icon, .menu-node:hover .menu-icon { color: #5eead4; }
.menu-children {
  padding-left: 18px;
  display: none;
  margin-top: 4px;
  border-left: 1px solid rgba(94, 234, 212, 0.16);
}
.menu-item.expanded > .menu-children { display: block; }
.menu-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layout.sidebar-collapsed .menu { padding: 8px; }
.layout.sidebar-collapsed .menu-node { grid-template-columns: 1fr; justify-items: center; padding: 11px 0; }
.layout.sidebar-collapsed .menu-icon {
  width: 38px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  font-size: 16px;
}
.layout.sidebar-collapsed .menu-node.active .menu-icon,
.layout.sidebar-collapsed .menu-node:hover .menu-icon,
.layout.sidebar-collapsed .menu-item.collapsed-open > .menu-node .menu-icon {
  background: rgba(45, 212, 191, 0.14);
  color: #5eead4;
  box-shadow: inset 0 0 0 1px rgba(94, 234, 212, 0.18);
}
.layout.sidebar-collapsed .menu-arrow, .layout.sidebar-collapsed .menu-label { display: none; }
.layout.sidebar-collapsed .menu-children { display: none; padding-left: 0; }
.layout.sidebar-collapsed .menu-item.collapsed-open > .menu-children { display: block; }

.mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.44);
  z-index: 7;
}
.mobile-backdrop.hidden { display: none; }

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: 60px 40px minmax(0, 1fr) auto;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: rgba(255,255,255,0.94);
  color: var(--text);
  gap: 16px;
  border-bottom: 1px solid rgba(216, 224, 231, 0.92);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
  backdrop-filter: blur(10px);
}
.top-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.top-icon {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 34px;
  min-width: 34px;
  line-height: 1;
  font-size: 16px;
  color: var(--primary-dark);
  background: #ecfdf9;
  border: 1px solid #bdebe5;
  border-radius: 8px;
}
.top-icon i { pointer-events: none; }
.top-icon:hover { background: #d9f8f0; }
#sidebarToggle {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
  border-radius: 8px;
  background: #ecfdf9;
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.06);
}
#sidebarToggle.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.title-stack { min-width: 0; }
#currentTitle { font-weight: 800; line-height: 1.2; color: #102a43; }
.breadcrumb {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52vw;
}
.top-actions { display: flex; gap: 12px; align-items: center; }
.top-actions #currentUser {
  color: #344054;
  font-weight: 700;
}
.topbar .ghost {
  color: var(--primary-dark);
  background: #ecfdf9;
  border-color: #bdebe5;
}
.topbar .ghost:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
}
.topbar .lang-actions {
  background: #f1f5f9;
  border: 1px solid var(--line);
}
.topbar .lang-option {
  color: #475467;
}
.topbar .lang-option.active {
  color: #fff;
}
.header-lang select {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-color: rgba(255,255,255,0.2);
}
.tabs {
  display: flex;
  align-items: end;
  gap: 2px;
  padding: 6px 8px 0;
  background: #eef2f7;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  overflow-y: hidden;
}
.tab {
  position: relative;
  cursor: default;
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 200px;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: #f8fafc;
  color: #475467;
  border-radius: 6px 6px 0 0;
  padding: 0 9px 0 12px;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.tab::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--primary);
  opacity: 0;
  transform: translateX(-50%) translateY(-2px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}
.tab:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: inset 0 -3px 0 #facc15, 0 -1px 8px rgba(15, 118, 110, 0.28);
}
.tab.active::after {
  border-top-color: #facc15;
}
.tab-title { overflow: hidden; text-overflow: ellipsis; }
.tab-close {
  width: 20px;
  height: 20px;
  padding: 0;
  background: transparent;
  color: #64748b;
  border-radius: 4px;
}
.tab.active .tab-close { color: #dcfce7; }
.tab-close:hover { background: #e2e8f0; color: var(--danger); }
.tab-menu {
  position: fixed;
  z-index: 20;
  width: 150px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
}
.tab-menu.hidden { display: none; }
.tab-menu button {
  width: 100%;
  display: block;
  text-align: left;
  background: transparent;
  border-radius: 4px;
  padding: 7px 8px;
}
.tab-menu button:hover { background: #f1f5f9; }
.frame-stack {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}
.frame-stack iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg);
  display: none;
}
.frame-stack iframe.active { display: block; }
.shell-empty {
  height: 100%;
  padding: 18px;
  display: grid;
  align-content: start;
}
.shell-empty .helper-block {
  max-width: 620px;
  margin: 0;
}

.footer-ticker {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 34px;
  border-top: 1px solid var(--line);
  background: #fff;
  color: #344054;
  overflow: hidden;
}
.footer-ticker.hidden { display: none; }
.footer-ticker-label {
  flex: 0 0 auto;
  height: 100%;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-right: 1px solid var(--line);
  background: #f8fafc;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}
.footer-ticker-viewport {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.footer-ticker-content {
  display: inline-block;
  min-width: 100%;
  padding-left: 100%;
  font-size: 13px;
  animation: footerMarquee 28s linear infinite;
}
@keyframes footerMarquee {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

.toast-host {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  transform: translateY(-8px);
  opacity: 0;
  pointer-events: auto;
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.18);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast b { display: block; margin-bottom: 3px; }
.toast span { color: #475467; }
.toast.success { border-left: 4px solid #16a34a; }
.toast.success b { color: #166534; }
.toast.error { border-left: 4px solid var(--danger); }
.toast.error b { color: var(--danger); }

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.44);
  animation: confirmFade 0.14s ease;
}
.confirm-card {
  width: min(440px, 100%);
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.24);
  position: relative;
  cursor: move;
  user-select: none;
  touch-action: none;
  transition: width 0.16s ease, box-shadow 0.16s ease;
  position: fixed;
}
.confirm-card.confirm-compact { width: min(380px, 100%); }
.confirm-card.confirm-large { width: min(680px, 100%); }
.confirm-card.dragging { box-shadow: 0 28px 70px rgba(15, 23, 42, 0.3); }
.confirm-window-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  gap: 5px;
}
.confirm-window-actions .modal-window-action {
  width: 28px;
  height: 28px;
  background: linear-gradient(180deg, #ffffff 0%, #f3f7fb 100%);
}
.confirm-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #ccfbf1;
  color: var(--primary-dark);
  font-size: 18px;
}
.confirm-backdrop.danger .confirm-icon {
  background: #fee4e2;
  color: var(--danger);
}
.confirm-copy h2 {
  margin: 0 92px 6px 0;
  font-size: 18px;
}
.confirm-copy p {
  margin: 0;
  color: #475467;
}
.confirm-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
button.ghost-light {
  background: #fff;
  color: #344054;
  border: 1px solid var(--line);
}
button.ghost-light:hover:not(:disabled) { background: #f8fafc; }
@keyframes confirmFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.panel { padding: 18px; min-height: 100vh; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.panel-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.panel h1 { margin: 0; font-size: 22px; }
.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  padding: 12px;
  margin-bottom: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.filter-bar label {
  display: grid;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}
.filter-field {
  flex: 0 1 156px;
  min-width: 130px;
}
.filter-field.keyword {
  flex-basis: 220px;
  max-width: 260px;
}
.filter-bar input,
.filter-bar select {
  min-height: 34px;
}
.filter-bar button {
  height: 34px;
}
.filter-bar button i {
  margin-right: 5px;
}
.filter-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
  min-height: 34px;
}
.panel-refresh {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid #b7e4da;
  background: #ecfdf7;
  color: var(--primary-dark);
  border-radius: 8px;
}
.panel-refresh:hover:not(:disabled) {
  background: #d9f8f0;
  border-color: #75d7c5;
}
.content {
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  overflow: auto;
}
.helper-block {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}
.helper-block p { margin: 6px 0 0; color: var(--muted); }
.helper-block code {
  background: #e2e8f0;
  border-radius: 4px;
  padding: 1px 5px;
}
.menu-tree-help {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: linear-gradient(135deg, #f8fafc 0%, #eef9f5 100%);
}
.menu-tree-help-copy {
  min-width: 220px;
}
.menu-tree-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.menu-tree-actions button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-color: #b7e4da;
  color: var(--primary-dark);
  background: rgba(255, 255, 255, 0.9);
}
.menu-tree-actions button:hover:not(:disabled) {
  background: #ecfdf7;
  border-color: #75d7c5;
}
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}
.stat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-height: 26px;
}
.stat-title {
  color: var(--text);
  font-weight: 700;
}
.stat code {
  flex: 0 0 auto;
  max-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 999px;
  padding: 2px 7px;
  background: #e0f2fe;
  color: #075985;
  font-size: 12px;
}
.stat b { display: block; font-size: 24px; margin-top: 8px; }
.stat p {
  min-height: 44px;
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}
.table-shell { display: grid; gap: 12px; }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; background: #fff; }
th, td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px;
  vertical-align: top;
}
th {
  background: #f8fafc;
  color: #475467;
  font-weight: 700;
  position: sticky;
  top: 0;
}
td .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.check-cell {
  width: 52px;
  text-align: center;
}
.check-cell input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}
.empty-cell { text-align: center; color: var(--muted); padding: 28px; }
.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.pager-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pager-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  white-space: nowrap;
}
.pager select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  background: #fff;
}
.drag-handle { color: #64748b; cursor: grab; width: 54px; text-align: center; }
tr.dragging { opacity: 0.55; outline: 2px solid var(--primary); }
.tree-toggle {
  width: 24px;
  height: 24px;
  padding: 0;
  margin-right: 4px;
  border-radius: 4px;
  background: #f8fafc;
  color: #475467;
}
.tree-toggle:hover {
  background: #e2e8f0;
  color: var(--primary);
}
.tree-name { display: inline-flex; align-items: center; gap: 8px; min-width: 170px; }
.tree-name i { width: 16px; color: #64748b; text-align: center; }
.menu-table tr.permission-row td {
  background: #fbfdff;
  color: #475467;
}
.menu-table tr.permission-row .tree-name {
  color: #334155;
}
.menu-table tr.virtual-row td {
  background: #f8fafc;
  font-weight: 700;
}
.badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef4ff;
  color: #3538cd;
  margin: 1px;
}
.type-badge {
  align-items: center;
  gap: 5px;
  min-width: 46px;
  justify-content: center;
  border: 1px solid transparent;
  font-weight: 700;
}
.type-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
}
.type-menu {
  color: #0f766e;
  background: #ccfbf1;
  border-color: #99f6e4;
}
.type-group {
  color: #7c3aed;
  background: #f3e8ff;
  border-color: #ddd6fe;
}
.type-button {
  color: #b45309;
  background: #fef3c7;
  border-color: #fde68a;
}
.type-api {
  color: #1d4ed8;
  background: #dbeafe;
  border-color: #bfdbfe;
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  padding: 20px;
  z-index: 30;
}
.modal.hidden { display: none; }
.modal-card {
  position: fixed;
  width: min(560px, 100%);
  min-width: min(360px, calc(100vw - 24px));
  min-height: 260px;
  max-height: 86vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  resize: both;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.24);
  transition: width 0.16s ease, max-height 0.16s ease, box-shadow 0.16s ease;
  will-change: transform;
}
.modal-card.wide { width: min(980px, 100%); }
.modal-card.modal-compact { width: min(460px, 100%); }
.modal-card.modal-large { width: min(1080px, calc(100vw - 40px)); max-height: 90vh; }
.modal-card.modal-permission {
  width: min(90vw, 1440px);
  height: min(88vh, 900px);
  max-height: calc(100vh - 32px);
  resize: both;
}
.modal-card.modal-maximized {
  left: 16px !important;
  top: 16px !important;
  width: calc(100vw - 32px);
  height: calc(100vh - 32px);
  max-height: calc(100vh - 32px);
  resize: none;
}
.modal-card.dragging {
  transition: width 0.16s ease, max-height 0.16s ease, box-shadow 0.16s ease;
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.3);
}
.modal-card header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  cursor: move;
  user-select: none;
  touch-action: none;
}
.modal-card h2 { margin: 0; font-size: 18px; }
.modal-window-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.modal-window-action {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid #d5dde7;
  background: linear-gradient(180deg, #ffffff 0%, #f3f7fb 100%);
  color: #334155;
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}
.modal-window-action:hover:not(:disabled) {
  background: #ecfdf7;
  border-color: #b7e4da;
  color: var(--primary-dark);
  transform: translateY(-1px);
}
.modal-window-action i {
  font-size: 13px;
}
#modalClose:hover:not(:disabled) {
  background: #fee4e2;
  border-color: #fecdca;
  color: var(--danger);
}
.modal-card .form {
  min-height: 0;
  max-height: calc(86vh - 58px);
  overflow: auto;
  padding: 16px;
}
.table-tools {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}
.column-picker {
  position: relative;
}
.column-picker summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  list-style: none;
}
.column-picker summary::-webkit-details-marker { display: none; }
.column-picker-menu {
  position: absolute;
  right: 0;
  z-index: 4;
  display: grid;
  gap: 6px;
  min-width: 180px;
  max-height: 260px;
  overflow: auto;
  padding: 10px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.14);
}
.column-picker-menu label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.action-col {
  position: sticky;
  right: 0;
  z-index: 1;
  background: #fff;
  box-shadow: -8px 0 12px rgba(255, 255, 255, 0.86);
}
.modal-card.modal-large .form { max-height: calc(90vh - 58px); }
.modal-card.modal-maximized .form { max-height: calc(100vh - 90px); }
.icon-picker {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f8fafc;
}
.icon-picker-current {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.icon-picker-current i {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--primary);
  font-size: 18px;
}
.icon-picker-current code {
  background: #e2e8f0;
  border-radius: 4px;
  padding: 2px 6px;
}
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 6px;
  max-height: 360px;
  overflow: auto;
  padding-right: 2px;
}
.icon-choice {
  display: grid;
  grid-template-rows: 24px 1fr;
  place-items: center;
  gap: 4px;
  min-height: 62px;
  padding: 7px 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #475467;
}
.icon-choice:hover:not(:disabled) {
  transform: none;
  border-color: var(--primary);
  color: var(--primary);
  background: #ecfdf3;
}
.icon-choice.active {
  border-color: var(--primary);
  background: #ccfbf1;
  color: var(--primary-dark);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.icon-choice i { font-size: 18px; }
.icon-choice span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}
.log-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.log-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.log-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}
.log-panel h2 {
  margin: 0;
  font-size: 15px;
}
.log-panel.error header {
  background: #fff1f2;
}
.logbox, pre {
  margin: 0;
  padding: 12px;
  background: #111827;
  color: #d1fae5;
  border-radius: 0;
  min-height: 360px;
  max-height: 62vh;
  overflow: auto;
  white-space: pre-wrap;
}
.logbox.error {
  background: #1f1315;
  color: #fecdd3;
}
.import-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.import-section {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: #344054;
}
.table-kind {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef4ff;
  color: #3538cd;
  font-size: 12px;
  margin-bottom: 8px;
}
.import-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.import-grid textarea {
  margin: 10px 0;
  width: 100%;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  font-family: Consolas, monospace;
}
.modal-card.modal-permission .form {
  display: flex;
  min-height: 0;
  max-height: none;
  overflow: hidden;
  padding: 0;
  gap: 0;
}
.permission-assignment {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  min-height: 0;
}
.permission-tree-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 9px 16px;
  border-bottom: 1px solid #e6eef5;
  background: #f8fbfd;
}
.permission-tree-intro {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 1 auto;
  color: #475467;
  white-space: nowrap;
}
.permission-tree-intro i { color: var(--primary); }
.permission-tree-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 1 auto;
  min-width: 0;
}
.permission-tree {
  min-height: 0;
  max-height: none;
  overflow: auto;
  border: 0;
  border-radius: 0;
  padding: 10px 16px 16px;
  background: linear-gradient(180deg, #f8fbfd 0%, #ffffff 100%);
}
.permission-tree-content {
  min-width: 0;
}
.permission-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 280px;
  min-width: 0;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.permission-search input {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
}
.permission-selected-only {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #475467;
}
.permission-tree-actions button {
  min-height: 32px;
  padding: 5px 10px;
}
.permission-assignment-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 16px;
  border-top: 1px solid #e6eef5;
  background: #fff;
  box-shadow: 0 -6px 18px rgba(15, 23, 42, 0.05);
}
.permission-selection-summary {
  color: #475467;
}
.permission-selection-summary strong {
  color: var(--primary-dark);
  font-size: 16px;
}
.modal-form-actions,
.permission-footer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.modal-form-actions {
  position: sticky;
  bottom: -16px;
  z-index: 2;
  margin: 2px -16px -16px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 -6px 18px rgba(15, 23, 42, 0.05);
}
.permission-match {
  border-color: #f5c451 !important;
  background: #fff9df !important;
}
.perm-node {
  position: relative;
  margin: 6px 0 6px 12px;
}
.perm-node::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 34px;
  bottom: 6px;
  width: 1px;
  background: #dbe7ef;
}
.perm-node summary {
  cursor: pointer;
  min-height: 34px;
  padding: 5px 8px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px solid #e4edf4;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.perm-node summary:hover {
  border-color: #b7e4da;
  background: #f6fffc;
}
.perm-children {
  margin-top: 4px;
  padding-left: 6px;
}
.perm-summary-title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 1 1 120px;
  min-width: 110px;
  color: #1f2937;
}
.perm-summary-title i { color: #0f766e; }
.form .perm-menu-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-width: 0;
  max-width: 100px;
  min-height: 26px;
  padding: 3px 7px;
  border: 1px solid #dbeafe;
  border-radius: 999px;
  background: #eff6ff;
  color: #344054;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.perm-menu-check input {
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
}
.perm-menu-check i { color: #2563eb; }
.perm-menu-check span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.perm-group-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  min-height: 26px;
  margin-left: auto;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #475467;
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
  user-select: none;
}
.perm-group-check:hover,
.perm-group-check:focus-visible {
  transform: none;
  border-color: var(--primary);
  color: var(--primary);
  background: #ecfdf3;
  outline: none;
}
.perm-group-check.active {
  border-color: var(--primary);
  background: #ccfbf1;
  color: var(--primary-dark);
}
.perm-group-check.partial {
  border-color: #a7f3d0;
  background: #f0fdfa;
  color: var(--primary-dark);
}
.perm-group-check em {
  font-style: normal;
  color: var(--muted);
}
.perm-leaf {
  display: grid;
  grid-template-columns: 18px minmax(130px, 1fr) minmax(190px, 1.2fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 5px 8px;
  margin: 4px 0 4px 18px;
  border: 1px solid #edf2f7;
  border-radius: 8px;
  background: #fff;
}
.perm-leaf:hover {
  border-color: #c7d7e3;
  background: #fbfdff;
}
.perm-leaf input {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
}
.perm-leaf-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  color: #344054;
}
.perm-leaf-name i {
  width: 18px;
  text-align: center;
  color: #64748b;
}
.perm-leaf code {
  color: #475467;
  font-size: 12px;
  overflow-wrap: anywhere;
  background: #f1f5f9;
  border-radius: 5px;
  padding: 3px 6px;
}
.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 14px;
}
.profile-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}
.profile-section h2 { margin: 0 0 12px; font-size: 16px; }
.profile-section.wide { grid-column: 1 / -1; }
.profile-kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #eef2f7;
}
.profile-kv:last-child { border-bottom: 0; }
.profile-kv span { color: var(--muted); }
.badge-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.permission-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
  padding: 8px;
  background: #f8fafc;
  border-radius: 6px;
}
.permission-cloud code {
  background: #e2e8f0;
  color: #334155;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 12px;
}
.permission-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 4px 6px;
  border: 1px solid #dbeafe;
  border-radius: 6px;
  background: #fff;
}
.permission-chip b {
  font-size: 12px;
  color: #0f172a;
  font-weight: 600;
}
.audit-detail-grid {
  display: grid;
  gap: 12px;
}
.audit-detail-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.audit-detail-section h3 {
  margin: 0;
  padding: 9px 12px;
  font-size: 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}
.audit-detail-section pre {
  min-height: 120px;
  max-height: 280px;
  background: #0f172a;
  color: #e5e7eb;
  overflow: auto;
}
.audit-diff-table {
  overflow: auto;
}
.audit-diff-table table {
  width: 100%;
  border-collapse: collapse;
}
.audit-diff-table th,
.audit-diff-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 13px;
}
.audit-diff-table code {
  color: #334155;
  background: #e2e8f0;
  border-radius: 4px;
  padding: 2px 6px;
}
.diff-before {
  color: #991b1b;
  background: #fff1f2;
  white-space: pre-wrap;
}
.diff-after {
  color: #166534;
  background: #f0fdf4;
  white-space: pre-wrap;
}
.desktop-only { display: inline-flex; }
.desktop-only.top-icon {
  align-items: center;
  justify-content: center;
}
.mobile-only { display: none; }

@media (max-width: 900px) {
  .topbar { padding: 0 14px; }
  .profile-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .auth-card { padding: 22px; }
  .auth-topbar { flex-direction: column; }
  .layout {
    position: relative;
    grid-template-columns: minmax(0, 1fr);
    overflow-x: clip;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 84vw);
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    box-shadow: var(--shadow);
    overflow-y: auto;
  }
  .brand {
    position: sticky;
    top: 0;
    background:
      linear-gradient(180deg, rgba(20, 184, 166, 0.14) 0, rgba(56, 189, 248, 0.08) 70%),
      linear-gradient(180deg, var(--sidebar) 0, var(--sidebar-ink) 100%);
    z-index: 1;
  }
  .menu {
    padding: 12px 10px 18px;
  }
  .menu li { margin: 4px 0; }
  .menu-node {
    min-height: 42px;
    grid-template-columns: 16px 18px 1fr;
    gap: 10px;
    padding: 10px 12px;
  }
  .menu-children {
    margin-left: 12px;
    padding-left: 12px;
  }
  .menu-item.expanded > .menu-children {
    display: none;
  }
  .menu-item.mobile-expanded > .menu-children {
    display: block;
  }
  .menu-item.mobile-expanded > .menu-node {
    background: linear-gradient(90deg, rgba(20, 184, 166, 0.24), rgba(56, 189, 248, 0.12));
    border-color: rgba(94, 234, 212, 0.24);
    color: #fff;
  }
  .menu-item.mobile-expanded > .menu-node .menu-arrow i {
    transform: rotate(90deg);
  }
  .layout.menu-open .sidebar { transform: translateX(0); }
  .layout.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); }
  .layout.sidebar-collapsed .brand span { display: inline; }
  .layout.sidebar-collapsed .menu-node {
    grid-template-columns: 14px 18px 1fr;
    justify-items: stretch;
    padding: 9px 10px;
  }
  .layout.sidebar-collapsed .menu-arrow,
  .layout.sidebar-collapsed .menu-label { display: block; }
  .layout.sidebar-collapsed .menu-icon {
    width: 20px;
    height: auto;
    display: inline-block;
    background: transparent;
    border-radius: 0;
  }
  .layout.sidebar-collapsed .menu-children { padding-left: 16px; }
  .layout.menu-open .menu-node {
    justify-items: stretch;
  }
  .layout.menu-open .menu-label,
  .layout.menu-open .menu-arrow {
    display: block;
  }
  .layout.menu-open .menu-icon {
    width: 20px;
    height: auto;
    display: inline-block;
    background: transparent;
    border-radius: 0;
  }
  .mobile-only { display: inline-flex; }
  .desktop-only { display: none; }
  .main {
    min-height: 100vh;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }
  .topbar {
    padding: 10px 14px;
    min-height: 56px;
    height: auto;
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .top-left {
    width: 100%;
    min-width: 0;
  }
  .title-stack {
    flex: 1;
    min-width: 0;
  }
  .top-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 8px;
  }
  .header-lang { min-width: 0; }
  .header-lang select {
    min-width: 92px;
    max-width: 100%;
  }
  .tabs {
    padding: 6px 6px 0;
    gap: 4px;
  }
  .tab {
    max-width: 150px;
    padding: 0 8px 0 10px;
  }
  .frame-stack {
    min-height: calc(100vh - 150px);
  }
  .footer-ticker-label {
    padding: 0 8px;
    font-size: 11px;
  }
  .panel { padding: 14px; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .panel-actions {
    width: 100%;
    justify-content: space-between;
  }
  .filter-bar {
    display: grid;
    grid-template-columns: 1fr;
  }
  .filter-field,
  .filter-field.keyword {
    min-width: 0;
    max-width: none;
    width: 100%;
  }
  .filter-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
  }
  .log-grid {
    grid-template-columns: 1fr;
  }
  .modal {
    align-items: stretch;
    padding: 12px;
  }
  .modal-card,
  .modal-card.wide {
    width: 100%;
    max-height: calc(100vh - 24px);
    left: 12px !important;
    top: 12px !important;
  }
  .modal-card.modal-compact,
  .modal-card.modal-large,
  .modal-card.modal-maximized {
    width: 100%;
    height: auto;
    max-height: calc(100vh - 24px);
  }
  .modal-card .form {
    max-height: calc(100vh - 86px);
  }
  .modal-card.modal-permission {
    width: calc(100vw - 24px);
    height: calc(100vh - 24px);
    max-height: calc(100vh - 24px);
    resize: none;
  }
  .modal-card.modal-permission .form {
    max-height: none;
  }
  .permission-tree-toolbar {
    padding: 10px 12px;
  }
  .permission-tree-actions,
  .permission-assignment-footer,
  .modal-form-actions,
  .permission-footer-actions {
    flex-wrap: wrap;
  }
  .modal-form-actions button {
    flex: 1 1 120px;
  }
  .permission-tree-actions {
    justify-content: flex-start;
  }
  .permission-tree {
    padding: 8px 10px 12px;
  }
  .modal-card header {
    cursor: default;
  }
  .top-actions #currentUser { display: none; }
  .breadcrumb { max-width: 100%; }
  table { min-width: 680px; }
  .perm-leaf {
    grid-template-columns: 18px 1fr;
  }
  .perm-leaf code, .perm-leaf .badge {
    grid-column: 2;
  }
  .perm-summary-title {
    min-width: 100%;
  }
  .perm-menu-check,
  .perm-group-check {
    max-width: 100%;
  }
  .perm-group-check {
    margin-left: 0;
  }
}
