/* ===== REPORTNEW UI - PORTRAIT / MOBILE ===== */

@media (max-width: 1023px), (hover: none) and (pointer: coarse) {
  :root {
    --sidebar-width: 0px;
    --mobile-update-top: calc(var(--header-h) + var(--safe-area-top));
    --toc-mobile-top: calc(var(--mobile-update-top) + 36px);
    --mobile-viewing-top: calc(var(--mobile-update-top) + 36px);
  }

  body {
    padding-top: calc(var(--header-h) + var(--safe-area-top));
    padding-bottom: calc(68px + var(--footer-h-mobile) + var(--safe-area-bottom));
  }

  body.logged-in {
    --header-h: 64px;
    --sidebar-width: 0px !important;
    padding-top: calc(var(--header-h) + var(--safe-area-top));
    padding-left: 0 !important;
  }

  body.logged-out {
    padding: 0;
  }

  #sidebar {
    display: none !important;
  }

  .sidebar-brand {
    display: none;
  }

  #contentWrap,
  body.sidebar-open #contentWrap,
  body.force-desktop-landscape.sidebar-open #contentWrap {
    margin-left: 0 !important;
  }

/* ===== HEADER mobile — see styles/components/header.css ===== */
  /* body:not(.logged-out) re-enables the header on mobile (desktop hides it via @media). */
  body:not(.logged-out) .app-header {
    display: block !important;
  }

/* ===== MOBILE HEADER — see styles/components/header.css @media ===== */

  body.logged-in .title-top {
    display: none;
  }

  body.logged-in .title-main {
    font-size: 20px;
    font-weight: 900;
    line-height: 1.15;
    text-align: left;
  }

  body.logged-in .logo-d {
    display: block;
  }

  /* ===== LOGIN SCREEN — see styles/login.css (shared HL + MODULAR) ===== */
/* All body.logged-out login rules moved to shared login.css */

/* ===== Body:not(.logged-out) header rules ===== */

  .welcome-banner {
    top: calc(var(--header-h) + var(--safe-area-top));
    left: 0 !important;
    padding: 6px 10px;
    font-size: 13px;
  }

  body.logged-in .welcome-banner {
    display: none !important;
  }

  .mobile-update-date,
  .mobile-viewing-info,
  #tocMobile {
    position: fixed;
    left: 0;
    right: 0;
    display: none;
    z-index: var(--z-banner);
    text-align: center;
  }

  body.logged-in .mobile-update-date {
    top: var(--mobile-update-top);
    display: none !important;
    padding: 6px 10px;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
    color: var(--brand);
    font-size: 13px;
    font-weight: 900;
  }

  body.logged-in #tocMobile {
    top: auto;
    bottom: calc(var(--footer-h-mobile) + var(--safe-area-bottom));
    display: block !important;
    padding: 8px 10px;
    background: #ffffff;
    border-top: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
    z-index: var(--z-dropdown);
  }

  #tocMobile .row {
    display: flex;
    gap: 8px;
    align-items: stretch;
  }

  .mobile-menu-btn,
  .mobile-view-other-btn,
  .mobile-logout-btn {
    flex: 1;
    min-width: 0;
    min-height: 38px;
    padding: 6px 8px;
    border: 1px solid var(--brand-border);
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 900;
    line-height: 1.15;
    white-space: normal;
  }

  .mobile-menu-btn::before {
    content: "☰";
    display: block;
    font-size: 16px;
    line-height: 1;
    margin-bottom: 2px;
  }

  .mobile-view-other-btn::before {
    content: "↺";
    display: block;
    font-size: 16px;
    line-height: 1;
    margin-bottom: 2px;
  }

  .mobile-logout-btn::before {
    content: "⎋";
    display: block;
    font-size: 16px;
    line-height: 1;
    margin-bottom: 2px;
  }

  .mobile-menu-btn {
    background: var(--brand-soft);
    color: var(--brand);
  }

  .mobile-menu-btn:disabled,
  .mobile-menu-btn.is-disabled {
    cursor: not-allowed;
    opacity: 0.48;
    filter: grayscale(0.4);
  }

  .mobile-view-other-btn {
    background: var(--warning);
    color: #ffffff;
    border-color: var(--warning);
  }

  .mobile-logout-btn {
    background: var(--danger);
    color: #ffffff;
    border-color: var(--danger);
  }

  .mobile-menu-dropdown {
    position: absolute;
    top: auto;
    bottom: calc(100% + 6px);
    left: 8px;
    right: 8px;
    z-index: var(--z-dropdown);
    display: none;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-panel);
  }

  .mobile-menu-content {
    max-height: min(62vh, 420px);
    overflow-y: auto;
    padding: 8px;
  }

  .mobile-menu-item {
    display: block;
    padding: 11px 12px;
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
  }

  .mobile-menu-item:hover {
    background: var(--brand-soft);
    color: var(--brand);
  }

  body.logged-in .mobile-viewing-info {
    top: var(--mobile-viewing-top);
    display: none;
    padding: 6px 10px;
    background: linear-gradient(90deg, var(--brand) 0%, #047a60 100%);
    color: #ffffff;
    font-size: 13px;
    font-weight: 900;
    line-height: 1.25;
  }

  main {
    width: 100%;
    max-width: none;
    padding: 12px;
  }

  body.logged-in main {
    padding-top: 12px;
  }

  .mobile-menu-home {
    display: block;
    margin: 0;
    padding: 14px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-soft);
  }

  .mobile-menu-home.hide {
    display: none !important;
  }

  .mobile-home-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
  }

  .mobile-home-kicker {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
  }

  .mobile-home-header h2 {
    margin: 2px 0 0;
    color: var(--brand);
    font-size: 20px;
    font-weight: 900;
    line-height: 1.15;
  }

  .mobile-home-back-btn {
    flex: 0 0 auto;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px 9px;
    border: 1px solid var(--brand-border);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--brand);
    font-size: 12px;
    font-weight: 900;
    line-height: 1;
    white-space: nowrap;
  }

  .mobile-home-back-btn:active {
    opacity: 0.82;
  }

  .mobile-home-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

