/* Living Terminal II: product-layer overrides loaded after module styles. */
@media (max-width: 760px) {
  body[data-route="intelligence"] .s5-shell,
  body[data-route="companies"] .s5-shell,
  body[data-route="tools"] .s5-shell,
  body[data-route="wall"] .s5-shell {
    grid-template-rows: 42px 34px 28px 46px minmax(0, 1fr) 20px;
  }

  .intel-mobile-dock { grid-template-columns: repeat(4, 1fr); }
  .s5-intelligence[data-mobile-surface="MAP"] .intel-rail { display: block; }
  .s5-intelligence[data-mobile-surface="MAP"] .intel-rail > :not(.intel-map-section) { display: none; }
  .s5-intelligence[data-mobile-surface="SOURCES"] .intel-map-section { display: none; }
  .s5-intelligence[data-mobile-surface="MAP"] .intel-map-section {
    grid-template-rows: 40px minmax(0, 1fr) 44px;
    width: 100%;
    height: 100%;
  }
  .s5-intelligence[data-mobile-surface="MAP"] .intel-world-map { min-height: 0; }
  .s5-intelligence[data-mobile-surface="MAP"] .intel-world-map button { min-width: 64px; min-height: 44px; }
  .s5-companies,
  .company-grid,
  .company-panel { width: 100%; min-width: 0; max-width: 100%; }
  .company-grid { overflow: hidden; }
  .company-history { max-width: calc(100vw - 18px); overflow: auto; }
}

.intel-map-section {
  display: grid;
  grid-template-rows: 27px minmax(150px, 1fr) 27px;
  min-height: 205px;
  border-bottom: 1px solid var(--line);
}

.intel-map-section > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
  color: var(--amber);
}

.intel-map-section > header span { color: var(--dim); font-size: 9px; }

