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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --error-color: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

header {
    background: #1e293b;
    color: #94a3b8;
    padding: 2rem;
    text-align: center;
    position: relative;
}

.github-link {
    position: absolute;
    top: 1rem;
    right: 1rem;
    color: #94a3b8;
    transition: color 0.2s ease, transform 0.2s ease;
}

.github-link:hover {
    color: #ffffff;
    transform: scale(1.1);
}

.github-link-toolbar {
    margin-left: auto;
    color: var(--text-secondary);
    transition: color 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
}

.github-link-toolbar:hover {
    color: var(--text-primary);
    transform: scale(1.1);
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #60a5fa;
}

header p {
    color: #ffffff;
    font-size: 1.15rem;
    margin-top: 0.5rem;
}

header .slogan {
    color: #4ade80;
}

header .slogan strong {
    font-weight: 700;
    font-size: 1.15em;
    color: #fb923c;
}

/* Privacy Notice */
.privacy-notice {
    text-align: center;
    color: var(--text-primary);
    padding: 0.75rem;
    margin: 0 auto 1rem auto;
}

main {
    max-width: 95vw;
    margin: 0 auto;
    padding: 2rem;
}

/* Upload Section */
#upload-section {
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

#drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--surface);
    position: relative;
}

#drop-zone:hover,
#drop-zone.drag-over {
    border-color: var(--primary-color);
    background: #f0f9ff;
}

#drop-zone.drag-over {
    transform: scale(1.01);
}

.drop-zone-content svg {
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.drop-zone-content p {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.drop-zone-content .sub-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

#file-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

#processing-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1rem;
    background: var(--surface);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Account Info */
.account-info {
    display: flex;
    justify-content: center;
    gap: 0;
    background: var(--surface);
    padding: 1.25rem 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.account-info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0 2rem;
    border-right: 1px solid var(--border-color);
    text-align: center;
}

.account-info-item:last-child {
    border-right: none;
}

.account-info-item .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 500;
}

.account-info-item .value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.btn-primary,
.btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--background);
}

#bill-count {
    color: var(--text-secondary);
    margin-left: auto;
}

/* Dashboard */
#dashboard {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Collapsible Chart Sections */
.chart-section {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.section-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--surface);
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: background-color 0.2s ease;
}


.section-header .chevron {
    transition: transform 0.3s ease;
}

.section-header[aria-expanded="false"] .chevron {
    transform: rotate(-90deg);
}

.section-content {
    padding: 0 1.5rem 1.5rem 1.5rem;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
}

.section-content.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

/* Chart Grid inside sections */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.chart-container {
    background: var(--background);
    padding: 1.25rem;
    border-radius: 8px;
}

.chart-container.wide {
    grid-column: 1 / -1;
}

.chart-container h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-weight: 700;
    text-align: center;
}

.chart-container canvas {
    max-height: 300px;
}

/* Chart Legend Styling */
.chart-container .chartjs-legend {
    margin-top: 1rem;
}

/* Make legend items more spaced and readable */
.chart-container canvas + div {
    padding-top: 0.5rem;
}

/* Data Table */
#data-table-section {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

#data-table-section h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.table-wrapper::-webkit-scrollbar {
    height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

#data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

#data-table th,
#data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

#data-table th {
    background: var(--background);
    font-weight: 700;
    color: var(--text-primary);
    position: sticky;
    top: 0;
}

#data-table tbody tr:nth-child(even) {
    background: var(--background);
}

#data-table tbody tr:hover,
#data-table tbody tr.highlighted {
    background: #dbeafe;
}

#data-table td:nth-child(n+4) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

#data-table th:nth-child(n+4) {
    text-align: right;
}

/* Error Section */
#error-section {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1.5rem;
}

#error-section h3 {
    color: var(--error-color);
    margin-bottom: 1rem;
}

#error-list {
    list-style: none;
}

#error-list li {
    padding: 0.5rem 0;
    color: #991b1b;
    border-bottom: 1px solid #fecaca;
}

#error-list li:last-child {
    border-bottom: none;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Responsive */

/* Large tablets and small desktops */
@media (max-width: 1200px) {
    main {
        max-width: 100%;
        padding: 1.5rem;
    }
}

/* Tablets */
@media (max-width: 900px) {
    #dashboard {
        grid-template-columns: 1fr;
    }

    .chart-container.wide {
        grid-column: 1;
    }

    .chart-container {
        padding: 1.25rem;
    }

    .chart-container canvas {
        max-height: 250px;
    }

    #data-table {
        font-size: 0.8rem;
    }

    #data-table th,
    #data-table td {
        padding: 0.5rem 0.75rem;
    }
}

/* Small tablets */
@media (max-width: 768px) {
    main {
        padding: 1rem;
    }

    .account-info {
        flex-direction: column;
        gap: 0.75rem;
        padding: 1rem;
    }

    .account-info-item {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 0 0 0.75rem 0;
    }

    .account-info-item:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    .toolbar {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .btn-primary,
    .btn-secondary {
        padding: 0.6rem 1.25rem;
        font-size: 0.9rem;
        flex: 1;
        min-width: 120px;
        text-align: center;
    }

    #dashboard {
        gap: 1rem;
    }

    .chart-container h3 {
        font-size: 1rem;
        font-weight: 700;
    }

    #data-table-section {
        padding: 1rem;
    }

    #data-table-section h3 {
        font-size: 1rem;
    }
}

/* Mobile phones */
@media (max-width: 600px) {
    header {
        padding: 1.5rem 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    header h2 {
        font-size: 1.25rem;
    }

    header p {
        font-size: 0.9rem;
    }

    #drop-zone {
        padding: 2rem 1rem;
    }

    .drop-zone-content p {
        font-size: 1rem;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
        min-width: unset;
    }

    .chart-container {
        padding: 1rem;
    }

    .chart-container canvas {
        max-height: 200px;
    }

    #data-table {
        font-size: 0.75rem;
    }

    #data-table th,
    #data-table td {
        padding: 0.4rem 0.5rem;
    }

    .account-info-item .label {
        font-size: 0.7rem;
    }

    .account-info-item .value {
        font-size: 0.9rem;
    }
}

/* Very small phones */
@media (max-width: 400px) {
    main {
        padding: 0.75rem;
    }

    header {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.25rem;
    }

    header h2 {
        font-size: 1.1rem;
    }

    .chart-container {
        padding: 0.75rem;
        border-radius: 8px;
    }

    .chart-container h3 {
        font-size: 0.9rem;
        font-weight: 700;
        margin-bottom: 0.75rem;
    }

    #data-table-section {
        padding: 0.75rem;
        border-radius: 8px;
    }

    .account-info {
        border-radius: 8px;
    }
}
