/* MarketDeck suite shell for F&O Analytics.
   This layer is presentation-only: existing routes, controls and page
   templates remain intact inside the shared workspace. */

html { color-scheme: dark; }

body.md-app {
  min-width: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--md-bg-deep);
  color: var(--md-text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14.5px;
}

body.md-app a { color: var(--md-link); }
body.md-app a:hover { color: var(--md-text); }
body.md-app h1,
body.md-app h2,
body.md-app h3,
body.md-app .brand-word { font-family: inherit; }
body.md-app :focus-visible { outline: 2px solid var(--md-primary); outline-offset: 2px; }
body.md-app input,
body.md-app select,
body.md-app textarea,
body.md-app button { font-family: inherit; }
body.md-app input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
body.md-app select,
body.md-app textarea { min-height: 38px; border-radius: 8px; }
body.md-app .btn { min-height: 36px; border-radius: 8px; }
body.md-app .btn-primary {
  background: var(--md-primary);
  border-color: var(--md-primary);
  color: #fff;
}
body.md-app .btn-primary:hover {
  background: var(--md-primary-hover);
  border-color: var(--md-primary-hover);
  color: #fff;
}
body.md-app table { font-variant-numeric: tabular-nums; }

.md-skip {
  position: fixed;
  left: 12px;
  top: -80px;
  z-index: 120;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--md-primary);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}
