:root {
    --navy: #17324d;
    --blue: #176b8a;
    --green: #16844c;
    --red: #c63b3b;
    --border: #dbe3ea;
    --background: #f3f6f9;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
    color: #1e293b;
    font: 14px Arial, Helvetica, sans-serif;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--navy);
    color: white;
}

nav a {
    margin-left: 14px;
    color: white;
    text-decoration: none;
}

.wrap {
    max-width: 1300px;
    margin: 20px auto;
    padding: 0 16px;
}

.card {
    margin-bottom: 16px;
    padding: 18px;
    background: white;
    border-radius: 9px;
    box-shadow: 0 2px 8px #00000011;
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    align-items: start;
    gap: 10px;
}

.row > input,
.row > select,
.row > button {
    height: 40px !important;
    min-height: 40px !important;
}

.metric {
    font-size: 26px;
    font-weight: bold;
}

.green {
    color: var(--green);
}

.red {
    color: var(--red);
}

.muted {
    color: #64748b;
}

.flash {
    padding: 12px;
    background: #e8f5ec;
    color: #146c3b;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: var(--blue);
    color: white;
}

th,
td {
    padding: 9px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

input,
select,
button {
    min-height: 40px;
    padding: 9px;
    border: 1px solid #bac8d3;
    border-radius: 5px;
}

input,
select {
    width: 100%;
}

button,
.btn {
    background: var(--blue);
    color: white;
    border: 0;
    cursor: pointer;
}

.danger {
    background: var(--red);
}

button:disabled {
    background: #94a3b8 !important;
    cursor: not-allowed;
    opacity: 0.7;
}

input:disabled {
    background: #e5e7eb;
    color: #64748b;
    cursor: not-allowed;
}

.client-picker {
    position: relative;
}

.client-picker select {
    max-height: 170px;
    margin-top: 6px;
}

.client-picker select[size="1"] {
    height: 40px;
}

.report-grid {
    display: grid;
    grid-template-columns: 1.3fr 0.7fr;
    gap: 18px;
}

.signature {
    margin-top: 35px;
    padding-top: 5px;
    border-top: 1px solid #111;
}

.print-only {
    display: none;
}

@media (max-width: 800px) {
    .grid,
    .row,
    .report-grid {
        grid-template-columns: 1fr;
    }

    header {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    nav a {
        display: inline-block;
        margin: 3px 10px 3px 0;
    }

    table {
        display: block;
        overflow: auto;
    }
}

/* Professional Half-Letter Report */
@page {
    size: 8.5in 5.5in;
    margin: 0.20in;
}

@media print {
    * {
        box-sizing: border-box;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    header,
    .no-print,
    body .wrap > h1,
    button {
        display: none !important;
    }

    html,
    body {
        width: 8.1in;
        height: 5.1in;
        margin: 0;
        background: white;
        color: #0f172a;
        font-family: Arial, Helvetica, sans-serif;
        font-size: 9px;
    }

    .wrap {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .print-only {
        display: flex !important;
    }

    .report-grid {
        display: grid;
        grid-template-columns: 1.35fr 0.65fr;
        gap: 10px;
        width: 100%;
    }

    .print-report-header {
        grid-column: 1 / -1;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 1px;
        padding: 0 2px 7px;
        border-bottom: 3px solid var(--navy);
        color: var(--navy);
    }

    .print-brand {
        display: flex;
        flex-direction: column;
    }

    .print-brand b {
        font-size: 17px;
        letter-spacing: 0.4px;
    }

    .print-brand span {
        margin-top: 2px;
        color: #475569;
        font-size: 9px;
    }

    .print-date {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        padding-left: 14px;
        border-left: 1px solid #94a3b8;
    }

    .print-date small {
        color: #64748b;
        font-size: 7px;
        letter-spacing: 1px;
    }

    .print-date b {
        margin-top: 2px;
        font-size: 11px;
    }

    .card {
        margin: 0 0 7px;
        padding: 8px;
        background: white;
        border: 1px solid #94a3b8;
        border-radius: 2px;
        box-shadow: none;
        break-inside: avoid;
    }

    .cash-report-card h2 {
        margin: 0 0 6px;
        color: var(--navy);
        font-size: 12px;
        letter-spacing: 0.8px;
    }

    .card table {
        display: table;
        width: 100%;
        overflow: visible;
        border: 1px solid #cbd5e1;
        border-collapse: collapse;
    }

    .card th,
    .card td {
        height: 21px;
        padding: 3px 5px;
        border-bottom: 1px solid #cbd5e1;
        line-height: 1.1;
    }

    .card th {
        background: var(--blue) !important;
        color: white !important;
        font-weight: 700;
    }

    .card td {
        color: #0f172a;
    }

    .card input {
        height: 17px;
        min-height: 17px;
        padding: 0;
        border: 0;
        background: transparent;
        color: #0f172a;
        font-size: 9px;
        font-weight: 600;
        text-align: center;
    }

    .cash-report-card table tr:nth-last-child(-n+3) th {
        background: #e2e8f0 !important;
        color: var(--navy) !important;
    }

    .cash-report-card table tr:nth-last-child(2) th {
        background: #dbeafe !important;
    }

    .cash-report-card table tr:last-child th,
    .report-grid > div .card table tr:last-child th {
        background: var(--navy) !important;
        color: white !important;
    }

    .signature {
        margin-top: 22px;
        padding-top: 4px;
        border-top: 1px solid #0f172a;
        font-size: 8px;
    }

    .report-grid > div > .card:last-child p {
        margin: 8px 0 0;
    }
}

/* RM-CJJ GLOBAL LOGO */
.site-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    text-decoration: none;
    font-weight: 700;
}

.site-brand img {
    width: 58px;
    height: 38px;
    object-fit: contain;
}

.login-brand {
    margin-bottom: 22px;
    text-align: center;
}

.login-brand img {
    display: block;
    width: 250px;
    max-width: 92%;
    height: 155px;
    margin: 0 auto 5px;
    object-fit: contain;
}

.login-brand h1 {
    margin: 0;
    color: #17324d;
    font-size: 23px;
}

@media print {
    .print-brand {
        display: flex !important;
        flex-direction: row !important;
        align-items: center;
        gap: 8px;
    }

    .print-brand img {
        display: block !important;
        width: 64px;
        height: 43px;
        object-fit: contain;
    }

    .print-brand > div {
        display: flex;
        flex-direction: column;
    }

    .print-brand b {
        font-size: 15px;
    }

    .print-brand span {
        font-size: 8px;
    }
}

/* COMPACT LIGHTWEIGHT LOGO */
.site-brand {
    gap: 8px !important;
}

.site-brand img {
    width: 40px !important;
    height: 28px !important;
    object-fit: contain;
}

.site-brand span {
    font-size: 14px;
    font-weight: 600;
}

.login-brand img {
    width: 170px !important;
    height: 105px !important;
    margin-bottom: 2px !important;
}

.login-brand h1 {
    font-size: 20px !important;
}

@media print {
    .print-brand {
        gap: 6px !important;
    }

    .print-brand img {
        width: 42px !important;
        height: 28px !important;
    }

    .print-brand b {
        font-size: 13px !important;
    }

    .print-brand span {
        font-size: 7px !important;
    }
}
