:root {
  --bg: #050505;
  --panel: #141414;
  --panel-soft: #101010;
  --border: rgba(218, 165, 50, 0.18);
  --border-strong: rgba(218, 165, 50, 0.34);
  --gold: #d9a32c;
  --gold-soft: #f0c35b;
  --text: #f5f0e6;
  --muted: #a9a39a;
  --dim: #716c64;
  --blue: #5da8ff;
  --red: #ff6b6b;
  --green: #44d18b;
  --font: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 78% 0%, rgba(217, 163, 44, 0.12), transparent 34%), var(--bg);
  color: var(--text);
  font-family: var(--font);
}

#sidebar {
  position: fixed;
  inset: var(--environment-banner-height, 0px) auto 0 0;
  width: 296px;
  background: #111;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.brand {
  height: 104px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.brand-mark, .user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  color: var(--gold-soft);
  background: rgba(217, 163, 44, 0.1);
}
.app-name {
  color: var(--gold-soft);
  font: 700 15px var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.app-parent, .eyebrow {
  color: var(--dim);
  font: 500 11px var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.back-link {
  margin-left: auto;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.back-link svg, .nav-icon { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }

.nav-section {
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.nav-label {
  margin: 14px 8px 6px;
  color: var(--dim);
  font: 500 10px var(--mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.nav-item {
  min-height: 44px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
}
.nav-item.active {
  background: rgba(217, 163, 44, 0.12);
  border-color: var(--border-strong);
  color: var(--gold-soft);
}
.sidebar-bottom {
  margin-top: auto;
  padding: 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.user-pill { display: flex; gap: 10px; align-items: center; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; font: 600 12px var(--mono); }
.user-name { font-weight: 700; font-size: 14px; }
.user-role { color: var(--dim); font: 500 10px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; }
.text-action {
  margin-top: 14px;
  border: 0;
  background: none;
  color: var(--muted);
  font: 500 12px var(--mono);
  cursor: pointer;
}

#main {
  min-height: 100vh;
  margin-left: 296px;
  padding: 26px 30px 44px;
}
.topbar {
  min-height: 76px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}
h1, h2 { margin: 0; }
h1 { font: italic 600 34px "Playfair Display", serif; color: var(--gold-soft); }
h2 { font-size: 18px; font-weight: 650; }
.topbar-actions, .button-grid, .import-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.module-select-wrap {
  min-width: 180px;
}
.module-select-wrap select {
  min-height: 38px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 10px 0 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.tab {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: var(--muted);
  font: 700 12px var(--mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}
.tab.active {
  color: var(--gold-soft);
  border-color: rgba(255,255,255,0.1);
  background: rgba(217, 163, 44, 0.08);
}
.tab-panel[hidden] {
  display: none;
}

.grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(420px, 1.2fr);
  gap: 18px;
  margin-top: 18px;
}
.panel {
  background: linear-gradient(145deg, rgba(255,255,255,0.045), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.28);
}
.panel + .panel { margin-top: 18px; }
.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.muted { color: var(--muted); font-size: 13px; line-height: 1.5; }
.select-row { display: block; margin-bottom: 14px; max-width: 360px; }
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.template-card {
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  background: rgba(0,0,0,0.2);
}
.template-card strong { display: block; margin-bottom: 6px; color: var(--text); }
.template-card span { display: block; min-height: 34px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.template-card .btn { width: 100%; margin-top: 12px; }

.btn {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text);
  background: rgba(255,255,255,0.04);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn.primary {
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  color: #141006;
  border-color: transparent;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.ghost:hover, .btn:hover:not(:disabled) { border-color: var(--border-strong); }

.import-controls {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(260px, 1.2fr);
  gap: 12px;
}
label span {
  display: block;
  margin-bottom: 7px;
  color: var(--dim);
  font: 600 10px var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
input, select {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  background: #080808;
  color: var(--text);
  padding: 0 12px;
  font: 500 14px var(--font);
}
input[type="file"] { padding: 10px; color: var(--muted); }

.summary-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.summary-row div {
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  background: rgba(0,0,0,0.22);
}
.summary-row strong { display: block; color: var(--gold-soft); font: 700 22px var(--mono); }
.summary-row span { color: var(--dim); font: 600 10px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; }
.status-box {
  min-height: 42px;
  padding: 12px;
  border: 1px dashed rgba(255,255,255,0.12);
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.detected-type {
  display: inline-flex;
  margin: 0 0 12px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--gold-soft);
  background: rgba(217, 163, 44, 0.08);
  font: 700 11px var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.check-row { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.check-row input { width: auto; min-height: 0; }
.import-actions { justify-content: flex-end; margin-top: 14px; }

.table-shell {
  max-width: 100%;
  overflow: auto;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}
th, td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}
th {
  color: var(--dim);
  background: rgba(0,0,0,0.24);
  font: 600 10px var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
td { color: var(--muted); }
.compact table { min-width: 620px; }
.row-valid { color: var(--green); }
.row-error { color: var(--red); }
.row-warn { color: var(--gold-soft); }

@media (max-width: 900px) {
  #sidebar { position: static; width: 100%; }
  #main { margin-left: 0; padding: 18px; }
  .grid, .import-controls { grid-template-columns: 1fr; }
  .summary-row { grid-template-columns: repeat(2, 1fr); }
  .topbar { align-items: flex-start; flex-direction: column; }
}
