/* =========================================================
   KKRTC REVENUE SHEET
   FULL SCREEN / COMPACT OFFICIAL REPORT
   FIXED: print orientation, professional print layout, UI polish
========================================================= */

:root {
    --navy: #355f7b;
    --navy-dark: #2c536e;
    --navy-deep: #244b65;

    --header-blue: #355f7b;
    --header-blue-2: #3d6b87;

    --line: #9cc7e5;
    --line-dark: #7faecf;

    --row-blue: #f4f9fd;
    --row-hover: #e7f3fb;

    --division: #6c9dbb;
    --division-dark: #5b8eac;

    --text: #315c78;

--green: #16a34a;
--red: #dc2626;

    --white: #ffffff;
}


/* =========================================================
   GLOBAL
========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
}

body {
    background: #f7f8f4;
    color: var(--text);
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
    font-size: 12px;
    overflow-x: hidden;
}


/* =========================================================
   TOP BLUE LINE
========================================================= */

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: var(--navy-dark);
    z-index: 9999;
}


//* =========================================================
   MASTHEAD
========================================================= */
.masthead {
    width: calc(100% - 30px);
    max-width: 1200px;
    margin: 28px auto 0;
    min-height: 68px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #ffffff 0%, #f7fafc 100%);
    border: 0.5px solid #d7e2e9;
    border-radius: 6px 6px 0 0;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .08);
}
.masthead-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
}
.masthead-logo-box {
    flex: 0 0 52px;
}
.masthead-logo {
    width: 52px;
    height: 52px;
    object-fit: contain;
}
.masthead-text {
    min-width: 0;
    text-align: left;
}
.masthead-title {
    color: var(--navy-deep);
    font-size: 18px;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
}
.masthead-sub {
    margin-top: 3px;
    color: #60798a;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}
.masthead-bottom {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
}
.masthead-report {
    color: var(--navy);
    font-size: 12px;
    font-weight: 700;
}
.masthead-meta {
    padding-left: 14px;
    border-left: 1px solid #d6e1e8;
    color: #506b7d;
    font-size: 11px;
    line-height: 1.6;
    text-align: left;
    white-space: nowrap;
}
.pyr-label {
    color: #8a9aa5;
    font-weight: 500;
    font-size: 10px;
}
/* =========================================================
   SHEET NAVIGATION
========================================================= */

.sheet-nav {
    width: calc(100% - 30px);
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 38px;
    padding: 4px 10px;
    background: var(--navy);
    border-radius: 0 0 6px 6px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, .08);
}

.nav-left {
    display: flex;
    gap: 4px;
}

.sheet-nav a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 27px;
    padding: 5px 14px;
    border-radius: 4px;
    color: #eaf4fa;
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    transition: background .15s ease, color .15s ease;
}

.sheet-nav a:hover {
    background: rgba(255, 255, 255, .14);
    color: #fff;
}

.sheet-nav a.active {
    background: #fff;
    color: var(--navy);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
}

.nav-system {
    color: rgba(255, 255, 255, .65);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: .3px;
}


/* =========================================================
   FILTER
========================================================= */

.filter {
    width: calc(100% - 30px);
    max-width: 1200px;
    margin: 14px auto 8px;
    color: #3d6178;
    font-size: 11px;
    font-weight: 600;
}

.filter form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter input[type="date"] {
    width: 130px;
    height: 30px;
    padding: 3px 8px;
    border: 0.5px solid #9fc9e5;
    border-radius: 4px;
    background: #fff;
    color: #315d79;
    font-size: 11px;
    outline: none;
}

.filter input[type="date"]:focus {
    border-color: #4c91c2;
    box-shadow: 0 0 0 2px rgba(76, 145, 194, .15);
}

.filter button {
    height: 30px;
    padding: 0 18px;
    border: 0;
    border-radius: 4px;
    background: var(--navy);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s ease;
}

.filter button:hover {
    background: var(--navy-dark);
}


/* =========================================================
   TOOLBAR
========================================================= */

.report-toolbar,
.toolbar {
    width: calc(100% - 30px);
    max-width: 1200px;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: #fff;
    border: 0.5px solid #d7e2e9;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .05);
}