.md-skip:focus { top: 12px; color: #fff; }

.md-shell { display: flex; align-items: flex-start; min-height: 100vh; }

.md-sidebar {
  width: 188px;
  flex: 0 0 188px;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: var(--md-sidebar);
  border-right: 1px solid var(--md-border-subtle);
}
.md-sidebar:focus { outline: none; }
.md-sidebar-head { padding: 12px 14px 11px; border-bottom: 1px solid var(--md-border-subtle); }
.md-factory {
  display: block;
  color: var(--md-text);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.025em;
  line-height: 24px;
  text-decoration: none;
}
.md-sidebar-scroll { flex: 1 1 auto; overflow-y: auto; padding: 0 8px 16px; }
.md-rail-label {
  display: block;
  padding: 14px 6px 6px;
  color: var(--md-text-muted);
  font: 500 10px/1.4 "IBM Plex Mono", ui-monospace, Consolas, monospace;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.md-product-list { margin: 0; padding: 0; list-style: none; }
.md-product {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 7px 9px;
  border-radius: 8px;
  color: var(--md-link-muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.25;
  text-decoration: none;
}
.md-product:hover { background: var(--md-surface-3); color: var(--md-text); }
.md-product.is-active {
  background: var(--md-primary-strong-soft);
  color: var(--md-text);
  font-weight: 650;
  box-shadow: inset 0 0 0 1px rgba(19, 146, 253, .12);
}
.md-product.is-active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 3px;
  background: var(--md-primary);
}
.md-product.is-disabled { color: var(--md-text-faint); cursor: not-allowed; opacity: .62; }
.md-product-desc { display: block; margin-top: 2px; color: var(--md-text-faint); font-size: 10.5px; font-weight: 400; }

.md-sidebar-foot { flex: 0 0 auto; padding: 12px; border-top: 1px solid var(--md-border-subtle); }
.md-account { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; min-width: 0; }
.md-avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--md-primary-soft);
  color: var(--md-primary-hover);
  font: 600 10px/1 "IBM Plex Mono", ui-monospace, monospace;
}
.md-account-name { overflow: hidden; color: var(--md-text); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.md-sidebar-foot .inline-logout { display: block; }
.md-sidebar-foot .inline-logout .btn { width: 100%; }
.md-sidebar-note { margin: 0; color: var(--md-text-faint); font-size: 11px; line-height: 1.4; }
.md-ops-link { display: block; margin: 0 0 8px; color: var(--md-link-muted); font-size: 12px; text-decoration: none; }

.md-main-column { flex: 1 1 auto; min-width: 0; width: calc(100% - 188px); }
.md-header {
  height: 48px;
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--md-topbar);
  border-bottom: 1px solid var(--md-border-subtle);
}
.md-identity { display: inline-flex; align-items: baseline; gap: 7px; text-decoration: none; white-space: nowrap; }
.md-identity-suite,
.md-identity-product { color: var(--md-text); font-size: 15px; font-weight: 700; letter-spacing: -.015em; }
.md-identity-product { font-weight: 600; }
.md-identity-separator { color: var(--md-border-strong); font-size: 12px; }
.md-header-spacer { flex: 1 1 auto; }
.md-header-actions { display: flex; align-items: center; gap: 8px; }
.md-header-actions a { min-height: 36px; display: inline-flex; align-items: center; padding: 0 11px; border-radius: 8px; text-decoration: none; font-size: 12.5px; }
.md-header-actions .md-create-account { background: var(--md-primary); color: #fff; font-weight: 650; }
.md-header-actions .md-create-account:hover { background: var(--md-primary-hover); color: #fff; }

.md-drawer-toggle {
  display: none;
  min-width: 44px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--md-border);
  border-radius: 8px;
  background: var(--md-surface-1);
  color: var(--md-link);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.md-scrim { display: none; }

.md-suite-rail {
  display: none;
  min-width: 0;
  background: var(--md-topbar);
  border-bottom: 1px solid var(--md-border-subtle);
}
.md-suite-scroll {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  height: 42px;
  padding: 0 20px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--md-border-strong) transparent;
}
.md-suite-link {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 11px;
  border-radius: 8px;
  color: var(--md-link);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}
.md-suite-link:hover { background: var(--md-surface-3); color: var(--md-text); }
.md-suite-link.is-active {
  background: var(--md-primary-soft);
  color: var(--md-text);
  box-shadow: inset 0 -2px 0 var(--md-primary);
}
.md-suite-link.is-disabled { color: var(--md-text-faint); cursor: not-allowed; }

/* The existing F&O navigation remains product-local and keeps every route. */
.md-local-nav.topbar {
  position: sticky;
  top: 48px;
  z-index: 35;
  min-height: 48px;
  gap: 12px;
  padding: 6px 14px;
  background: var(--md-surface-1);
  border-bottom-color: var(--md-border-subtle);
}
.md-local-nav .brand { gap: 7px; }
.md-local-nav .brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--md-primary-soft);
  color: var(--md-primary-hover);
  font-size: 10px;
}
.md-local-nav .brand-word { color: var(--md-text); font-family: inherit; font-size: 14px; font-weight: 650; }
.md-local-nav .nav { min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.md-local-nav .nav a { color: var(--md-link-muted); border-radius: 6px; white-space: nowrap; }
.md-local-nav .nav a:hover { color: var(--md-text); background: var(--md-surface-3); }
.md-local-nav .nav a.active { color: var(--md-text); background: var(--md-primary-soft); box-shadow: inset 0 -2px 0 var(--md-primary); }
.md-local-nav .market-pill { background: var(--md-surface-2); border-color: var(--md-border); }
.md-local-nav .market-pill a { color: var(--md-link-muted); }
.md-local-nav .market-pill a.active { background: var(--md-primary); color: #fff; }

body.md-app main { min-width: 0; }
body.md-app main.home-v2 { background: var(--md-home-bg); }
body.md-app main.home-v2 .panel { border-color: var(--md-home-line); }
body.md-app main.home-v2 .btn:not(.btn-primary) { color: var(--md-link); }

@media (max-width: 1024px) {
  .md-main-column { width: 100%; }
  .md-drawer-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .md-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 70;
    transform: translateX(-100%);
    visibility: hidden;
    box-shadow: 0 12px 36px rgba(0, 0, 0, .5);
    transition: transform 150ms ease, visibility 0s linear 150ms;
  }
  .md-sidebar.is-open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 150ms ease, visibility 0s linear 0s;
  }
  .md-scrim {
    position: fixed;
    inset: 0;
    z-index: 60;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: rgba(0, 0, 0, .62);
    cursor: pointer;
  }
  .md-scrim:not([hidden]) { display: block; }
  .md-suite-rail { display: block; position: sticky; top: 48px; z-index: 34; }
  .md-local-nav.topbar { top: 90px; }
}

@media (max-width: 767px) {
  .md-header { position: static; min-height: 56px; height: auto; padding: 6px 12px; }
  .md-identity-suite,
  .md-identity-separator { display: none; }
  .md-header-actions a { min-height: 44px; padding-inline: 9px; }
  .md-header-actions .md-create-account { display: none; }
  .md-drawer-toggle { min-height: 44px; }
  .md-suite-rail { position: sticky; top: 0; z-index: 39; }
  .md-suite-scroll { height: 48px; padding: 0 12px; }
  .md-suite-link { min-height: 44px; font-size: 13.5px; }
  .md-local-nav.topbar { position: static; padding: 8px 12px; gap: 8px; }
  .md-local-nav .brand { flex: 1 1 auto; }
  .md-local-nav .brand-word { font-size: 14px; }
  .md-local-nav .nav-toggle-btn { width: 44px; height: 44px; }
  .md-local-nav .nav { order: 10; }
  .md-local-nav .nav a { min-height: 44px; display: flex; align-items: center; }
  .md-local-nav .market-pill { order: 4; width: 100%; }
  .md-local-nav .market-pill a { flex: 1 1 0; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
  body.md-app main { padding-inline: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .md-sidebar { transition: none; }
}
