/* ==========================================================================
   Mobile experience (<= 768px). Desktop rules live in style.css and are
   intentionally left untouched.
   ========================================================================== */
@media (max-width: 768px) {
  :root {
    --m-safe-bottom: env(safe-area-inset-bottom, 0px);
    --m-radius: 14px;
    --m-border: #e6ebf2;
  }

  html { -webkit-text-size-adjust: 100%; }
  [hidden] { display: none !important; }
  body { background: #f4f7fb; }
  main { margin: 10px auto; padding: 0 10px calc(28px + var(--m-safe-bottom)); }
  h2 { font-size: 1.2rem; }
  h3 { font-size: 1.02rem; }

  /* ---------- mobile top bar ---------- */
  .top-nav {
    flex-wrap: nowrap;
    flex-direction: row !important;
    align-items: center;
    gap: 8px;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px;
    min-height: 54px;
    box-shadow: 0 1px 0 rgba(15, 23, 42, .04);
  }
  .top-nav .nav-left,
  .top-nav .nav-right { display: none; }
  .m-menu-btn {
    order: -1;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 12px;
    background: #f1f5f9;
    color: #0f172a;
    border: 1px solid #e2e8f0;
  }
  .m-menu-btn svg { width: 20px; height: 20px; }
  .m-topbar-title {
    display: block !important;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .m-topbar-profile {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-height: 38px;
    padding: 0 12px;
    border-radius: 999px;
    background: #0f172a;
    color: #fff !important;
    font-size: 13px;
  }

  .m-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(15, 23, 42, .4);
    opacity: 0;
    transition: opacity .2s ease;
  }
  .m-nav-backdrop.show { opacity: 1; }
  .m-nav-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 3010;
    width: min(84vw, 340px);
    padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(24px + var(--m-safe-bottom));
    background: #fff;
    box-shadow: 18px 0 40px rgba(15, 23, 42, .18);
    transform: translateX(-102%);
    transition: transform .24s cubic-bezier(.32, .72, 0, 1);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .m-nav-drawer.show { transform: translateX(0); }
  .m-nav-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
  }
  .m-nav-drawer-title { font-size: 17px; font-weight: 800; }
  .m-nav-close {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #475569;
    border: none;
    font-size: 20px;
    line-height: 1;
  }
  .m-nav-group { margin: 14px 0 4px; }
  .m-nav-group-title {
    margin: 0 0 6px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    color: #94a3b8;
  }
  .m-nav-link {
    display: flex;
    align-items: center;
    min-height: 46px;
    padding: 0 12px;
    margin: 2px 0;
    border-radius: 10px;
    color: #1f2937;
    text-decoration: none;
    font-size: 15px;
  }
  .m-nav-link.active {
    background: #eef4ff;
    color: #1d4ed8;
    font-weight: 700;
  }
  body.m-nav-open { overflow: hidden; }

  /* ---------- page head / actions ---------- */
  .page-head { flex-direction: column; align-items: stretch; gap: 8px; }
  .page-head h2 { margin-bottom: 2px; }
  .scheme-merge-hint { font-size: 12.5px; line-height: 1.55; }
  .page-head-action-form .stock-action-btn,
  .page-head > .stock-action-btn { width: 100%; justify-content: center; }
  .stock-list-actions { gap: 8px; align-items: stretch; }
  .stock-list-actions h3 { width: 100%; }
  .stock-list-actions .btn,
  .stock-list-actions button,
  .stock-list-actions .stock-action-btn { min-height: 42px; }
  .csv-download-wrap { margin-left: auto; }
  .btn-csv-download { min-width: 42px; min-height: 42px; }

  /* ---------- sticky filter / action rows ---------- */
  .scheme-switch-form,
  .tech-overview-controls,
  .scheme-panel { border-radius: 12px; }
  .scheme-multi-pick,
  .tech-filters .scheme-multi-pick {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .scheme-multi-pick::-webkit-scrollbar { display: none; }
  .scheme-check {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 6px 12px;
    border: 1px solid #dbe3ee;
    border-radius: 999px;
    background: #fff;
  }
  .scheme-check.is-active { border-color: #1f2a44; background: #eef2f7; font-weight: 600; }
  .scheme-check input { accent-color: #1f2a44; }
  .scheme-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .scheme-actions > * { width: 100%; }
  .scheme-actions .btn,
  .scheme-actions button,
  .scheme-actions form { width: 100%; }
  .scheme-actions .btn,
  .scheme-actions button { min-height: 42px; }

  /* ---------- stats ---------- */
  .stats-grid,
  .pano-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px;
  }
  .stats-grid > .panel {
    padding: 10px;
    margin-bottom: 0;
    border-radius: 12px;
  }
  .stats-grid h4 { font-size: 11.5px; margin-bottom: 4px; }
  .stats-grid strong { font-size: 14px; line-height: 1.4; }
  .stat-help { width: 15px; height: 15px; }

  /* ---------- tabs ---------- */
  .page-tabs-nav {
    position: sticky;
    top: calc(54px + env(safe-area-inset-top, 0px));
    z-index: 12;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 2px;
    margin: 0 -10px 12px;
    padding: 0 10px;
    background: rgba(244, 247, 251, .96);
    backdrop-filter: blur(8px);
    scrollbar-width: none;
  }
  .page-tabs-nav::-webkit-scrollbar { display: none; }
  .page-tab {
    flex: 0 0 auto;
    min-height: 46px;
    padding: 10px 14px;
    font-size: 14px;
  }

  /* ---------- anchors / page directory ---------- */
  .anchor-nav {
    display: block;
    left: auto;
    right: 14px;
    top: auto;
    bottom: calc(14px + var(--m-safe-bottom));
    transform: none;
    max-height: none;
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
    z-index: 1500;
  }
  .anchor-nav-toggle {
    position: fixed;
    right: 14px;
    bottom: calc(14px + var(--m-safe-bottom));
    z-index: 1520;
    flex-direction: row;
    gap: 6px;
    width: auto;
    min-width: 56px;
    height: 50px;
    padding: 0 16px;
    border: none;
    border-radius: 999px;
    background: #0f172a;
    color: #fff;
    box-shadow: 0 10px 26px rgba(15, 23, 42, .28);
  }
  .anchor-nav-toggle-icon { border-color: currentColor; }
  .anchor-nav-toggle-label {
    display: inline !important;
    writing-mode: horizontal-tb !important;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
  }
  .anchor-nav-body,
  .anchor-nav.collapsed .anchor-nav-body {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(74px + var(--m-safe-bottom));
    width: auto !important;
    max-height: 58dvh;
    padding: 0;
    border: 1px solid var(--m-border);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
    opacity: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(12px);
    transition: opacity .18s ease, transform .18s ease;
  }
  .anchor-nav:not(.m-open) .anchor-nav-body { display: none; }
  .anchor-nav.m-open .anchor-nav-body { display: flex; }
  .anchor-nav.m-open .anchor-nav-toggle {
    background: #fff;
    color: #0f172a;
    border: 1px solid var(--m-border);
  }
  .anchor-nav-title,
  .anchor-nav.collapsed .anchor-nav-title,
  .anchor-nav-list,
  .anchor-nav.collapsed .anchor-nav-list { display: block !important; }
  .anchor-nav-title { padding: 14px 16px 6px; font-size: 13px; }
  .anchor-nav-list { padding: 0 8px 12px; overflow-y: auto; }
  .anchor-nav-list a { min-height: 44px; padding: 11px 12px; font-size: 14px; }
  .tech-locator .anchor-nav-body { width: auto; }
  .anchor-nav.m-open .tech-locator-search,
  .anchor-nav.m-open .tech-locator-hint,
  .anchor-nav.m-open .tech-locator-matches,
  .anchor-nav.m-open .tech-locator-list { display: block !important; }
  .tech-locator-search { padding: 0 14px 8px; }
  .tech-locator-input { min-height: 42px; font-size: 16px; }
  .tech-locator-matches { max-height: 34dvh; }

  /* ---------- dialog as bottom sheet ---------- */
  dialog {
    position: fixed;
    inset: auto 0 0 0;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 88dvh;
    margin: 0;
    padding: 18px 16px calc(18px + var(--m-safe-bottom));
    border: none;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -18px 50px rgba(15, 23, 42, .24);
    overflow-y: auto;
    overscroll-behavior: contain;
    animation: m-sheet-up .22s cubic-bezier(.32, .72, 0, 1);
  }
  dialog::backdrop { background: rgba(15, 23, 42, .45); }
  dialog::before {
    content: "";
    display: block;
    width: 42px;
    height: 4px;
    margin: -8px auto 12px;
    border-radius: 999px;
    background: #dbe3ee;
  }
  #newTradeDialog { width: 100%; }
  .trade-dialog-form { gap: 14px; }
  .trade-form-row { grid-template-columns: 1fr; }
  .trade-form-actions { flex-direction: column-reverse; }
  .trade-form-actions button { width: 100%; min-height: 44px; }
  dialog form:not(.trade-dialog-form) { flex-direction: column; align-items: stretch; }
  dialog form:not(.trade-dialog-form) input,
  dialog form:not(.trade-dialog-form) select,
  dialog form:not(.trade-dialog-form) textarea,
  dialog form:not(.trade-dialog-form) button { width: 100%; min-height: 44px; }
  dialog form:not(.trade-dialog-form) > div { display: flex; flex-direction: column; gap: 10px; width: 100%; }
  @keyframes m-sheet-up {
    from { transform: translateY(18px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

  /* ---------- form controls ---------- */
  input, select, textarea, button, .btn { font-size: 16px; }
  input:not([type="checkbox"]):not([type="radio"]), select { min-height: 44px; border-radius: 10px; }
  input[type="checkbox"], input[type="radio"] { min-height: 0; width: 18px; height: 18px; accent-color: #1f2a44; }
  button, .btn { min-height: 44px; border-radius: 10px; }
  .smartbox-list { left: 10px !important; right: 10px !important; width: auto !important; max-height: 50dvh !important; }
  .smartbox-item { min-height: 44px; }

  /* ---------- generic tables: horizontal fallback ---------- */
  .table-scroll,
  .table-wrapper,
  .plan-table-wrap { overflow-x: auto; }
  .table-scroll table,
  .table-wrapper table,
  .plan-table-wrap table { min-width: 0; }

  .m-table-host { position: relative; }
  .m-table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 8px 0 6px;
    font-size: 12px;
    color: #64748b;
  }
  .m-table-mode-btn {
    min-height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid #dbe3ee;
    background: #fff;
    color: #334155;
    font-size: 12px;
  }

  /* card mode */
  .m-mode-cards table.m-cards-table,
  .m-mode-cards .m-cards-table {
    display: block;
    width: 100%;
    min-width: 0 !important;
    border-collapse: separate;
    border-spacing: 0;
  }
  .m-mode-cards table.m-cards-table thead,
  .m-mode-cards table.m-cards-table tr.m-table-head-row { display: none !important; }
  .m-mode-cards table.m-cards-table tbody { display: block; }
  .m-mode-cards table.m-cards-table tr.m-row-card {
    display: block;
    position: relative;
    margin: 0 0 10px;
    padding: 12px;
    border: 1px solid var(--m-border);
    border-radius: var(--m-radius);
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
  }
  .m-mode-cards table.m-cards-table tr.m-row-card > td {
    display: grid;
    grid-template-columns: minmax(78px, 32%) minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    border: none;
    white-space: normal !important;
    text-align: right;
    font-size: 13px;
    line-height: 1.45;
    min-width: 0 !important;
  }
  .m-mode-cards table.m-cards-table tr.m-row-card > td::before {
    content: attr(data-label);
    align-self: start;
    text-align: left;
    font-size: 11.5px;
    font-weight: 500;
    color: #94a3b8;
    padding-top: 2px;
    overflow-wrap: anywhere;
  }
  .m-mode-cards table.m-cards-table tr.m-row-card > td.m-cell-primary {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    width: auto;
    max-width: 100%;
    padding: 0 8px 2px 0;
    text-align: left;
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
  }
  .m-mode-cards table.m-cards-table tr.m-row-card > td.m-cell-primary::before { display: none; }
  .m-mode-cards table.m-cards-table tr.m-row-card > td.m-cell-primary a { color: inherit; }
  .m-mode-cards table.m-cards-table tr.m-row-card > td.m-cell-long {
    display: block;
    margin-top: 6px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #f8fafc;
    text-align: left;
  }
  .m-mode-cards table.m-cards-table tr.m-row-card > td.m-cell-long::before {
    display: block;
    margin-bottom: 4px;
    color: #94a3b8;
  }
  .m-mode-cards table.m-cards-table tr.m-row-card > td.m-cell-action {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #e2e8f0;
  }
  .m-mode-cards table.m-cards-table tr.m-row-card > td.m-cell-action::before { display: none; }
  .m-mode-cards table.m-cards-table tr.m-row-card > td.m-cell-action form,
  .m-mode-cards table.m-cards-table tr.m-row-card > td.m-cell-action button,
  .m-mode-cards table.m-cards-table tr.m-row-card > td.m-cell-action .btn {
    width: 100%;
    margin: 0;
  }
  .m-mode-cards table.m-cards-table tr.m-row-card > td.m-cell-action button { min-height: 40px; }
  .m-mode-cards table.m-cards-table tr.m-row-card > td.m-cell-check {
    display: inline-flex;
    width: auto;
    margin-right: 4px;
    padding: 0;
  }
  .m-mode-cards table.m-cards-table tr.m-row-card > td.m-cell-check::before { display: none; }
  .m-mode-cards table.m-cards-table tr.m-row-card > td.m-cell-check input {
    width: 22px;
    height: 22px;
    min-height: 0;
  }
  .m-mode-cards table.m-cards-table tr.m-row-card > td input,
  .m-mode-cards table.m-cards-table tr.m-row-card > td select { width: 100%; text-align: left; }
  .m-mode-cards table.m-cards-table tr.m-row-card > td .trade-edit-form { display: contents; }
  .m-mode-cards table.m-cards-table tr.m-row-card > td form { margin: 0; }

  .m-mode-cards table.m-cards-table tr.m-row-group > td,
  .m-mode-cards table.m-cards-table tr.m-row-summary > td {
    display: block;
    padding: 10px 12px;
    border: none;
    white-space: normal !important;
    font-size: 13px;
    line-height: 1.55;
    text-align: left;
  }
  .m-mode-cards table.m-cards-table tr.m-row-group > td {
    margin: 14px 0 8px;
    border-radius: 10px;
    background: #e8eef8;
    font-weight: 700;
    color: #0f172a;
  }
  .m-mode-cards table.m-cards-table tr.m-row-group > td::before,
  .m-mode-cards table.m-cards-table tr.m-row-summary > td::before,
  .m-mode-cards table.m-cards-table tr.m-row-empty > td::before { display: none; }
  .m-mode-cards table.m-cards-table tr.m-row-summary > td {
    margin: 0 0 10px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    color: #475569;
  }
  .m-mode-cards table.m-cards-table tr.m-row-empty > td {
    display: block;
    padding: 18px 12px;
    border: 1px dashed #dbe3ee;
    border-radius: 12px;
    text-align: center;
    color: #94a3b8;
    white-space: normal !important;
  }
  .m-mode-cards table.m-cards-table tr.m-row-loadmore > td {
    display: block;
    padding: 4px 0 10px;
    border: none;
    text-align: center;
  }
  .m-mode-cards table.m-cards-table tr.m-row-loadmore > td::before { display: none; }
  .m-row-loadmore button { width: 100%; min-height: 44px; }

  /* table mode */
  .m-mode-table .m-cards-table {
    display: table;
    min-width: 620px;
    table-layout: fixed;
  }
  .m-mode-table .m-cards-table th,
  .m-mode-table .m-cards-table td {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .m-mode-table .m-cards-table th { white-space: nowrap; }
  .m-mode-table .m-cards-table thead,
  .m-mode-table .m-cards-table tr.m-table-head-row { display: table-header-group; }
  .m-mode-table .m-cards-table tbody { display: table-row-group; }
  .m-mode-table .m-cards-table tr { display: table-row; }
  .m-mode-table .m-cards-table th,
  .m-mode-table .m-cards-table td { display: table-cell; }
  .m-mode-table .m-cards-table th { white-space: nowrap; }
  .m-mode-table .m-cards-table td { white-space: normal; overflow-wrap: anywhere; }
  .m-mode-table .m-cards-table th:first-child,
  .m-mode-table .m-cards-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    width: 1%;
    background: #fff;
  }
  .m-mode-table .m-cards-table thead th:first-child { background: #f8fafc; }
  .m-table-scroll-hint {
    margin: 0 0 6px;
    font-size: 12px;
    color: #94a3b8;
  }

  /* pagination */
  .stock-list-pager,
  .stock-trades-pager { gap: 8px; }
  .stock-list-pager .btn,
  .stock-trades-pager .btn { flex: 1 1 0; min-width: 0; min-height: 44px; }
  .stock-list-pager > span,
  .stock-trades-pager > span { flex: 1 1 100%; text-align: center; }

  /* ---------- charts ---------- */
  .chart-scroll,
  .table-wrapper { overflow: visible; }
  .chart-scroll .chart-box,
  .chart-scroll .chart-box.chart-lg,
  .chart-scroll .chart-container.chart-dupont { min-width: 0 !important; width: 100%; }
  .chart-box { height: 260px; }
  .chart-lg { height: 320px; }
  .chart-container { height: 300px; }
  .chart-container.chart-sm { height: 220px; }
  .chart-container.chart-md { height: 260px; }
  .chart-container.chart-dupont { height: 460px; min-width: 0; }
  .chart-container.chart-vol-trend { height: 520px; }
  .chart-container.chart-combo { height: auto; min-height: 360px; }
  .pano-chart { height: 62dvh; min-height: 380px; min-width: 0; }
  .chart-grid { grid-template-columns: 1fr; }
  #homeAllocPanel { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  #homeAllocPanel > div {
    padding: 10px 8px;
    border: 1px solid var(--m-border);
    border-radius: 12px;
    background: #fff;
    min-width: 0;
  }
  #homeAllocPanel > div h3 { font-size: 12px; margin: 0 0 4px; }
  #homeAllocPanel .chart-box { height: 172px; }
  .chart-empty-hint { padding: 30px 10px; }

  .pano-tap-info,
  .m-chart-tap-info {
    margin: 8px 0 0;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    font-size: 12.5px;
    line-height: 1.6;
    color: #334155;
  }
  .pano-tap-info:empty { display: none; }

  /* ---------- home ---------- */
  #homeSchemePanel .scheme-actions { grid-template-columns: 1fr 1fr; }
  .panel-collapse-summary { min-height: 42px; }
  .panel-collapse-summary-row .panel-collapse-title { flex: 1 1 100%; }
  .panel-collapse-summary-row > button { min-height: 42px; }
  .hold-rules-note { font-size: 13px; }
  .tag-list { gap: 8px; }
  .tag { min-height: 34px; padding: 4px 10px; }

  /* ---------- tech overview mobile controls ---------- */
  .tech-overview-controls.m-mobile-controls { display: none; }
  .m-tech-mobile-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    padding: 8px 10px;
    border: 1px solid var(--m-border);
    border-radius: 12px;
    background: #fff;
    position: sticky;
    top: calc(54px + env(safe-area-inset-top, 0px));
    z-index: 11;
    box-shadow: 0 6px 16px rgba(15, 23, 42, .06);
  }
  .m-tech-mobile-count { flex: 1 1 auto; min-width: 0; font-size: 12px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-tech-mobile-bar button {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid #dbe3ee;
    background: #fff;
    color: #334155;
    font-size: 12.5px;
  }
  .m-tech-mobile-bar button.is-active { background: #0f172a; color: #fff; border-color: #0f172a; }

  .m-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 3200;
    background: rgba(15, 23, 42, .42);
    opacity: 0;
    transition: opacity .18s ease;
  }
  .m-sheet-backdrop.show { opacity: 1; }
  .m-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3210;
    max-height: 82dvh;
    padding: 14px 16px calc(20px + var(--m-safe-bottom));
    border-radius: 20px 20px 0 0;
    background: #fff;
    box-shadow: 0 -18px 50px rgba(15, 23, 42, .24);
    transform: translateY(102%);
    transition: transform .24s cubic-bezier(.32, .72, 0, 1);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .m-sheet.show { transform: translateY(0); }
  .m-sheet::before {
    content: "";
    display: block;
    width: 42px;
    height: 4px;
    margin: -4px auto 12px;
    border-radius: 999px;
    background: #dbe3ee;
  }
  .m-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
  }
  .m-sheet-head h3 { margin: 0; font-size: 16px; }
  .m-sheet-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #475569;
    font-size: 19px;
    line-height: 1;
  }
  .m-sheet .tech-filters,
  .m-sheet .tech-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    width: 100%;
  }
  .m-sheet .filter-group { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
  .m-sheet .filter-label { font-size: 12px; }
  .m-sheet .tech-actions .btn,
  .m-sheet .tech-actions button { width: 100%; min-height: 44px; }
  .m-sheet .col-settings { width: 100%; }
  .m-sheet .col-settings > button { width: 100%; }
  .m-sheet #tag-filter { width: 100%; min-height: 44px; }
  .m-tech-sort-list { display: flex; flex-direction: column; gap: 4px; }
  .m-tech-sort-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: #f8fafc;
    color: #334155;
    font-size: 14px;
    text-align: left;
  }
  .m-tech-sort-item.is-active { border-color: #93c5fd; background: #eff6ff; color: #1d4ed8; font-weight: 600; }
  .m-tech-sort-item small { color: #94a3b8; font-size: 11px; }
  .m-sheet .tech-overview-count { display: none; }
  .col-settings-panel { z-index: 3400; left: 10px; right: 10px; width: auto; max-height: 60dvh; }
  .col-item { min-height: 40px; }

  /* ---------- panorama ---------- */
  .pano-hint { font-size: 12px; }
  .pano-legend { width: 100%; flex-wrap: wrap; white-space: normal; }
  .pano-foot-hint { font-size: 11px; }

  /* ---------- stock detail ---------- */
  .kline-range-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .kline-range-bar label { display: flex; align-items: center; gap: 8px; font-size: 12px; }
  .kline-range-bar input[type="date"] { flex: 1 1 auto; }
  .kline-range-bar button { width: 100%; }
  .kline-quick-ranges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; width: 100%; }
  .kline-quick-ranges .kline-quick-range { width: auto; }
  .indicator-toggles {
    flex-direction: column;
    flex-wrap: wrap;
    overflow: visible;
    margin: 0 -10px 12px;
    padding: 8px 10px;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .indicator-toggle-row {
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .indicator-toggle-row::-webkit-scrollbar { display: none; }
  .toggle { flex: 0 0 auto; min-height: 38px; padding: 0 10px; border: 1px solid #e2e8f0; border-radius: 999px; background: #fff; }
  .toggles-label { flex: 0 0 auto; align-self: center; }
  .price-win-grid { grid-template-columns: 1fr; }
  .stock-title-row h2 { font-size: 1.15rem; }
  .stock-list-actions #observeBtn,
  .stock-list-actions #loadSignalsBtn,
  .stock-list-actions #syncTechBtn { flex: 1 1 calc(50% - 8px); }
  .stock-list-actions #indicatorFilter { flex: 1 1 100%; }
  .stock-list-actions #limitInput { flex: 0 0 120px; }
  .signals-output { font-size: 13px; }
  .signal-head { align-items: flex-start; }
  .main-force-detail { padding-left: 16px; }
  .dupont-legend, #dupontFormula { font-size: 12px; }

  /* ---------- plan ---------- */
  .plan-layout { grid-template-columns: 1fr; }
  .plan-sidebar { position: static; max-height: none; }
  .plan-sidebar h3 { margin-bottom: 6px; }
  .plan-day-list {
    display: flex;
    flex-direction: row;
    gap: 8px;
    max-height: none;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .plan-day-list::-webkit-scrollbar { display: none; }
  .plan-day-item { flex: 0 0 156px; }
  .plan-day-item a { min-height: 74px; }
  .plan-day-meta { padding-right: 0; }
  .plan-day-edit {
    position: static;
    margin-top: 4px;
    width: 100%;
    min-height: 34px;
  }
  .plan-main-head { flex-direction: column; }
  .plan-main-actions { width: 100%; }
  .plan-main-actions button { width: 100%; }
  .plan-add-form { grid-template-columns: 1fr; }
  .plan-scheme-pick { gap: 6px; }
  .plan-comments-form textarea { min-height: 88px; }
  .plan-table .plan-action-cell { width: auto; }
  .plan-row-actions { display: flex; gap: 8px; width: 100%; }
  .plan-row-actions .plan-edit-btn,
  .plan-row-actions .plan-delete-btn { flex: 1 1 0; min-height: 42px; }

  /* ---------- logs / glossary / profile ---------- */
  .log-period-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .log-period-tabs::-webkit-scrollbar { display: none; }
  .log-period-tab { flex: 0 0 auto; min-height: 40px; }
  .log-period-tabs .scheme-multi-label { flex: 0 0 auto; align-self: center; }
  .oplog-note { min-width: 0; }
  .glossary-table { min-width: 0; }
  .m-glossary-search {
    position: sticky;
    top: calc(54px + env(safe-area-inset-top, 0px));
    z-index: 10;
    margin: 0 0 10px;
    padding: 8px;
    background: #f4f7fb;
  }
  .m-glossary-search input { width: 100%; min-height: 44px; border-radius: 12px; }
  #syncProgress { width: 100%; max-width: 100%; }


  /* auth / standalone forms */
  main > form {
    padding: 16px;
    border: 1px solid var(--m-border);
    border-radius: 16px;
    background: #fff;
    gap: 14px;
  }
  main > form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    font-size: 13px;
    color: #475569;
  }
  main > form label input { width: 100%; }
  main > form button { width: 100%; }
  .hero { padding: 18px; border-radius: 16px; }
  .hero h1 { font-size: 1.5rem; }

  /* ---------- toast ---------- */
  .toast {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: calc(16px + var(--m-safe-bottom));
    max-width: none;
    z-index: 5000;
    text-align: center;
  }
  /* card engine details */
  .m-mode-cards table.m-cards-table tr.m-row-card > th { display: none; }
  .m-mode-cards table.m-cards-table tr.m-row-card > td[data-label=""] {
    display: block;
    text-align: left;
    padding: 4px 0;
  }
  .m-mode-cards table.m-cards-table tr.m-row-card > td[data-label=""]::before { display: none; }
  .col-moves { display: inline-flex; gap: 2px; margin-left: auto; }
  .col-move {
    width: 28px;
    height: 28px;
    min-height: 0;
    padding: 0;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
    font-size: 12px;
  }
  .col-item { gap: 8px; }
  .col-item-label { min-width: 0; }

  /* card mode does not need horizontal scroll */
  .m-mode-cards .table-scroll,
  .m-mode-cards .table-wrapper { overflow: visible; }

  /* tables inside bottom sheets */
  .m-sheet .table-scroll { overflow-x: auto; }

}

@media (max-width: 420px) {
  #homeAllocPanel { grid-template-columns: 1fr; }
  #homeAllocPanel .chart-box { height: 210px; }
  .stats-grid, .pano-stats { gap: 6px; }
  .stats-grid > .panel { padding: 9px 8px; }
  .stats-grid h4 { font-size: 11px; }
  .stats-grid strong { font-size: 13px; }
  .tech-overview-controls.m-mobile-controls { display: none; }
  .m-tech-mobile-bar { gap: 6px; padding: 7px 8px; }
  .m-tech-mobile-bar button { padding: 0 10px; font-size: 12px; }
}

@media (max-width: 768px) {
  .cf-btn { width: 34px; height: 34px; border-radius: 8px; }
  .cf-head { top: 4px; right: 6px; }
  .cf-host.is-cf-fallback,
  .cf-host:fullscreen,
  .cf-host:-webkit-full-screen {
    padding: calc(10px + env(safe-area-inset-top)) 10px calc(12px + env(safe-area-inset-bottom));
  }
  .cf-host.is-cf-fallback .cf-title,
  .cf-host:fullscreen .cf-title,
  .cf-host:-webkit-full-screen .cf-title { font-size: 14px; }
}

@media (max-width: 768px) {
  .trade-ref-title-row h3 { flex: 1 1 100%; }
  .trade-ref-title-row .stock-action-btn { margin-left: 0; width: 100%; min-height: 42px; }
  .trade-ref-status { flex: 1 1 100%; }
  .trade-ref-meta-updated { margin-left: 0; }
  .trade-ref-controls { gap: 10px; padding: 10px; }
  .trade-ref-controls .toggle { min-height: 32px; }
  .trade-ref-control { flex: 1 1 100%; justify-content: space-between; }
  .trade-ref-control select,
  .trade-ref-control input[type="date"] { min-height: 36px; }
  .trade-ref-group { flex: 1 1 100%; flex-direction: column; align-items: stretch; gap: 8px; }
  .trade-ref-hv-info { line-height: 1.6; }
  .trade-win-odds-head { align-items: stretch; }
  .trade-win-odds-head h3 { flex: 1 1 100%; }
  .trade-win-odds-head .trade-ref-control { flex: 1 1 100%; justify-content: space-between; }
  .trade-win-odds-head #tradeWinOddsAnchor { flex: 1 1 100%; }
  .trade-win-odds-grid { grid-template-columns: repeat(2, 1fr); }
  .trade-sim-form { align-items: stretch; }
  .trade-sim-form label { flex: 1 1 100%; }
  .trade-sim-form input { width: 100%; min-height: 38px; }
  .trade-sim-form button { flex: 1 1 100%; min-height: 42px; }
}
