:root {
  --bg: #f6f1e7;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-strong: #ffffff;
  --line: rgba(123, 95, 45, 0.14);
  --text: #2d2418;
  --muted: #7f715e;
  --accent: #bc5f1d;
  --accent-soft: #fff1dc;
  --green: #1f7a5c;
  --green-soft: #e8f5ef;
  --warn: #a9472a;
  --shadow: 0 22px 48px rgba(85, 60, 25, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(240, 183, 76, 0.28), transparent 22%),
    radial-gradient(circle at bottom left, rgba(41, 122, 95, 0.12), transparent 24%),
    linear-gradient(180deg, #f8f2e6 0%, #f2ece0 100%);
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  padding: 24px 18px;
  background: rgba(55, 41, 22, 0.96);
  color: #fff4dc;
}

.brand-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.08);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: linear-gradient(135deg, #ffcf67 0%, #ee8a32 100%);
  color: #4a2a03;
  font-weight: 700;
}

.brand-title {
  font-size: 22px;
  font-weight: 700;
}

.brand-note {
  margin-top: 6px;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 244, 220, 0.72);
}

.nav-list {
  display: grid;
  gap: 8px;
  margin-top: 28px;
}

.nav-item {
  padding: 14px 16px;
  border: 0;
  border-radius: 16px;
  text-align: left;
  color: #f8ebcf;
  background: transparent;
  transition: transform 160ms ease, background 160ms ease;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  transform: translateX(2px);
}

.sidebar-foot {
  margin-top: 30px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
}

.foot-label {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f4cf7b;
}

.foot-copy {
  margin-top: 10px;
  line-height: 1.7;
  color: rgba(255, 244, 220, 0.78);
}

.main-area {
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.topbar-title {
  font-size: 34px;
  font-weight: 700;
}

.topbar-note {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.7;
  max-width: 720px;
}

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

.status-pill {
  padding: 12px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}

.panel,
.unlock-panel {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.unlock-panel.hidden {
  display: none;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.panel h2,
.panel h3,
.unlock-panel h2 {
  margin: 0;
}

.panel p,
.unlock-panel p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

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

.metric-card {
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(255, 244, 220, 0.92) 0%, rgba(255, 255, 255, 0.95) 100%);
  border: 1px solid rgba(184, 132, 58, 0.16);
}

.metric-label {
  color: #866e49;
  font-size: 14px;
}

.metric-value {
  margin-top: 10px;
  font-size: 30px;
  font-weight: 700;
  color: #4c3212;
}

.metric-note {
  margin-top: 8px;
  color: #8b7a64;
  font-size: 13px;
}

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

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

.arch-card {
  padding: 18px;
  border-radius: 20px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.arch-card h4,
.schema-page-card h4,
.schema-table-card h4 {
  margin: 0;
}

.arch-card p,
.schema-page-card p,
.schema-table-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(124, 101, 63, 0.12);
  text-align: left;
  vertical-align: top;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(255, 251, 245, 0.95);
  color: #7a6641;
  font-size: 13px;
  letter-spacing: 0.03em;
}

tbody tr:hover {
  background: rgba(255, 248, 235, 0.68);
}

.text-input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid rgba(128, 102, 65, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
}

.text-input.compact {
  width: auto;
  min-width: 220px;
}

.textarea-input {
  min-height: 120px;
  resize: vertical;
}

.primary-btn,
.ghost-btn {
  border: 0;
  border-radius: 999px;
  padding: 13px 18px;
}

.primary-btn {
  background: linear-gradient(135deg, #ee9c3f 0%, #cd6322 100%);
  color: #fffaf1;
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.92);
  color: #604728;
  border: 1px solid rgba(132, 101, 61, 0.16);
}

.ghost-btn.warn {
  color: var(--warn);
  background: #fff1ed;
}

.unlock-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: #f4ecda;
  color: #785d30;
  font-size: 12px;
  margin: 2px 6px 2px 0;
}

.tag.green {
  background: var(--green-soft);
  color: var(--green);
}

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

.tag.gray {
  background: #f0ede7;
  color: #73685a;
}

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

.tiny-btn {
  border: 0;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: #f1efe8;
  color: #5f5240;
}

.tiny-btn.primary {
  background: #fff1dc;
  color: #b85b1c;
}

.tiny-btn.warn {
  background: #fff1ed;
  color: #ab4d2d;
}

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

.form-field {
  display: grid;
  gap: 8px;
}

.form-field span {
  font-size: 14px;
  color: #725f42;
}

.form-span-2 {
  grid-column: span 2;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.product-layout {
  align-items: flex-start;
}

.media-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.media-preview-card {
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(132, 101, 61, 0.14);
}

.preview-label {
  margin-bottom: 10px;
  font-size: 13px;
  color: #846d4a;
}

.preview-box {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 176px;
  overflow: hidden;
  border-radius: 18px;
  border: 1px dashed rgba(164, 122, 60, 0.28);
  background:
    radial-gradient(circle at top right, rgba(244, 205, 120, 0.26), transparent 38%),
    linear-gradient(180deg, rgba(255, 249, 239, 0.95) 0%, rgba(248, 241, 226, 0.92) 100%);
}

.preview-box.wide {
  min-height: 152px;
}

.preview-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-empty {
  padding: 18px;
  text-align: center;
  color: #98846a;
  font-size: 14px;
}

.file-input {
  padding: 10px 12px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

.tree-text {
  margin: 0;
  padding: 16px;
  min-height: 360px;
  border-radius: 18px;
  background: #29231b;
  color: #f5e8cb;
  overflow: auto;
  line-height: 1.7;
}

.schema-page-card,
.schema-table-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-strong);
}

.schema-stack {
  display: grid;
  gap: 12px;
}

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

.empty-state {
  color: var(--muted);
}

.path-cell {
  min-width: 220px;
  color: #6a5a45;
}

.indented {
  display: inline-block;
}

.hidden {
  display: none !important;
}

.drawer-mask {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(29, 20, 8, 0.42);
  backdrop-filter: blur(3px);
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  width: min(560px, 100vw);
  height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(249, 204, 111, 0.22), transparent 30%),
    linear-gradient(180deg, #fbf7ee 0%, #f3ebdc 100%);
  border-left: 1px solid rgba(123, 95, 45, 0.14);
  box-shadow: -20px 0 48px rgba(56, 36, 13, 0.16);
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 22px 18px;
  border-bottom: 1px solid rgba(123, 95, 45, 0.12);
}

.drawer-title {
  font-size: 24px;
  font-weight: 700;
}

.drawer-note {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.drawer-content {
  flex: 1;
  overflow: auto;
  padding: 18px 22px 26px;
}

.drawer-section {
  margin-bottom: 18px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(123, 95, 45, 0.12);
}

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

.mini-metric {
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 243, 214, 0.95) 0%, rgba(255, 255, 255, 0.98) 100%);
  border: 1px solid rgba(188, 126, 49, 0.12);
}