.toolbar-left {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.toolbar-title {
    color: var(--navy-deep);
    font-size: 14px;
    font-weight: 800;
}

.toolbar-date {
    color: #6c8496;
    font-size: 11px;
    font-weight: 600;
}

.toolbar-right {
    display: flex;
    gap: 6px;
}

.toolbar-btn,
.toolbar button {
    height: 30px;
    padding: 0 14px;
    border: 0.5px solid transparent;
    border-radius: 4px;
    background: var(--navy);
    color: #fff;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
}

.toolbar-btn:hover,
.toolbar button:hover {
    background: var(--navy-dark);
}

.toolbar-btn:active,
.toolbar button:active {
    transform: translateY(1px);
}

.print-btn {
    background: #fff;
    color: var(--navy);
    border-color: #9fc9e5;
}

.print-btn:hover {
    background: #eaf4fa;
}

.excel-btn {
    background: #1f7a4d;
}

.excel-btn:hover {
    background: #185f3c;
}


/* =========================================================
   TABLE CONTAINER
========================================================= */

.table-box {
    width: calc(100% - 30px);
    max-width: 1350px;
    margin: 0 auto 24px;
    max-height: calc(100vh - 200px);
    overflow: auto;
    background: #fff;
    border: 0.5px solid #b9d1e2;
    border-radius: 6px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .07);
}

.table-box::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

.table-box::-webkit-scrollbar-track {
    background: #edf3f7;
}

.table-box::-webkit-scrollbar-thumb {
    background: #7599ae;
    border-radius: 5px;
}

.table-box::-webkit-scrollbar-thumb:hover {
    background: #557b91;
}


/* =========================================================
   TABLE
========================================================= */
#revenueTable {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
    font-size: 10px;
}


/* =========================================================
   HEADER
   ========================================================= */

#revenueTable thead th {
    background: #E91E63;
    color: #fff;
    border-right: 1px solid #9abbd0;
    border-bottom: 1px solid #c2d8e7;
    padding: 5px 6px;
    height: 28px;
    text-align: center;
    vertical-align: middle;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.15;
    white-space: nowrap;
    box-sizing: border-box;
}

/* Header Row 1 */
#revenueTable thead tr:first-child th {
    height: 32px;
    font-size: 10px;
    font-weight: 700;
    position: sticky;
    top: 0;
    z-index: 103;
}

/* Header Row 2 */
#revenueTable thead tr:nth-child(2) th {
    position: sticky;
    top: 32px;   /* = row1's height, now accurate with border-box */
    z-index: 102;
}

/* Header Row 3 */
#revenueTable thead tr:nth-child(3) th {
    position: sticky;
    top: 60px;   /* = 32 (row1) + 28 (row2), NOT 64 */
    z-index: 101;
}

/* =========================================================
   BODY
   ========================================================= */

#revenueTable tbody td {
    height: 22px;
    padding: 3px 6px;

    background: #fff;
    color: #315d79;

    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);


    text-align: center !important;
    vertical-align: middle !important;


    white-space: nowrap;

    font-size: 10px;
    font-weight: 500;

    font-variant-numeric: tabular-nums;

    /* IMPORTANT:
       Body cells are NOT sticky */
    position: static;
}


/* =========================================================
   ZEBRA STRIPING
   ========================================================= */

#revenueTable tbody tr.depot-row:nth-child(even) td {
    background: #fbfdfe;
}


/* =========================================================
   FIRST COLUMN - NORMAL / NOT STICKY
   ========================================================= */

/* =========================================================
   FIRST COLUMN - COMPACT WIDTH
========================================================= */

#revenueTable tbody td:first-child {
    position: static;
    left: auto;
    z-index: auto;

    min-width: 85px;
    width: 85px;
    max-width: 85px;

    text-align: left;

    background: #fff;
    color: #28638a;

    font-weight: 500;

    box-shadow: none;
}

#revenueTable thead th:first-child {
    width: 35px;
    min-width: 35px;
    max-width: 35px;
}
/* First column zebra */
#revenueTable tbody tr.depot-row:nth-child(even) td:first-child {
    background: #fbfdfe;
}


