* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f1117;
    color: #e1e4e8;
    min-height: 100vh;
}

header {
    background: #161b22;
    padding: 16px 24px;
    border-bottom: 1px solid #30363d;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

header h1 {
    font-size: 20px;
    color: #58a6ff;
}

.controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.controls input[type="date"] {
    background: #21262d;
    border: 1px solid #30363d;
    color: #e1e4e8;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
}

.controls button {
    background: #21262d;
    border: 1px solid #30363d;
    color: #e1e4e8;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.controls button:hover {
    background: #30363d;
}

.controls span {
    color: #8b949e;
}

main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Cards */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 20px;
}

.card-label {
    color: #8b949e;
    font-size: 13px;
    margin-bottom: 8px;
}

.card-value {
    font-size: 28px;
    font-weight: 600;
}

.card-sub {
    color: #8b949e;
    font-size: 12px;
    margin-top: 4px;
}

.card-trend {
    font-size: 12px;
    margin-top: 6px;
    min-height: 18px;
}

.card-trend .trend-sub {
    color: #484f58;
    font-size: 11px;
    margin-left: 4px;
}

.collapsible {
    cursor: pointer;
    user-select: none;
}

.collapsible:hover {
    color: #58a6ff;
}

.collapsed {
    display: none;
}

.card-actual {
    border-color: #238636;
    border-left: 3px solid #238636;
}

.table-scroll {
    overflow-x: auto;
}

.positive { color: #3fb950; }
.negative { color: #f85149; }
.neutral { color: #e1e4e8; }

/* Charts */
.charts {
    margin-bottom: 24px;
}

.chart-container {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 20px;
    height: 350px;
}

/* Tables */
.table-section {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 24px;
    overflow-x: auto;
}

.table-section h2 {
    font-size: 16px;
    margin-bottom: 16px;
    color: #8b949e;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid #30363d;
    color: #8b949e;
    font-weight: 600;
    white-space: nowrap;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid #21262d;
    white-space: nowrap;
}

tr:hover td {
    background: #1c2128;
}

tfoot td {
    font-weight: 600;
    border-top: 2px solid #30363d;
    color: #58a6ff;
}

.product-link {
    color: #58a6ff;
    text-decoration: none;
    cursor: pointer;
}

.product-link:hover {
    text-decoration: underline;
}

/* Shipments */
.shipment-bar {
    display: flex;
    height: 24px;
    border-radius: 6px;
    overflow: hidden;
    margin: 8px 0;
}

.shipment-bar > div {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    min-width: 30px;
}

.ship-delivered { background: #238636; }
.ship-transit { background: #1f6feb; }
.ship-office { background: #d29922; }
.ship-returned { background: #f85149; }
.ship-other { background: #484f58; }

.shipment-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.shipment-legend > span {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* Navigation */
.nav-btn {
    font-size: 13px;
    background: #21262d;
    border: 1px solid #30363d;
    color: #58a6ff;
    padding: 4px 12px;
    border-radius: 6px;
    text-decoration: none;
    margin-left: 12px;
    vertical-align: middle;
}
.nav-btn:hover {
    background: #30363d;
}
.nav-link {
    color: #58a6ff;
    text-decoration: none;
}
.nav-link:hover {
    text-decoration: underline;
}

.section-title {
    font-size: 16px;
    color: #8b949e;
    margin-bottom: 12px;
}

/* Reconciliation summary */
.recon-summary {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    align-items: stretch;
}
.recon-block {
    flex: 1;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 20px;
}
.recon-block h2 {
    font-size: 16px;
    color: #8b949e;
    margin-bottom: 16px;
}
.recon-block-actual {
    border-color: #238636;
    border-left: 3px solid #238636;
}
.recon-vs {
    display: flex;
    align-items: center;
    font-size: 18px;
    font-weight: 700;
    color: #484f58;
    padding: 0 8px;
}
.recon-row {
    display: flex;
    gap: 24px;
}
.recon-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.recon-label {
    font-size: 12px;
    color: #8b949e;
}
.recon-value {
    font-size: 24px;
    font-weight: 600;
    color: #e1e4e8;
}

/* TTN reconciliation */
.recon-ttn-section {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 24px;
}
.recon-ttn-section h2 {
    font-size: 16px;
    color: #8b949e;
    margin-bottom: 16px;
}
.ttn-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}
.ttn-card {
    background: #21262d;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}
.ttn-label {
    font-size: 12px;
    color: #8b949e;
    margin-bottom: 6px;
}
.ttn-value {
    font-size: 28px;
    font-weight: 700;
    color: #e1e4e8;
}
.ttn-delivered { border-bottom: 3px solid #238636; }
.ttn-returned { border-bottom: 3px solid #f85149; }
.ttn-office { border-bottom: 3px solid #d29922; }
.ttn-transit { border-bottom: 3px solid #1f6feb; }
.ttn-paid { border-bottom: 3px solid #3fb950; }
.ttn-nopay { border-bottom: 3px solid #f85149; }

/* USD rate input */
.usd-rate-wrap {
    margin-left: 8px;
    font-size: 12px;
    color: #8b949e;
}
.usd-rate-input {
    width: 54px;
    background: #21262d;
    border: 1px solid #30363d;
    color: #e1e4e8;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    text-align: center;
}

/* Shipment cards grid */
.shipment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}
.ship-card {
    background: #21262d;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}
.ship-card-label {
    font-size: 12px;
    color: #8b949e;
    margin-bottom: 6px;
}
.ship-card-value {
    font-size: 28px;
    font-weight: 700;
    color: #e1e4e8;
}
.ship-card-sub {
    font-size: 12px;
    color: #8b949e;
    margin-top: 4px;
}
.ship-delivered { border-bottom: 3px solid #238636; }
.ship-transit-card { border-bottom: 3px solid #1f6feb; }
.ship-office-card { border-bottom: 3px solid #d29922; }
.ship-returned-card { border-bottom: 3px solid #f85149; }
.ship-other-card { border-bottom: 3px solid #484f58; }
.ship-total-card { border-bottom: 3px solid #58a6ff; }
.ship-buyout-card { border-bottom: 3px solid #3fb950; }
.ship-cod-card { border-bottom: 3px solid #a371f7; }

/* Loading */
.loading {
    text-align: center;
    color: #8b949e;
    padding: 40px;
}

@media (max-width: 768px) {
    .recon-summary {
        flex-direction: column;
    }
    .recon-vs {
        justify-content: center;
        padding: 4px;
    }
    .recon-row {
        flex-wrap: wrap;
        gap: 12px;
    }
    header {
        padding: 12px 16px;
    }
    main {
        padding: 12px;
    }
    .card-value {
        font-size: 22px;
    }
}