.mini-metric-label {
  font-size: 12px;
  color: #8a7450;
}

.mini-metric-value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 700;
  color: #4a3213;
}

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

.detail-card {
  padding: 16px;
  border-radius: 18px;
  background: #fffdf9;
  border: 1px solid rgba(123, 95, 45, 0.1);
}

.detail-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.detail-subtitle {
  margin: 14px 0 8px;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: #8b7249;
}

.detail-line {
  line-height: 1.7;
  color: #463726;
}

.detail-line + .detail-line {
  margin-top: 10px;
}

.drawer-table {
  overflow: auto;
  margin-top: 14px;
}

.drawer-table table {
  min-width: 0;
}

.chain-graph {
  padding: 18px;
  border-radius: 24px;
  border: 1px solid rgba(123, 95, 45, 0.12);
  background:
    radial-gradient(circle at top right, rgba(241, 197, 95, 0.16), transparent 26%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0%, rgba(250, 244, 233, 0.96) 100%);
  overflow: auto;
}

.graph-tree,
.graph-children {
  list-style: none;
  margin: 0;
  padding: 0;
}

.graph-tree {
  display: grid;
  gap: 16px;
}

.graph-branch {
  position: relative;
}

.graph-children {
  position: relative;
  display: grid;
  gap: 12px;
  margin-top: 12px;
  margin-left: 28px;
  padding-left: 24px;
}

.graph-children::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 12px;
  left: 8px;
  width: 1px;
  background: linear-gradient(180deg, rgba(206, 155, 67, 0.5) 0%, rgba(206, 155, 67, 0.14) 100%);
}

.graph-node {
  position: relative;
  padding: 16px 18px;
  border-radius: 20px;
  background: #fffdf9;
  border: 1px solid rgba(123, 95, 45, 0.12);
  box-shadow: 0 12px 28px rgba(76, 51, 17, 0.08);
}

.graph-node::before {
  content: "";
  position: absolute;
  top: 20px;
  left: -24px;
  width: 24px;
  height: 1px;
  background: rgba(206, 155, 67, 0.42);
}

.graph-tree > .graph-branch > .graph-node::before {
  display: none;
}

.graph-node.ordered {
  border-color: rgba(31, 122, 92, 0.18);
  background: linear-gradient(135deg, rgba(232, 245, 239, 0.76) 0%, rgba(255, 255, 255, 0.98) 100%);
}

.graph-node.pending {
  background: linear-gradient(135deg, rgba(255, 244, 220, 0.82) 0%, rgba(255, 255, 255, 0.98) 100%);
}

.graph-node-name {
  font-size: 18px;
  font-weight: 700;
}

.graph-node-meta,
.graph-node-path {
  margin-top: 6px;
  font-size: 13px;
  color: #846f56;
}

.graph-node-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

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

  .sidebar {
    padding-bottom: 10px;
  }

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

  .sidebar-foot {
    display: none;
  }

  .topbar,
  .panel-title-row {
    flex-direction: column;
  }

  .metric-grid,
  .metric-grid.slim,
  .split-grid,
  .triple-grid,
  .form-grid,
  .media-preview-grid,
  .detail-grid,
  .drawer-metrics {
    grid-template-columns: 1fr;
  }

  .form-span-2 {
    grid-column: span 1;
  }

  .detail-drawer {
    width: 100vw;
  }

  .drawer-head,
  .drawer-content {
    padding-left: 16px;
    padding-right: 16px;
  }

  .graph-children {
    margin-left: 12px;
    padding-left: 18px;
  }

  .graph-node::before {
    left: -18px;
    width: 18px;
  }
}