/* =========================================================
   HOVER
   ========================================================= */

#revenueTable tbody tr.depot-row:hover td {
    background: var(--row-hover) !important;
}


/* =========================================================
   SUBTOTAL ROW
   ========================================================= */
#revenueTable tr.subtotal td {
    position: static;
    height: 24px;
    padding: 4px 6px;

    background: linear-gradient(135deg, #307dac 0%, #3787b8 100%);
    color: #ffffff;

    font-size: 10px;
    font-weight: 800;

    cursor: pointer;
      --green: #86efac;
    --red: #fca5a5;
}





#revenueTable thead th:first-child {
    text-align: left !important;
    padding-left: 10px !important;
}

/* Subtotal row first cell + its toggle button — left align */
#revenueTable tr.subtotal td:first-child {
    text-align: left !important;
    padding-left: 10px !important;
}


/* =========================================================
   SUBTOTAL FIRST COLUMN - NOT STICKY
   ========================================================= */


/* =========================================================
   OPTIONAL: KEEP HEADER ABOVE EVERYTHING
   ========================================================= */

#revenueTable thead {
    position: relative;
    z-index: 100;
}



.division-toggle-btn {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
}

.division-arrow {
    color: #3f51b5;
    font-size: 9px;
    transition: transform .15s ease;
}

tr.subtotal.collapsed .division-arrow {
    transform: rotate(-90deg);
}

tr.depot-row.division-hidden {
    display: none;
}

#revenueTable tr.grandtotal td {
    height: 26px;
    padding: 5px 6px;

    background: linear-gradient(135deg, #355f7b 0%, #355f7b 50%, #355f7b 100%);
    color: #ffffff;

    border-bottom: 0;
    font-size: 10px;
    font-weight: 900;

  --green: #86efac;
    --red: #fca5a5;
}


.green {
    color: var(--green) !important;
    font-weight: 700 !important;
}

.red {
    color: var(--red) !important;
    font-weight: 700 !important;
}

.print-footer td {
    padding: 6px !important;
    background: #eef3f6 !important;
    color: #61798a !important;
    font-size: 9px !important;
    text-align: left !important;
}


/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 900px) {
    .masthead, .sheet-nav, .filter, .report-toolbar, .toolbar, .table-box {
        width: calc(100% - 16px);
    }
    .masthead-title { font-size: 15px; }
    .masthead-sub { font-size: 9px; }
    .masthead-logo { width: 45px; height: 45px; }
}


