/* ==========================================================================
   Print / PDF layer — every screen exports through the browser's PDF writer.

   Only the active .tabpane prints. App chrome (rail, topbar, mobile nav,
   drawers, modals) is dropped, colours are forced to ink-on-paper, and the
   panes that scroll on screen are unclipped so nothing is cut off.
   ========================================================================== */

#print-header, #print-footer { display: none; }

@media print {
  @page {
    size: A4 portrait;
    margin: 8mm 10mm 10mm 10mm;
  }

  html, body {
    background: #ffffff !important;
    color: #0f172a !important;
    height: auto !important;
    overflow: visible !important;
    font-family: "Noto Sans Tamil", "Inter", -apple-system, sans-serif !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Force the crisp high-contrast paper palette regardless of the on-screen theme */
  :root, html[data-theme] {
    --ink: #ffffff;
    --ink-deep: #f8fafc;
    --ink-raise: #ffffff;
    --parchment: #0f172a;
    --parchment-dim: #334155;
    --line: #cbd5e1;
    --th-bg: #ffffff;
    --th-surface: #ffffff;
    --th-text: #0f172a;
    --th-text-dim: #334155;
    --th-border: #991b1b;
  }

  /* ---------- chrome off ---------- */
  .topbar, .rail, .brand-cell, .mobile-nav, .drawer, .drawer-scrim,
  .jv-zoom-fab,
  .modal-scrim, .tools-popout, .toast-stack, .chart-pager, .chart-pair-tabs,
  .form-sticky, .now-panel, #need-profile, .page-head .btn-sm,
  [data-action], .btn-icon, .btn-sm, .div-select, .segmented,
  .table-scroll::-webkit-scrollbar {
    display: none !important;
  }

  /* ---------- one screen per document ---------- */
  .tabpane { display: none !important; }
  .tabpane:not(.hidden) { display: block !important; }

  .app, .main, .jv-scroll, .main-inner {
    display: block !important;
    position: static !important;
    inset: auto !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #ffffff !important;
  }

  /* Nothing on paper may clip or scroll */
  .card, .chart-layout, .chart-main, .chart-page, .pos-list, .table-scroll,
  .si-cell, .pan-board, .tabpane, section, article {
    overflow: visible !important;
    max-height: none !important;
    height: auto !important;
    box-shadow: none !important;
  }
  .chart-page { display: block !important; }

  .card, section.card {
    border: 1pt solid #cbd5e1 !important;
    border-radius: 4px !important;
    background: #ffffff !important;
    break-inside: avoid;
    page-break-inside: avoid;
    margin: 0 0 5mm !important;
    padding: 3mm 4mm !important;
  }

  h1, h2, h3 {
    color: #991b1b !important;
    break-after: avoid;
    font-weight: 700 !important;
  }
  table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin-bottom: 4mm !important;
  }
  th {
    background: #fef2f2 !important;
    color: #991b1b !important;
    border: 1pt solid #cbd5e1 !important;
    border-bottom: 2pt solid #991b1b !important;
    padding: 5px 8px !important;
    font-size: 9.5pt !important;
    font-weight: 700 !important;
    text-align: left !important;
  }
  td {
    border: 1pt solid #cbd5e1 !important;
    color: #0f172a !important;
    padding: 4px 8px !important;
    font-size: 9pt !important;
  }
  tbody tr:nth-child(even) td {
    background: #f8fafc !important;
  }
  thead { display: table-header-group; }
  tr { break-inside: avoid; page-break-inside: avoid; }

  /* ---------- charts ---------- */
  .chart-pair {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 6mm !important;
    margin-bottom: 5mm !important;
  }
  .chart-pair > .chart-box { display: block !important; }

  .si-chart {
    background: #ffffff !important;
    border: 2pt solid #991b1b !important;
    border-radius: 4px !important;
    break-inside: avoid;
    page-break-inside: avoid;
    box-shadow: none !important;
  }
  .si-cell {
    background: #ffffff !important;
    border: 1pt solid #e2e8f0 !important;
  }
  .si-blank {
    background: #fffaf5 !important;
    border: 1pt solid #e2e8f0 !important;
  }
  .si-rasi {
    color: #7f1d1d !important;
    font-weight: 700 !important;
    font-size: 9pt !important;
  }
  .si-cusp, .ch-ct-cusp {
    color: #0284c7 !important;
    font-weight: 600 !important;
  }
  .si-center, .si-center-rich, .jk-ct-v {
    color: #0f172a !important;
  }
  .si-center {
    border: 1.5pt solid #c2410c !important;
    border-radius: 4px !important;
    background: #fffdfa !important;
  }
  .chip {
    font-size: 9.5pt !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
  }
  .chip.lagna {
    background: #991b1b !important;
    color: #ffffff !important;
    padding: 1px 4px !important;
    border-radius: 3px !important;
    font-weight: 700 !important;
  }

  .jk-chart-wrap {
    width: 600px !important;
    max-width: 600px !important;
    margin: 0 auto !important;
    background: #ffffff !important;
    border: 2pt solid #991b1b !important;
  }
  .jk-outer-lbl {
    background: #ffffff !important;
    color: #0f172a !important;
    border-color: #c2410c !important;
  }
  .hero-picker, .tile-grid, .recent-list { display: none !important; }

  /* ---------- printed header ---------- */
  #print-header {
    display: block !important;
    border-bottom: 2pt solid #991b1b !important;
    margin: 0 0 4mm !important;
    padding-bottom: 2.5mm !important;
  }
  #print-header .print-invocation {
    font-size: 9pt;
    text-align: center;
    color: #991b1b;
    font-weight: 700;
    letter-spacing: 0.18em;
    margin-bottom: 1.5mm;
  }
  #print-header .print-brand-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1.5mm;
  }
  #print-header .print-brand {
    font-family: var(--font-display, serif);
    font-size: 17pt;
    font-weight: 700;
    color: #991b1b;
    letter-spacing: 0.03em;
    line-height: 1.1;
  }
  #print-header .print-subbrand {
    font-size: 9.5pt;
    color: #c2410c;
    font-weight: 600;
  }
  #print-header .print-screen {
    font-size: 13pt;
    font-weight: 700;
    color: #0f172a;
    text-align: right;
  }
  #print-header .print-meta-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5mm 3.5mm;
    margin-top: 2mm;
    padding: 2mm 3mm;
    background: #fffaf5;
    border: 1pt solid #fed7aa;
    border-radius: 4px;
    font-size: 8.5pt;
    line-height: 1.35;
  }
  #print-header .print-meta-item b {
    color: #991b1b;
    font-weight: 600;
  }

  /* ---------- printed footer ---------- */
  #print-footer {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    border-top: 1pt solid #cbd5e1;
    margin-top: 4mm;
    padding-top: 2mm;
    font-size: 8pt;
    color: #64748b;
  }

  a[href]::after { content: none !important; }
}
