:root {
  --bg: #061729;
  --panel: #0f2238;
  --panel-2: #15263d;
  --border: #2a4363;
  --text: #eff6ff;
  --muted: #8fa7c1;
  --blue: #2997ff;
  --blue-2: #1a5dcc;
  --green: #57d97a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background: radial-gradient(circle at top, #102b46, var(--bg) 60%);
  color: var(--text);
}

body {
  overflow: hidden;
}

.wrapper {
  width: min(100% - 24px, 1920px);
  height: 100vh;
  margin: 0 auto;
  padding: 14px 0;
}

.dashboard {
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid #1c3553;
  border-radius: 12px;
  overflow: hidden;
  background: #0b1d32;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: #1a2b43;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  height: 42px;
  display: flex;
  align-items: center;
}

.brand-logo {
  display: block;
  height: 100%;
  width: auto;
  max-width: 180px;
  object-fit: contain;
}

.brand h1 {
  margin: 0;
  font-size: 40px;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(180deg, #dfe5ec, #bac8d8);
  color: #18314c;
  font-size: 0.82rem;
  font-weight: 700;
}

.user-text small {
  display: block;
  color: var(--muted);
}

.user-text strong {
  display: block;
}

.logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  color: #fff;
  background: linear-gradient(180deg, #329eff, #1f61cc);
  cursor: pointer;
  text-decoration: none;
}

.content {
  display: grid;
  grid-template-columns: 84px 1fr;
  grid-template-rows: minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.left-rail {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--border);
  background: #1b2d45;
  padding: 10px 0;
}

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 10px 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.68rem;
  line-height: 1.1;
}

.rail-item:hover,
.rail-item:focus-visible {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.rail-item.is-active {
  color: var(--text);
  background: linear-gradient(90deg, rgba(41, 151, 255, 0.18), transparent);
  border-left: 3px solid var(--blue);
}

.rail-icon {
  font-size: 20px;
}

.rail-settings {
  padding: 12px 4px;
}

.main-panel {
  display: flex;
  flex-direction: column;
  padding: 18px;
  min-height: 0;
  gap: 14px;
}

.panel-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.breadcrumb {
  color: var(--muted);
  font-size: 14px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.86rem;
  cursor: pointer;
}

.tbtn:hover {
  border-color: var(--blue);
}

.tbtn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.tbtn:disabled:hover {
  border-color: var(--border);
}

.tbtn-primary {
  background: linear-gradient(180deg, var(--blue), var(--blue-2));
  border-color: transparent;
  font-weight: 600;
}

.tbtn-danger {
  color: #ff8a8a;
}

.split-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.tree-panel,
.detail-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, #182b44, #13253a);
}

.tree-panel-head,
.detail-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.tree-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.tree-panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}

.icon-btn:hover {
  color: var(--text);
}

.tree-scroll {
  flex: 1;
  overflow: auto;
  padding: 8px 6px;
}

.tree-add {
  margin: 10px 14px 14px;
  padding: 8px 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}

.tree-add:hover {
  color: var(--text);
  border-color: var(--blue);
}

