:root {
  /* Xboard/Ant Design Professional Palette */
  --bg: #f0f2f5;
  --panel: #ffffff;
  --text: #000000d9;
  --text-dim: #000000a6;
  --text-faint: #00000073;
  --border: #d9d9d9;
  --border-light: #f0f0f0;
  --shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03), 0 1px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px 0 rgba(0, 0, 0, 0.02);
  --shadow-card: 0 1px 2px -2px rgba(0, 0, 0, 0.16), 0 3px 6px 0 rgba(0, 0, 0, 0.12), 0 5px 12px 4px rgba(0, 0, 0, 0.09);
  
  /* Brand/Accent (Ant Design Blue) */
  --accent: #1677ff;
  --accent-hover: #4096ff;
  --accent-active: #0958d9;
  --accent-soft: #e6f4ff;
  
  /* Indicators */
  --success: #52c41a;
  --warn: #faad14;
  --danger: #ff4d4f;
  
  /* Radius */
  --radius-lg: 8px;
  --radius-md: 6px;
  --radius-sm: 4px;
  
  /* Sidebar */
  --sidebar-bg: #ffffff;
  --sidebar-item-active: #e6f4ff;
  
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5715;
}

/* Main Layout */
.admin-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 1000;
}

.sidebar-header {
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
}

.sidebar-brand strong {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.sidebar-brand span {
  font-size: 12px;
  color: var(--text-faint);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}

.sidebar-nav-label {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.sidebar-item-wrap {
  margin-bottom: 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  color: var(--text-dim);
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
}

.sidebar-item:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text);
}

.sidebar-item.active {
  background: var(--sidebar-item-active);
  color: var(--accent);
  font-weight: 500;
}

.sidebar-item strong {
  font-size: 14px;
}

/* Main Content */
.admin-main {
  flex: 1;
  margin-left: 260px;
  padding: 24px;
  max-width: 100%;
}

.topbar {
  margin-bottom: 24px;
}

.topbar-copy h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.topbar-copy p {
  margin: 4px 0 0;
  color: var(--text-dim);
}

/* Cards */
.card {
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.card h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--text);
}

/* Stats Grid */
.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

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

.stat-card {
  padding: 16px 24px;
}

.stat-card span {
  font-size: 14px;
  color: var(--text-dim);
}

.stat-card strong {
  display: block;
  font-size: 24px;
  font-weight: 600;
  margin-top: 4px;
}

/* Tables */
.table-wrap {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  background: #fafafa;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-light);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:hover {
  background: #fafafa;
}

/* Node Hierarchy */
.node-child {
  background: #fafafa;
}

.node-child td:first-child {
  padding-left: 40px;
  position: relative;
}

.node-child td:first-child::before {
  content: "";
  position: absolute;
  left: 20px;
  top: 0;
  bottom: 50%;
  width: 10px;
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.relation-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fafafa;
  white-space: nowrap;
}

.relation-chip code {
  font-size: 12px;
}

.relation-arrow {
  color: var(--accent);
  font-weight: 700;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 4px 15px;
  font-size: 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  border: 1px solid transparent;
  user-select: none;
}

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

.btn-primary:hover {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background-color: #fff;
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.btn-ghost {
  color: var(--accent);
}

.btn-ghost:hover {
  background: var(--accent-soft);
}

/* Form Elements */
.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 4px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all 0.2s;
}

.field input:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.1);
  outline: 0;
}

/* Toggle Switch (Ant Design Style) */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
  vertical-align: middle;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.25);
  transition: .2s;
  border-radius: 100px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
  background-color: var(--accent);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

/* Status Pills */
.status-pill {
  padding: 0 7px;
  font-size: 12px;
  line-height: 20px;
  border-radius: 4px;
  display: inline-block;
}

.status-ok { background: #f6ffed; border: 1px solid #b7eb8f; color: #52c41a; }
.status-warn { background: #fffbe6; border: 1px solid #ffe58f; color: #faad14; }
.status-danger { background: #fff1f0; border: 1px solid #ffa39e; color: #ff4d4f; }

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1000;
  background-color: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 100px;
}

.modal-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05);
  width: 520px;
  overflow: hidden;
  animation: modalIn 0.2s cubic-bezier(0.075, 0.82, 0.165, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* Loading busy state */
.btn.busy {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* Sidebar Submenus */
.sidebar-submenu {
  margin-top: 2px;
  padding-left: 24px;
}

.sidebar-submenu.collapsed {
  display: none;
}

.sidebar-nav-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  cursor: pointer;
  border-radius: var(--radius-md);
  color: var(--text-dim);
}

.sidebar-nav-item-header:hover {
  background: rgba(0, 0, 0, 0.04);
}

/* Login Page Styling */
.login-container {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #f0f2f5;
}

.login-card {
  width: 400px;
  padding: 40px;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.login-header h1 {
  text-align: center;
  font-size: 32px;
  font-weight: 600;
  margin: 0 0 8px;
}

.login-header p {
  text-align: center;
  color: var(--text-faint);
  margin-bottom: 32px;
}

.page-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar-spaced {
  justify-content: space-between;
  margin-bottom: 16px;
}

.toolbar-group {
  display: flex;
  gap: 12px;
}

.topbar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.topbar-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f0f7ff;
  color: var(--primary-color);
  font-size: 12px;
}

.notice {
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.notice-success {
  background: #f6ffed;
  border-color: #b7eb8f;
  color: #389e0d;
}

.notice-error {
  background: #fff2f0;
  border-color: #ffccc7;
  color: #cf1322;
}

.notice-info {
  background: #e6f4ff;
  border-color: #91caff;
  color: #0958d9;
}

.subtle-text {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 12px;
}

.summary-item {
  background: #fafafa;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
}

.summary-item span {
  display: block;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.summary-item strong {
  font-size: 18px;
}

.compact-grid {
  margin-bottom: 0;
}

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

.row-actions .btn {
  height: 28px;
  padding: 0 10px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

.sidebar-footer-btn {
  width: 100%;
}

.sidebar-arrow {
  transition: transform 0.2s ease;
}

.sidebar-arrow.expanded {
  transform: rotate(90deg);
}

.node-name-block {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.node-toggle {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  color: var(--text-secondary);
}

.node-toggle-placeholder {
  display: inline-block;
  border-color: transparent;
  background: transparent;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

.modal-card-inner {
  position: relative;
}

.btn-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border-color);
  background: #fff;
}

.tabs-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.pagination-shell {
  display: flex;
  gap: 8px;
  padding: 16px 0;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.page-btn.active {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: #e6f4ff;
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-secondary);
  background: #fff;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
}

.busy-spinner {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.login-field {
  margin-bottom: 24px;
}

.login-field label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-dim);
}

.input-wrapper input {
  height: 40px;
}

.btn-login {
  width: 100%;
  height: 40px;
  font-size: 16px;
}

/* Responsive */
@media (max-width: 900px) {
  .admin-sidebar {
    display: none;
  }
  .admin-main {
    margin-left: 0;
    padding: 16px;
  }
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .toolbar-spaced,
  .toolbar-group,
  .topbar-meta,
  .row-actions,
  .tabs-nav {
    flex-wrap: wrap;
  }
  .modal-card {
    width: calc(100vw - 24px);
  }
}
