/* ============================================================
   CSS VARIABLES — mapped to the shared tool theme (../shared/rm-tools.css)
   Light is the default; :root[data-theme="dark"] is set by rm-tools.js.
   Blue = values and links, gold (amber) = highlights, as before.
   ============================================================ */
:root {
  --bg:           var(--rm-bg);
  --bg-card:      var(--rm-surface);
  --bg-card2:     var(--rm-surface-2);
  --bg-hover:     var(--rm-primary-soft);
  --border:       var(--rm-border);
  --border-dim:   var(--rm-border);
  --text:         var(--rm-text);
  --text-sec:     var(--rm-muted);
  --text-dim:     var(--rm-muted);
  --blue:         #1a5fb4;
  --gold:         #8a5300;
  --green:        var(--rm-success);
  --red:          var(--rm-danger);
  --svg-sf:       #d6e6f7;
  --svg-ss:       #1a5fb4;
  --svg-gold:     #8a5300;
  --svg-red:      #c0392b;
  --svg-dim:      #52708f;
  --svg-cl:       #a9bccf;
  --svg-tdim:     #52708f;
  --svg-text:     #0b2a4a;
}
:root[data-theme="dark"] {
  --blue:         #7cb8ff;
  --gold:         #ffb020;
  --svg-sf:       #163a63;
  --svg-ss:       #7cb8ff;
  --svg-gold:     #ffb020;
  --svg-red:      #ff7a6b;
  --svg-dim:      #9ebfe0;
  --svg-cl:       #2f557f;
  --svg-tdim:     #9ebfe0;
  --svg-text:     #e8f2ff;
}

:root {
  --header-h: 65px;   /* height of the shared tool bar (.rm-bar), which stays at the top */
  --sidebar-w: 260px;
  --footer-h: 48px;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--rm-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; border: none; background: none; }
.mono { font-family: var(--rm-mono); }

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
#loading-overlay.hidden { display: none; }
.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  font-family: var(--rm-mono);
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ============================================================
   HEADER
   ============================================================ */
