* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, Helvetica, sans-serif;
}

:root {
    --bg: #f4f4f4;
    --card: #ffffff;
    --text: #222222;
    --muted: #666666;
    --header: #f3f4f6;
    --headerText: #111827;
    --gold: #d4af37;
    --border: #dddddd;
    --input: #ffffff;
    --tile: linear-gradient(135deg, #111827, #1f2937);
}

body.dark {
    --bg: #0b1220;
    --card: #111827;
    --text: #f9fafb;
    --muted: #cbd5e1;
    --header: #f3f4f6;
    --headerText: #111827;
    --gold: #facc15;
    --border: #374151;
    --input: #1f2937;
    --tile: linear-gradient(135deg, #1f2937, #374151);
}

body {
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}

#loginOverlay {
    position: fixed;
    inset: 0;
    background: #f3f4f6;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.loginCard {
    background: white;
    color: #222;
    width: 520px;
    max-width: 92%;
    padding: 38px;
    border-radius: 18px;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0,0,0,.18);
}

.logo {
    width: 420px;
    max-width: 96%;
    height: auto;
    margin-bottom: 22px;
}

.logoSmall {
    width: 430px;
    max-width: 100%;
    height: auto;
    background: transparent;
    padding: 0;
}

.loginCard h1 {
    margin-bottom: 8px;
    font-size: 30px;
}

.loginCard p {
    margin-bottom: 25px;
    color: #666;
}

input,
select {
    width: 100%;
    max-width: 440px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: 16px;
    background: var(--input);
    color: var(--text);
}

input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: bold;
}

button {
    background: var(--gold);
    color: #111;
    border: none;
    padding: 14px 22px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    font-size: 15px;
}

button:hover {
    opacity: .9;
}

header {
    background: var(--header);
    color: var(--headerText);
    padding: 30px 42px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #d1d5db;
}

.headerLeft {
    display: flex;
    align-items: center;
    gap: 28px;
}

.headerLeft h2 {
    font-size: 34px;
    line-height: 1.1;
    color: var(--headerText);
}

.headerLeft span {
    font-size: 20px;
    color: var(--headerText);
}

.headerButtons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.tabBar {
    max-width: 1400px;
    margin: 22px auto 0;
    padding: 0 24px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
}

.tab {
    background: #111827;
    color: white;
    border-radius: 14px;
    padding: 16px 12px;
}

.tab.active {
    background: var(--gold);
    color: #111;
}

main {
    width: 100%;
    max-width: 1400px;
    margin: 24px auto 35px;
    padding: 0 24px;
}

.page {
    display: none;
}

.activePage {
    display: block;
}

.card {
    background: var(--card);
    color: var(--text);
    padding: 30px;
    margin-bottom: 25px;
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
    border: 1px solid rgba(255,255,255,.04);
}

.card h3 {
    margin-bottom: 22px;
    font-size: 26px;
}

.dashboardGrid {
    display: grid;
    grid-template-columns: repeat(4, minmax(170px, 1fr));
    gap: 18px;
}

.dashboardTile {
    background: var(--tile);
    color: white;
    padding: 26px;
    border-radius: 18px;
    box-shadow: 0 8px 18px rgba(0,0,0,.12);
}

.dashboardTile strong {
    display: block;
    font-size: 30px;
    line-height: 1.1;
    color: var(--gold);
    margin-bottom: 8px;
    word-break: break-word;
}

.dashboardTile span {
    font-size: 17px;
    color: #e5e7eb;
}

.buttonRow {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.tableScroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

th {
    background: #111827;
    color: white;
    padding: 14px;
    text-align: left;
    white-space: nowrap;
}

td {
    padding: 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

#printReport {
    display: none;
}

@media(max-width: 1200px) {
    .dashboardGrid {
        grid-template-columns: repeat(2, 1fr);
    }

    .tabBar {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media(max-width: 800px) {
    header {
        padding: 18px;
        flex-direction: column;
        align-items: flex-start;
        gap: 18px;
    }

    .headerLeft {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
    }

    .logoSmall {
        width: 100%;
        max-width: 460px;
    }

    .headerLeft h2 {
        font-size: 26px;
    }

    .headerLeft span {
        font-size: 16px;
    }

    .headerButtons {
        width: 100%;
        flex-direction: column;
    }

    .headerButtons button {
        width: 100%;
    }

    .tabBar {
        grid-template-columns: repeat(2, 1fr);
        padding: 0 14px;
        margin-top: 16px;
    }

    .tab {
        width: 100%;
        padding: 16px 10px;
        font-size: 15px;
    }

    main {
        padding: 0 14px;
        margin-top: 18px;
    }

    .card {
        padding: 22px;
        border-radius: 16px;
    }

    .card h3 {
        font-size: 23px;
    }

    .dashboardGrid {
        grid-template-columns: 1fr;
    }

    .dashboardTile strong {
        font-size: 30px;
    }

    input,
    select,
    button {
        max-width: 100%;
        width: 100%;
        font-size: 16px;
    }

    .buttonRow {
        flex-direction: column;
    }

    table {
        min-width: 980px;
        font-size: 15px;
    }
}

@media print {
    body * {
        visibility: hidden;
    }

    #printReport,
    #printReport * {
        visibility: visible;
    }

    #printReport {
        display: block;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 30px;
        background: white;
        color: black;
    }

    #printReport table {
        min-width: 0;
        width: 100%;
        border-collapse: collapse;
    }

    #printReport th {
        background: #111827 !important;
        color: white !important;
        padding: 10px;
    }

    #printReport td {
        padding: 10px;
        border-bottom: 1px solid #ccc;
    }

    #printReport h1,
    #printReport h2,
    #printReport h3 {
        margin-bottom: 15px;
    }
}