:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --secondary: #34a853;
    --danger: #ea4335;
    --warning: #fbbc04;
    --background: #f8f9fa;
    --surface: #ffffff;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --border: #dadce0;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
    --incc-accent: #8e44ad;
    --ipca-accent: #e67e22;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 1rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background-color: var(--surface);
    border-radius: 16px;
    box-shadow: 0 8px 32px var(--shadow);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 2.5rem 2rem;
    text-align: center;
}

header h1 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    font-weight: 400;
}

/* Main Content */
main {
    padding: 2rem;
}

/* Controls Card */
.controls-card {
    background: var(--background);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px solid var(--border);
}

.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 1rem;
    align-items: end;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-wrapper label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

input[type="month"],
select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--surface);
    color: var(--text-primary);
    transition: all 0.2s ease;
    font-family: inherit;
}

input[type="month"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235f6368' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.button-wrapper {
    display: flex;
    align-items: flex-end;
}

button {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.3);
    white-space: nowrap;
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.4);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

button:disabled {
    background: var(--border);
    cursor: not-allowed;
    box-shadow: none;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Error Card */
.error-card {
    background: #fef2f2;
    border: 2px solid var(--danger);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.error-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.error-card p {
    color: var(--danger);
    font-weight: 500;
    flex: 1;
}

/* Data Display */
.data-display {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    animation: fadeIn 0.4s ease;
}

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

/* Index Cards */
.index-card {
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow);
    transition: all 0.3s ease;
}

.index-card:hover {
    box-shadow: 0 4px 16px var(--shadow-hover);
    transform: translateY(-4px);
}

.card-header {
    padding: 1.5rem;
    color: white;
}

.incc-header {
    background: linear-gradient(135deg, var(--incc-accent) 0%, #9b59b6 100%);
}

.ipca-header {
    background: linear-gradient(135deg, var(--ipca-accent) 0%, #f39c12 100%);
}

.card-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.card-subtitle {
    font-size: 0.85rem;
    opacity: 0.95;
    font-weight: 400;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
}

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

thead {
    background: var(--background);
}

th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
}

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

tbody tr {
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background-color: var(--background);
}

/* Rate Value Styling */
.rate-positive {
    color: var(--danger);
    font-weight: 700;
    font-size: 1.1rem;
}

.rate-negative {
    color: var(--secondary);
    font-weight: 700;
    font-size: 1.1rem;
}

.rate-neutral {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 1.1rem;
}

.no-data {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
    font-style: italic;
}

/* Footer */
footer {
    background: var(--background);
    padding: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
}

.footer-note {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    body {
        padding: 0;
    }

    .container {
        border-radius: 0;
        min-height: 100vh;
    }

    header {
        padding: 2rem 1rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    main {
        padding: 1rem;
    }

    .controls-card {
        padding: 1rem;
    }

    .controls-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .button-wrapper {
        align-items: stretch;
    }

    button {
        width: 100%;
        padding: 1rem;
    }

    .data-display {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .hide-mobile {
        display: none;
    }

    th, td {
        padding: 0.75rem 0.5rem;
        font-size: 0.9rem;
    }

    .card-header {
        padding: 1rem;
    }

    .card-header h3 {
        font-size: 1.25rem;
    }

    .card-subtitle {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    th, td {
        padding: 0.5rem 0.25rem;
        font-size: 0.85rem;
    }

    .rate-positive,
    .rate-negative,
    .rate-neutral {
        font-size: 1rem;
    }
}

/* Tablet Landscape */
@media (min-width: 769px) and (max-width: 1024px) {
    .controls-grid {
        grid-template-columns: 1fr 1fr;
    }

    .button-wrapper {
        grid-column: 1 / -1;
    }

    button {
        width: 100%;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }

    .container {
        box-shadow: none;
    }

    .controls-card,
    button,
    .loading,
    .error-card {
        display: none !important;
    }

    .index-card {
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid var(--border);
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #1a1a1a;
        --surface: #2d2d2d;
        --text-primary: #e8eaed;
        --text-secondary: #9aa0a6;
        --border: #3c4043;
        --shadow: rgba(0, 0, 0, 0.3);
        --shadow-hover: rgba(0, 0, 0, 0.4);
    }

    body {
        background: linear-gradient(135deg, #434343 0%, #000000 100%);
    }

    input[type="month"],
    select {
        background: var(--surface);
        color: var(--text-primary);
    }

    .controls-card {
        background: var(--surface);
    }

    thead {
        background: #3c4043;
    }

    tbody tr:hover {
        background-color: #3c4043;
    }

    .error-card {
        background: #3c1f1f;
        border-color: var(--danger);
    }
}
