:root {
    /* Color Palette - Premium Dark Blue Mode */
    --bg-main: #020617;
    /* Darker navy */
    --bg-card: #0f172a;
    /* Slate 900 */
    --bg-card-hover: #1e293b;
    /* Slate 800 */
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.4);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.08);
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);

    /* Typography - 1.250 Major Third Scale */
    --base-font: 'Inter', sans-serif;
    --font-size-base: 16px;
    --font-size-lg: 1.25rem;
    --font-size-xl: 1.563rem;
    --font-size-2xl: 1.953rem;
    --font-size-3xl: 2.441rem;

    /* Soft Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 10px 30px -10px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 50px -15px rgba(0, 0, 0, 0.5);

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--base-font);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent body scroll */
}

/* Background Blobs for depth */
.background-blobs {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.1;
    animation: floating 20s infinite alternate ease-in-out;
}

.blob-1 {
    width: 60vw;
    height: 60vw;
    background: var(--primary);
    top: -20%;
    right: -20%;
}

.blob-2 {
    width: 50vw;
    height: 50vw;
    background: #1d4ed8;
    bottom: -15%;
    left: -15%;
    animation-delay: -5s;
}

@keyframes floating {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(50px, 50px) scale(1.1);
    }
}

.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Access Screen */
.access-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    background: var(--bg-main);
    padding: 1.5rem;
}

.access-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.access-icon {
    width: 80px;
    height: 80px;
    background: var(--success-bg);
    color: var(--success);
    border-radius: 20px;
    display: grid;
    place-items: center;
    margin: 0 auto 1.5rem;
}

.access-card h2 {
    font-size: var(--font-size-xl);
    margin-bottom: 0.5rem;
}

.access-card p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group input {
    width: 100%;
    padding: 1rem 1.25rem;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    filter: brightness(1.1);
    box-shadow: 0 10px 20px var(--primary-glow);
    transform: translateY(-2px);
}

.btn-secondary {
    width: 100%;
    padding: 1rem;
    background: var(--bg-card-hover);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-muted);
}

header {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-shrink: 0;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1 {
    font-size: var(--font-size-xl);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.btn-icon {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--primary-glow);
}

/* Card & Table Area */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0;
    /* Remove padding to maximize space */
    box-shadow: var(--shadow-md);
    overflow: hidden;
    flex: 1;
    /* Occupy all available space */
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* Important for flex child scroll */
}

.table-container {
    flex: 1;
    overflow-y: auto;
    /* Scroll bar for data */
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.table-container::-webkit-scrollbar {
    width: 6px;
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: center;
    padding: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    position: sticky;
    /* Sticky headers */
    top: 0;
    background: var(--bg-card);
    z-index: 10;
    cursor: pointer;
    transition: var(--transition);
}

th:hover {
    color: var(--text-main);
    background: var(--bg-card-hover);
}

td {
    padding: 1.25rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

th:nth-child(1),
td:nth-child(1) {
    text-align: center;
}

tbody tr {
    transition: var(--transition);
    cursor: pointer;
}

tbody tr:hover {
    background: var(--bg-card-hover);
}

tbody tr:last-child td {
    border-bottom: none;
}

.impuesto-tag {
    font-weight: 600;
    color: var(--text-main);
}

/* Status Messages */
.status-message {
    padding: 3rem 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.hidden {
    display: none !important;
}

/* Modal Styling */
.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
}

.modal-header h3 {
    font-size: var(--font-size-lg);
    margin-bottom: 1.5rem;
    color: var(--success);
}

.modal-body {
    font-size: 1rem;
    color: var(--text-main);
    margin-bottom: 2.5rem;
    line-height: 1.8;
    text-align: left;
}

.presentation-fields {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: -1rem;
    margin-bottom: 2rem;
}

.presentation-field label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 600;
}

.presentation-field textarea {
    width: 100%;
    min-height: 4.25rem;
    max-height: 4.25rem;
    resize: none;
    padding: 0.9rem 1rem;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    outline: none;
    transition: var(--transition);
}

.presentation-field textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.attachment-row {
    display: flex;
    gap: 0.75rem;
}

.icon-btn {
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card-hover);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.icon-btn:hover {
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 8px 20px -12px var(--primary-glow);
}

.attachment-status {
    min-height: 1.25rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.4;
    word-break: break-word;
}

.modal-footer {
    display: flex;
    gap: 1rem;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Date Status Colors */
tbody tr.date-past td {
    color: #ef4444;
}

tbody tr.date-today td {
    color: #22c55e;
}

tbody tr.date-past .impuesto-tag,
tbody tr.date-today .impuesto-tag {
    color: currentColor;
}

/* Success State */
tbody tr.processed td {
    color: var(--success);
    background: var(--success-bg);
}

/* Footer */
footer {
    padding: 1.5rem;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Mobile Specific Optimizations */
@media (max-width: 640px) {
    .container {
        padding: 0.75rem;
    }

    h1 {
        font-size: 1.25rem;
    }

    th {
        padding: 0.75rem 0.5rem;
        font-size: 0.75rem;
        display: table-cell !important;
        text-align: center;
    }

    td {
        padding: 1rem 0.5rem;
        font-size: 0.8125rem;
        display: table-cell !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        text-align: left;
    }

    table {
        table-layout: fixed !important;
    }

    /* Column distribution */
    th:nth-child(1),
    td:nth-child(1) {
        width: 100px;
    }

    th:nth-child(2),
    td:nth-child(2) {
        width: 45px;
    }

    th:nth-child(3),
    td:nth-child(3) {
        width: auto;
    }

    .impuesto-tag {
        font-size: 0.8125rem;
    }

    .modal-content {
        padding: 2rem 1.5rem;
    }

    .presentation-fields {
        margin-top: -0.75rem;
    }

    .modal-footer {
        flex-direction: column-reverse;
    }
}