.intel-world-map {
  position: relative;
  min-height: 150px;
  overflow: hidden;
  background:
    linear-gradient(25deg, transparent 48%, #182019 49% 51%, transparent 52%) 18px 20px / 58px 33px,
    linear-gradient(-18deg, transparent 46%, #121a14 47% 53%, transparent 54%) 2px 8px / 72px 42px,
    radial-gradient(ellipse at 50% 48%, #09110b, #020302 72%);
}

.intel-world-map::after {
  position: absolute;
  inset: 10% 4%;
  border: 1px solid #1f2a22;
  content: "";
  pointer-events: none;
}

.intel-world-map button {
  position: absolute;
  z-index: 1;
  left: var(--map-x);
  top: var(--map-y);
  display: grid;
  min-width: 54px;
  min-height: 34px;
  padding: 3px 5px;
  transform: translate(-50%, -50%);
  border: 1px solid #34503b;
  color: #dfe8e0;
  background: #050806e8;
  text-align: left;
  font: 9px/1.1 var(--mono);
}

.intel-world-map button::before {
  position: absolute;
  left: -4px;
  top: 50%;
  width: 7px;
  height: 7px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: var(--positive);
  box-shadow: 0 0 0 2px #061009;
  content: "";
}

.intel-world-map button b { color: var(--amber); font-size: 8px; }
.intel-world-map button strong { font-size: 11px; }
.intel-world-map button small { color: var(--dim); font-size: 8px; white-space: nowrap; }
.intel-world-map button[aria-pressed="true"] { border-color: var(--cyan); box-shadow: inset 0 -2px var(--cyan); }
.intel-world-map button:disabled { opacity: .34; }
.intel-map-reset { min-height: 26px; border-top: 1px solid var(--line); color: var(--cyan); font: 900 9px var(--mono); }

@media (min-width: 1121px) {
  .s5-intelligence { grid-template-columns: 250px minmax(0, 1fr) 300px; }
}

@media (min-width: 761px) and (max-width: 1120px) {
  .s5-intelligence {
    grid-template-columns: minmax(0, 1fr) 285px;
    grid-template-rows: 28px 36px minmax(0, 1fr) 44px;
  }
  .intel-mobile-dock {
    display: grid;
    grid-column: 1 / 3;
    grid-row: 4;
    grid-template-columns: repeat(4, 1fr);
  }
  .intel-mobile-dock button { min-height: 42px; border-right: 1px solid var(--line); }
  .s5-intelligence[data-mobile-surface="MAP"] .intel-wire,
  .s5-intelligence[data-mobile-surface="SOURCES"] .intel-wire { display: none; }
  .s5-intelligence[data-mobile-surface="MAP"] .intel-rail,
  .s5-intelligence[data-mobile-surface="SOURCES"] .intel-rail { display: block; grid-column: 1; grid-row: 3; }
  .s5-intelligence[data-mobile-surface="MAP"] .intel-rail > :not(.intel-map-section) { display: none; }
  .s5-intelligence[data-mobile-surface="SOURCES"] .intel-map-section { display: none; }
  .s5-intelligence[data-mobile-surface="MAP"] .intel-map-section { height: 100%; grid-template-rows: 34px minmax(0, 1fr) 36px; }
}

.s5-wall[data-mode="CLOCK"] { grid-template-rows: 48px minmax(0, 1fr); }
.s5-wall[data-mode="CLOCK"] .s5-wall-grid { display: none; }
.s5-wall[data-mode="CLOCK"] .s5-wall-clocks {
  grid-template-columns: 2.25fr repeat(2, 1fr);
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 2px;
}
.s5-wall[data-mode="CLOCK"] .s5-wall-clocks .is-primary-clock { grid-row: 1 / 3; }
.s5-wall[data-mode="CLOCK"] .is-primary-clock strong { font-size: clamp(58px, 8vw, 144px); letter-spacing: -.05em; }
.s5-wall[data-mode="CLOCK"] .is-primary-clock b { font-size: clamp(16px, 2vw, 28px); }
.s5-wall[data-mode="CLOCK"] .s5-wall-clocks div:not(.is-primary-clock) strong { font-size: clamp(24px, 3vw, 54px); }

@media (max-width: 760px) {
  .s5-wall[data-mode="CLOCK"] { grid-template-rows: 74px minmax(0, 1fr); }
  .s5-wall[data-mode="CLOCK"] .s5-wall-clocks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: minmax(180px, 1.4fr) repeat(3, minmax(84px, .7fr));
    overflow: auto;
  }
  .s5-wall[data-mode="CLOCK"] .s5-wall-clocks .is-primary-clock { grid-column: 1 / 3; grid-row: 1; }
  .s5-wall[data-mode="CLOCK"] .is-primary-clock strong { font-size: clamp(48px, 16vw, 78px); }
}

/* Amber is a signal and locator, not a large chrome fill. */
.s5-market-bar > strong,
.s5-desk-flow > header b,
.tools-head b,
.company-head > b,
.intel-controls > b,
.intel-priority > b {
  color: var(--amber, #ff9d00);
  background: #050505;
  box-shadow: inset 2px 0 var(--amber, #ff9d00);
}

.s5-panel > header b {
  color: var(--amber);
  background: transparent;
  box-shadow: inset 2px 0 var(--amber);
}

.s5-workspace-nav button[aria-pressed="true"],
.s5-market-bar button.is-active,
.tools-mobile-dock button[aria-pressed="true"],
.intel-mobile-dock button[aria-pressed="true"],
.company-mobile-dock button[aria-pressed="true"] {
  color: #fff;
  background: #090909;
  box-shadow: inset 0 -2px var(--amber, #ff9d00);
}

.global-nav a.is-contextual[aria-current="page"] { color: var(--text); background: #080808; }
.s5-operator-tabs button[aria-pressed="true"],
.s5-ranges button[aria-pressed="true"],
.s5-indicators button[aria-pressed="true"],
.s5-power-head button[aria-pressed="true"],
.s5-multi-pane button[aria-pressed="true"] {
  color: #fff;
  background: #090909;
  box-shadow: inset 0 -2px var(--amber, #ff9d00);
}

.s5-watch-tools button[aria-pressed="true"],
.s5-mobile-nav button[aria-pressed="true"],
.s5-flow-mobile button[aria-pressed="true"],
.s5-flow [data-flow-instrument][aria-pressed="true"],
.s5-desk-flow [data-desk-flow-instrument][aria-pressed="true"],
.s5-wall-head button[aria-pressed="true"] {
  color: #fff;
  background: #090909;
  box-shadow: inset 0 -2px var(--amber, #ff9d00);
}

.s5-tools {
  grid-template-columns: minmax(430px, 1.2fr) minmax(250px, .58fr) minmax(250px, .62fr);
  grid-template-rows: 34px minmax(210px, .82fr) minmax(220px, 1fr);
  gap: 1px;
  background: #222;
}

.tools-screener { grid-column: 1; grid-row: 2 / 4; }
.tools-risk { grid-column: 2; grid-row: 2; }
.tools-calcs { grid-column: 3; grid-row: 2; display: grid; grid-template-rows: 28px minmax(0, 1fr); }
.tools-operator { grid-column: 2 / 4; grid-row: 3; }
.tools-calcs form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); min-height: 0; overflow: auto; }
.tools-calcs fieldset { display: grid; align-content: start; gap: 3px; min-width: 0; margin: 0; padding: 5px; border: 0; border-right: 1px solid #242424; }
.tools-calcs legend { padding: 0; color: #ff9d00; font-weight: 900; }
.tools-calcs label { display: grid; grid-template-columns: 1fr 1.2fr; align-items: center; gap: 4px; color: #777; }
.tools-calcs input { min-width: 0; min-height: 26px; border: 1px solid #303030; color: #fff; background: #050505; font: inherit; }
.tools-calcs output { display: block; margin-top: 3px; padding: 6px; border-top: 1px solid #303030; color: #fff; font-size: 12px; font-variant-numeric: tabular-nums; }

@media (max-width: 1100px) {
  .s5-tools { grid-template-columns: 1fr; grid-template-rows: 34px minmax(0, 1fr) 50px; }
  .s5-tools .tools-panel { display: none !important; grid-column: 1; grid-row: 2; }
  .s5-tools[data-mobile-surface="SCREENER"] .tools-screener,
  .s5-tools[data-mobile-surface="RISK"] .tools-risk,
  .s5-tools[data-mobile-surface="CALCS"] .tools-calcs,
  .s5-tools[data-mobile-surface="OPS"] .tools-operator { display: grid !important; }
  .tools-mobile-dock { display: grid; grid-template-columns: repeat(4, 1fr); grid-column: 1; grid-row: 3; }
  .tools-mobile-dock button { min-height: 44px; border: 1px solid #242424; color: #aaa; background: #030303; }
}

@media (max-width: 760px) {
  .tools-calcs form { grid-template-columns: 1fr; }
  .tools-calcs fieldset { grid-template-columns: repeat(2, 1fr); border-right: 0; border-bottom: 1px solid #242424; }
  .tools-calcs legend,.tools-calcs output { grid-column: 1 / 3; }
  .tools-calcs input { min-height: 44px; }
}

.company-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 6px 8px;
  background: #252525;
}

.company-kpis > div {
  display: grid;
  gap: 2px;
  padding: 7px;
  background: #030303;
  font-variant-numeric: tabular-nums;
}

.company-kpis b { color: var(--dim); font-size: 9px; }
.company-kpis strong { color: #fff; font-size: 14px; }
.company-kpis small { color: var(--secondary); font-size: 9px; }
.company-relationships { margin: 6px 8px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.company-relationships summary { min-height: 28px; padding: 7px 4px; color: var(--cyan); cursor: pointer; font-weight: 900; }
.company-relationships p { margin: 0; padding: 6px; color: var(--dim); }
.company-financial-trend { display: flex; align-items: end; gap: 3px; height: 72px; margin: 7px 8px 0; padding: 5px; border: 1px solid var(--line); }
.company-financial-trend span { position: relative; display: grid; align-content: end; flex: 1; height: 100%; padding: 2px; background: linear-gradient(to top,#382800 calc(var(--financial-share) * 100%),#070707 calc(var(--financial-share) * 100%)); }
.company-financial-trend i { color: var(--dim); font-style: normal; font-size: 9px; }
.company-financial-trend b { color: #fff; font-size: 9px; }

.s5-desk-bbo {
  position: sticky;
  z-index: 1;
  top: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  min-height: 22px;
  background: #252525;
}

.s5-desk-bbo span { display: flex; align-items: center; justify-content: space-between; padding: 3px 5px; background: #050505; color: #777; }
.s5-desk-bbo b { color: #fff; font-variant-numeric: tabular-nums; }
.s5-desk-tape-head,
.s5-desk-flow [data-desk-tape] > div {
  display: grid;
  grid-template-columns: 55px 1fr .85fr .95fr 38px;
  gap: 4px;
  align-items: center;
  min-height: 18px;
  padding: 2px 5px;
  border-bottom: 1px solid #151515;
  font-variant-numeric: tabular-nums;
}
.s5-desk-tape-head { position: sticky; z-index: 1; top: 0; color: #777; background: #050505; }
.s5-desk-flow [data-desk-tape] > div.is-large { border-left: 2px solid var(--amber); background: #100b03; }

@media (min-width: 1101px) and (max-height: 800px) {
  .s5-market-grid.has-live-desk { grid-template-rows: minmax(170px, 1.05fr) minmax(70px, .42fr) minmax(178px, 1.06fr); }
}