/* =========================================================
   PRINT
   Root cause of the sideways PDF: some print drivers
   (esp. "Microsoft Print to PDF" via a non-Chromium print
   path) ignore @page{size:landscape} and fall back to the
   printer's Portrait default, then auto-rotate the wide
   table to fit â€” producing a sideways page.

   Fix: force landscape at the @page level AND explicitly
   size the printable area, so even drivers that partially
   ignore @page still get a landscape-shaped canvas instead
   of rotating a portrait one.
========================================================= */
@media print {

    /* =========================================================
       A4 — ONE PAGE COMPACT PRINT
    ========================================================= */
    @page {
        size: A4 portrait;
        margin: 4mm 5mm;
    }

    html,
    body {
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        color: #000 !important;
        overflow: visible !important;
    }

    body::before {
        display: none !important;
    }

    /* =========================================================
       HIDE SCREEN ELEMENTS
    ========================================================= */
    .sheet-nav,
    .filter,
    .report-toolbar,
    .toolbar,
    .division-toggle-btn {
        display: none !important;
    }

    /* =========================================================
       COMPACT MASTHEAD
    ========================================================= */
    .masthead {
        width: 100% !important;
        max-width: none !important;
        margin: 0 0 1.5mm !important;
        padding: 1.5mm 2.5mm !important;
        min-height: 0 !important;
        background: #fff !important;
        color: #000 !important;
        border: none !important;
        box-shadow: none !important;
        line-height: 1 !important;
    }

    .masthead-logo {
        width: 26px !important;
        height: 26px !important;
        filter: grayscale(100%) !important;
    }

    .masthead-title {
        font-size: 14px !important;
        line-height: 1 !important;
        color: #000 !important;
        font-weight: 700 !important;
    }

    .masthead-sub {
        font-size: 10px !important;
        line-height: 1.5 !important;
        color: #000 !important;
    }

    .masthead-report {
        font-size: 9px !important;
        line-height: 1 !important;
        color: #000 !important;
        font-weight: 700 !important;
    }

    .masthead-meta {
        font-size: 7.5px !important;
        line-height: 1 !important;
        color: #000 !important;
    }

    /* =========================================================
       TABLE CONTAINER — no border here, table owns the only border
    ========================================================= */
    .table-box {
        width: 100% !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        background: #fff !important;
        border: 1px solid #9fc9e5;
        border-radius: 0 !important;
        box-shadow: none !important;
    }

    /* =========================================================
       MAIN TABLE — VERY COMPACT
    ========================================================= */
    #revenueTable {
        width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border-collapse: collapse !important;
        border-spacing: 0 !important;
        table-layout: auto !important;
 border: 1px solid #000000;
        background: #fff !important;
        color: #000 !important;
        font-size: 7px !important;
        line-height: 1 !important;
    }

    /* =========================================================
       SINGLE SOURCE OF TRUTH — ALL BORDERS
       (every th/td, in every row type, inherits from here only —
       no other rule in this file re-declares border, which is
       what was causing the doubled border line before)
    ========================================================= */
  

    /* =========================================================
       HEADER — COMPACT
    ========================================================= */
        /* =========================================================
       HEADER — COMPACT
    ========================================================= */
    #revenueTable thead,
    #revenueTable thead tr {
        background: #fff !important;
        color: #000 !important;
    }

    #revenueTable thead th {
        position: static !important;
        height: 17px !important;
        min-height: 17px !important;
        padding: 1px 2px !important;
        font-size: 8px !important;
        line-height: 1 !important;
        font-weight: 700 !important;
        text-align: center !important;
        vertical-align: middle !important;
        background: #fff !important;
        color: #000 !important;
        white-space: normal !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    /* =========================================================
       HEADER OUTER BOX BORDER
       Thicker frame around the entire thead block
    ========================================================= */
  

    /* =========================================================
       ALL BODY ROWS — INCLUDING DIVISION / SUBTOTAL / GRANDTOTAL
       NO BACKGROUND SHADING ANYWHERE — ALL WHITE
    ========================================================= */
    #revenueTable tbody tr,
    #revenueTable tbody tr.division-row,
    #revenueTable tbody tr.division,
    #revenueTable tbody tr.subtotal,
    #revenueTable tbody tr.grandtotal {
        background: #fff !important;
        color: #000 !important;
    }

    #revenueTable tbody td,
    #revenueTable tbody tr.division-row td,
    #revenueTable tbody tr.division td,
    #revenueTable tbody tr.subtotal td,
    #revenueTable tbody tr.grandtotal td {
        height: 12px !important;
        min-height: 12px !important;
        padding: 3px 2px !important;
        font-size: 8px !important;
        text-align: center !important;
        line-height: 1 !important;
        vertical-align: middle !important;
        background: #fff !important;
        color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }

    /* Remove zebra striping */
    #revenueTable tbody tr:nth-child(odd) td,
    #revenueTable tbody tr:nth-child(even) td {
        background: #fff !important;
    }

    /* division row: bold, no background */
    #revenueTable tbody tr.division-row td,
    #revenueTable tbody tr.division td {
        font-weight: 700 !important;
    }

    /* subtotal: bold, black text, no background */
    #revenueTable tbody tr.subtotal td {
        font-weight: 700 !important;
        font-size: 8px !important;
        color: #000 !important;
        background: #fff !important;
    }

    /* grandtotal: bold, black text, no background */
    #revenueTable tbody tr.grandtotal td {
        height: 14px !important;
        min-height: 14px !important;
        font-weight: 700 !important;
        font-size: 8px !important;
        color: #000 !important;
        background: #fff !important;
    }

    /* =========================================================
       FIRST COLUMN / STICKY RESET
    ========================================================= */
   

    /* =========================================================
       LINKS / TEXT ELEMENTS
    ========================================================= */
    #revenueTable a {
        color: #000 !important;
        text-decoration: none !important;
    }

    #revenueTable span,
    #revenueTable strong,
    #revenueTable b {
        color: #000 !important;
    }

    /* =========================================================
       BUTTONS
    ========================================================= */
    #revenueTable button {
        color: #000 !important;
        background: #fff !important;
        
        padding: 0 !important;
        box-shadow: none !important;
    }

    /* =========================================================
       PAGE BREAK CONTROL
    ========================================================= */
    #revenueTable {
        page-break-inside: auto !important;
        break-inside: auto !important;
    }
    #revenueTable tr {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
    #revenueTable thead {
        display: table-header-group !important;
    }
    #revenueTable tfoot {
        display: table-footer-group !important;
    }