/* ===== MOBILE HOME CARDS — see styles/danh-muc.css ===== */

/* Promo potential results: grid bảng dạng card */
@media (max-width: 1023px), (hover: none) and (pointer: coarse) {
  .pro-tab-btn { font-size: 12px; padding: 6px 8px; }
  .pro-tab-btn small { font-size: 10px; }
  .pro-result-item { padding: 10px; }
  .pro-result-item .agent-result-name { font-size: 13px; }
  .pro-result-item table { font-size: 11px; }
  .pro-result-item th, .pro-result-item td { padding: 3px 5px; }
  .pro-result-item .metric-badge { font-size: 10px; padding: 2px 6px; }
}
.pro-result-item { background: #fff; border: 1px solid var(--brand-border, #b3d9d0); border-radius: var(--radius-lg, 12px); padding: 14px 12px 12px; margin-bottom: 10px; box-shadow: var(--shadow-brand, 0 2px 10px rgba(2,91,72,0.12)); border-top: 4px solid var(--brand, #025b48); }
.pro-result-item .agent-result-header { display: flex; align-items: flex-start; gap: 4px; margin-bottom: 2px; }
.pro-result-item .agent-icon { flex-shrink: 0; font-size: 14px; line-height: 1.2; background: linear-gradient(135deg, #22c55e, #059669); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.pro-result-item .agent-result-header-text { flex: 1; min-width: 0; }
.pro-result-item .agent-result-name { font-weight: 900; font-size: 14px; color: var(--brand, #025b48); }
.pro-result-item .agent-result-sub { font-size: 10.5px; color: var(--muted, #6b7280); font-weight: 600; }
.pro-result-item .agent-result-mos-ngn { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.pro-result-item .agent-result-details { font-size: 12px; color: var(--muted, #4a5568); margin-bottom: 8px; }
.pro-result-item table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 6px 0; }
.pro-result-item th { background: #f1f5f9; color: #374151; font-weight: 800; padding: 4px 6px; border: 1px solid #d1d5db; text-align: center; text-transform: uppercase; }
.pro-result-item td { padding: 4px 6px; border: 1px solid #d1d5db; text-align: center; font-weight: 700; }
.pro-result-item .metric-badge { display: inline-block; background: #eef2ff; color: #4338ca; font-weight: 800; font-size: 11px; padding: 3px 8px; border-radius: 4px; margin-bottom: 6px; }

.mos-filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 0 0 10px; }
.mos-filter-label { font-weight: 800; font-size: 12px; color: var(--muted, #4a5568); margin-right: 3px; }
.mos-filter-btn { padding: 4px 8px; border: 1px solid var(--brand-border, #b3d9d0); border-radius: var(--radius, 8px); background: #fff; color: var(--brand, #025b48); font-weight: 800; font-size: 11px; cursor: pointer; }
.mos-filter-btn.active { background: var(--brand, #025b48); color: #fff; border-color: var(--brand, #025b48); }
.mos-filter-btn:hover:not(.active) { background: var(--brand-soft, #e6f4f1); }

.agent-result-btn table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 6px 0; }
.agent-result-btn th { background: #f1f5f9; color: #374151; font-weight: 800; padding: 4px 6px; border: 1px solid #d1d5db; text-align: center; text-transform: uppercase; }
.agent-result-btn td { padding: 4px 6px; border: 1px solid #d1d5db; text-align: center; font-weight: 700; }
.agent-result-btn .metric-badge { display: inline-block; background: #eef2ff; color: #4338ca; font-weight: 800; font-size: 11px; padding: 3px 8px; border-radius: 4px; margin-bottom: 6px; }
.badge-mos { display: inline-block; background: #f0fdf4; color: #15803d; font-weight: 800; font-size: 11px; padding: 3px 8px; border-radius: 4px; vertical-align: middle; }
.badge-ngn { display: inline-block; background: #fef2f2; color: #b91c1c; font-weight: 800; font-size: 11px; padding: 3px 8px; border-radius: 4px; vertical-align: middle; }

  /* MDRT pair rows: mobile xếp dọc, bỏ đường kẻ | giữa 2 cột */
  .mstar-pair-row { grid-template-columns: 1fr !important; gap: 10px !important; }
  .mstar-pair-row > div { grid-column: 1 !important; }
  .mstar-pair-left { border-right: none !important; padding-right: 0 !important; }

  .section-container,
  .section-container.modern-info-container {
    margin-top: 12px;
    padding: 10px;
    border-radius: var(--radius);
  }

  .info-groups-container,
  #sectionManulifePro .info-groups-container,
  #sectionMbaPro .info-groups-container,
  #sectionChucDanh .info-groups-container {
    grid-template-columns: 1fr;
    gap: 10px;
    grid-auto-flow: row;
  }

  .info-group {
    grid-column: 1 / -1 !important;
    border-radius: var(--radius);
    overflow: hidden;
  }

  .info-group-header {
    min-height: 46px;
    padding: 10px 12px;
    gap: 8px;
  }

  .info-group-icon {
    width: 22px;
    flex-basis: 22px;
    font-size: 17px;
  }

  .info-group-title {
    font-size: 13px;
  }

  .info-group-content,
  .info-group-content.two-columns,
  #sectionMStar .info-group-content.two-columns,
  #sectionChucDanh .info-group-content.two-columns,
  #sectionMbaPro .info-group-content.two-columns,
  #sectionManulifePro .info-group-content.three-row-layout,
  #sectionManulifePro .info-group-content.two-row-layout {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }

  /* Theo dõi các lớp học yêu cầu — mobile */
  /* summaryRow: 2 cột (là div con thứ 2 của parent-group-content) */
  .info-group-content.parent-group-content > div:nth-child(2)[style*="display: grid"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  /* sub-group rows: 4 cột */
  .info-group-content.parent-group-content > div[style*="display: grid"] {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  /* summaryRow: "Kỹ năng huấn luyện" & "Kỹ năng lãnh đạo" label 2 dòng */
  .info-group-content.parent-group-content > div:nth-child(2) .info-item-modern:nth-child(3) .info-label,
  .info-group-content.parent-group-content > div:nth-child(2) .info-item-modern:nth-child(4) .info-label {
    -webkit-line-clamp: 2 !important;
    max-height: calc(11px * 1.3 * 2) !important;
  }

  .lop-hoc-sub-title {
    font-size: 13px !important;
    padding: 6px 0 2px !important;
  }

  /* Fast-Track subgroups mobile: 2 cột */
  .fasttrack-subgroup-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
  /* SBW (cuối subgroup 2) và Thưởng Fast Track tạm tính (cuối subgroup 4): full-width */
  .fasttrack-subgroup:nth-child(2) .info-item-modern:last-child,
  .fasttrack-subgroup:nth-child(4) .info-item-modern:last-child {
    grid-column: 1 / -1 !important;
  }

  .info-group.collapsed .info-group-content {
    max-height: 0 !important;
    min-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
  }

  .info-item,
  .info-item-modern {
    min-height: 0;
    padding: 5px 8px;
  }

  .info-label,
.thin,
.li-label {
    font-size: 11px;
    white-space: normal !important;

    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;

    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;

    min-height: unset;
    max-height: unset;
}

  .label-desk { display: none !important; }
  .promo-desk { display: none !important; }
  .promo-mob { display: block !important; grid-column: 1 / -1 !important; overflow: hidden; }
  .info-group-content.parent-group-content {
    display: flex !important;
    flex-direction: column;
  }
  .label-mob {
    display: flex !important;
    flex-direction: column;
  }
  .label-mob span:first-child { text-align: left; }
  .label-mob span:last-child { text-align: right; }

  #sectionChucDanh .info-item-modern .info-label {
    white-space: normal !important;
    overflow: visible;
    text-overflow: clip;
  }

  .info-value,
  .info-item .val,
  .hl {
    font-size: 14px;
    text-align: right;
  }

  .info-grid,
  .sub-block,
  .sub-content,
  .income-input-row,
  .income-input-row-4-col,
  .income-input-row-2-col,
  .income-group-1,
  .subsection-content {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .list-dot li,
  .bullet-strong li {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .hl {
    text-align: left;
  }

  .thumbnail-slideshow {
    top: calc(var(--header-h) + var(--safe-area-top));
    left: 0 !important;
    bottom: var(--footer-h-mobile);
  }

  .slide img {
    width: 98%;
    height: 98%;
  }

  .agent-selection {
    margin: 12px 0 0;
    padding: 10px;
  }

  .selection-container,
  .search-wrapper,
  .agent-search-container {
    align-items: stretch;
    gap: 8px;
  }

  .search-wrapper,
  .agent-search-container {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(86px, 0.72fr);
    gap: 8px;
  }

  .agent-search-input {
    min-width: 0;
    width: 100%;
    grid-column: 1 / -1;
    flex: unset;
  }

  .search-agent-btn,
  .view-my-report-btn {
    flex: unset;
    min-width: 0;
    width: 100%;
    min-height: 42px;
    font-size: 12px;
    white-space: normal;
  }

  .region-filter-section {
    flex: unset;
    width: auto;
  }

  .dropdown-toggle {
    min-height: 42px;
  }

  .manulife-pro-filters {
    padding: 10px;
  }

  .filter-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .filter-btn {
    min-height: 64px;
    padding: 8px;
    font-size: 12px;
  }

  .search-result,
  .filter-results {
    margin-top: 10px;
    padding: 10px;
  }

  .filter-results-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .export-buttons-group {
    width: 100%;
  }

  .export-filter-btn {
    flex: 1;
  }

  .agent-result-btn {
    padding: 10px 12px;
  }

  .agent-result-name {
    font-size: 14px;
  }

  .agent-result-sub {
    font-size: 10.5px;
    color: var(--muted, #6b7280);
    font-weight: 600;
  }

  .agent-result-mos-ngn {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 4px;
  }

  .agent-result-details {
    font-size: 12px;
  }

  .warning-section,
  .pinned-warning,
  .pro-alert,
  .stage-allocation-warning {
    padding: 12px;
  }

  .popup-content,
  .custom-confirm-modal,
  .loading-content {
    width: calc(100vw - 24px);
    padding: 18px;
  }

  .popup-buttons,
  .custom-confirm-buttons {
    flex-direction: column;
  }

  #pageFooter {
    min-height: var(--footer-h-mobile);
    flex-direction: row;
    justify-content: space-between;
    gap: 4px;
    padding: 4px 10px;
    font-size: 10px;
    border-radius: 0;
  }

  body.logged-in #pageFooter {
    left: 0;
  }

  .footer-left {
    justify-content: flex-start;
  }
  .footer-right {
    justify-content: flex-end;
  }

  #pageFooter img {
    height: 12px;
  }

  .print-btn,
  #supportFooter {
    min-height: 24px;
    padding: 4px 8px;
    font-size: 10px;
  }

  #supportDesk {
    display: none !important;
  }
}

@media (max-width: 1023px), (hover: none) and (pointer: coarse) {
  body.logged-in {
    --mobile-nav-h: 40px;
    --mobile-footer-real-h: 56px;
    padding-bottom: calc(var(--mobile-nav-h) + var(--mobile-footer-real-h) + 14px + var(--safe-area-bottom));
  }

  body.logged-in #tocMobile {
    bottom: calc(var(--mobile-footer-real-h) + var(--safe-area-bottom));
    height: var(--mobile-nav-h);
    padding: 4px 8px;
  }

  #tocMobile .row {
    gap: 6px;
    height: 100%;
    justify-content: center;
  }

  .mobile-menu-btn,
  .mobile-view-other-btn,
  .mobile-logout-btn {
    min-height: 0;
    height: 32px;
    padding: 3px 8px;
    font-size: 11px;
    line-height: 1.1;
  }

  .mobile-menu-btn {
    width: 100%;
    max-width: none;
  }

  .mobile-menu-btn::before,
  .mobile-view-other-btn::before,
  .mobile-logout-btn::before {
    display: inline-block;
    font-size: 13px;
    margin-right: 5px;
    margin-bottom: 0;
  }

  #pageFooter {
    min-height: var(--mobile-footer-real-h);
    height: var(--mobile-footer-real-h);
    padding: 3px 10px;
  }

  #supportDesk {
    display: none !important;
  }
}

@media (max-width: 1023px), (hover: none) and (pointer: coarse) {
  #tocMobile .row {
    width: 100%;
  }

  .mobile-menu-btn {
    width: 100%;
    max-width: none;
    min-height: 32px;
    height: 32px;
  }

  .mobile-home-header {
    display: block;
  }

  .mobile-home-back-btn {
    display: none !important;
  }

/* ===== MOBILE HOME CARDS further override — see styles/danh-muc.css ===== */
}

@media (min-width: 768px) and (max-width: 1023px) {
  body {
    padding-top: calc(var(--header-h) + 102px + var(--safe-area-top));
  }

  main {
    padding: 16px;
  }

  .info-group-content,
  .info-group-content.two-columns,
  #sectionManulifePro .info-group-content.three-row-layout,
  #sectionManulifePro .info-group-content.two-row-layout,
  .filter-buttons,
  .income-input-row,
  .income-input-row-4-col,
  .subsection-content {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (orientation: landscape) and (min-width: 900px) and (hover: none) and (pointer: coarse) {
  body.force-desktop-landscape {
    --sidebar-width: 280px;
    padding-top: calc(var(--header-h) + var(--safe-area-top));
  }

  body.force-desktop-landscape.logged-in .app-header {
    left: var(--sidebar-width);
  }

  body.force-desktop-landscape.logged-in #sidebar {
    display: block !important;
    top: 0;
    width: 280px;
    bottom: 0;
  }

  body.force-desktop-landscape.logged-in .sidebar-brand {
    display: flex;
  }

  body.force-desktop-landscape.logged-in #contentWrap,
  body.force-desktop-landscape.logged-in.sidebar-open #contentWrap {
    margin-left: var(--sidebar-width) !important;
  }

  body.force-desktop-landscape.logged-in #pageFooter {
    left: var(--sidebar-width);
  }

  body.force-desktop-landscape.logged-in #tocMobile,
  body.force-desktop-landscape.logged-in .mobile-update-date,
  body.force-desktop-landscape.logged-in .mobile-viewing-info {
    display: none !important;
  }

  body.force-desktop-landscape .header-grid {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  body.force-desktop-landscape .brand-row {
    justify-content: flex-start;
  }

  body.force-desktop-landscape .title-wrap {
    align-items: flex-start;
  /* Manulife Pro compact cards: giảm font mobile */
  #sectionManulifePro .info-group-content [style*="font-size:18px"] { font-size: 11px !important; }
  #sectionManulifePro .info-group-content [style*="font-size:13px"] { font-size: 9px !important; }
  #sectionManulifePro .info-group-content [style*="font-size:10px"] { font-size: 7px !important; }
  #sectionManulifePro .info-group-content [style*="font-size:22px"] { font-size: 13px !important; }
  #sectionManulifePro .info-group-content [style*="font-size:15px"] { font-size: 11px !important; }
  .compact-fyp { flex: 4 1 0% !important; }
  .compact-sbw { flex: 1 1 0% !important; }
}

body.force-desktop-landscape .title-top,
  body.force-desktop-landscape .title-main {
    text-align: left;
    white-space: nowrap;
  }
}
