/* TiKi Tax V5.5.9 — Financial Reports mobile view only */
@media (max-width: 768px) {
  html, body, #root { width:100%; max-width:100%; overflow-x:hidden; }
  body.tiki-financial-report-mobile main,
  body.tiki-financial-report-mobile main > *,
  body.tiki-financial-report-mobile .tiki-report-mobile-scope {
    max-width:100%; min-width:0; box-sizing:border-box;
  }

  /* Report view selector: stays below app header and always fits. */
  body.tiki-financial-report-mobile .tiki-report-tools {
    position:relative; top:auto; z-index:20; width:100%; max-width:100%;
    display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px;
    overflow:visible; padding:8px 16px; box-sizing:border-box;
  }
  body.tiki-financial-report-mobile .tiki-report-tools strong { display:none; }
  body.tiki-financial-report-mobile .tiki-report-tools button {
    width:100%; min-width:0; max-width:100%; padding:9px 6px;
    white-space:normal; line-height:1.15;
  }

  /* Disable the old zoom based compact implementation on phones. */
  body.tiki-financial-report-mobile.tiki-report-compact .tiki-report-scroll {
    zoom:1 !important; width:100% !important; transform:none !important;
  }

  /* Main report component and cards */
  body.tiki-financial-report-mobile main { overflow-x:hidden; padding-bottom:calc(120px + env(safe-area-inset-bottom)); }
  body.tiki-financial-report-mobile main .space-y-6 { max-width:100%; min-width:0; }
  body.tiki-financial-report-mobile main [class*="grid-cols"],
  body.tiki-financial-report-mobile main [class*="flex"] { min-width:0; }
  body.tiki-financial-report-mobile main svg { max-width:100%; }

  /* Top heading + related links + year/filter/export controls. */
  body.tiki-financial-report-mobile .tiki-pl-heading-row { width:100%; max-width:100%; min-width:0; }
  body.tiki-financial-report-mobile .tiki-pl-heading-row > div { width:100%; max-width:100%; min-width:0; }
  body.tiki-financial-report-mobile .tiki-pl-related,
  body.tiki-financial-report-mobile .tiki-pl-actions {
    display:grid !important; grid-template-columns:repeat(2,minmax(0,1fr));
    gap:8px !important; width:100%; max-width:100%; min-width:0;
  }
  body.tiki-financial-report-mobile .tiki-pl-related > *,
  body.tiki-financial-report-mobile .tiki-pl-actions > * {
    width:100% !important; min-width:0 !important; max-width:100% !important;
  }
  body.tiki-financial-report-mobile .tiki-pl-related > span { grid-column:1/-1; }

  /* Comfortable: only the breakdown table itself may scroll sideways. */
  body.tiki-financial-report-mobile:not(.tiki-report-compact) .tiki-report-scroll {
    width:100% !important; max-width:100% !important; min-width:0 !important;
    overflow-x:auto !important; overflow-y:hidden;
    -webkit-overflow-scrolling:touch; overscroll-behavior-x:contain;
  }
  body.tiki-financial-report-mobile:not(.tiki-report-compact) .tiki-report-scroll table th:first-child,
  body.tiki-financial-report-mobile:not(.tiki-report-compact) .tiki-report-scroll table td:first-child {
    position:sticky; left:0; z-index:2; background:hsl(var(--background));
  }

  /* Fit annual: replace desktop annual matrix with readable category cards. */
  body.tiki-financial-report-mobile.tiki-report-compact .tiki-report-scroll { display:none !important; }
  .tiki-mobile-annual { display:none; }
  body.tiki-financial-report-mobile.tiki-report-compact .tiki-mobile-annual {
    display:block; width:100%; max-width:100%; min-width:0;
  }
  .tiki-mobile-annual-section { margin:0 0 16px; }
  .tiki-mobile-annual-section-title {
    padding:10px 12px; border-radius:10px; font-weight:800; font-size:14px; margin-bottom:8px;
  }
  .tiki-mobile-annual-section.revenue .tiki-mobile-annual-section-title { background:#ecfdf3; color:#16743a; }
  .tiki-mobile-annual-section.expenses .tiki-mobile-annual-section-title { background:#fff1f1; color:#b42318; }
  .tiki-mobile-annual-card {
    width:100%; max-width:100%; min-width:0; box-sizing:border-box;
    border:1px solid hsl(var(--border)); border-radius:12px; padding:12px;
    margin:0 0 10px; background:hsl(var(--background));
  }
  .tiki-mobile-annual-card-head {
    display:grid; grid-template-columns:minmax(0,1fr) auto; gap:10px; align-items:start;
    margin-bottom:10px;
  }
  .tiki-mobile-annual-name { min-width:0; font-weight:700; overflow-wrap:anywhere; }
  .tiki-mobile-annual-total { white-space:nowrap; font-weight:800; color:#08783e; }
  .tiki-mobile-annual-months {
    display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px;
  }
  .tiki-mobile-month {
    min-width:0; border-radius:8px; padding:7px 6px; background:hsl(var(--muted)/.45);
    cursor:pointer;
  }
  .tiki-mobile-month-label { display:block; font-size:11px; color:hsl(var(--muted-foreground)); overflow-wrap:anywhere; }
  .tiki-mobile-month-value { display:block; margin-top:2px; font-size:12px; font-weight:650; white-space:nowrap; }
  .tiki-mobile-annual-card.total-card { background:hsl(var(--muted)/.25); }
  .tiki-mobile-annual-card.net-card { border-width:2px; }

  body.tiki-financial-report-mobile:fullscreen main { overflow-x:auto; }
  body.tiki-financial-report-mobile:fullscreen .tiki-mobile-annual { display:none !important; }
  body.tiki-financial-report-mobile:fullscreen .tiki-report-scroll { display:block !important; overflow-x:auto !important; }
}

@media (max-width: 360px) {
  body.tiki-financial-report-mobile .tiki-pl-related,
  body.tiki-financial-report-mobile .tiki-pl-actions { grid-template-columns:1fr; }
  .tiki-mobile-annual-months { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
