/* Token Intell - responsive layer for the standalone web/*.html exports (canvas frame 1440px, inline styles).
   Everything lives inside max-width media queries so >=1440px renders exactly as the canvas export.
   Inline styles are beaten with !important. Breakpoints: fluid desktop <=1439, tablet 768-1023, phone <=767. */

.ti-nav-btn, .ti-scrim { display: none; }

/* ---------- Fluid desktop: 1024-1439 (also the base for tablet/phone) ---------- */
@media (max-width: 1439.98px) {
  html, body { min-height: 100vh; }
  body { display: block !important; padding: 0 !important; }
  .ti { width: 100% !important; height: auto !important; min-height: 100vh; overflow-x: clip !important; overflow-y: visible !important; }

  /* shell: sidebar + column */
  .ti > div:first-child:has(> aside[aria-label="Main navigation"]) { min-height: 100vh; height: auto !important; }
  .ti aside[aria-label="Main navigation"] {
    position: sticky; top: 0; align-self: flex-start; height: 100vh; overflow-y: auto;
  }
  .ti aside[aria-label="Main navigation"] + div { min-width: 0; }
  .ti aside[aria-label="Main navigation"] + div > main { overflow: visible !important; min-width: 0; }
  .ti aside[aria-label="Main navigation"] + div > header { min-width: 0; }
  .ti aside[aria-label="Main navigation"] + div > header > div:first-of-type {
    flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .ti aside[aria-label="Main navigation"] + div > header > .field {
    flex: 0 1 280px; width: auto !important; min-width: 0;
  }
  .ti aside[aria-label="Main navigation"] + div > header > .field > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ti aside[aria-label="Main navigation"] + div > header > .btn { flex-shrink: 0; }
}

/* ---------- Tablet: 768-1023 -> 64px icon rail ---------- */
@media (max-width: 1023.98px) and (min-width: 768px) {
  .ti aside[aria-label="Main navigation"] {
    width: 64px !important; padding: 16px 8px !important; align-items: stretch;
  }
  .ti aside[aria-label="Main navigation"] > div:first-child { justify-content: center; padding: 2px 0 14px !important; }
  .ti aside[aria-label="Main navigation"] > div:first-child > b { display: none; }
  .ti aside[aria-label="Main navigation"] > button.btn { justify-content: center !important; padding: 0 !important; gap: 0 !important; }
  .ti aside[aria-label="Main navigation"] > button.btn > :not(:first-child) { display: none; }
  .ti aside[aria-label="Main navigation"] .nav .lab { display: none; }
  .ti aside[aria-label="Main navigation"] .nav a { position: relative; justify-content: center; padding: 0 !important; height: 40px; }
  .ti aside[aria-label="Main navigation"] .nav a > .chip { display: none; }
  .ti aside[aria-label="Main navigation"] .nav a > span:not(.chip) {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; flex: none !important;
  }
  .ti aside[aria-label="Main navigation"] > div:last-child { justify-content: center; padding: 12px 0 0 !important; }
  .ti aside[aria-label="Main navigation"] > div:last-child > a { display: flex !important; justify-content: center; }
  .ti aside[aria-label="Main navigation"] > div:last-child > a > :not(:first-child) { display: none; }
  .ti aside[aria-label="Main navigation"] + div > header { padding: 0 20px !important; gap: 10px !important; }
  .ti aside[aria-label="Main navigation"] + div > header > .field { flex-basis: 220px; }
  .ti aside[aria-label="Main navigation"] + div > main { padding: 20px !important; }
}

/* ---------- Phone: <=767 -> off-canvas drawer ---------- */
@media (max-width: 767.98px) {
  html.ti-nav-open, html.ti-nav-open body { overflow: hidden; }

  .ti aside[aria-label="Main navigation"] {
    position: fixed !important; top: 0; bottom: 0; left: 0; height: auto !important; align-self: auto;
    width: min(288px, 86vw) !important; z-index: 60; overflow-y: auto; overscroll-behavior: contain;
    transform: translateX(-100%); visibility: hidden;
    transition: transform .2s ease, visibility 0s linear .2s;
    box-shadow: 0 0 32px rgba(15, 16, 36, .28);
  }
  html.ti-nav-open .ti aside[aria-label="Main navigation"] { transform: none; visibility: visible; transition: transform .2s ease; }
  .ti-scrim { position: fixed; inset: 0; z-index: 50; background: rgba(15, 16, 36, .5); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
  html.ti-nav-open .ti-scrim { display: block; opacity: 1; pointer-events: auto; }
  @media (prefers-reduced-motion: reduce) {
    .ti aside[aria-label="Main navigation"], .ti-scrim { transition: none !important; }
  }

  /* tap targets in the drawer */
  .ti aside[aria-label="Main navigation"] .nav a { height: 44px !important; }
  .ti aside[aria-label="Main navigation"] > button.btn { height: 44px !important; }
  .ti aside[aria-label="Main navigation"] > div:last-child { min-height: 44px; }

  /* topbar: row 1 = menu, crumbs, date, theme; row 2 = search */
  .ti aside[aria-label="Main navigation"] + div > header {
    height: auto !important; flex-wrap: wrap; padding: 10px 16px !important; gap: 8px !important; align-items: center;
  }
  .ti-nav-btn {
    display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px; padding: 0; margin-left: -6px;
    border: 0; border-radius: 8px; background: transparent; color: var(--mu); font-family: inherit; cursor: pointer;
  }
  .ti-nav-btn:focus-visible { outline: 2px solid var(--pr); outline-offset: 1px; }
  .ti aside[aria-label="Main navigation"] + div > header > .field {
    order: 10; flex: 1 0 100%; width: auto !important; max-width: none;
  }
  .ti aside[aria-label="Main navigation"] + div > header > .btn { height: 40px; }
  .ti aside[aria-label="Main navigation"] + div > header > .btn:not(.g) { padding: 0 10px; font-size: 12.5px; gap: 5px; }
  .ti aside[aria-label="Main navigation"] + div > header > .btn:not(.g) > svg:first-child { display: none; }
  .ti aside[aria-label="Main navigation"] + div > header > .btn.g { width: 40px !important; }
  .ti aside[aria-label="Main navigation"] + div > main { padding: 16px !important; }
}

/* =====================================================================================================
   Chunk 2: content reflow (grids, tables, charts, segments, action rows, modals, sign-in, marketing)
   ===================================================================================================== */

/* ---------- <=1439: things that must not run off the edge at any fluid width ---------- */
@media (max-width: 1439.98px) {
  /* action rows (buttons as direct children) wrap instead of clipping */
  .ti div:has(> .btn) { flex-wrap: wrap; }
  /* tables: the card scrolls horizontally, the page does not */
  .ti .card:has(table) { overflow-x: auto !important; max-width: 100%; }
  /* charts with axis labels: the card scrolls rather than scaling the text down */
  .ti .card:has(svg text) { overflow-x: auto !important; }
  /* segmented controls scroll inside themselves */
  .ti .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .ti .seg::-webkit-scrollbar { display: none; }
  .ti .seg > span { flex-shrink: 0; }
  /* tab strips scroll inside themselves */
  .ti main > div[style*="gap:22px"][style*="border-bottom"] { overflow-x: auto; scrollbar-width: none; }
  .ti main > div[style*="gap:22px"][style*="border-bottom"] > span { flex-shrink: 0; white-space: nowrap; }
  /* chart cards: keep chart text at its designed size and scroll the card */
  .ti .card:has(svg[viewBox="0 0 1080 230"]) svg { min-width: 1080px; }
  .ti .card:has(svg[viewBox="0 0 640 250"]) svg { min-width: 640px; }
  .ti .card svg[viewBox="0 0 600 150"]:has(text) { min-width: 640px; }
  /* flex children holding long text may shrink */
  .ti main [style*="display:flex"] > div[style*="flex:1"] { min-width: 0; }
}

/* ---------- Tablet + phone grids (<=1023) ---------- */
@media (max-width: 1023.98px) {
  .ti [style*="repeat(4,"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .ti [style*="fr) minmax"] { grid-template-columns: minmax(0, 1fr) !important; }
  .ti [style*="grid-template-columns:1fr 1fr;"] { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important; }
}

/* ---------- Phone content (<=767) ---------- */
@media (max-width: 767.98px) {
  .ti [style*="repeat(3,"], .ti [style*="grid-template-columns:1fr 1fr"] { grid-template-columns: minmax(0, 1fr) !important; }
  .ti [style*="repeat(4,"] { grid-template-columns: minmax(0, 1fr) !important; }
  .ti [style*="repeat(4,"]:has(> .card > .lab) { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px !important; }
  /* tables keep their natural (min-content) width; the card scrolls only when a table truly needs more room */
  /* page header rows (title + actions) stack */
  .ti main > div:first-child[style*="align-items:flex-end"] { flex-wrap: wrap; align-items: stretch !important; }
  .ti main > div:first-child[style*="align-items:flex-end"] > div:first-child { flex: 1 1 100% !important; }
  .ti main [style*="font-size:26px"] { font-size: 22px !important; }
  .ti .btn { min-height: 40px; }

  /* modals become a full-width sheet over a fixed overlay */
  .ti div[style*="position:absolute;inset:0;background:rgba(5,5,15"] { position: fixed !important; }
  .ti section[role="dialog"] {
    position: fixed !important; left: 16px !important; right: 16px; top: 16px !important; margin-left: 0 !important;
    width: auto !important; max-height: calc(100vh - 32px); overflow-y: auto;
  }
  .ti section[role="dialog"] > div[style*="padding:18px 22px"], .ti section[role="dialog"] > div[style*="padding:20px 22px"] { padding-inline: 16px !important; }
  .ti section[role="dialog"] [style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }

  /* sign-in: hide the marketing panel, form goes full width */
  .ti > div:first-child > div[style*="background:#0B0B1E"] { display: none !important; }
  .ti > div:first-child:has(> div[style*="width:560px"]) { min-height: 100vh; }
  .ti > div:first-child > div[style*="width:560px"] { width: auto !important; flex: 1; min-width: 0; padding: 32px 20px; }
  .ti [style*="width:560px"] > div[style*="width:380px"] { width: 100% !important; max-width: 380px; }

  /* marketing/onboarding headers */
  .ti header[style*="padding:0 56px"] { padding: 0 16px !important; gap: 12px !important; }
  .ti header[style*="padding:0 56px"] > b { margin-left: 0 !important; }
  .ti header[style*="padding:0 56px"] > nav { display: none !important; }
  .ti [style*="padding:0 56px"]:not(header) { padding-inline: 16px !important; }
  .ti .card[style*="padding:22px 26px"] { flex-direction: column; align-items: stretch !important; gap: 14px !important; }
  .ti .card[style*="padding:22px 26px"] > .btn { justify-content: center; }
  .ti h1[style*="font-size:44px"] { font-size: 30px !important; }
  .ti header[style*="padding:0 40px"] { height: auto !important; flex-wrap: wrap; padding: 12px 16px !important; row-gap: 8px; }
  .ti header[style*="padding:0 40px"] > span[style*="flex:1"] { display: none; }
  .ti header[style*="padding:0 40px"] > b { flex: 1; }
  .ti header[style*="padding:0 40px"] > div { order: 3; flex: 1 0 100%; justify-content: center; }
  .ti header[style*="padding:0 40px"] > div > span:not([style*="width:28px"]) { font-size: 0 !important; }
  .ti header[style*="padding:0 40px"] > div > span[style*="font-weight:600"] { font-size: 13px !important; }
  .ti header[style*="padding:0 40px"] > div > span[style*="width:28px"] { width: 16px !important; }
  .ti div[style*="max-width:880px"] { margin-top: 24px !important; padding-inline: 16px; }
}

/* ---------- Tablet extras (768-1023) ---------- */
@media (max-width: 1023.98px) and (min-width: 768px) {
  .ti > div:first-child > div[style*="background:#0B0B1E"] { padding: 40px 32px !important; }
  .ti > div:first-child > div[style*="width:560px"] { width: 400px !important; padding: 0 24px; }
  .ti [style*="width:560px"] > div[style*="width:380px"] { width: 100% !important; }
  .ti header[style*="padding:0 56px"] { padding: 0 24px !important; gap: 16px !important; }
  .ti header[style*="padding:0 56px"] > b { margin-left: 0 !important; }
  .ti [style*="padding:0 56px"]:not(header) { padding-inline: 24px !important; }
  .ti div[style*="max-width:880px"] { padding-inline: 24px; }
}

/* ---------- Sign-in / SSO image hero (.ti-hero) ---------- */
@media (max-width: 1439.98px) {
  /* split screen always fills the window height (no blank band below the panels) */
  .ti > div:first-child:has(> .ti-hero) { min-height: 100vh; }
}
@media (max-width: 1199.98px) {
  /* narrower panel: scale the art to the panel width and park it mid-panel; copy sits on the
     image's own navy above and below (sampled edge colours #03123F / #01104A), art stays crisp */
  .ti .ti-hero {
    background-color: #02113F !important;
    background-image: linear-gradient(180deg, #03123F 0%, #03123F 30%, rgba(3,18,63,0) 46%, rgba(1,16,74,0) 70%, #01104A 92%),
                      url(signin-hero.jpg) !important;
    background-size: 100% 100%, 135% auto !important;
    background-position: 0 0, 32% 52% !important;
    background-repeat: no-repeat !important;
  }
  .ti .ti-hero h2 { font-size: 36px !important; }
}
@media (max-width: 1199.98px) and (max-height: 760px) {
  /* short window: smaller art, nudged up, so the coin stack clears the copy */
  .ti .ti-hero { background-size: 100% 100%, 96% auto !important; background-position: 0 0, 60% 40% !important; }
  .ti .ti-hero > div:first-child > span { display: none !important; } /* eyebrow chip */
}
@media (min-width: 1200px) and (max-width: 1439.98px) and (max-height: 820px) {
  /* laptop-height windows: drop the eyebrow chip so the headline clears the dashboard art */
  .ti .ti-hero > div:first-child > span { display: none !important; }
}
