:root {
  --bg: #08070d;
  --bg2: #120b1b;
  --panel: rgba(20, 17, 32, 0.86);
  --panel2: rgba(33, 26, 48, 0.78);
  --gold: #f5bd58;
  --amber: #ff9f45;
  --cyan: #51e4ff;
  --green: #7cf49a;
  --pink: #ff66b3;
  --red: #ff5b6e;
  --text: #f4efff;
  --muted: #b8accd;
  --line: rgba(255,255,255,.13);
  --shadow: 0 24px 80px rgba(0,0,0,.42);
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  background:
    radial-gradient(circle at 15% 0%, rgba(245,189,88,.16), transparent 32%),
    radial-gradient(circle at 92% 8%, rgba(81,228,255,.11), transparent 30%),
    linear-gradient(135deg, var(--bg), #0d0b15 42%, #070510);
  color: var(--text);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.desktop-app { height: 100vh; display: grid; grid-template-rows: 34px 1fr 26px; min-width: 960px; }
.menu-bar {
  display: flex; align-items: stretch; gap: 2px; padding: 0 8px; background: linear-gradient(180deg, #1a1325, #0b0911); border-bottom: 1px solid var(--line); z-index: 20;
  box-shadow: 0 8px 24px rgba(0,0,0,.32);
}
.menu-title { display: flex; align-items: center; gap: 7px; padding: 0 12px 0 2px; color: #f8e3b7; font-weight: 800; letter-spacing: .02em; white-space: nowrap; font-size: 13px; }
.menu-title img { width: 22px; height: 22px; }
.menu { position: relative; display: flex; align-items: stretch; }
.menu-button { background: transparent; border: 0; color: var(--text); padding: 0 12px; height: 33px; border-radius: 0; }
.menu:hover .menu-button, .menu:focus-within .menu-button { background: rgba(255,255,255,.09); color: var(--gold); }
.menu-panel {
  display: none; position: absolute; top: 34px; left: 0; min-width: 220px; padding: 8px; background: rgba(12,10,18,.98); border: 1px solid rgba(245,189,88,.28); border-radius: 0 0 14px 14px; box-shadow: var(--shadow); z-index: 30;
}
.menu:hover .menu-panel, .menu:focus-within .menu-panel { display: grid; gap: 6px; }
.wide-menu { min-width: 370px; }
.tall-menu { max-height: 70vh; overflow: auto; }
.menu-panel button, .menu-panel select, .menu-panel input {
  width: 100%; border: 1px solid rgba(255,255,255,.13); background: rgba(255,255,255,.06); color: var(--text); border-radius: 10px; padding: 7px 9px; text-align: left;
}
.menu-panel button:hover { border-color: rgba(81,228,255,.55); background: rgba(81,228,255,.12); }
.menu-panel select option { background: #130f1c; color: var(--text); }
.menu-panel label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.menu-panel hr { width: 100%; border: 0; border-top: 1px solid var(--line); margin: 2px 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check-line { display: flex !important; grid-template-columns: 18px 1fr; align-items: center; gap: 8px; color: var(--text) !important; }
.check-line input { width: auto !important; }
.menu-note { color: var(--muted); line-height: 1.4; font-size: 12px; margin: 3px 2px; }
.menu-spacer { flex: 1; }
.transport-status { display:flex; align-items:center; color: var(--muted); font-size: 12px; padding: 0 8px; }
.workspace { min-height: 0; overflow: hidden; display: grid; grid-template-rows: 104px minmax(180px, 1.05fr) minmax(220px, .95fr); gap: 12px; padding: 12px; }
.brand-strip {
  display: grid; grid-template-columns: minmax(280px, 430px) 1fr auto; gap: 18px; align-items: center; min-height: 0;
  border: 1px solid rgba(245,189,88,.2); border-radius: var(--radius); padding: 10px 14px; background: linear-gradient(135deg, rgba(31,22,44,.78), rgba(7,7,13,.72)); box-shadow: var(--shadow);
}
.header-logo { width: 100%; max-height: 82px; object-fit: contain; justify-self: start; }
.project-readout { display: grid; gap: 5px; min-width: 0; }
.project-readout strong { font-size: clamp(18px, 2vw, 28px); color: #fff6df; overflow:hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-readout span { color: var(--muted); font-size: 13px; overflow:hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-stack { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; }
.badge { border: 1px solid rgba(255,255,255,.14); border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 800; color: var(--cyan); background: rgba(0,0,0,.2); white-space: nowrap; }
.badge.good { color: var(--green); border-color: rgba(124,244,154,.35); }
.badge.warn { color: var(--gold); border-color: rgba(245,189,88,.38); }
.badge.bad { color: var(--red); border-color: rgba(255,91,110,.44); }
.overview-grid { min-height: 0; display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(290px, .7fr); gap: 12px; }
.detail-grid { min-height: 0; display: grid; grid-template-columns: minmax(280px, .95fr) minmax(280px, 1fr) minmax(280px, .95fr); gap: 12px; }
.glass-panel { min-height: 0; overflow: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; display: grid; grid-template-rows: auto 1fr; }
.panel-heading { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; border-bottom: 1px solid rgba(255,255,255,.1); padding-bottom: 8px; margin-bottom: 10px; }
h1, h2 { margin: 0; font-size: 16px; letter-spacing: .02em; }
.small-label { color: var(--muted); font-size: 11px; }
.section-timeline { min-height: 0; overflow: auto; display: grid; gap: 10px; grid-auto-rows: minmax(86px, auto); }
.section-card { border: 1px solid rgba(81,228,255,.2); border-radius: 16px; padding: 10px; background: linear-gradient(135deg, rgba(81,228,255,.08), rgba(245,189,88,.06)); display: grid; gap: 8px; }
.section-card h3 { margin: 0; display: flex; justify-content: space-between; gap: 10px; align-items: center; color: #fff4dd; font-size: 15px; }
.section-meta { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 11px; }
.mini-bars { display: grid; grid-template-columns: repeat(16, 1fr); gap: 3px; height: 28px; align-items:end; }
.mini-bars span { display:block; min-height: 3px; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, var(--cyan), #276ce8); opacity: .86; }
.score-meter { height: 18px; border-radius: 999px; border: 1px solid rgba(255,255,255,.13); overflow: hidden; background: rgba(0,0,0,.26); }
.score-meter span { height: 100%; display: block; border-radius: inherit; background: linear-gradient(90deg, var(--red), var(--gold), var(--green)); transition: width .25s ease; }
.score-readout { color: var(--muted); line-height: 1.4; padding-top: 10px; }
.issue-list { overflow: auto; display: grid; gap: 6px; align-content: start; padding-top: 8px; }
.issue { border-left: 3px solid var(--gold); background: rgba(255,255,255,.04); padding: 7px 8px; border-radius: 10px; color: #eadff9; font-size: 12px; }
.issue.bad { border-left-color: var(--red); }
.issue.good { border-left-color: var(--green); }
.track-matrix { overflow: auto; display: grid; gap: 7px; align-content: start; }
.track-row { display: grid; grid-template-columns: 92px 1fr 54px; gap: 8px; align-items: center; font-size: 12px; }
.track-row b { color: #fff2d3; overflow:hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-lane { height: 16px; border-radius: 999px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1); overflow: hidden; display:flex; }
.track-lane span { display:block; height:100%; background: linear-gradient(90deg, var(--cyan), var(--gold)); opacity:.84; }
.track-row em { color: var(--muted); font-style: normal; text-align:right; }
.log-box, .console-log { margin: 0; min-height: 0; overflow: auto; color: #dccff3; line-height: 1.48; font-size: 12px; white-space: pre-wrap; }
.console-log { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: rgba(0,0,0,.22); border-radius: 12px; padding: 10px; border: 1px solid rgba(255,255,255,.08); }
.empty-state { display:flex; align-items:center; justify-content:center; color: var(--muted); border: 1px dashed rgba(255,255,255,.16); border-radius: 14px; text-align: center; padding: 16px; }
.app-footer { display:flex; align-items:center; justify-content:center; color: #9f93b6; font-size: 11px; background: #07050b; border-top: 1px solid rgba(255,255,255,.1); }
@media (max-width: 1100px) {
  html, body { overflow: auto; }
  .desktop-app { min-width: 0; min-height: 100vh; height: auto; grid-template-rows: auto 1fr auto; }
  .menu-bar { flex-wrap: wrap; min-height: 34px; }
  .workspace { overflow: visible; grid-template-rows: auto auto auto; }
  .brand-strip, .overview-grid, .detail-grid { grid-template-columns: 1fr; }
  .menu-panel { position: fixed; top: 34px; left: 8px; right: 8px; min-width: auto; }
}

.reference-panel { min-width: 0; }
.detail-grid { grid-template-columns: minmax(210px, .75fr) minmax(300px, 1.15fr) minmax(250px, .9fr) minmax(250px, .9fr); }
.reference-intake { min-height: 0; overflow: auto; display: grid; gap: 9px; align-content: start; }
.reference-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.reference-form-grid label, .reference-controls label { display: grid; gap: 4px; color: var(--muted); font-size: 11px; }
.reference-form-grid textarea, .reference-controls select {
  width: 100%; min-width: 0; resize: vertical; border: 1px solid rgba(255,255,255,.13); border-radius: 12px; padding: 8px; color: var(--text); background: rgba(0,0,0,.24);
}
.reference-controls { display: grid; grid-template-columns: minmax(110px, .7fr) 1fr .42fr; gap: 8px; align-items: end; }
.reference-controls button, .ref-chip-button {
  border: 1px solid rgba(81,228,255,.28); background: rgba(81,228,255,.08); color: var(--text); border-radius: 12px; padding: 8px 9px; text-align: left; min-height: 34px;
}
.reference-controls button:hover, .ref-chip-button:hover { border-color: rgba(245,189,88,.52); background: rgba(245,189,88,.11); }
.reference-db-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 7px; max-height: 174px; overflow: auto; padding-right: 3px; }
.reference-card { border: 1px solid rgba(255,255,255,.12); border-radius: 13px; padding: 8px; background: rgba(255,255,255,.045); display: grid; gap: 4px; cursor: pointer; }
.reference-card:hover, .reference-card.active { border-color: rgba(245,189,88,.5); background: rgba(245,189,88,.08); }
.reference-card b { color: #fff4dc; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reference-card span { color: var(--muted); font-size: 10.5px; line-height: 1.3; }
.reference-detail { border: 1px solid rgba(255,255,255,.1); border-radius: 14px; background: rgba(0,0,0,.18); padding: 9px; color: #e7dcf8; font-size: 11.5px; line-height: 1.42; white-space: pre-wrap; max-height: 210px; overflow: auto; }
.trait-pill-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.trait-pill { border: 1px solid rgba(124,244,154,.26); color: var(--green); background: rgba(124,244,154,.06); border-radius: 999px; padding: 3px 7px; font-size: 10px; }
@media (max-width: 1280px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 1100px) {
  .reference-form-grid, .reference-controls { grid-template-columns: 1fr; }
}
