:root {
  color-scheme: dark;
  --bg: #11110d;
  --bg-soft: #181713;
  --panel: rgba(31, 29, 23, .88);
  --panel-solid: #201d17;
  --panel2: rgba(43, 39, 31, .84);
  --text: #f2eadb;
  --muted: #bdb197;
  --line: rgba(214, 197, 162, .18);
  --moss: #7f9a6d;
  --moss-bright: #a4c68a;
  --copper: #bd7452;
  --rust: #98463a;
  --sand: #d8c7a6;
  --beige: #e9dcc6;
  --cream: #f6eedf;
  --bad: #a64b42;
  --warn: #bd8f55;
  --shadow: rgba(0, 0, 0, .34);
  font-family: "Avenir Next", "SF Pro Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}
* { box-sizing: border-box; }
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  overflow-wrap: break-word;
}
a { color: inherit; }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-body { display: grid; place-items: center; min-height: 100vh; padding: max(20px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom)); }
.login-shell { width: min(100%, 560px); }
.login-card {
  border: 1px solid rgba(215, 198, 163, .28);
  background: var(--panel-solid);
  border-radius: 34px;
  padding: clamp(24px, 6vw, 40px);
  box-shadow: 0 28px 90px rgba(0,0,0,.36), inset 0 1px 0 rgba(255,246,229,.08);
}
.login-brand { display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: center; gap: 18px; margin-bottom: 26px; }
.login-mark, .brand-mark {
  display: inline-grid;
  place-items: center;
  border-radius: 22px;
  color: var(--cream);
  background: var(--moss);
  box-shadow: 0 0 34px rgba(117, 143, 100, .28);
  font-weight: 950;
  letter-spacing: -.05em;
}
.login-mark { width: 72px; height: 72px; font-size: 38px; }
.login-brand h1 { margin: 0; font-size: clamp(38px, 10vw, 62px); line-height: .92; letter-spacing: -.055em; }
.login-brand p { margin: 9px 0 0; color: var(--muted); font-size: clamp(16px, 4vw, 20px); }
.login-form { display: grid; gap: 18px; }
.login-form label, .filters label { display: grid; gap: 7px; color: var(--muted); font-weight: 820; }
.login-form label span, .filters label span { letter-spacing: .01em; }
.login-form input {
  width: 100%;
  min-height: 58px;
  border: 1px solid rgba(215, 198, 163, .24);
  border-radius: 18px;
  background: rgba(14, 13, 10, .72);
  color: var(--text);
  padding: 12px 15px;
  outline: none;
}
.login-form input:focus, .filters input:focus, .filters select:focus { border-color: rgba(159, 190, 133, .72); box-shadow: 0 0 0 3px rgba(117, 143, 100, .16); }
.primary-login, .google-login {
  min-height: 58px;
  border: 0;
  border-radius: 18px;
  font-weight: 900;
  color: #17130f;
}
.primary-login { margin-top: 10px; background: var(--moss-bright); }
.google-login {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  background: var(--sand);
}
.google-login span { width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center; background: rgba(255,255,255,.55); font-weight: 950; }
.login-separator { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin: 20px 0; color: var(--muted); }
.login-separator span { height: 1px; background: var(--line); }
.login-separator em { font-style: normal; }
.login-message { min-height: 18px; margin: 2px 0 0; color: var(--sand); font-size: 13px; opacity: 0; transition: opacity .18s ease; }
.login-message.visible { opacity: 1; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 62px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: env(safe-area-inset-top) 12px 0;
  background: rgba(20, 18, 14, .96);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(215, 198, 163, .13);
}
.topbar-brand { min-width: 0; display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 950; letter-spacing: -.03em; white-space: nowrap; }
.brand-mark { width: 34px; height: 34px; border-radius: 12px; font-size: 19px; }
.connection-strip { display: flex; gap: 7px; min-width: 0; overflow: hidden; white-space: nowrap; justify-content: flex-end; }
.connection-chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; border: 1px solid rgba(215, 198, 163, .16); border-radius: 999px; padding: 6px 9px; color: var(--beige); background: rgba(39, 34, 27, .7); font-size: 11px; font-weight: 850; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.connection-chip.compact { max-width: 96px; }
.status-dot { width: 9px; height: 9px; border-radius: 999px; display: inline-block; background: var(--sand); box-shadow: 0 0 12px rgba(215,198,163,.5); }
.status-dot.online { background: var(--moss-bright); box-shadow: 0 0 15px rgba(159,190,133,.82); }
.status-dot.offline { background: var(--bad); box-shadow: 0 0 15px rgba(179,82,72,.8); }
.status-dot.pending { background: var(--warn); }
.menu-toggle { width: 44px; height: 44px; border: 1px solid rgba(215, 198, 163, .18); border-radius: 15px; background: rgba(39, 34, 27, .72); display: grid; place-items: center; padding: 10px; gap: 4px; }
.menu-toggle span { width: 19px; height: 2px; border-radius: 99px; background: var(--beige); transition: transform .18s ease, opacity .18s ease; }
.menu-toggle.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-toggle.open span:nth-child(2) { opacity: 0; }
.menu-toggle.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.menu-backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .24); }
.app-menu { position: fixed; z-index: 40; top: calc(58px + env(safe-area-inset-top)); right: 12px; width: min(84vw, 280px); padding: 10px; border: 1px solid rgba(215,198,163,.24); border-radius: 22px; background: rgba(39, 34, 27, .97); box-shadow: 0 26px 70px var(--shadow); }
.menu-item { width: 100%; min-height: 44px; display: flex; align-items: center; border: 0; border-radius: 14px; padding: 10px 12px; color: var(--text); background: transparent; text-decoration: none; font-weight: 850; }
.menu-item:hover { background: rgba(215,198,163,.1); }
.menu-item.danger { color: #f0c2ad; }

.app-shell { width: min(100%, 1180px); max-width: 100%; margin: 0 auto; padding: 20px 14px 44px; overflow-x: clip; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 8px; margin: 10px 0 18px; min-width: 0; }
.hero > div:first-child { min-width: 0; }
.eyebrow, .panel-kicker { color: var(--moss-bright); text-transform: uppercase; letter-spacing: .14em; font-weight: 900; font-size: 11px; margin: 0 0 7px; }
h1 { margin: 0; font-size: clamp(42px, 13vw, 76px); line-height: .88; letter-spacing: -.065em; }
h2 { margin: 0; font-size: clamp(20px, 5vw, 31px); letter-spacing: -.035em; }
/* Hero stays minimal: small section label plus Captain AI title. Refresh lives in the menu. */
.loading-state { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; color: var(--sand); font-weight: 850; }
.orbital-loader { width: 24px; height: 24px; border-radius: 999px; border: 3px solid rgba(215,198,163,.22); border-top-color: var(--moss-bright); animation: spin .8s linear infinite; display: inline-block; }
.orbital-loader.small { width: 18px; height: 18px; border-width: 2px; }
.inline-loader { display: flex; align-items: center; gap: 8px; color: var(--sand); }
@keyframes spin { to { transform: rotate(360deg); } }

.summary-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.summary-card, .chart-panel, .quality-panel, .governance-card, .limit-card, .codex-card, .instrument-card, .filters {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 16px 44px rgba(0,0,0,.2), inset 0 1px 0 rgba(255,246,229,.05);
}
.summary-card { border-radius: 22px; padding: 15px 13px; min-height: 108px; display: grid; align-content: center; gap: 8px; }
.summary-card span, .governance-card span { display: block; color: var(--muted); font-size: 12px; font-weight: 850; }
.summary-card strong { display: block; font-size: clamp(34px, 9vw, 48px); line-height: .92; letter-spacing: -.045em; }
.governance-card strong { display: block; margin-top: 3px; font-size: clamp(24px, 7vw, 36px); line-height: 1; letter-spacing: -.04em; }
.governance-card p { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.35; }
.chart-panel, .quality-panel { border-radius: 26px; padding: 15px; display: grid; gap: 14px; }
.donut-wrap { display: grid; place-items: center; padding: 6px 0; }
.status-donut { width: min(64vw, 238px); aspect-ratio: 1; border-radius: 999px; position: relative; display: grid; place-items: center; box-shadow: 0 18px 44px rgba(0,0,0,.22); }
.donut-svg { width: 100%; height: 100%; display: block; }
.donut-value { fill: var(--cream); font-size: 11px; font-weight: 950; paint-order: stroke; stroke: rgba(20,18,14,.74); stroke-width: 4px; stroke-linejoin: round; }
.donut-center { fill: var(--cream); font-size: 22px; font-weight: 950; letter-spacing: -.04em; }
.donut-caption { fill: var(--muted); font-size: 10px; font-weight: 850; }
.status-legend { display: grid; gap: 7px; }
.legend-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.legend-row strong { color: var(--text); }
.legend-dot { width: 10px; height: 10px; border-radius: 999px; }
.quality-note { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; text-align: center; }
.governance-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.governance-card { border-radius: 20px; padding: 13px; }
.governance-card strong { font-size: 20px; line-height: 1.1; }
.governance-ok .governance-card:first-child, .governance-ok .governance-card:nth-child(2) { border-color: rgba(159, 190, 133, .32); }

.filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; min-width: 0; border-radius: 24px; padding: 11px; margin-bottom: 14px; }
.filters label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.filters input, .filters select { width: 100%; min-height: 42px; border: 1px solid rgba(215,198,163,.22); border-radius: 14px; background: rgba(14, 13, 10, .58); color: var(--text); padding: 9px 10px; text-transform: none; letter-spacing: 0; outline: none; }
.filter-search { grid-column: 1 / -1; }
.clear-filters { border: 1px solid var(--line); color: var(--text); background: rgba(39,34,27,.8); border-radius: 14px; padding: 10px; font-weight: 850; grid-column: 1 / -1; }
.empty-state { border: 1px dashed var(--line); color: var(--muted); border-radius: 18px; padding: 18px; text-align: center; background: rgba(39,34,27,.42); }
.instrument-list { display: grid; gap: 12px; min-width: 0; }
.instrument-card { min-width: 0; border-radius: 24px; overflow: hidden; }
.card-button { width: 100%; min-width: 0; border: 0; background: transparent; color: inherit; padding: 13px; display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; text-align: left; }
.logo { width: 48px; height: 48px; border-radius: 16px; background: rgba(14,13,10,.72); object-fit: contain; border: 1px solid var(--line); padding: 3px; }
.card-main { min-width: 0; }
.ticker-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ticker { font-weight: 950; font-size: 18px; letter-spacing: .03em; }
.company { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.headline { color: var(--beige); font-size: 12px; margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.opinion-line { color: var(--muted); font-size: 12px; margin-top: 5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.price-block { min-width: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.price { font-weight: 950; font-size: 16px; }
.date, .earnings-line { color: var(--muted); font-size: 11px; }
.earnings-line { max-width: 8.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 900; border: 1px solid var(--line); color: var(--beige); background: rgba(215,198,163,.08); }
.badge.observe_shadow, .badge.shadow_observe_active { color: #dcedcf; border-color: rgba(159,190,133,.35); background: rgba(117,143,100,.24); }
.badge.shadow_trigger_review, .badge.shadow_invalidated_review, .badge.manual_review { color: #f0d3bb; border-color: rgba(182,106,74,.36); background: rgba(140,63,53,.24); }
.badge.update_card { color: #f3dfb2; border-color: rgba(194,165,106,.36); background: rgba(105,82,46,.24); }
.badge.stale_or_blocked { color: #efd3a2; border-color: rgba(194,148,82,.4); background: rgba(123,73,35,.28); }
.status-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.tag { border: 1px solid var(--line); border-radius: 999px; padding: 3px 7px; color: var(--beige); background: rgba(14,13,10,.38); font-size: 10px; font-weight: 850; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-świeże, .tag-pewność { color: #dcedcf; border-color: rgba(159,190,133,.28); }
.details { border-top: 1px solid var(--line); padding: 12px 13px 15px; background: rgba(14, 13, 10, .34); }
.detail-grid { display: grid; gap: 10px; }
.detail-section { border: 1px solid rgba(215,198,163,.14); background: rgba(39,34,27,.52); border-radius: 18px; padding: 11px; }
.detail-section h3 { margin: 0 0 7px; font-size: 13px; color: var(--moss-bright); text-transform: uppercase; letter-spacing: .08em; }
.detail-section p { margin: 0; color: var(--beige); font-size: 13px; line-height: 1.42; }
.muted-copy { margin-top: 8px !important; color: var(--muted) !important; }
.inline-pills { margin-top: 9px; }
.analysis-boundary { margin-top: 8px !important; color: #dcd0b9 !important; }
.notes-list { margin: 0; padding-left: 18px; color: var(--beige); font-size: 13px; line-height: 1.42; }
.notes-list li + li { margin-top: 6px; }
.meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.meta { background: rgba(14,13,10,.34); border-radius: 13px; padding: 8px; }
.meta span { display:block; color: var(--muted); font-size: 11px; }
.meta strong { display:block; margin-top: 2px; font-size: 13px; }
.level-list { display: grid; gap: 7px; }
.level { display:flex; justify-content:space-between; gap: 12px; border-bottom: 1px dashed rgba(215,198,163,.17); padding-bottom: 6px; font-size: 13px; }
.level small { color: var(--muted); }
.level-main { min-width: 0; display: grid; gap: 4px; }
.level-meta { display: flex; flex-wrap: wrap; gap: 5px; margin: 3px 0; }
.level-note { max-width: 44%; text-align: right; overflow-wrap: anywhere; }
.pills { display:flex; flex-wrap:wrap; gap: 6px; }
.pill { border:1px solid var(--line); border-radius:999px; padding:5px 8px; font-size:11px; color:var(--beige); background: rgba(14,13,10,.24); }
.role-pill { color: #dcedcf; border-color: rgba(159,190,133,.32); }
.alert-row { border-left: 3px solid rgba(215,198,163,.28); padding-left: 8px; }
.alert-high { border-left-color: var(--bad); }
.alert-medium { border-left-color: var(--warn); }
.alert-low { border-left-color: var(--moss); }

.subpage-header { margin: 10px 0 16px; }
.subpage-header h2 { font-size: clamp(31px, 9vw, 54px); }
.subpage-header p { color: var(--muted); margin: 10px 0 0; line-height: 1.45; }
.limits-content { display: grid; gap: 12px; }
.limits-grid { display: grid; gap: 12px; }
.limit-card, .codex-card { border-radius: 24px; padding: 14px; }
.limit-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 11px; }
.limit-head strong { font-size: 19px; }
.limit-head span { color: var(--muted); font-size: 12px; font-weight: 850; }
.limit-bar { height: 11px; border-radius: 999px; background: rgba(14,13,10,.56); overflow: hidden; margin-bottom: 11px; }
.limit-bar span { display: block; height: 100%; background: var(--moss); border-radius: inherit; }
.compact-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.codex-card p { color: var(--muted); line-height: 1.45; margin: 0 0 12px; }

@media (min-width: 760px) {
  .topbar { padding-left: 20px; padding-right: 20px; }
  .app-shell { padding: 30px 22px 60px; }
  .summary-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .governance-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .filters { grid-template-columns: 1.3fr repeat(4, minmax(0, .75fr)) auto; align-items: end; }
  .filter-search, .clear-filters { grid-column: auto; }
  .instrument-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-section.wide { grid-column: 1 / -1; }
  .limits-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .topbar-brand span:last-child { display: none; }
  .connection-strip { justify-content: flex-start; }
  .connection-chip:nth-child(n+4) { display: none; }
  .app-shell { padding-top: 16px; }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .summary-cards, .governance-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .governance-card strong { font-size: 17px; }
  .card-button { grid-template-columns: 42px minmax(0, 1fr); align-items: flex-start; }
  .logo { width: 42px; height: 42px; border-radius: 14px; }
  .price-block { grid-column: 2 / -1; align-items: flex-start; flex-direction: row; flex-wrap: wrap; gap: 5px 8px; margin-top: 4px; }
  .earnings-line { max-width: 100%; }
  .meta-grid { grid-template-columns: minmax(0, 1fr); }
  .level { display: grid; gap: 6px; }
  .level-note { max-width: 100%; text-align: left; }
  .login-card { border-radius: 28px; }
  .login-brand { grid-template-columns: 62px minmax(0, 1fr); }
  .login-mark { width: 62px; height: 62px; border-radius: 20px; }
}

/* Phase 1.2 mockup alignment */
.topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 62px;
}
.connection-strip { justify-content: space-between; gap: 10px; }
.connection-chip { max-width: none; min-height: 36px; padding: 7px 10px; font-size: 12px; }
.connection-chip strong { color: var(--moss-bright); font-weight: 950; }
.connection-chip.role-chip strong { color: var(--cream); }
.role-icon { width: 18px; height: 18px; display: inline-grid; place-items: center; color: var(--sand); font-weight: 950; font-size: 18px; }
.menu-toggle { border-color: transparent; background: transparent; }

.hero { margin: 22px 0 18px; text-align: center; }
.hero-center { width: 100%; display: grid; justify-items: center; gap: 11px; }
.captain-logo { width: min(38vw, 180px); max-width: 180px; filter: drop-shadow(0 14px 24px rgba(0,0,0,.32)); }
.captain-logo svg { display: block; width: 100%; height: auto; }
.cap-top { fill: var(--cream); stroke: var(--sand); stroke-width: 3; }
.cap-band { fill: #25211b; stroke: #0d0c09; stroke-width: 3; }
.cap-visor { fill: #12110e; stroke: #3b3428; stroke-width: 3; }
.cap-rope { fill: none; stroke: var(--copper); stroke-width: 7; stroke-linecap: round; }
.cap-badge { fill: #1b1712; stroke: var(--copper); stroke-width: 4; }
.cap-anchor { fill: none; stroke: var(--sand); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.hero h1 { text-align: center; font-size: clamp(56px, 15vw, 94px); }
.command-panel {
  width: min(100%, 760px);
  min-height: 56px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(182, 106, 74, .88);
  border-radius: 19px;
  background: var(--rust);
  color: var(--sand);
  text-transform: uppercase;
  letter-spacing: .34em;
  font-size: clamp(14px, 3.4vw, 22px);
  font-weight: 950;
  padding: 14px 18px;
  box-shadow: 0 14px 32px rgba(0,0,0,.28), inset 0 1px 0 rgba(244,234,216,.08);
}

.summary-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.summary-card {
  border-radius: 22px;
  min-height: clamp(130px, 27vw, 172px);
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  gap: 10px;
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--panel);
}
.summary-card strong { font-size: clamp(38px, 10vw, 64px); line-height: .86; }
.summary-card span { color: var(--sand); text-transform: uppercase; letter-spacing: .22em; font-size: clamp(10px, 2.4vw, 14px); font-weight: 950; }
.summary-card:active { transform: translateY(1px); }

.quality-panel, .chart-panel { border-radius: 24px; padding: 18px 16px; margin-bottom: 14px; }
.panel-heading { text-align: center; }
.panel-heading h2 { font-size: clamp(22px, 5.5vw, 36px); }
.quality-panel .panel-heading h2 { display: none; }
.quality-panel .panel-kicker, .chart-panel .panel-kicker { margin-bottom: 2px; font-size: clamp(14px, 3.2vw, 19px); color: var(--sand); }
.bar-chart { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 8px; align-items: end; margin-top: 12px; }
.bar-plot { position: relative; min-width: 0; height: 248px; border-left: 1px solid rgba(215,198,163,.52); border-bottom: 1px solid rgba(215,198,163,.52); padding: 0 4px 0; }
.bar-items { position: relative; z-index: 1; height: 100%; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; align-items: end; }
.bar-item { height: 100%; display: grid; grid-template-rows: 24px minmax(0, 1fr) 32px; align-items: end; justify-items: center; gap: 3px; min-width: 0; }
.bar-value { color: var(--cream); font-size: 12px; font-weight: 900; }
.bar-track { width: min(100%, 42px); height: 188px; display: flex; align-items: flex-end; justify-content: center; }
.bar-track span { width: 100%; min-height: 4px; border-radius: 5px 5px 0 0; background: var(--moss); box-shadow: inset 0 1px 0 rgba(244,234,216,.12); }
.bar-item.tone-moss .bar-track span { background: var(--moss); }
.bar-item.tone-moss2 .bar-track span { background: var(--moss-bright); }
.bar-item.tone-sand .bar-track span { background: var(--sand); }
.bar-item.tone-copper .bar-track span { background: var(--copper); }
.bar-item.tone-rust .bar-track span { background: var(--rust); }
.bar-item.tone-brown .bar-track span { background: #815239; }
.bar-item strong { color: var(--cream); font-size: 11px; line-height: 1.05; font-weight: 800; text-align: center; overflow-wrap: anywhere; }
.quality-note { margin-top: 8px; }

.chart-panel { margin-top: 20px; }
.list-context {
  margin: 0 0 12px;
  border: 1px solid rgba(182, 106, 74, .34);
  border-radius: 18px;
  background: rgba(140, 63, 53, .16);
  padding: 12px 13px;
  text-align: center;
}
.list-context strong { display: block; color: var(--cream); font-size: 15px; }
.list-context span { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.35; }

@media (min-width: 760px) {
  .summary-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .quality-panel, .chart-panel { padding: 24px; }
}

@media (max-width: 560px) {
  .topbar { grid-template-columns: minmax(0, 1fr) 44px; }
  .connection-strip { justify-content: flex-start; }
  .connection-chip { font-size: 11px; padding: 6px 8px; }
  .connection-chip.captain-chip { max-width: 46vw; }
  .connection-chip.role-chip { max-width: 32vw; }
  .connection-chip:nth-child(n+3) { display: none; }
  .captain-logo { width: min(39vw, 154px); }
  .command-panel { border-radius: 16px; letter-spacing: .24em; min-height: 50px; }
  .summary-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .summary-card { min-height: 124px; padding: 10px 6px; }
  .summary-card strong { font-size: clamp(38px, 12vw, 54px); }
  .summary-card span { letter-spacing: .18em; font-size: 10px; }
  .quality-panel, .chart-panel { padding: 16px 12px; }
  .bar-chart { grid-template-columns: 36px minmax(0, 1fr); gap: 6px; }
  .bar-plot { height: 224px; }
  .bar-track { height: 170px; width: min(100%, 36px); }
  .bar-items { gap: 5px; }
  .bar-item { grid-template-rows: 22px minmax(0, 1fr) 34px; }
  .bar-item strong { font-size: 10px; }
}

/* Phase 1.3 visual refinement: closer to the approved mobile reference. */
body { background: #11110d; }
.app-shell { padding-top: 18px; }
.topbar {
  min-height: 58px;
  border-bottom-color: rgba(214, 197, 162, .11);
}
.connection-strip { gap: 12px; }
.connection-chip {
  min-height: 34px;
  border-color: rgba(214, 197, 162, .16);
  background: rgba(31, 29, 23, .66);
  color: var(--cream);
  font-weight: 620;
  letter-spacing: -.01em;
}
.connection-chip strong { font-weight: 650; }
.role-icon svg { width: 18px; height: 18px; display: block; fill: none; stroke: var(--sand); stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.menu-toggle span { height: 3px; width: 24px; background: var(--sand); }

.hero { margin: 18px 0 16px; }
.hero-center { gap: 8px; }
.captain-logo { width: min(32vw, 150px); max-width: 150px; filter: drop-shadow(0 16px 20px rgba(0,0,0,.28)); }
.cap-top { fill: #f5ecd8; stroke: #d8c7a6; stroke-width: 2.6; }
.cap-top-shadow { fill: #e4d6bd; opacity: .78; }
.cap-band { fill: #151410; stroke: #0d0c09; stroke-width: 2.4; }
.cap-band-light { fill: none; stroke: rgba(246,238,223,.16); stroke-width: 3.2; stroke-linecap: round; }
.cap-visor { fill: #0b0b09; stroke: #2f2b23; stroke-width: 2.6; }
.cap-visor-light { fill: none; stroke: rgba(216,199,166,.18); stroke-width: 2.4; stroke-linecap: round; }
.cap-rope { fill: none; stroke: #bd7452; stroke-width: 6.2; stroke-linecap: round; }
.cap-badge { fill: #181611; stroke: #bd7452; stroke-width: 4; }
.cap-anchor { fill: none; stroke: #e1d3b4; stroke-width: 3.8; stroke-linecap: round; stroke-linejoin: round; }
.hero h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  font-size: clamp(58px, 14vw, 88px);
  letter-spacing: -.065em;
  color: var(--cream);
  text-shadow: 0 5px 16px rgba(0,0,0,.25);
}
.command-panel {
  margin-top: 4px;
  min-height: 52px;
  border-color: rgba(189, 116, 82, .58);
  background: #98463a;
  color: #ead8b8;
  font-weight: 720;
  letter-spacing: .30em;
  box-shadow: 0 10px 26px rgba(0,0,0,.24), inset 0 1px 0 rgba(246,238,223,.08);
  grid-template-columns: auto auto;
  gap: 14px;
}
.command-icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .74; }

.summary-cards { gap: 10px; margin-bottom: 14px; }
.summary-card {
  min-height: clamp(126px, 25vw, 160px);
  gap: 8px;
  padding: 14px 8px;
  border-color: rgba(214, 197, 162, .18) !important;
  background: rgba(31, 29, 23, .74);
  box-shadow: 0 14px 34px rgba(0,0,0,.20), inset 0 1px 0 rgba(246,238,223,.035);
}
.summary-icon { width: 34px; height: 34px; color: var(--sand); display: grid; place-items: center; margin-bottom: 2px; }
.summary-icon svg, .summary-icon .summary-downloaded-icon { width: 100%; height: 100%; display: block; }
.summary-icon svg { fill: none; stroke: currentColor; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.summary-icon .summary-downloaded-icon { background: currentColor; -webkit-mask: var(--icon-url) center / contain no-repeat; mask: var(--icon-url) center / contain no-repeat; }
.summary-card.tone-moss .summary-icon, .summary-card.tone-moss .summary-label { color: #91b27d; }
.summary-card.tone-copper .summary-icon, .summary-card.tone-copper .summary-label { color: #c47a57; }
.summary-card.tone-rust .summary-icon, .summary-card.tone-rust .summary-label { color: #bd6d5d; }
.summary-card strong {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  font-size: clamp(40px, 10.5vw, 58px);
  letter-spacing: -.04em;
  color: var(--cream);
}
.summary-card span.summary-label {
  font-weight: 650;
  letter-spacing: .24em;
  font-size: clamp(10px, 2.2vw, 13px);
}

.quality-panel, .chart-panel {
  border-color: rgba(214, 197, 162, .18);
  background: rgba(31, 29, 23, .74);
  box-shadow: 0 14px 34px rgba(0,0,0,.20), inset 0 1px 0 rgba(246,238,223,.035);
}
.quality-panel { padding: 18px 14px 17px; }
.panel-heading { text-align: left; padding-left: 38px; position: relative; }
.panel-heading::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 2px;
  width: 18px;
  height: 22px;
  background: currentColor;
  color: var(--sand);
  clip-path: polygon(0 72%, 18% 72%, 18% 100%, 0 100%, 0 72%, 27% 50%, 45% 50%, 45% 100%, 27% 100%, 27% 50%, 54% 27%, 72% 27%, 72% 100%, 54% 100%, 54% 27%, 81% 0, 100% 0, 100% 100%, 81% 100%, 81% 0);
  opacity: .95;
}
.quality-panel .panel-kicker, .chart-panel .panel-kicker {
  color: var(--sand);
  font-weight: 670;
  letter-spacing: .30em;
  font-size: clamp(13px, 3vw, 18px);
  margin-bottom: 6px;
}
.bar-chart { display: block; margin-top: 13px; }
.bar-plot {
  height: 178px;
  border-left: 0;
  border-bottom: 1px solid rgba(214,197,162,.42);
  padding: 0 4px;
}
.bar-items { height: 100%; gap: 10px; }
.bar-item { grid-template-rows: 22px minmax(0, 1fr) 34px; gap: 3px; }
.bar-value { font-size: 13px; font-weight: 700; }
.bar-track { height: 116px; width: min(100%, 30px); }
.bar-track span { border-radius: 5px 5px 0 0; box-shadow: inset 0 1px 0 rgba(246,238,223,.12); }
.bar-item strong { font-weight: 520; font-size: 11px; color: var(--beige); }
.quality-note { margin-top: 12px; color: var(--sand); font-weight: 420; }

@media (max-width: 560px) {
  .app-shell { padding: 14px 18px 44px; }
  .connection-chip { font-size: 11px; min-height: 33px; padding: 6px 9px; }
  .connection-chip.captain-chip { max-width: 45vw; }
  .connection-chip.role-chip { max-width: 34vw; }
  .captain-logo { width: min(31vw, 126px); }
  .hero h1 { font-size: clamp(56px, 13.5vw, 78px); }
  .command-panel { min-height: 50px; border-radius: 16px; letter-spacing: .22em; font-size: clamp(13px, 3.2vw, 18px); }
  .command-icon { width: 19px; height: 19px; }
  .summary-cards { gap: 9px; }
  .summary-card { min-height: 118px; border-radius: 20px; padding: 12px 5px; }
  .summary-icon { width: 30px; height: 30px; }
  .summary-card strong { font-size: clamp(40px, 11vw, 54px); }
  .summary-card span.summary-label { font-size: 9.5px; letter-spacing: .20em; }
  .quality-panel { padding: 16px 11px 15px; }
  .panel-heading { padding-left: 34px; }
  .bar-plot { height: 166px; padding: 0 1px; }
  .bar-items { gap: 7px; }
  .bar-track { height: 100px; width: min(100%, 26px); }
  .bar-item { grid-template-rows: 20px minmax(0, 1fr) 36px; }
  .bar-value { font-size: 12px; }
  .bar-item strong { font-size: 10px; }
}

/* Phase 1.4 reference-match sizing/colors sampled from the approved screenshot. */
:root {
  --ref-bg: #11110d;
  --ref-panel: #25241f;
  --ref-chip: #201f1b;
  --ref-border: rgba(193, 178, 159, .24);
  --ref-cream: #f1e3c6;
  --ref-text: #efe8d8;
  --ref-muted: #bdb197;
  --ref-green: #8ed97e;
  --ref-green-soft: #7c905b;
  --ref-command: #753825;
  --ref-copper: #bd7452;
  --ref-alert: #825747;
  --ref-sand: #bf9b67;
  --ref-rust: #9a4438;
  --ref-brown: #8a5639;
}
body { background: var(--ref-bg); }
.app-shell { padding: 12px 18px 44px; }
.topbar {
  min-height: 55px;
  padding-left: 18px;
  padding-right: 14px;
  background: #11110d;
  border-bottom: 1px solid rgba(193, 178, 159, .12);
}
.connection-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr) minmax(0, .95fr);
  gap: 10px;
  justify-content: stretch;
  align-items: center;
}
.connection-chip {
  min-width: 0;
  max-width: none;
  min-height: 31px;
  border-color: var(--ref-border);
  background: rgba(32, 31, 27, .88);
  border-radius: 999px;
  color: var(--ref-text);
  font-size: 10.5px;
  font-weight: 430;
  line-height: 1.05;
  padding: 5px 8px;
  gap: 6px;
  box-shadow: inset 0 1px 0 rgba(241,227,198,.035);
}
.connection-chip strong {
  color: var(--ref-green);
  font-weight: 500;
}
.connection-chip.role-chip strong { color: var(--ref-text); }
.data-chip strong { color: var(--ref-text); }
.data-chip small {
  display: block;
  color: var(--ref-muted);
  font-size: 9.5px;
  margin-top: 1px;
  font-weight: 390;
}
.status-dot {
  width: 14px;
  height: 14px;
  background: var(--ref-green);
  box-shadow: 0 0 0 7px rgba(142, 217, 126, .16), 0 0 16px rgba(142, 217, 126, .54);
}
.nav-icon svg, .role-icon svg {
  width: 19px;
  height: 19px;
  display: block;
  fill: none;
  stroke: var(--ref-cream);
  stroke-width: 1.95;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.menu-toggle {
  width: 38px;
  height: 38px;
  padding: 9px 5px;
  gap: 4px;
}
.menu-toggle span {
  width: 24px;
  height: 2.5px;
  background: var(--ref-cream);
}
.hero { margin: 18px 0 14px; }
.hero-center { gap: 7px; }
.captain-logo { width: min(29vw, 118px); max-width: 118px; }
.cap-top { fill: #f1e3c6; stroke: #d9caa9; stroke-width: 2.2; }
.cap-top-shadow { fill: #e4d6bd; opacity: .7; }
.cap-band { fill: #14130f; stroke: #080806; stroke-width: 2.2; }
.cap-band-light { stroke: rgba(241,227,198,.14); stroke-width: 2.8; }
.cap-visor { fill: #0c0b09; stroke: #302a20; stroke-width: 2.4; }
.cap-visor-light { stroke: rgba(191,155,103,.22); stroke-width: 2.1; }
.cap-rope { stroke: #bd7452; stroke-width: 5.6; }
.cap-badge { fill: #16120e; stroke: #bd7452; stroke-width: 3.6; }
.cap-anchor { stroke: #e8d7b2; stroke-width: 3.5; }
.hero h1 {
  font-family: "Avenir Next", "SF Pro Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-weight: 520;
  font-size: clamp(52px, 12.5vw, 72px);
  letter-spacing: -.055em;
  line-height: .92;
  color: var(--ref-cream);
  text-shadow: 0 5px 14px rgba(0,0,0,.23);
}
.command-panel {
  width: 100%;
  min-height: 49px;
  border-radius: 14px;
  border-color: rgba(189, 116, 82, .62);
  background: var(--ref-command);
  color: #ead8b8;
  font-size: clamp(13px, 3.1vw, 16px);
  font-weight: 430;
  letter-spacing: .28em;
  gap: 12px;
  padding: 12px 14px;
}
.command-icon { width: 18px; height: 18px; stroke-width: 1.5; opacity: .78; }
.summary-cards { gap: 10px; margin-bottom: 14px; }
.summary-card {
  min-height: 112px;
  border-radius: 17px;
  border-color: var(--ref-border) !important;
  background: rgba(37, 36, 31, .76);
  padding: 10px 5px;
  gap: 5px;
  box-shadow: 0 10px 26px rgba(0,0,0,.18), inset 0 1px 0 rgba(241,227,198,.025);
}
.summary-icon { width: 31px; height: 31px; margin-bottom: 3px; }
.summary-icon svg { stroke-width: 2.05; }
.summary-icon .summary-downloaded-icon { width: 100%; height: 100%; }
.summary-card.tone-moss .summary-icon, .summary-card.tone-moss .summary-label { color: #7fae72; }
.summary-card.tone-copper .summary-icon, .summary-card.tone-copper .summary-label { color: #bd7452; }
.summary-card.tone-rust .summary-icon, .summary-card.tone-rust .summary-label { color: #b56a59; }
.summary-card strong {
  font-family: "SF Compact Rounded", "SF Pro Rounded", "Avenir Next", system-ui, -apple-system, sans-serif;
  font-weight: 450;
  font-size: clamp(34px, 9.1vw, 46px);
  line-height: .9;
  letter-spacing: -.045em;
  color: var(--ref-cream);
}
.summary-card span.summary-label {
  font-weight: 430;
  letter-spacing: .26em;
  font-size: 9.5px;
  line-height: 1.35;
}
.quality-panel, .chart-panel {
  border-radius: 17px;
  border-color: var(--ref-border);
  background: rgba(37, 36, 31, .76);
  box-shadow: 0 10px 26px rgba(0,0,0,.18), inset 0 1px 0 rgba(241,227,198,.025);
}
.quality-panel { padding: 16px 12px 15px; }
.panel-heading {
  text-align: center;
  padding-left: 0;
}
.panel-heading::before { display: none; }
.quality-panel .panel-kicker, .chart-panel .panel-kicker {
  color: #d7c6a3;
  font-weight: 430;
  letter-spacing: .32em;
  font-size: clamp(13px, 3.1vw, 16px);
  margin-bottom: 8px;
}
.bar-chart { margin-top: 8px; }
.bar-plot {
  height: 142px;
  border-bottom: 1px solid rgba(193,178,159,.44);
  padding: 0 3px;
}
.bar-items { gap: 8px; }
.bar-item { grid-template-rows: 20px minmax(0, 1fr) 32px; gap: 2px; }
.bar-value {
  color: var(--ref-cream);
  font-size: 12px;
  font-weight: 430;
}
.bar-track { height: 82px; width: min(100%, 26px); }
.bar-track span { border-radius: 4px 4px 0 0; box-shadow: none; }
.bar-item.tone-moss .bar-track span { background: #6f8d62; }
.bar-item.tone-moss2 .bar-track span { background: #9dbc83; }
.bar-item.tone-sand .bar-track span { background: #d2bf93; }
.bar-item.tone-copper .bar-track span { background: #bd7452; }
.bar-item.tone-rust .bar-track span { background: #9a4438; }
.bar-item.tone-brown .bar-track span { background: #8b5b3f; }
.bar-item strong {
  color: var(--ref-text);
  font-size: 9.7px;
  line-height: 1.08;
  font-weight: 390;
}
.quality-note {
  margin-top: 11px;
  color: var(--ref-muted);
  font-size: 11.5px;
  line-height: 1.35;
  font-weight: 380;
}
@media (max-width: 560px) {
  .app-shell { padding: 12px 18px 44px; }
  .connection-strip { grid-template-columns: 1fr 1.03fr .9fr; gap: 8px; }
  .connection-chip { font-size: 10px; padding: 5px 7px; }
  .connection-chip.captain-chip, .connection-chip.role-chip, .connection-chip.data-chip { max-width: none; }
  .captain-logo { width: min(28vw, 112px); }
  .hero h1 { font-size: clamp(52px, 12.2vw, 68px); }
  .command-panel { min-height: 48px; letter-spacing: .25em; }
  .summary-card { min-height: 108px; }
  .summary-icon { width: 30px; height: 30px; }
  .bar-plot { height: 138px; }
  .bar-track { height: 78px; width: min(100%, 25px); }
  .bar-items { gap: 6px; }
  .bar-item strong { font-size: 9.3px; }
}

/* Phase 1.5 topbar reference correction: inline menu, not pill cards. */
.topbar {
  height: 52px;
  min-height: 52px;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 8px;
  padding: env(safe-area-inset-top) 14px 0 14px;
  background: #11110d;
  border-bottom: 1px solid rgba(193, 178, 159, .12);
  backdrop-filter: none;
}
.connection-strip {
  display: grid;
  grid-template-columns: minmax(0, .92fr) minmax(0, 1.1fr) minmax(0, .92fr);
  gap: 10px;
  align-items: center;
  justify-content: stretch;
  overflow: visible;
}
.connection-chip {
  min-width: 0;
  max-width: none;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--ref-text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 390;
  line-height: 1.08;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.connection-chip strong {
  color: var(--ref-green);
  font-weight: 430;
}
.connection-chip.role-chip strong,
.connection-chip.data-chip strong {
  color: var(--ref-text);
  font-weight: 430;
}
.connection-chip > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-chip small {
  display: block;
  margin-top: 2px;
  color: var(--ref-muted);
  font-size: 9px;
  font-weight: 350;
  line-height: 1;
}
.status-dot {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  border-radius: 999px;
  background: var(--ref-green);
  box-shadow: 0 0 0 6px rgba(142, 217, 126, .17), 0 0 14px rgba(142, 217, 126, .58);
}
.status-dot.online { background: var(--ref-green); box-shadow: 0 0 0 6px rgba(142, 217, 126, .17), 0 0 14px rgba(142, 217, 126, .58); }
.nav-icon,
.role-icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
}
.nav-icon svg,
.role-icon svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: var(--ref-cream);
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.menu-toggle {
  width: 34px;
  height: 34px;
  padding: 7px 4px;
  gap: 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
}
.menu-toggle span {
  width: 23px;
  height: 2.4px;
  background: var(--ref-cream);
}
.app-menu { top: calc(48px + env(safe-area-inset-top)); }

@media (max-width: 560px) {
  .topbar { grid-template-columns: minmax(0, 1fr) 34px; padding-left: 14px; padding-right: 12px; }
  .connection-strip { grid-template-columns: minmax(0, .92fr) minmax(0, 1.05fr) minmax(0, .88fr); gap: 8px; }
  .connection-chip { font-size: 9.7px; gap: 5px; }
  .data-chip small { font-size: 8.6px; }
  .status-dot { width: 14px; height: 14px; box-shadow: 0 0 0 5px rgba(142, 217, 126, .18), 0 0 12px rgba(142, 217, 126, .58); }
  .nav-icon, .role-icon { width: 18px; height: 18px; }
  .nav-icon svg, .role-icon svg { width: 18px; height: 18px; }
  .menu-toggle { width: 32px; height: 32px; }
  .menu-toggle span { width: 22px; height: 2.3px; }
}

/* Phase 1.6 topbar hard match: four visible reference items, no clipping. */
.topbar {
  height: 54px;
  min-height: 54px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  padding: env(safe-area-inset-top) 16px 0 16px;
  background: #11110d;
  overflow: visible;
}
.connection-strip {
  display: grid;
  grid-template-columns: 122px 116px 88px;
  gap: 8px;
  align-items: center;
  justify-content: start;
  overflow: visible;
  white-space: nowrap;
}
.connection-chip {
  display: flex;
  align-items: center;
  min-width: 0;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  color: #efe8d8;
  font-size: 10.5px;
  line-height: 1.05;
  letter-spacing: -.02em;
  font-weight: 390;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.connection-chip span,
.connection-chip strong {
  white-space: nowrap;
}
.connection-chip strong {
  font-weight: 450;
}
.captain-chip strong {
  color: #8ed97e;
}
.data-chip strong,
.role-chip strong {
  color: #efe8d8;
}
.data-chip small {
  display: block;
  color: #bdb197;
  font-size: 9px;
  line-height: 1;
  margin-top: 2px;
  font-weight: 350;
}
.status-dot,
.status-dot.online {
  width: 15px;
  height: 15px;
  min-width: 15px;
  margin-right: 6px;
  border-radius: 50%;
  background: #8ed97e;
  box-shadow: 0 0 0 5px rgba(142,217,126,.22), 0 0 11px rgba(142,217,126,.54);
}
.nav-icon,
.role-icon {
  width: 19px;
  height: 19px;
  min-width: 19px;
  margin-right: 6px;
}
.nav-icon svg,
.role-icon svg {
  width: 19px;
  height: 19px;
  stroke: #f1e3c6;
  stroke-width: 1.9;
}
.menu-toggle {
  width: 34px;
  height: 34px;
  padding: 6px 4px;
  background: transparent;
  border: 0;
  justify-self: end;
}
.menu-toggle span {
  width: 24px;
  height: 2.5px;
  background: #f1e3c6;
}

@media (max-width: 390px) {
  .topbar { padding-left: 12px; padding-right: 10px; }
  .connection-strip { grid-template-columns: 116px 104px 78px; gap: 6px; }
  .connection-chip { font-size: 9.8px; }
  .data-chip small { font-size: 8.4px; }
  .status-dot, .status-dot.online { width: 14px; height: 14px; min-width: 14px; margin-right: 5px; box-shadow: 0 0 0 4px rgba(142,217,126,.22), 0 0 10px rgba(142,217,126,.54); }
  .nav-icon, .role-icon { width: 18px; height: 18px; min-width: 18px; margin-right: 5px; }
  .nav-icon svg, .role-icon svg { width: 18px; height: 18px; }
  .menu-toggle { width: 32px; }
  .menu-toggle span { width: 23px; }
}

/* Phase 1.7 requested corrections: logo, command banner, topbar visibility, chart axes. */
:root { --ref-bg: #171713; }
body { background: #171713; }
.topbar { background: #171713; }
@media (max-width: 560px) {
  .topbar { grid-template-columns: minmax(0, 1fr) 32px; padding-left: 12px; padding-right: 10px; }
  .connection-strip { grid-template-columns: 108px 103px 92px; gap: 6px; }
  .connection-chip { font-size: 9.6px; }
  .role-chip { justify-self: start; }
  .data-chip small { font-size: 8.4px; }
}
@media (max-width: 370px) {
  .connection-strip { grid-template-columns: 102px 98px 86px; gap: 5px; }
  .connection-chip { font-size: 9.1px; }
}
.captain-emblem {
  width: min(27vw, 108px);
  max-width: 108px;
  filter: drop-shadow(0 14px 22px rgba(0,0,0,.28));
}
.emblem-ring {
  fill: rgba(37,36,31,.62);
  stroke: #bf9b67;
  stroke-width: 3;
}
.emblem-shield {
  fill: #753825;
  stroke: #bd7452;
  stroke-width: 3.2;
}
.emblem-anchor,
.emblem-wave {
  fill: none;
  stroke: #f1e3c6;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.emblem-wave { stroke-width: 4; opacity: .72; }
.command-panel {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  text-align: center;
}
.command-icon { display: none !important; }
.hero h1 { font-weight: 440; letter-spacing: -.045em; }
.summary-card strong {
  font-family: "SF Pro Display", "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-weight: 420;
}
.summary-icon svg { stroke-width: 1.9; }
.quality-panel { padding: 16px 12px 15px; }
.bar-chart {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 7px;
  align-items: end;
  margin-top: 10px;
}
.bar-axis {
  height: 148px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #f1e3c6;
  font-size: 10px;
  font-weight: 360;
  text-align: right;
  padding-right: 2px;
}
.bar-plot {
  position: relative;
  height: 176px;
  border-left: 1px solid rgba(193,178,159,.55);
  border-bottom: 1px solid rgba(193,178,159,.55);
  padding: 0 2px;
}
.bar-lines {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 28px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}
.bar-lines span { display: block; border-top: 1px dashed rgba(193,178,159,.16); }
.bar-items { position: relative; z-index: 1; height: 100%; gap: 7px; }
.bar-item { grid-template-rows: 20px minmax(0, 1fr) 34px; }
.bar-track { height: 116px; width: min(100%, 28px); }
.bar-item strong {
  color: #f1e3c6;
  opacity: .86;
  font-size: 9.3px;
  font-weight: 350;
}
.bar-item.tone-moss .bar-track span { background: #6f8d62; }
.bar-item.tone-moss2 .bar-track span { background: #9dbc83; }
.bar-item.tone-sand .bar-track span { background: #d0bd8f; }
.bar-item.tone-copper .bar-track span { background: #bd7452; }
.bar-item.tone-rust .bar-track span { background: #a64a3f; }
.bar-item.tone-brown .bar-track span { background: #8c5a3e; }
.quality-note { color: #bdb197; opacity: .78; }

/* Phase 1.8 topbar role visibility fix: override older mobile rule hiding the third chip. */
@media (max-width: 560px) {
  .connection-strip {
    grid-template-columns: 110px 96px 82px;
    gap: 8px;
  }
  .connection-chip,
  .connection-chip:nth-child(n+3),
  .connection-chip.captain-chip,
  .connection-chip.data-chip,
  .connection-chip.role-chip {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-width: none !important;
  }
  .connection-chip { font-size: 9.3px; }
  .role-chip { justify-self: start; }
  .role-icon { display: inline-grid !important; }
}
@media (max-width: 370px) {
  .connection-strip {
    grid-template-columns: 104px 91px 76px;
    gap: 6px;
  }
  .connection-chip { font-size: 8.7px; }
  .nav-icon, .role-icon { width: 17px; height: 17px; min-width: 17px; margin-right: 4px; }
  .nav-icon svg, .role-icon svg { width: 17px; height: 17px; }
}

/* Phase 1.9 topbar centering: center status group within the space before hamburger. */
.topbar {
  grid-template-columns: minmax(0, 1fr) 34px;
}
.connection-strip {
  width: min(100%, 326px);
  margin-inline: auto;
  justify-content: center;
}
@media (max-width: 560px) {
  .connection-strip {
    width: min(100%, 316px);
    margin-inline: auto;
    justify-content: center;
  }
}
@media (max-width: 390px) {
  .connection-strip {
    width: min(100%, 302px);
    grid-template-columns: 108px 98px 80px;
    gap: 6px;
  }
}
@media (max-width: 370px) {
  .connection-strip {
    width: min(100%, 286px);
    grid-template-columns: 101px 91px 76px;
    gap: 5px;
  }
}


/* Phase 1.10 topbar data age and contrast. */
.connection-chip,
.connection-chip span,
.connection-chip strong,
.connection-chip.role-chip strong,
.connection-chip.data-chip strong {
  color: #f6eedf;
}
.data-chip small { display: none; }
.nav-icon svg,
.role-icon svg {
  stroke: #f6eedf;
}
@media (max-width: 560px) {
  .connection-strip { grid-template-columns: 110px 95px 82px; }
  .connection-chip { font-size: 9.6px; }
}
@media (max-width: 370px) {
  .connection-strip { grid-template-columns: 104px 88px 76px; }
  .connection-chip { font-size: 9px; }
}

/* Mobile topbar readability: force only the three literal labels to white. */
.topbar-label {
  color: #ffffff !important;
}

/* Phase 1.13 connected state and menu polish. */
.topbar-label {
  color: #fffdf6 !important;
}
.captain-chip .captain-state,
.captain-chip strong.captain-state {
  color: #8ed878 !important;
  text-shadow: 0 0 7px rgba(142, 216, 120, .22);
}
.status-dot,
.status-dot.online {
  width: 19px;
  height: 19px;
  min-width: 19px;
  margin-right: 8px;
  background: #8ed878;
  box-shadow: 0 0 0 4px rgba(142,216,120,.22), 0 0 12px rgba(142,216,120,.46);
}
@media (max-width: 560px) {
  .status-dot,
  .status-dot.online {
    width: 18px;
    height: 18px;
    min-width: 18px;
    margin-right: 6px;
  }
}
.app-menu {
  background: rgba(28, 27, 22, .98);
  border-color: rgba(191, 155, 103, .24);
  box-shadow: 0 22px 58px rgba(0, 0, 0, .42), inset 0 1px 0 rgba(241, 227, 198, .035);
  padding: 8px;
}
.menu-item {
  gap: 10px;
  min-height: 42px;
  padding: 9px 10px;
  border-radius: 12px;
  color: #f1e3c6;
  font-weight: 380;
  letter-spacing: .01em;
}
.menu-item:hover,
.menu-item:focus-visible {
  background: rgba(191, 155, 103, .11);
  outline: none;
}
.menu-item.danger {
  color: #d99a84;
}
.menu-icon {
  width: 19px;
  height: 19px;
  min-width: 19px;
  display: inline-grid;
  place-items: center;
  color: #bf9b67;
}
.menu-item.danger .menu-icon {
  color: #d99a84;
}
.menu-icon svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Phase 1.14 dropdown width trim. */
.app-menu {
  width: min(72vw, 230px);
  right: 14px;
  padding: 8px;
}
.menu-item {
  min-height: 40px;
  padding: 8px 10px;
  gap: 10px;
}
@media (max-width: 560px) {
  .app-menu {
    width: min(68vw, 220px);
    right: 14px;
  }
}
@media (max-width: 390px) {
  .app-menu {
    width: min(66vw, 208px);
    right: 12px;
  }
}

/* Phase 1.15 user-verified diode and dropdown sizing. */
.status-dot,
.status-dot.online {
  width: 12px;
  height: 12px;
  min-width: 12px;
  margin-right: 8px;
  box-shadow: 0 0 0 4px rgba(142, 216, 120, .22), 0 0 12px rgba(142, 216, 120, .46);
}
.app-menu {
  width: min(72vw, 170px);
  right: 14px;
}
@media (max-width: 560px) {
  .status-dot,
  .status-dot.online {
    width: 12px;
    height: 12px;
    min-width: 12px;
    margin-right: 6px;
  }
  .app-menu {
    width: min(62vw, 170px);
    right: 12px;
  }
}
@media (max-width: 390px) {
  .app-menu {
    width: min(58vw, 164px);
    right: 10px;
  }
}


/* Phase 1.16 uploaded Captain logo asset. */
.captain-logo-img {
  display: block;
  width: min(30vw, 112px);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 14px 22px rgba(0,0,0,.28));
}
.captain-emblem,
.emblem-ring,
.emblem-shield,
.emblem-anchor,
.emblem-wave {
  display: none !important;
}
@media (max-width: 560px) {
  .captain-logo-img {
    width: min(29vw, 108px);
  }
}

/* Phase 1.18 horizontal Captain brand lockup. */
.hero-center {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-areas:
    "logo title"
    "command command";
  align-items: center;
  justify-content: center;
  column-gap: 16px;
  row-gap: 12px;
}
.captain-logo-img {
  grid-area: logo;
  width: clamp(58px, 16vw, 92px);
  max-width: 92px;
  filter: drop-shadow(0 12px 20px rgba(0,0,0,.28));
}
.hero h1 {
  grid-area: title;
  font-family: "Avenir Next", "SF Pro Display", "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: clamp(54px, 15vw, 92px);
  font-weight: 520;
  letter-spacing: -.06em;
  line-height: .9;
}
.command-panel {
  grid-area: command;
  margin-top: 0;
}
@media (max-width: 560px) {
  .hero-center {
    column-gap: 12px;
    row-gap: 11px;
  }
  .captain-logo-img {
    width: clamp(54px, 15vw, 78px);
    max-width: 78px;
  }
  .hero h1 {
    font-size: clamp(52px, 14.5vw, 78px);
  }
}
@media (max-width: 370px) {
  .hero-center { column-gap: 9px; }
  .captain-logo-img { width: clamp(48px, 14vw, 68px); }
  .hero h1 { font-size: clamp(46px, 13.5vw, 68px); }
}

/* Phase 1.19 larger logo and full-width command panel. */
.hero-center {
  width: 100%;
  grid-template-columns: auto auto;
}
.captain-logo-img {
  width: clamp(76px, 21vw, 124px);
  max-width: 124px;
}
.command-panel {
  width: 100%;
  max-width: none;
  justify-self: stretch;
}
@media (max-width: 560px) {
  .captain-logo-img {
    width: clamp(70px, 20vw, 100px);
    max-width: 100px;
  }
  .command-panel {
    width: 100%;
  }
}
@media (max-width: 370px) {
  .captain-logo-img {
    width: clamp(62px, 19vw, 88px);
  }
}

/* Phase 1.20 two-column Captain hero. */
.hero-center {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(96px, 34%) minmax(0, 1fr);
  grid-template-rows: 2fr 1fr;
  grid-template-areas:
    "logo title"
    "logo command";
  align-items: stretch;
  justify-content: stretch;
  column-gap: 16px;
  row-gap: 8px;
}
.captain-logo-img {
  grid-area: logo;
  align-self: center;
  justify-self: center;
  width: clamp(112px, 31vw, 176px);
  max-width: 176px;
}
.hero h1 {
  grid-area: title;
  align-self: end;
  justify-self: start;
  font-size: clamp(42px, 11vw, 68px);
  line-height: .92;
  margin: 0;
}
.command-panel {
  grid-area: command;
  align-self: start;
  justify-self: stretch;
  width: 100%;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 13px;
  font-size: clamp(10px, 2.55vw, 14px);
  letter-spacing: .22em;
}
@media (max-width: 560px) {
  .hero-center {
    grid-template-columns: minmax(96px, 34%) minmax(0, 1fr);
    column-gap: 12px;
    row-gap: 7px;
  }
  .captain-logo-img {
    width: clamp(108px, 32vw, 142px);
    max-width: 142px;
  }
  .hero h1 {
    font-size: clamp(40px, 10.6vw, 58px);
  }
  .command-panel {
    min-height: 34px;
    padding: 7px 10px;
    border-radius: 12px;
    font-size: clamp(9px, 2.35vw, 12px);
    letter-spacing: .18em;
  }
}
@media (max-width: 370px) {
  .hero-center {
    grid-template-columns: minmax(86px, 33%) minmax(0, 1fr);
    column-gap: 9px;
  }
  .captain-logo-img {
    width: clamp(92px, 31vw, 124px);
  }
  .hero h1 {
    font-size: clamp(34px, 10vw, 50px);
  }
  .command-panel {
    min-height: 31px;
    font-size: clamp(8px, 2.15vw, 10px);
    letter-spacing: .14em;
  }
}

/* Phase 1.22 Captain-left logo-right brand row. */
.hero-center {
  width: 100%;
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "title logo"
    "command command";
  align-items: center;
  justify-content: center;
  column-gap: 16px;
  row-gap: 12px;
}
.hero h1 {
  grid-area: title;
  align-self: center;
  justify-self: end;
  font-size: clamp(52px, 14vw, 88px);
  line-height: .9;
  margin: 0;
}
.captain-logo-img {
  grid-area: logo;
  align-self: center;
  justify-self: start;
  width: clamp(82px, 22vw, 132px);
  max-width: 132px;
}
.command-panel {
  grid-area: command;
  width: 100%;
  max-width: none;
  justify-self: stretch;
  align-self: center;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: clamp(12px, 3vw, 16px);
  letter-spacing: .24em;
}
@media (max-width: 560px) {
  .hero-center {
    column-gap: 12px;
    row-gap: 11px;
  }
  .hero h1 {
    font-size: clamp(50px, 13.5vw, 76px);
  }
  .captain-logo-img {
    width: clamp(76px, 21vw, 108px);
    max-width: 108px;
  }
  .command-panel {
    min-height: 44px;
    padding: 9px 12px;
    font-size: clamp(11px, 2.75vw, 14px);
    letter-spacing: .21em;
  }
}
@media (max-width: 370px) {
  .hero-center { column-gap: 9px; }
  .hero h1 { font-size: clamp(44px, 12.8vw, 66px); }
  .captain-logo-img { width: clamp(66px, 20vw, 94px); }
  .command-panel {
    min-height: 40px;
    font-size: clamp(9px, 2.45vw, 12px);
    letter-spacing: .16em;
  }
}

/* Phase 1.23 compact hero command spacing. */
.hero-center {
  row-gap: 0;
}
.command-panel {
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 11px;
  font-size: clamp(10px, 2.65vw, 14px);
  letter-spacing: .20em;
}
@media (max-width: 560px) {
  .hero-center {
    row-gap: 0;
  }
  .command-panel {
    min-height: 32px;
    padding: 5px 10px;
    border-radius: 10px;
    font-size: clamp(9px, 2.35vw, 12px);
    letter-spacing: .16em;
  }
}
@media (max-width: 370px) {
  .command-panel {
    min-height: 30px;
    padding: 4px 8px;
    border-radius: 9px;
    font-size: clamp(8px, 2.1vw, 10px);
    letter-spacing: .12em;
  }
}

/* Phase 1.24 dashboard cards and chart polish. */
.hero {
  margin-bottom: 24px;
}
.command-panel {
  font-weight: 650;
}
.summary-cards {
  gap: 16px;
  margin-top: 2px;
  margin-bottom: 18px;
}
.summary-card {
  min-height: 118px;
  padding: 12px 7px;
}
.summary-card strong {
  font-size: clamp(34px, 8.8vw, 46px);
  font-weight: 500;
  letter-spacing: -.045em;
}
.summary-icon {
  width: 32px;
  height: 32px;
}
.summary-icon svg {
  stroke-width: 2.05;
}
.summary-card.tone-copper .summary-icon,
.summary-card.tone-copper .summary-label {
  color: #d7c6a3;
}
.summary-card.tone-rust .summary-icon,
.summary-card.tone-rust .summary-label {
  color: #c87560;
}
.summary-label {
  font-weight: 430;
}
.quality-note strong {
  color: #f1e3c6;
  font-weight: 520;
}
.chart-panel {
  overflow: visible;
}
.donut-svg {
  width: min(100%, 330px);
  max-width: 330px;
  overflow: visible;
}
.donut-callout-svg {
  display: block;
  margin: 0 auto;
}
.donut-callout path {
  fill: none;
  stroke-width: 1.2;
  opacity: .92;
}
.donut-callout text {
  fill: #f1e3c6;
  font-size: 8.6px;
  font-weight: 390;
  letter-spacing: .01em;
}
.donut-center {
  font-weight: 500;
}
.status-legend {
  display: none;
}
@media (max-width: 560px) {
  .hero {
    margin-bottom: 22px;
  }
  .summary-cards {
    gap: 12px;
    margin-bottom: 17px;
  }
  .summary-card {
    min-height: 112px;
  }
  .summary-card strong {
    font-size: clamp(32px, 8.4vw, 42px);
  }
  .summary-icon {
    width: 30px;
    height: 30px;
  }
  .donut-svg {
    width: min(100%, 310px);
  }
  .donut-callout text {
    font-size: 7.8px;
  }
}
@media (max-width: 370px) {
  .summary-cards {
    gap: 9px;
  }
  .summary-card strong {
    font-size: clamp(30px, 8vw, 38px);
  }
  .donut-svg {
    width: min(100%, 292px);
  }
  .donut-callout text {
    font-size: 7.1px;
  }
}

/* Phase 1.25 data-quality chart baseline and legend. */
.bar-chart {
  align-items: start;
}
.bar-axis {
  height: 138px;
  padding-top: 0;
}
.bar-plot {
  height: 138px;
  padding: 0 2px;
}
.bar-lines {
  bottom: 0;
}
.bar-items {
  height: 100%;
  align-items: end;
}
.bar-item {
  grid-template-rows: 20px minmax(0, 1fr);
  align-items: end;
}
.bar-track {
  height: 110px;
  align-self: end;
}
.quality-label-row {
  grid-column: 2;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
  margin-top: 7px;
  padding-left: 0;
  color: #d7c6a3;
  font-size: 9.5px;
  font-weight: 360;
  text-align: center;
  line-height: 1.1;
}
.quality-label-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.quality-note {
  text-align: left;
}
.quality-legend {
  display: grid;
  gap: 6px 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 4px;
}
.quality-legend-item {
  display: flex;
  align-items: baseline;
  gap: 5px;
  color: #bdb197;
  font-size: 11.5px;
  line-height: 1.28;
}
.quality-legend-item i {
  width: 7px;
  height: 7px;
  min-width: 7px;
  border-radius: 999px;
  transform: translateY(-1px);
}
.quality-legend-item strong {
  color: #f1e3c6;
  font-weight: 520;
}
.quality-legend-item.tone-moss i { background: #6f8d62; }
.quality-legend-item.tone-moss2 i { background: #9dbc83; }
.quality-legend-item.tone-sand i { background: #d0bd8f; }
.quality-legend-item.tone-copper i { background: #bd7452; }
.quality-legend-item.tone-rust i { background: #a64a3f; }
.quality-legend-item.tone-brown i { background: #8c5a3e; }
@media (max-width: 560px) {
  .bar-axis, .bar-plot { height: 130px; }
  .bar-track { height: 104px; }
  .quality-label-row { gap: 5px; font-size: 8.6px; }
  .quality-legend { grid-template-columns: 1fr; gap: 5px; }
  .quality-legend-item { font-size: 10.8px; }
}

/* Phase 1.26 data-quality axis and guide-line alignment. */
.bar-chart {
  display: block;
}
.bar-axis {
  display: none;
}
.bar-plot {
  width: 100%;
}
.bar-lines {
  display: block;
  position: absolute;
  inset: 0 0 0 0;
}
.bar-lines span {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed rgba(193,178,159,.18);
}
.bar-lines span:nth-child(1) { top: 0; display: none; }
.bar-lines span:nth-child(2) { top: 25%; }
.bar-lines span:nth-child(3) { top: 50%; }
.bar-lines span:nth-child(4) { top: 75%; }
.quality-label-row {
  grid-column: auto;
  width: 100%;
  padding-left: 2px;
  padding-right: 2px;
  box-sizing: border-box;
}

/* Phase 1.27 chart guide scale and donut readability. */
.section-heading h2 {
  display: none;
}
.bar-plot {
  height: 150px;
}
.bar-track {
  height: 150px;
}
.bar-lines span:nth-child(1) { display: none; }
.bar-lines span:nth-child(2) { top: 25%; }
.bar-lines span:nth-child(3) { top: 50%; }
.bar-lines span:nth-child(4) { top: 75%; }
.donut-wrap {
  margin-top: 4px;
}
.donut-svg {
  width: min(100%, 390px);
  max-width: 390px;
}
.donut-callout text {
  fill: #fff7e8;
  font-size: 10.2px;
  font-weight: 620;
  letter-spacing: .01em;
}
.donut-callout path {
  stroke-width: 1.45;
  opacity: .96;
}
.donut-segment-value {
  fill: #11110d;
  font-size: 10px;
  font-weight: 400;
  paint-order: stroke fill;
  stroke: rgba(244, 234, 216, .22);
  stroke-width: 1.4px;
}
@media (max-width: 560px) {
  .bar-plot, .bar-track { height: 138px; }
  .donut-svg {
    width: min(100%, 360px);
  }
  .donut-callout text {
    font-size: 9.4px;
  }
  .donut-segment-value {
    font-size: 9.2px;
  }
}
@media (max-width: 370px) {
  .bar-plot, .bar-track { height: 130px; }
  .donut-svg {
    width: min(100%, 330px);
  }
  .donut-callout text {
    font-size: 8.6px;
  }
  .donut-segment-value {
    font-size: 8.4px;
  }
}

/* Phase 1.28 restore data-quality chart proportions and legend color. */
.bar-plot {
  height: 138px;
}
.bar-track {
  height: 110px;
}
.quality-legend-item {
  color: navajowhite !important;
}
@media (max-width: 560px) {
  .bar-plot { height: 130px; }
  .bar-track { height: 104px; }
}
@media (max-width: 370px) {
  .bar-plot { height: 130px; }
  .bar-track { height: 104px; }
}

/* Phase 1.29 remove distribution panel and lighten filter typography. */
.filters,
.filters label,
.filters label span,
.filters select,
.filters input,
.filters button,
.clear-filters {
  font-weight: 360 !important;
}
.filters label span {
  letter-spacing: .14em;
}
.filters select,
.filters input {
  font-weight: 350 !important;
}
.clear-filters {
  font-weight: 380 !important;
}

/* Phase 1.30 data-quality guide lines relative to bar baseline. */
.bar-lines span:nth-child(1) { display: none; }
.bar-lines span:nth-child(2) { top: 80.1%; } /* 25% of 110px bar track from 138px plot baseline */
.bar-lines span:nth-child(3) { top: 60.1%; } /* 50% */
.bar-lines span:nth-child(4) { top: 40.2%; } /* 75% */
@media (max-width: 560px) {
  .bar-lines span:nth-child(2) { top: 80%; } /* 25% of 104px from 130px */
  .bar-lines span:nth-child(3) { top: 60%; }
  .bar-lines span:nth-child(4) { top: 40%; }
}
@media (max-width: 370px) {
  .bar-lines span:nth-child(2) { top: 80%; }
  .bar-lines span:nth-child(3) { top: 60%; }
  .bar-lines span:nth-child(4) { top: 40%; }
}

/* Phase 1.31 white UI typography for dark background. */
:root {
  --ref-text: #fffdf6;
  --ref-cream: #fffdf6;
  --text: #fffdf6;
  --muted: #fff5e5;
}
body,
.dashboard-shell,
.hero h1,
.command-panel,
.summary-card,
.summary-card strong,
.summary-label,
.chart-panel,
.chart-panel h2,
.chart-panel h3,
.quality-panel,
.quality-panel h2,
.quality-note,
.quality-legend-item,
.quality-legend-item strong,
.quality-label-row,
.filters,
.filters label,
.filters label span,
.filters input,
.filters select,
.filters button,
.clear-filters,
.instrument-card,
.instrument-card h3,
.instrument-card p,
.instrument-card span,
.instrument-card strong,
.instrument-meta,
.empty-state,
.loading-text,
.login-shell,
.login-card,
.login-card h1,
.login-card p,
.login-card label,
.login-card input,
.limits-view,
.limits-view h2,
.limits-view h3,
.limits-view p,
.app-menu,
.menu-item {
  color: #fffdf6 !important;
}
.hero h1 {
  text-shadow: 0 0 10px rgba(255, 253, 246, .16);
}
.filters input::placeholder {
  color: rgba(255, 253, 246, .62) !important;
}
.filters input,
.filters select,
.login-card input {
  border-color: rgba(255, 253, 246, .24);
}
.quality-label-row,
.quality-note,
.quality-legend-item {
  color: #fff5e5 !important;
}

/* Phase 1.32 user-verified title and filter typography. */
.hero h1 {
  text-shadow: 0 0 10px rgba(105, 88, 29, .16);
  padding: 0 0 0 20px;
  font-family: fangsong;
}
.filters,
.filters label,
.filters label span,
.filters select,
.filters input,
.filters button,
.clear-filters {
  font-weight: 560 !important;
}


/* Phase 1.33 loader copy and typography. */
.loading-text,
.loading-state,
.loading-state p,
.loading-state span,
.loading-label {
  color: #fffdf6 !important;
  font-weight: 360 !important;
}

/* Phase 1.34 centered loader alignment. */
.loading-state,
.loading-shell,
.loading-view,
#loading-state {
  min-height: 52vh;
  display: grid;
  place-items: center;
  text-align: center;
}
.loading-state > *,
.loading-shell > *,
.loading-view > *,
#loading-state > * {
  justify-self: center;
}
.loading-text,
.loading-state p,
.loading-state span,
.loading-label {
  font-weight: 460 !important;
  text-align: center;
}
.spinner,
.loading-spinner {
  margin-left: auto;
  margin-right: auto;
}

/* Phase 1.35 loader horizontal-only centering. */
.loading-state,
.loading-shell,
.loading-view,
#loading-state {
  min-height: unset !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center;
}
.loading-state .loader,
.loading-state .loading-content,
.loading-state > p,
.loading-shell .loader,
.loading-view .loader,
#loading-state .loader {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 10px;
  margin-left: auto;
  margin-right: auto;
}
.loading-state .spinner,
.loading-state .loading-spinner,
.spinner,
.loading-spinner {
  order: 2;
  margin-left: 0;
  margin-right: 0;
}
.loading-text,
.loading-state p,
.loading-state span,
.loading-label {
  order: 1;
  font-weight: 460 !important;
  text-align: center;
}
@media (max-width: 560px) {
  .loading-state,
  .loading-shell,
  .loading-view,
  #loading-state {
    min-height: unset !important;
  }
  .loading-state .loader,
  .loading-state .loading-content,
  .loading-state > p,
  .loading-shell .loader,
  .loading-view .loader,
  #loading-state .loader {
    gap: 8px;
  }
}

/* Phase 1.36 keep loader hidden after data loads. */
.loading-state[hidden],
.loading-shell[hidden],
.loading-view[hidden],
#loading-state[hidden] {
  display: none !important;
}

/* Phase 1.39 center filter labels above their controls. */
.filters label {
  text-align: center;
  align-items: stretch;
}
.filters label > span {
  display: block;
  width: 100%;
  text-align: center;
}
.filters input,
.filters select {
  text-align: center;
  text-align-last: center;
}
.filters input::placeholder {
  text-align: center;
}

/* Phase 1.40 keep filter labels centered, restore control text left alignment. */
.filters input,
.filters select {
  text-align: left;
  text-align-last: left;
}
.filters input::placeholder {
  text-align: left;
}

/* Phase 1.41 human decision stages on cards. */
.badge.stage-observation { color: #f8fff0; border-color: rgba(159,190,133,.42); background: rgba(117,143,100,.28); }
.badge.stage-activation { color: #fff0df; border-color: rgba(194,165,106,.42); background: rgba(148,95,45,.30); }
.badge.stage-decision { color: #fff1ec; border-color: rgba(200,117,96,.46); background: rgba(140,63,53,.32); }
.badge.stage-position { color: #eef8ff; border-color: rgba(116,160,185,.42); background: rgba(54,86,103,.30); }
.badge.stage-context { color: #fff7e8; border-color: rgba(215,198,163,.34); background: rgba(93,80,61,.30); }
.status-tags .tag { font-weight: 560; }

/* Phase 1.42 collapsed card decision score and simplified capsules. */
.filters label[for="filter-freshness"], .status-tags[hidden] { display: none !important; }
.identity-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.identity-row .ticker { font-size: 20px; font-weight: 650; letter-spacing: .02em; }
.identity-row .company { font-size: 13px; font-weight: 430; opacity: .92; }
.capsule-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 7px; }
.score-badge, .source-badge { border: 1px solid rgba(255,253,246,.22); border-radius: 999px; padding: 4px 8px; font-size: 11px; line-height: 1; white-space: nowrap; color: #fffdf6; }
.source-badge { background: rgba(255,253,246,.08); }
.score-badge.score-0_20 { background: rgba(136,54,45,.42); border-color: rgba(200,95,75,.52); }
.score-badge.score-21_40 { background: rgba(158,82,54,.40); border-color: rgba(206,123,88,.48); }
.score-badge.score-41_60 { background: rgba(137,111,67,.40); border-color: rgba(213,188,137,.44); }
.score-badge.score-61_80 { background: rgba(104,132,82,.42); border-color: rgba(165,199,132,.48); }
.score-badge.score-81_100 { background: rgba(78,132,77,.48); border-color: rgba(156,214,138,.52); }
.instrument-card .headline { margin-top: 10px; line-height: 1.42; }
.instrument-card .opinion-line:empty { display: none; }
.price-block .date { display: none; }
.price-block .change { font-size: 12px; font-weight: 520; }
.price-block .change.positive { color: #aee29b !important; }
.price-block .change.negative { color: #e58b78 !important; }
.price-block .change.neutral { color: #fff5e5 !important; }
@media (max-width: 560px) {
  .identity-row .ticker { font-size: 19px; }
  .identity-row .company { font-size: 12px; }
  .score-badge, .source-badge { font-size: 10.5px; padding: 4px 7px; }
}

/* Phase 1.43 card capsule alignment and score-first ordering. */
.capsule-row { align-items: center; }
.capsule-row .score-badge { order: 1; }
.capsule-row .badge { order: 2; }
.capsule-row .source-badge { order: 3; }
.badge, .score-badge, .source-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  line-height: 1;
  padding: 6px 10px;
  font-weight: 560;
}
.score-badge { font-weight: 650; min-width: 54px; }
.source-badge { font-weight: 520; }
.price-block { justify-content: center; }
.price-block .earnings-line:not(:empty) {
  font-weight: 650;
  color: #fffdf6 !important;
}
@media (max-width: 560px) {
  .badge, .score-badge, .source-badge { min-height: 26px; padding: 5px 9px; }
  .price-block { align-items: center; }
}

/* Phase 1.44 left-align price and hide empty price metadata. */
.price-block {
  justify-content: flex-start !important;
  text-align: left;
}
.price-block .change[hidden],
.price-block .earnings-line:empty {
  display: none !important;
}

/* Phase 1.45 richer collapsed card layout and fast-read styling. */
.card-button {
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: flex-start;
  padding: 18px 16px 17px;
  gap: 13px;
}
.logo {
  margin-top: 2px;
}
.card-main {
  display: grid;
  gap: 0;
}
.identity-row {
  gap: 10px;
  align-items: baseline;
}
.identity-row .ticker {
  font-size: clamp(24px, 7vw, 36px);
  line-height: .95;
  font-weight: 720;
  letter-spacing: .015em;
}
.identity-row .company {
  font-size: clamp(15px, 4.2vw, 22px);
  color: #fffdf6 !important;
  opacity: .9;
  line-height: 1.1;
  white-space: normal;
}
.capsule-row {
  gap: 9px;
  margin-top: 13px;
  margin-bottom: 14px;
}
.badge, .score-badge, .source-badge {
  min-height: 31px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: clamp(13px, 3.65vw, 18px);
  font-weight: 550;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.score-badge {
  min-width: 74px;
  font-weight: 670;
}
.source-badge {
  background: rgba(255,253,246,.07);
  border-color: rgba(255,253,246,.30);
}
.instrument-card .headline {
  color: #f1e5cf !important;
  font-size: clamp(15px, 4vw, 20px);
  line-height: 1.52;
  margin-top: 0;
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}
.price-block {
  grid-column: 2 / -1;
  display: flex;
  flex-direction: row;
  align-items: center !important;
  justify-content: flex-start !important;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 17px;
}
.price {
  color: #ead7b7 !important;
  font-size: clamp(24px, 6.8vw, 34px);
  line-height: 1;
  font-weight: 590;
  letter-spacing: -.035em;
}
.price-block .change {
  font-size: clamp(14px, 4vw, 20px);
  font-weight: 650;
}
.price-block .change.positive { color: #46bf67 !important; }
.price-block .change.negative { color: #ff343f !important; }
.price-block .earnings-line:not(:empty) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255,253,246,.28);
  background: transparent;
  color: #fffdf6 !important;
  font-size: clamp(13px, 3.5vw, 18px);
  font-weight: 520;
  line-height: 1;
  white-space: nowrap;
  max-width: none;
}
@media (max-width: 560px) {
  .card-button {
    grid-template-columns: 44px minmax(0, 1fr);
    padding: 17px 15px 16px;
    gap: 12px;
  }
  .logo { width: 44px; height: 44px; }
  .capsule-row { gap: 8px; margin-top: 12px; margin-bottom: 13px; }
  .badge, .score-badge, .source-badge { min-height: 28px; padding: 5px 12px; }
  .score-badge { min-width: 64px; }
  .price-block { gap: 7px 14px; margin-top: 16px; }
}

/* Phase 1.46 four-panel collapsed card layout. */
.card-button {
  display: grid;
  grid-template-columns: 1fr;
  padding: 18px 17px 17px;
  gap: 0;
}
.card-header-panel {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 13px;
  width: 100%;
}
.card-header-panel .logo {
  width: 48px;
  height: 48px;
  margin: 0;
}
.identity-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 9px;
  min-width: 0;
}
.identity-row .ticker {
  font-size: clamp(26px, 7.4vw, 38px);
  line-height: .95;
  font-weight: 720;
}
.identity-row .company {
  font-size: clamp(14px, 4vw, 21px);
  line-height: 1.1;
  min-width: 0;
  max-width: 100%;
}
.capsule-row {
  width: 100%;
  margin: 13px 0 13px;
  gap: 8px;
  justify-content: flex-start;
}
.instrument-card .headline {
  width: 100%;
  color: #f2e6d0 !important;
  font-size: clamp(14px, 3.65vw, 18px);
  line-height: 1.45;
  margin: 0;
  grid-column: 1 / -1;
}
.price-block {
  width: 100%;
  grid-column: 1 / -1;
  display: flex;
  flex-flow: row nowrap;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 10px;
  margin-top: 17px;
  min-width: 0;
}
.price {
  color: #f0ddbd !important;
  font-size: clamp(22px, 6.4vw, 32px);
  font-weight: 590;
  flex: 0 0 auto;
}
.price-block .change {
  font-size: clamp(13px, 3.6vw, 18px);
  font-weight: 650;
  flex: 0 0 auto;
}
.price-block .earnings-line:not(:empty) {
  min-height: 26px;
  padding: 4px 10px;
  font-size: clamp(11px, 3.15vw, 15px);
  font-weight: 500;
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 560px) {
  .card-button { padding: 17px 15px 16px; }
  .card-header-panel { grid-template-columns: 44px minmax(0, 1fr); gap: 11px; }
  .card-header-panel .logo { width: 44px; height: 44px; }
  .capsule-row { margin: 12px 0 12px; gap: 7px; }
  .badge, .score-badge, .source-badge { font-size: clamp(12px, 3.45vw, 16px); min-height: 27px; padding: 5px 10px; }
  .score-badge { min-width: 60px; }
  .instrument-card .headline { font-size: clamp(13px, 3.5vw, 16px); line-height: 1.42; }
  .price-block { gap: 8px; margin-top: 15px; }
}
@media (max-width: 380px) {
  .price-block { gap: 6px; }
  .price { font-size: clamp(20px, 6vw, 27px); }
  .price-block .change { font-size: clamp(12px, 3.3vw, 16px); }
  .price-block .earnings-line:not(:empty) { font-size: clamp(10px, 2.9vw, 13px); padding: 4px 8px; }
}

/* Phase 1.47 card copy cleanup and smaller ticker. */
.identity-row .ticker {
  font-size: clamp(22px, 6.15vw, 32px);
  font-weight: 710;
}
.instrument-card .headline {
  font-size: clamp(13px, 3.45vw, 16px);
  line-height: 1.42;
}
.price-block .earnings-line:empty {
  display: none !important;
}
@media (max-width: 560px) {
  .identity-row .ticker { font-size: clamp(21px, 6vw, 30px); }
  .instrument-card .headline { font-size: clamp(12.5px, 3.35vw, 15.5px); }
}

/* Expanded-card price chart: read-only analytical view. */
.price-chart-section { overflow: hidden; }
.price-chart-block { display: grid; gap: 10px; min-width: 0; }
.chart-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.chart-toolbar strong { display: block; color: var(--ref-cream, var(--cream)); font-size: 14px; }
.chart-current-price { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.chart-range-controls { display: inline-flex; gap: 5px; padding: 3px; border: 1px solid rgba(214,197,162,.16); border-radius: 999px; background: rgba(14,13,10,.28); }
.chart-range-button { min-width: 38px; min-height: 30px; border: 0; border-radius: 999px; color: var(--beige); background: transparent; font-size: 11px; font-weight: 760; }
.chart-range-button.active { color: #10100d; background: var(--sand); }
.price-chart-status { color: var(--muted); font-size: 12px; min-height: 20px; }
.price-chart-canvas { width: 100%; min-height: 260px; border: 1px solid rgba(214,197,162,.12); border-radius: 16px; overflow: hidden; background: rgba(14,13,10,.26); }
.empty-chart-state { min-height: 230px; display: grid; place-items: center; padding: 18px; color: var(--muted); text-align: center; }
.chart-level-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.chart-legend-item, .chart-legend-empty { display: inline-flex; align-items: center; gap: 6px; border: 1px solid rgba(214,197,162,.16); border-radius: 999px; padding: 5px 8px; color: var(--beige); background: rgba(14,13,10,.26); font-size: 10.5px; line-height: 1.1; }
.chart-legend-item i { width: 9px; height: 9px; border-radius: 999px; background: var(--sand); flex: 0 0 auto; }
.chart-legend-item strong { max-width: 190px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 650; }
.chart-legend-item em { color: var(--muted); font-style: normal; }
.chart-entry_watch i { background: #8ed97e; }
.chart-trim_take_profit i { background: #d8c7a6; }
.chart-risk_exit i { background: #bd7452; }
.chart-pullback_rebuy i { background: #7f9a6d; }
.chart-boundary { margin-top: 2px !important; font-size: 12px !important; }
.fallback-price-svg { width: 100%; height: auto; display: block; }
.chart-candle line { stroke-width: 1.1; }
.chart-candle rect { stroke-width: .8; }
.chart-candle.up line, .chart-candle.up rect { stroke: #8ed97e; fill: rgba(142,217,126,.32); }
.chart-candle.down line, .chart-candle.down rect { stroke: #bd7452; fill: rgba(189,116,82,.35); }
.chart-overlay-line line { stroke: var(--sand); stroke-width: 1.2; stroke-dasharray: 6 5; }
.chart-overlay-line text { fill: var(--beige); font-size: 10px; paint-order: stroke; stroke: rgba(14,13,10,.82); stroke-width: 3px; stroke-linejoin: round; }
.chart-overlay-line.chart-entry_watch line { stroke: #8ed97e; }
.chart-overlay-line.chart-trim_take_profit line { stroke: #d8c7a6; }
.chart-overlay-line.chart-risk_exit line { stroke: #bd7452; }
.chart-overlay-line.chart-pullback_rebuy line { stroke: #7f9a6d; }

@media (max-width: 560px) {
  .chart-toolbar { grid-template-columns: minmax(0, 1fr); }
  .chart-range-controls { justify-self: start; }
  .price-chart-canvas { min-height: 238px; }
  .chart-legend-item strong { max-width: 132px; }
}