#site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--hf-bg);
  border-bottom: 1px solid var(--hf-border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 1000;
  gap: 12px;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.header-brand svg { width: 30px; height: 30px; }
.brand-title {
  font-family: var(--rm-mono);
  font-size: 1.05rem;
  color: var(--hf-text);
  line-height: 1.2;
}
.au-badge {
  background: #f0a500;
  color: #1a1a1a;
  font-family: var(--rm-mono);
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 3px;
  padding: 1px 5px;
  letter-spacing: 0.04em;
}
.brand-sub {
  font-family: var(--rm-mono);
  font-size: 0.68rem;
  color: var(--hf-text-dim);
  margin-top: 1px;
}
.header-spacer { flex: 1; }
.header-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}
.header-nav a {
  font-family: var(--rm-body);
  font-size: 0.88rem;
  color: var(--hf-text-dim);
  padding: 5px 10px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
.header-nav a:hover {
  background: rgba(255,255,255,0.08);
  color: var(--hf-text);
  text-decoration: none;
}
.grade-badge {
  background: rgba(240,165,0,0.15);
  color: #f0a500;
  border: 1px solid rgba(240,165,0,0.4);
  font-family: var(--rm-mono);
  font-size: 0.72rem;
  border-radius: 20px;
  padding: 2px 10px;
  margin: 0 6px;
}

/* Theme Toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s;
  color: var(--hf-text-dim);
}
.theme-toggle:hover { background: rgba(255,255,255,0.08); }
.theme-toggle svg { width: 14px; height: 14px; flex-shrink: 0; }
.toggle-track {
  width: 38px; height: 22px;
  background: #444c56;
  border-radius: 11px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}
.toggle-knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
body.is-light .toggle-track { background: #58a6ff; }
body.is-light .toggle-knob { transform: translateX(16px); }
.toggle-label {
  font-family: var(--rm-mono);
  font-size: 0.72rem;
  color: var(--hf-text-dim);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sp-layout { display: flex; align-items: flex-start; }
#sidebar {
  position: sticky;
  top: var(--header-h);
  flex-shrink: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 900;
  padding-bottom: 20px;
}
#sidebar::-webkit-scrollbar { width: 5px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.sidebar-search {
  padding: 10px 12px 6px;
}
.sidebar-search input {
  width: 100%;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: var(--rm-mono);
  font-size: 0.78rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.sidebar-search input:focus { border-color: var(--gold); }
.sidebar-search input::placeholder { color: var(--text-dim); }

.sidebar-nav-label {
  font-family: var(--rm-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 10px 16px 6px;
}
.sidebar-home {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-family: var(--rm-mono);
  font-size: 0.82rem;
  color: var(--text-sec);
  cursor: pointer;
  transition: background 0.13s, color 0.13s;
  margin-bottom: 4px;
  user-select: none;
}
.sidebar-home:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-home.active { color: var(--blue); }

.sidebar-group { margin-bottom: 2px; }
.sidebar-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  cursor: pointer;
  font-family: var(--rm-body);
  font-size: 0.85rem;
  color: var(--text-sec);
  transition: background 0.13s, color 0.13s;
  user-select: none;
}
.sidebar-group-header:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-group-abbr {
  font-family: var(--rm-mono);
  font-size: 0.78rem;
  color: var(--gold);
  min-width: 38px;
}
.sidebar-group-name { flex: 1; font-size: 0.82rem; }
.sidebar-arrow {
  width: 14px; height: 14px;
  color: var(--text-dim);
  transition: transform 0.18s;
  flex-shrink: 0;
}
.sidebar-group.open .sidebar-arrow { transform: rotate(90deg); }
.sidebar-children { display: none; }
.sidebar-group.open .sidebar-children { display: block; }

.sidebar-leaf {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 16px 5px 38px;
  font-family: var(--rm-mono);
  font-size: 0.8rem;
  color: var(--text-sec);
  cursor: pointer;
  transition: background 0.13s, color 0.13s;
  border-left: 3px solid transparent;
  position: relative;
}
.sidebar-leaf::before {
  content: '';
  position: absolute;
  left: 26px;
  top: 50%;
  width: 6px; height: 1px;
  background: var(--border);
}
.sidebar-leaf:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-leaf.active {
  color: var(--gold);
  background: rgba(240,165,0,0.07);
  border-left: 3px solid var(--gold);
}

/* ============================================================
   BREADCRUMB
   ============================================================ */
#breadcrumb {
  position: sticky;
  top: var(--header-h);
  z-index: 800;
  background: var(--bg-card2);
  border-bottom: 1px solid var(--border-dim);
  padding: 8px 24px;
  font-family: var(--rm-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
}
.bc-sep { margin: 0 6px; color: var(--text-dim); }
.bc-link { color: var(--blue); cursor: pointer; }
.bc-link:hover { text-decoration: underline; }
.bc-current { color: var(--gold); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
#main-content {
  flex: 1;
  min-width: 0;
  padding-bottom: 28px;
  min-height: calc(100vh - var(--header-h));
}

/* ============================================================
   HOME PAGE
   ============================================================ */
#view-home { padding: 24px; }
.home-hero {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 36px 32px;
  text-align: center;
  max-width: 760px;
  margin: 0 auto 32px;
}
.home-hero-icon { margin-bottom: 16px; }
.home-hero-icon svg { width: 56px; height: 56px; }
.home-title {
  font-family: var(--rm-mono);
  font-size: 1.6rem;
  color: var(--gold);
  margin-bottom: 10px;
  line-height: 1.2;
}
.home-subtitle {
  font-family: var(--rm-mono);
  font-size: 0.85rem;
  color: var(--text-sec);
  margin-bottom: 28px;
}
.home-stats {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}
.stat-box {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 24px;
  text-align: center;
  min-width: 110px;
}
.stat-value {
  font-family: var(--rm-mono);
  font-size: 1.8rem;
  color: var(--blue);
  font-weight: 700;
  line-height: 1;
}
.stat-label {
  font-family: var(--rm-body);
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 4px;
}
.home-section-label {
  font-family: var(--rm-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  max-width: 1000px;
  margin-left: auto;
  margin-right: auto;
}
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  max-width: 1000px;
  margin: 0 auto;
}
.home-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 3px solid transparent;
  border-radius: 8px;
  padding: 16px 18px;
  cursor: pointer;
  transition: border-top-color 0.15s, background 0.13s, transform 0.12s;
}
.home-card:hover {
  border-top-color: var(--gold);
  background: var(--bg-hover);
  transform: translateY(-2px);
}
.home-card-abbr {
  font-family: var(--rm-mono);
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 4px;
}
.home-card-name {
  font-family: var(--rm-body);
  font-size: 0.82rem;
  color: var(--text-sec);
  margin-bottom: 10px;
  line-height: 1.3;
}
.home-card-count {
  font-family: var(--rm-mono);
  font-size: 0.78rem;
  color: var(--blue);
}
.home-card-desc {
  font-family: var(--rm-body);
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 6px;
  line-height: 1.4;
}

/* ============================================================
   PROFILE DETAIL PAGE
   ============================================================ */
#view-profile { padding: 20px 24px; display: none; }
.profile-header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-dim);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
}
.profile-header-text { flex: 1; }
.profile-title {
  font-family: var(--rm-mono);
  font-size: 2rem;
  color: var(--gold);
  line-height: 1.1;
}
.profile-subtitle {
  font-family: var(--rm-body);
  font-size: 0.9rem;
  color: var(--text-sec);
  margin-top: 4px;
}
.profile-table-ref {
  display: inline-block;
  background: rgba(88,166,255,0.1);
  border: 1px solid rgba(88,166,255,0.3);
  color: var(--blue);
  font-family: var(--rm-mono);
  font-size: 0.72rem;
  border-radius: 4px;
  padding: 2px 8px;
  margin-top: 8px;
}