#revenueTable tbody td {
    border-top: none !important;
    border-bottom: none !important;
}

/* =========================================================
   REMOVE ROW BORDERS
   KEEP SUBTOTAL + GRAND TOTAL BORDERS
========================================================= */

/* Normal rows - remove only horizontal TD borders */
#revenueTable tbody tr:not(.subtotal):not(.grandtotal) td {
    border-top: none !important;
    border-bottom: none !important;
}

/* =========================================================
   SUBTOTAL - KEEP BORDER
========================================================= */

#revenueTable tbody tr.subtotal td {
    border-top: 1px solid #000 !important;
    border-bottom: 1px solid #000 !important;
}

/* =========================================================
   GRAND TOTAL - KEEP BORDER
========================================================= */

#revenueTable tbody tr.grandtotal td {
    border-top: 1px solid #000 !important;
    border-bottom: 1px solid #000 !important;
}

/* =========================================================
   THEAD - COMPLETE OUTER BORDER
   Works with 3 ROWS + ROWSPAN + COLSPAN
========================================================= */

#revenueTable thead {
    position: relative !important;

    border-top: 1px solid #000 !important;
    border-bottom: 1px solid #000 !important;
}

/* LEFT OUTER BORDER */
#revenueTable thead::before {
    content: "";
    position: absolute;

    left: 0;
    top: 0;
    bottom: 0;

    width: 1px;
    background: #000;

    z-index: 10;
}

/* RIGHT OUTER BORDER */
#revenueTable thead::after {
    content: "";
    position: absolute;

    right: 0;
    top: 0;
    bottom: 0;

    width: 1px;
    background: #000;

    z-index: 10;
}
#revenueTable thead th {
    border-top: 1px solid #000 !important;
    border-bottom: 1px solid #000 !important;

    /* DO NOT create vertical borders between header cells */
    border-left: none !important;
    border-right: none !important;
}
   
/* =========================================================
   REVENUE TABLE - 3 ROW HEADER
========================================================= */

#revenueTable thead {
    background: #fff !important;
    color: #000 !important;
    border: 1px solid #000 !important;
}

/* ALL HEADER CELLS */
#revenueTable thead th {
    border: 1px solid #000 !important;

    font-weight: 700 !important;
    font-size: 8px !important;

    padding: 3px 3px !important;

    text-align: center !important;
    vertical-align: middle !important;

    line-height: 1.1 !important;

    background: #fff !important;
    color: #000 !important;

    white-space: normal !important;
}

/* Small text also bold */
#revenueTable thead th small {
    font-weight: 700 !important;
    font-size: 7px !important;
}

/* First and last header cells */
#revenueTable thead tr:first-child th:first-child {
    border-left: 1px solid #000 !important;
}

#revenueTable thead tr:last-child th:last-child {
    border-right: 1px solid #000 !important;
}
    /* =========================================================
       REMOVE SCREEN EFFECTS
    ========================================================= */
    *,
    *::before,
    *::after {
        box-shadow: none !important;
        text-shadow: none !important;
    }

    /* =========================================================
       BLACK TEXT EVERYWHERE
    ========================================================= */
    .masthead,
    .masthead *,
    .table-box,
    #revenueTable,
    #revenueTable * {
        color: #000 !important;
    }
}