/* ===== Scoped to this page only ===== */
.report-page .select2-container--default .select2-selection--single .select2-selection__rendered{
  font-weight: normal !important; font-style: normal !important; color:#495057;
}
.report-page .select2-currency{ width:100% !important; }
.report-page .select2-container--default .select2-selection--single{
  height:38px; padding:6px 12px; border:1px solid #ced4da; border-radius:4px; display:flex; align-items:center;
}
.report-page .select2-container--default .select2-selection--single .select2-selection__rendered{ line-height:normal; }

/* ===== Mobile “cards” only on this page ===== */
@media (max-width:768px){
  .report-page .table{ display:block; border:none; }
  .report-page .table thead{ display:none; }
  .report-page .table tbody{ display:flex; flex-direction:column; }
  .report-page .table tr{ display:flex; flex-direction:column; border:1px solid #ddd; margin-bottom:10px; padding:10px; background:#f9f9f9; }
  .report-page .table td{ display:flex; justify-content:space-between; padding:5px 0; }
  .report-page .table td::before{ content:attr(data-label); font-weight:700; margin-right:10px; color:#333; }
}

/* ===== Desktop transactions tables (BOTH aggr & D-acc) ===== */
@media (min-width:769px){
  .report-page .transactions-wrapper{
    overflow-y:auto; overflow-x:hidden; position:relative;
  }

  .report-page .transactions-table{
    table-layout:fixed; border-collapse:separate; border-spacing:0;
    /* sticky fallbacks – JS will set real values */
    --th1-h:38px; --thead-h:76px; --broker-h:32px;

    /* one palette */
    --hdr-b:#c6d0e8;   /* header border */
    --grid-b:#d7e0f3;  /* vertical grid + instrument frame */
    --hdr1-bg:#eef3ff; /* row 1 bg */
    --hdr2-bg:#f7f9ff; /* row 2 bg */
  }

  /* compact cells */
  .report-page .transactions-table th,
  .report-page .transactions-table td{
    box-sizing:border-box; font-size:.88rem; line-height:1.2;
    padding:.45rem .55rem; vertical-align:middle;
  }

  /* Sticky header rows – same border color on both rows */
  .report-page .transactions-table thead tr.head-row-1 th{
    position:sticky; top:0; z-index:31;
    background:var(--hdr1-bg);
    border:1px solid var(--hdr-b);
    border-bottom:0;
    box-shadow:0 2px 4px -3px rgba(0,0,0,.25);
    font-weight:700;
  }
  .report-page .transactions-table thead tr.head-row-2 th{
    position:sticky; top:var(--th1-h); z-index:30;
    background:var(--hdr2-bg);
    border:1px solid var(--hdr-b);
    box-shadow:0 2px 4px -3px rgba(0,0,0,.15);
    font-weight:600;
  }

  /* Make vertical separators uniform under both header rows */
  .report-page .transactions-table thead tr.head-row-1 th + th{ border-left-color:var(--hdr-b); }
  .report-page .transactions-table thead tr.head-row-2 th + th{ border-left-color:var(--hdr-b); }

  /* Body grid */
  .report-page .transactions-table tbody td{ border-bottom:1px solid #edf1f7; }
  .report-page .transactions-table tbody td + td{ border-left:1px solid var(--grid-b); }

  /* Sticky group rows */
  .report-page .transactions-table .group-title{
    position:sticky; top:var(--thead-h); z-index:25;
    background:#eef3ff; color:#1f3b7b; font-weight:700;
    border:1px solid var(--hdr-b); border-top-width:2px; padding:.5rem .6rem;
  }
  .report-page .transactions-table .instrument-title{
    position:sticky; top:calc(var(--thead-h) + var(--broker-h)); z-index:20;
    background:#f7f9ff; color:#2b3d6b; font-weight:600;
    border:1px solid var(--hdr-b); border-bottom:0; border-radius:6px 6px 0 0;
    padding:.45rem .55rem;
  }

  /* === Bring back the ticker “frame” === */
  .report-page .transactions-table .instrument-row td{
    border-left:1px solid var(--grid-b);
    border-right:1px solid var(--grid-b);
  }
  .report-page .transactions-table .instrument-row.instrument-first td{
    border-top:1px solid var(--grid-b);
  }
  .report-page .transactions-table .instrument-row.instrument-last td{
    border-bottom:1px solid var(--grid-b);
    border-radius:0 0 6px 6px;
  }

  /* --- fix Bootstrap bleed + crisp edges (keep last) --- */
  .report-page .transactions-table thead th{
    border-color: var(--hdr-b) !important;
    border-bottom-width: 1px !important;
    background-clip: padding-box;
  }
  .report-page .transactions-table thead tr.head-row-1 th{
    border-bottom: 0 !important;
  }
  .report-page .transactions-table thead tr.head-row-1 th:first-child{
    border-top-left-radius: 8px;
  }
  .report-page .transactions-table thead tr.head-row-1 th:last-child{
    border-top-right-radius: 8px;
  }
  .report-page .transactions-table thead tr.head-row-2 th:first-child{
    border-left-width: 1px;
  }
  .report-page .transactions-table thead tr.head-row-2 th:last-child{
    border-right-width: 1px;
  }
}
/* --- unify header color + crisp edges --- */
@media (min-width:769px){
  /* pick a neutral, non-blue tone */
  .report-page .transactions-table{
    --hdr-b:  #cbd5e1;   /* borders */
    --grid-b: #e3e8f3;   /* column separators / frames */
    --hdr-bg: #f3f5f9;   /* single header background */
  }

  /* force BOTH header rows to the same bg (and same border color) */
  .report-page .transactions-table thead tr.head-row-1 th,
  .report-page .transactions-table thead tr.head-row-2 th{
    background: var(--hdr-bg) !important;
    border-color: var(--hdr-b) !important;
  }

  /* row 1 shouldn’t draw a bottom border so row 2 sits flush */
  .report-page .transactions-table thead tr.head-row-1 th{
    border-bottom: 0 !important;
  }

  /* rounded top corners (like the old version) */
  .report-page .transactions-table thead tr.head-row-1 th:first-child{ border-top-left-radius:8px; }
  .report-page .transactions-table thead tr.head-row-1 th:last-child { border-top-right-radius:8px; }

  /* ensure left/right edges on row 2 are visible */
  .report-page .transactions-table thead tr.head-row-2 th:first-child{ border-left-width:1px; }
  .report-page .transactions-table thead tr.head-row-2 th:last-child { border-right-width:1px; }
}

/* ===== Summary table (desktop) ===== */
@media (min-width:769px){
  .report-page .summary-table{
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    /* palette aligned with transactions-table */
    --hdr-b:  #cbd5e1;   /* header borders */
    --grid-b: #e3e8f3;   /* column separators */
    --hdr-bg: #f3f5f9;   /* single header bg */
  }

  .report-page .summary-table th,
  .report-page .summary-table td{
    box-sizing: border-box;
    font-size: .9rem;
    line-height: 1.2;
    padding: .5rem .6rem;
    vertical-align: middle;
  }

  /* center both header rows horizontally & vertically */
  .report-page .summary-table thead th{
    text-align: center;
    vertical-align: middle;
    background: var(--hdr-bg);
    border: 1px solid var(--hdr-b);
    background-clip: padding-box;
    font-weight: 600;
  }

  /* two-level header look (not sticky here) */
  .report-page .summary-table thead tr.head-row-1 th{
    border-bottom: 0;          /* row 2 sits flush */
    font-weight: 700;          /* group row a bit bolder */
  }
  .report-page .summary-table thead tr.head-row-1 th:first-child{ border-top-left-radius: 8px; }
  .report-page .summary-table thead tr.head-row-1 th:last-child { border-top-right-radius: 8px; }

  /* subtle grid like transactions */
  .report-page .summary-table thead tr.head-row-2 th + th,
  .report-page .summary-table tbody td + td{
    border-left: 1px solid var(--grid-b);
  }
  .report-page .summary-table tbody td{
    border-bottom: 1px solid #edf1f7;
  }

  /* right-align numbers except 1st column */
  .report-page .summary-table tbody td:not(:first-child){
    text-align: right;
  }

  /* standout last row */
  .report-page .summary-table tbody tr.summary-total td{
    background: #eef3ff;
    font-weight: 700;
    border-top: 2px solid var(--hdr-b);
  }
  .report-page .summary-table tbody tr.summary-total td:first-child{ border-bottom-left-radius: 6px; }
  .report-page .summary-table tbody tr.summary-total td:last-child { border-bottom-right-radius: 6px; }
}

/* mobile cards you already have will apply automatically since this table keeps .table */
/* ===== Summary table (non-sticky) ===== */
.summary-table{
  /* outer frame */
  border: 1px solid #c6d0e8;
  border-radius: 8px;
  overflow: hidden;           /* keeps rounded corners crisp */
  border-collapse: separate;  /* ensure radius works cross-browser */
  border-spacing: 0;
  --hdr-b:#c6d0e8;
  --hdr1-bg:#eef3ff;
  --hdr2-bg:#f7f9ff;
}

.summary-table th,
.summary-table td{
  box-sizing:border-box;
  font-size:.9rem;
  line-height:1.25;
  padding:.5rem .6rem;
  vertical-align: middle;
}

/* headers – centered both ways */
.summary-table thead th{
  text-align:center;
  vertical-align: middle;
  background-clip: padding-box;
  border-bottom:1px solid var(--hdr-b);
}

/* first header row (spanned) */
.summary-table thead .head-row-1 th{
  background: var(--hdr1-bg);
  border-bottom: 0;                 /* let row2 sit flush */
  font-weight: 700;
}

/* second header row (leaf cols) */
.summary-table thead .head-row-2 th{
  background: var(--hdr2-bg);
  border-top: 1px solid var(--hdr-b);
}

/* subtle grid in body */
.summary-table tbody td{
  border-top: 1px solid #edf1f7;
}

/* standout last row */
.summary-table tbody tr.summary-total{
  background: #f8fbff;
  font-weight: 700;
  border-top: 2px solid #b8c6e8;
}
.summary-table tbody tr.summary-total td{
  border-top-color: #b8c6e8;  /* match the heavier divider */
}

.transactions-table [data-tip] { position: relative; cursor: help; }
.transactions-table [data-tip]:hover::after,
.transactions-table [data-tip]:focus::after{
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translate(-50%, -8px);
  white-space: nowrap;
  background: rgba(17,24,39,.95);
  color: #fff;
  font-size: .75rem;
  line-height: 1.2;
  padding: 6px 8px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 9999;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
}
.transactions-table [data-tip]:hover::before,
.transactions-table [data-tip]:focus::before{
  content: '';
  position: absolute;
  left: 50%;
  bottom: calc(100% - 2px);
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(17,24,39,.95);
  z-index: 9999;
}

/* Lay the 3 tables side-by-side */
.bycountry-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 16px;
  align-items: start;
}
@media (max-width: 991.98px) {
  .bycountry-grid { grid-template-columns: 1fr; }
}

/* Opt the country tables OUT of the mobile “cards” transform */
.report-page .bycountry-grid .table      { display: table !important; }
.report-page .bycountry-grid .table thead{ display: table-header-group !important; }
.report-page .bycountry-grid .table tbody{ display: table-row-group !important; }

.report-page .bycountry-grid .table tr { display: table-row !important; }
.report-page .bycountry-grid .table td,
.report-page .bycountry-grid .table th { display: table-cell !important; }

/* Reuse the .transactions-table palette, but turn OFF sticky for these */
.bycountry-grid .transactions-table.no-sticky thead tr.head-row-2 th {
  position: static !important;
  top: auto !important;
  box-shadow: none !important;
}

/* Nice rounded header corners, same palette vars already defined for .transactions-table */
.bycountry-grid .transactions-table thead tr.head-row-2 th:first-child { border-top-left-radius: 8px; }
.bycountry-grid .transactions-table thead tr.head-row-2 th:last-child  { border-top-right-radius: 8px; }

/* Light body grid + framed sides like your other tables */
.bycountry-wrapper {
  max-height: 50vh;
  overflow: auto;
  border-left: 1px solid #d7e0f3;
  border-right: 1px solid #d7e0f3;
  border-radius: 0 0 8px 8px;
}
.bycountry-grid .transactions-table tbody td { border-bottom: 1px solid #edf1f7; }
.bycountry-grid .transactions-table tbody tr:last-child td:first-child { border-bottom-left-radius: 8px; }
.bycountry-grid .transactions-table tbody tr:last-child td:last-child  { border-bottom-right-radius: 8px; }

/* Make the country column just wide enough for the header */
.bycountry-wrapper .transactions-table col.col-country { width: 10ch; } /* ~“Страна” width */

/* Disable sticky for these mini tables (both header rows) */
.bycountry-grid .transactions-table.no-sticky thead th {
  position: static !important;
  top: auto !important;
  box-shadow: none !important;
}