.tree-root,
.tree-children {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-children {
  padding-left: 32px;
}

.tree-node.is-collapsed > .tree-children {
  display: none;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.tree-icon {
  display: inline-flex;
  flex: 0 0 20px;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.tree-row:hover {
  background: rgba(255, 255, 255, 0.04);
}

.tree-row.is-selected {
  background: rgba(41, 151, 255, 0.16);
  outline: 1px solid rgba(41, 151, 255, 0.4);
}

.tree-toggle {
  display: grid;
  flex: 0 0 18px;
  width: 18px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  place-items: center;
  transition: transform 0.15s ease;
}

.tree-node:not(.is-collapsed) > .tree-row .tree-toggle {
  transform: rotate(90deg);
}

.tree-toggle-spacer {
  width: 16px;
  display: inline-block;
}

.tree-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-root > .tree-node > .tree-row {
  padding: 10px 8px;
}

.tree-root > .tree-node > .tree-row .tree-label {
  font-size: 1.1rem;
  font-weight: 600;
}

.tree-root > .tree-node > .tree-row .tree-icon {
  flex-basis: 28px;
  width: 28px;
  height: 28px;
  font-size: 1.4rem;
}

.tree-menu-btn {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0;
}

.tree-row:hover .tree-menu-btn,
.tree-row.is-selected .tree-menu-btn,
.tree-menu-btn:focus-visible {
  opacity: 1;
}

.tree-menu-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.tree-menu {
  position: fixed;
  z-index: 1000;
  min-width: 160px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.tree-menu button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  text-align: left;
}

.tree-menu button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.tree-menu .is-danger {
  color: #ff8a8a;
}

.badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-warning {
  background: #4a3a12;
  color: #ffcf6b;
}

.badge-success {
  background: #113b22;
  color: var(--green);
}

.badge-danger {
  background: #4a1616;
  color: #ff8a8a;
}

.detail-empty {
  margin: auto;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 24px;
  text-align: center;
}

.detail-body {
  flex: 1;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail-actions {
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  padding: 0 14px 14px;
}

.detail-actions:has(.bbtn[hidden]) {
  display: none;
}

.detail-panel {
  border-color: #2f5f8f;
  background: linear-gradient(180deg, #17375a, #112b49);
}

.detail-panel-head {
  border-bottom-color: #2f5f8f;
  background: rgba(41, 151, 255, 0.08);
}

.detail-panel.is-editing {
  border-color: var(--blue);
  background: linear-gradient(180deg, #1d4a3f, #12342d);
}

.detail-panel.is-editing .detail-panel-head {
  border-bottom-color: var(--blue);
}

.detail-field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.detail-field input,
.detail-field select,
.detail-field textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0a1c33;
  color: var(--text);
  font: inherit;
}

.detail-field textarea {
  resize: vertical;
  min-height: 64px;
}

.detail-field input[type="checkbox"] {
  width: auto;
  padding: 0;
  accent-color: var(--blue);
}

.detail-field input:disabled,
.detail-field select:disabled,
.detail-field textarea:disabled {
  color: var(--text);
  opacity: 0.8;
  cursor: default;
  -webkit-text-fill-color: var(--text);
}

.bottom-actions {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}

.bbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 0.86rem;
  cursor: pointer;
}

.bbtn:hover {
  border-color: var(--blue);
}

.bbtn[hidden] {
  display: none;
}

.bbtn-primary {
  background: linear-gradient(180deg, var(--blue), var(--blue-2));
  border-color: transparent;
  font-weight: 600;
}

.bbtn-danger {
  color: #ff8a8a;
}

.statusbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  flex-shrink: 0;
  min-height: 48px;
  padding: 10px 20px;
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, #15263c 0%, #0f1d30 100%);
  font-size: 0.88rem;
  color: var(--muted);
}

.status-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 500;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: var(--green);
  box-shadow: 0 0 8px rgba(87, 217, 122, 0.6);
  display: inline-block;
  position: relative;
  flex-shrink: 0;
}

.status-dot::after {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1px solid var(--green);
  animation: pulse-ring 2.2s infinite ease-out;
  opacity: 0;
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.7);
    opacity: 0.85;
  }
  100% {
    transform: scale(1.8);
    opacity: 0;
  }
}

.company-name {
  letter-spacing: 0.01em;
}

.status-version {
  color: var(--muted);
  font-size: 0.8rem;
  opacity: 0.7;
}

@media (max-width: 680px) {
  .statusbar {
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 8px;
    padding: 12px 16px;
  }
}

@media (max-width: 900px) {
  .content {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .left-rail {
    flex-direction: row;
    justify-content: space-between;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .rail-nav {
    flex-direction: row;
  }

  .split-panel {
    grid-template-columns: 1fr;
  }
}