/* Top detail grid: cross-section | dimension table */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
/* Bottom detail grid: dim schematic | gauge table */
.detail-grid-lower {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  .detail-grid, .detail-grid-lower { grid-template-columns: 1fr; }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.card-header {
  background: var(--bg-card2);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  font-family: var(--rm-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-header-badge {
  background: rgba(240,165,0,0.15);
  color: var(--gold);
  border: 1px solid rgba(240,165,0,0.3);
  font-size: 0.68rem;
  border-radius: 3px;
  padding: 1px 5px;
}
.card-body { padding: 16px; }
.card-body-nopad { padding: 0; }

/* SVG Container */
.svg-container {
  width: 100%;
  background: var(--bg-card2);
  border-radius: 4px;
  overflow: hidden;
}
.svg-container svg {
  display: block;
  width: 100%;
  height: auto;
}

/* ============================================================
   DATA TABLES
   ============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--rm-mono);
  font-size: 0.88rem;
}
.data-table th {
  background: var(--bg-card2);
  color: var(--text-sec);
  font-weight: 400;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-dim);
  color: var(--text);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }
.val-blue  { color: var(--blue);  font-weight: 700; }
.val-gold  { color: var(--gold);  font-weight: 700; }
.val-green { color: var(--green); font-weight: 700; }
.val-red   { color: var(--red);   font-weight: 700; }
.val-dim   { color: var(--text-dim); }
.pref-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.8em;
  font-family: var(--rm-mono);
}
.pref-1 { background: rgba(63,185,80,0.12);   color: var(--green); border: 1px solid rgba(63,185,80,0.3); }
.pref-2 { background: rgba(240,165,0,0.12);   color: var(--gold);  border: 1px solid rgba(240,165,0,0.3); }
.pref-3 { background: rgba(255,123,114,0.12); color: var(--red);   border: 1px solid rgba(255,123,114,0.3); }
.pref-note { color: var(--text-dim); font-size: 0.8em; }

/* ============================================================
   DIMENSION TABLE — with desc column
   ============================================================ */
.dim-desc {
  font-family: var(--rm-body);
  font-size: 0.76rem;
  color: var(--text-dim);
}

/* ============================================================
   NOTES CARD
   ============================================================ */
.notes-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
}
.notes-body {
  padding: 14px 18px;
  font-family: var(--rm-body);
  font-size: 0.82rem;
  color: var(--text-sec);
  line-height: 1.6;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 6px 20px;
}
.note-item { display: flex; gap: 8px; }
.note-key {
  font-family: var(--rm-mono);
  color: var(--gold);
  flex-shrink: 0;
  min-width: 28px;
}

/* ============================================================
   FOOTER
   ============================================================ */
/* Standards / disclaimer strip, above the shared site footer */
#site-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 20px;
  padding: 12px 20px;
  background: var(--bg-card2);
  border-top: 1px solid var(--border);
}
.footer-col {
  flex: 1;
  font-family: var(--rm-mono);
  font-size: 0.74rem;
  color: var(--text-sec);
  text-align: center;
}
.footer-col:first-child { text-align: left; }
.footer-col:last-child  { text-align: right; }
.footer-gold { color: var(--gold); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px 32px;
  max-width: 520px;
  width: 90%;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px; right: 14px;
  background: none; border: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }
.modal-title {
  font-family: var(--rm-mono);
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 14px;
}
.modal-body {
  font-family: var(--rm-body);
  font-size: 0.88rem;
  color: var(--text-sec);
  line-height: 1.65;
}
.modal-body p { margin-bottom: 10px; }
.modal-body strong { color: var(--text); }
.modal-body ul { padding-left: 16px; margin-bottom: 10px; }
.modal-body li { margin-bottom: 4px; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
/* Phones / small tablets: the profile list becomes a drawer, opened with the "Profiles" button */
@media (max-width: 820px) {
  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: min(300px, 86vw); height: auto;
    z-index: 1100;
    transform: translateX(-105%);
    transition: transform .25s ease;
    box-shadow: var(--rm-shadow-lg);
  }
  #sidebar.open { transform: none; }
  .sp-nav .grade-badge { display: none; }
  .footer-col, .footer-col:first-child, .footer-col:last-child { flex-basis: 100%; text-align: left; }
}
@media (min-width: 821px) { .sp-profiles-btn { display: none; } }
@media (max-width: 700px) {
  .detail-grid, .detail-grid-lower { grid-template-columns: 1fr; }
  .home-title { font-size: 1.2rem; }
  #view-profile { padding: 12px; }
  .profile-title { font-size: 1.4rem; }
}

/* ============================================================
   TOOL BAR ADDITIONS (shared .rm-bar from rm-tools.css)
   ============================================================ */
.ibeam { fill: var(--blue); }
.rm-logo-mark .ibeam { width: 22px; height: 22px; fill: var(--rm-amber); }
.rm-logo .au-badge { font: 700 .62rem var(--rm-mono); padding: 2px 5px; border-radius: 3px; vertical-align: middle; }
.sp-nav .grade-badge { font: .72rem var(--rm-mono); }
.home-hero-icon .ibeam { fill: var(--blue); }
.home-title, .profile-title, .modal-title { font-family: var(--rm-head); letter-spacing: .02em; }
/* Phones: the logo mark already goes home, so drop the Home button and the name to fit the bar */
@media (max-width: 560px) { .sp-home-btn, .rm-logo > span:last-child { display: none; } }
