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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    color: #333;
    display: flex;
    flex-direction: column;
}

/* Fixed Top Bar */
.top-bar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.top-bar.hidden {
    display: none;
}

.top-bar h1 {
    font-size: 1.5rem;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.title-icon {
    height: 28px;
    width: auto;
    vertical-align: middle;
}

/* Scrollable Content */
.content-wrapper {
    flex: 1;
    overflow-y: auto;
    margin-top: 40px; /* Reduced height */
    margin-bottom: 80px; /* Height of bottom bar */
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 40px - 80px);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    flex: 1;
}

/* Fixed Bottom Bar */
.bottom-bar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 15px 20px;
    text-align: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.bottom-bar.hidden {
    display: none;
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 10px;
}

.section {
    margin: 20px 0;
}

.hidden {
    display: none !important;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    animation: fadeIn 0.3s ease-in;
}

/* Limit login section width */
#login-section .container {
    max-width: 800px;
}

#login-section .card {
    max-width: 800px;
    margin: 0 auto;
}

/* Login title styling */
.login-title {
    font-size: 2rem;
    margin-bottom: 20px;
    color: #333;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.login-title .title-icon {
    height: 32px;
    width: auto;
    vertical-align: middle;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card h2 {
    margin-bottom: 20px;
    color: #333;
    text-align: center;
}

/* Reduce space above results */
#results-section .card h2 {
    margin-top: 0;
    margin-bottom: 15px;
}

.card p {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
}

/* Buttons */
.btn {
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary {
    background: #4285F4;
    color: white;
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3);
}

.btn-primary:hover {
    background: #357ae8;
    box-shadow: 0 6px 16px rgba(66, 133, 244, 0.4);
    transform: translateY(-2px);
}

.btn-secondary {
    background: #f1f3f4;
    color: #666;
}

.btn-secondary:hover {
    background: #e8eaed;
}

#authorize-button {
    display: block;
    margin: 0 auto;
    width: fit-content;
}

.google-icon {
    width: 20px;
    height: 20px;
}

.privacy-note {
    margin-top: 30px;
    font-size: 14px;
    color: #999;
    text-align: center;
}

.copyright {
    padding: 20px;
    font-size: 13px;
    color: #999;
    text-align: center;
    margin-top: auto;
}

/* Loading */
.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 30px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-status {
    color: #666;
    font-size: 16px;
}

/* Results */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.results-header h2 {
    margin: 0;
    text-align: left;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 600px) {
    .summary-stats {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.stat-card .stat-label {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 8px;
}

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

.stat-card .stat-detail {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 4px;
}

/* Results Layout */
.results-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

@media (max-width: 968px) {
    .results-layout {
        grid-template-columns: 1fr;
    }
}

/* Table */
.table-container {
    overflow-x: auto;
}

.table-container h3 {
    margin-bottom: 15px;
    color: #333;
}

#table-footer {
    margin-top: 15px;
}

.table-footnote {
    font-size: 13px;
    color: #666;
    font-style: italic;
    line-height: 1.5;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #667eea;
}

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

thead {
    background: #f8f9fa;
}

th {
    padding: 14px 12px;
    text-align: left;
    font-weight: 600;
    color: #666;
    border-bottom: 2px solid #e9ecef;
    font-size: 15px;
}

th:nth-child(2),
th:nth-child(3) {
    text-align: right;
}

td {
    padding: 14px 12px;
    border-bottom: 1px solid #e9ecef;
    font-size: 15px;
}

tbody tr:hover {
    background: #f8f9fa;
}

tbody tr:last-child td {
    border-bottom: none;
}

.size-cell {
    font-weight: 600;
    color: #667eea;
    text-align: right;
}

.label-cell {
    font-weight: 500;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.messages-cell {
    color: #666;
    text-align: right;
}

/* Calculated/Unlabeled row */
tbody tr.calculated-row {
    background: #f1f3f5;
    font-style: italic;
    opacity: 0.9;
}

/* Totals row */
tbody tr.totals-row {
    background: #f8f9fa;
    font-weight: bold;
    border-top: 2px solid #dee2e6;
}

tbody tr.totals-row td {
    padding: 20px 16px;
    font-size: 16px;
}

#refresh-button {
    display: inline-block;
    margin: 0;
}

.refresh-icon {
    display: inline-block;
    font-size: 20px;
}

#refresh-button:hover .refresh-icon {
    animation: spin 0.5s ease-in-out;
}

#refresh-button.loading {
    background: #95a5a6;
    cursor: not-allowed;
    opacity: 0.7;
}

#refresh-button.loading:hover {
    background: #95a5a6;
    transform: none;
    box-shadow: none;
}

/* Estimated values styling - darker gray */
.estimated {
    color: #7f8c8d !important;
}

.stat-value.estimated {
    color: #7f8c8d;
}

.size-cell.estimated {
    color: #7f8c8d;
}

/* Error */
.error-card {
    text-align: center;
}

.error-card h2 {
    color: #dc3545;
}

#error-message {
    color: #666;
    background: #f8d7da;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #f5c6cb;
}

/* Footer */
.main-footer {
    display: none; /* Hidden with fixed bottom bar */
}

/* Chart Section */
.chart-section {
    display: flex;
    flex-direction: column;
}

.chart-section h3 {
    margin-bottom: 10px;
    color: #333;
}

.chart-description {
    font-size: 13px;
    color: #666;
    margin-bottom: 15px;
    font-style: italic;
}

/* Pie Chart */
.pie-chart {
    display: block;
    margin: 0 auto 20px;
}

.pie-chart path {
    cursor: pointer;
    transition: all 0.2s ease;
}

.pie-chart path:hover {
    opacity: 1 !important;
    stroke-width: 3;
    filter: brightness(1.15);
    transform-origin: center;
}


.chart-legend {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
}

.legend-item {
    font-size: 13px;
    color: #666;
}

/* Responsive - Tablet and below */
@media (max-width: 768px) {
    .card {
        padding: 25px 15px;
    }
    
    .login-title {
        font-size: 1.5rem;
    }
    
    .login-title .title-icon {
        height: 26px;
    }
    
    /* Hide pie chart on small screens */
    .chart-section {
        display: none;
    }
    
    /* Shrink summary cards */
    .summary-stats {
        gap: 12px;
    }
    
    .stat-card {
        padding: 15px 12px;
    }
    
    .stat-card .stat-label {
        font-size: 12px;
    }
    
    .stat-card .stat-value {
        font-size: 22px;
    }
}

/* Responsive - Mobile (iPhone SE and similar) */
@media (max-width: 375px) {
    .content-wrapper {
        padding: 8px;
    }
    
    .container {
        padding: 0;
    }
    
    .card {
        padding: 15px 8px;
        border-radius: 8px;
    }
    
    .top-bar {
        padding: 12px 15px;
    }
    
    .top-bar h1 {
        font-size: 1.1rem;
    }
    
    .title-icon {
        height: 20px;
    }
    
    /* Force single column and compact summary cards */
    .summary-stats {
        grid-template-columns: 1fr !important;
        gap: 8px;
        margin-bottom: 20px;
    }
    
    .stat-card {
        padding: 10px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: left;
    }
    
    .stat-card .stat-label {
        font-size: 12px;
        margin-bottom: 0;
    }
    
    .stat-card .stat-value {
        font-size: 20px;
        font-weight: bold;
    }
    
    /* Compact table for horizontal scrolling prevention */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        font-size: 12px;
        width: 100%;
        min-width: 100%;
    }
    
    th, td {
        padding: 8px 4px;
        font-size: 12px;
    }
    
    /* Make label column wrap */
    .label-cell {
        max-width: 120px;
        word-wrap: break-word;
        word-break: break-word;
    }
    
    /* Compact header and buttons */
    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        margin-bottom: 20px;
    }
    
    .login-title {
        font-size: 1.3rem;
    }
    
    .login-title .title-icon {
        height: 22px;
    }
    
    .card h2 {
        font-size: 1.2rem;
    }
    
    .card h3 {
        font-size: 1rem;
        margin-bottom: 10px;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 14px;
        width: 100%;
    }
    
    #refresh-button {
        width: 100%;
    }
    
    /* Bottom bar compact */
    .bottom-bar {
        padding: 12px 15px;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    /* Reduce totals row padding */
    tbody tr.totals-row td {
        padding: 12px 4px;
        font-size: 13px;
    }
}
