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

body {
    min-height: 100vh;
    background: #eef1f8;
    font-family: 'Poppins', system-ui, sans-serif;
    color: #1f2937;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #ffffff;
    border-bottom: 1px solid rgba(168, 85, 247, 0.25);
    box-shadow: 0 4px 20px rgba(67, 56, 202, 0.08);
    transition: transform 0.35s ease, opacity 0.35s ease;
}

.app-header--enter {
    animation: slideDown 0.4s ease;
}

.app-header__inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.app-header__logo {
    height: 40px;
    width: auto;
    margin-right: auto;
}

.app-header__back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #faf5ff;
    border: 1px solid rgba(168, 85, 247, 0.35);
    color: #6d28d9;
    text-decoration: none;
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.app-header__back:hover {
    transform: translateX(-2px);
    box-shadow: 0 4px 14px rgba(168, 85, 247, 0.25);
    background: #f3e8ff;
}

.app-header__back svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.2;
}

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

.app-header__link {
    padding: 8px 14px;
    border-radius: 999px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    color: #4b5563;
    border: 1px solid transparent;
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.app-header__link:hover,
.app-header__link.is-active {
    color: #6d28d9;
    background: rgba(168, 85, 247, 0.1);
    border-color: rgba(168, 85, 247, 0.25);
    transform: translateY(-1px);
}

.app-header__link--admin {
    display: none;
}

body.is-admin .app-header__link--admin {
    display: inline-block;
}

.app-header__user {
    font-size: 0.8rem;
    color: #6b7280;
    margin-left: 4px;
}

.app-header__logout {
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid rgba(168, 85, 247, 0.35);
    background: #fff;
    color: #6d28d9;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.app-header__logout:hover {
    background: #faf5ff;
    box-shadow: 0 4px 14px rgba(168, 85, 247, 0.2);
    transform: translateY(-1px);
}

.app-header__logout:active {
    transform: scale(0.97);
}

.app-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px 40px;
}

.card {
    background: #fff;
    border: 1px solid rgba(192, 132, 252, 0.25);
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(67, 56, 202, 0.1);
    overflow: visible;
}

.card__header {
    padding: 14px 20px;
    background: linear-gradient(90deg, rgba(192, 132, 252, 0.22), rgba(168, 85, 247, 0.18));
    border-bottom: 1px solid rgba(192, 132, 252, 0.25);
    font-weight: 600;
    font-size: 0.95rem;
}

.card__body {
    padding: 20px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-grid .span-2 {
    grid-column: span 2;
}

.field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: #374151;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="password"],
.field input[type="datetime-local"],
.field textarea,
.field select {
    width: 100%;
    padding: 11px 12px;
    border-radius: 10px;
    border: 1px solid rgba(168, 85, 247, 0.3);
    font: inherit;
    font-size: 0.95rem;
    background: #fafafa;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
    outline: none;
    border-color: #a855f7;
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}

.field textarea {
    min-height: 88px;
    resize: vertical;
}

.field-counter {
    display: block;
    margin-top: 4px;
    font-size: 0.75rem;
    color: #6b7280;
    text-align: right;
}

.field-counter.is-limit {
    color: #b45309;
    font-weight: 500;
}

.field input[type="datetime-local"] {
    cursor: pointer;
    color-scheme: light;
}

.field input[type="datetime-local"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.75;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 20px;
    padding: 4px 0;
}

.radio-group label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    cursor: pointer;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 20px;
    border-radius: 999px;
    border: 0;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease, opacity 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0) scale(0.98);
}

.btn.is-loading {
    opacity: 0.85;
    pointer-events: none;
    position: relative;
}

.btn.is-loading::after {
    content: "";
    width: 16px;
    height: 16px;
    margin-left: 8px;
    border: 2px solid rgba(17, 24, 39, 0.2);
    border-top-color: #111827;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.btn--primary {
    color: #111827;
    background: linear-gradient(90deg, #a855f7, #c084fc);
    box-shadow: 0 8px 20px rgba(168, 85, 247, 0.35);
}

.btn--primary:hover {
    filter: brightness(1.04);
    box-shadow: 0 10px 24px rgba(168, 85, 247, 0.42);
}

.btn--ghost {
    background: #fff;
    color: #6d28d9;
    border: 1px solid rgba(168, 85, 247, 0.35);
}

.btn--danger {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}

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

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

.data-table th,
.data-table td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.9rem;
}

.data-table th {
    background: rgba(192, 132, 252, 0.12);
    font-weight: 600;
}

.row-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.autocomplete-wrap {
    position: relative;
    z-index: 1;
}

.autocomplete-wrap:focus-within {
    z-index: 40;
}

.autocomplete-list {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    max-height: 220px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 10px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
    z-index: 50;
    display: none;
}

.autocomplete-list.is-open {
    display: block;
}

.autocomplete-list button {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    background: transparent;
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.autocomplete-list button:hover,
.autocomplete-list button.is-active {
    background: rgba(168, 85, 247, 0.12);
}

.login-wrap {
    min-height: calc(100vh - 80px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.login-card:hover {
    box-shadow: 0 16px 40px rgba(67, 56, 202, 0.14);
}

.login-card__logo-wrap {
    display: flex;
    justify-content: center;
    padding: 28px 20px 4px;
    background: #fff;
    border-radius: 16px 16px 0 0;
}

.login-card .card__body {
    padding-top: 16px;
}

.login-card__logo {
    width: clamp(140px, 40vw, 180px);
    height: auto;
}

.login-card .card__body p {
    color: #6b7280;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.login-error {
    color: #dc2626;
    font-size: 0.88rem;
    margin-top: 10px;
    display: none;
}

.login-error.is-visible {
    display: block;
}

.form-message {
    font-size: 0.88rem;
    margin-top: 10px;
    display: none;
}

.form-message.is-visible {
    display: block;
}

.form-message.is-success {
    color: #059669;
}

.form-message.is-info {
    color: #6b7280;
}

.form-message.is-error {
    color: #dc2626;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.5);
}

.modal.is-open {
    display: flex;
}

.modal__card {
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: 16px;
    padding: 22px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.modal__card--info {
    max-width: 400px;
    border: 1px solid rgba(168, 85, 247, 0.2);
    box-shadow: 0 16px 36px rgba(67, 56, 202, 0.12);
}

.modal__card--info p {
    font-size: 0.9rem;
    line-height: 1.5;
    color: #4b5563;
    margin-bottom: 4px;
}

.modal--info .modal__actions {
    justify-content: center;
    margin-top: 14px;
}

.modal__card h3 {
    margin-bottom: 14px;
}

.modal__card--wide {
    max-width: 560px;
}

.modal__actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 18px;
}

.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filter-panel {
    display: grid;
    grid-template-columns: minmax(170px, 220px) minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 12px;
}

.filter-panel__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-meta {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 14px;
}

.catalogo-page {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.catalogo-hint {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 14px;
}

.admin-danger-zone {
    border-color: rgba(220, 38, 38, 0.25);
}

.admin-danger-zone .card__header {
    background: linear-gradient(90deg, rgba(254, 226, 226, 0.9), rgba(254, 202, 202, 0.5));
    color: #991b1b;
}

.admin-tools {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.admin-tool-card__actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.admin-tool-card--safe .card__header {
    background: linear-gradient(90deg, rgba(219, 234, 254, 0.9), rgba(191, 219, 254, 0.5));
    color: #1e40af;
}

.admin-tool-card--import .card__header {
    background: linear-gradient(90deg, rgba(237, 233, 254, 0.95), rgba(221, 214, 254, 0.55));
    color: #5b21b6;
}

.import-filename {
    font-size: 0.85rem;
    color: #4b5563;
}

.data-table td.cell-obs {
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table td.cell-money {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.hidden {
    display: none !important;
}

html.has-recibo-session #login-screen {
    display: none !important;
}

html.has-recibo-session #app-screen {
    display: block !important;
}

html.has-recibo-session #app-screen.auth-enter,
html.has-recibo-session #app-screen.auth-enter .card {
    animation: none !important;
}

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

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

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

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

.auth-enter {
    animation: fadeInUp 0.42s ease both;
}

.auth-leave {
    animation: fadeOutDown 0.28s ease both;
}

.auth-shake {
    animation: shake 0.45s ease;
}

#app-screen.auth-enter .card {
    animation: fadeInUp 0.45s ease 0.08s both;
}

.recibo-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 12px 20px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #fff;
    background: #374151;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 9999;
}

.recibo-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.recibo-toast--success {
    background: linear-gradient(90deg, #7c3aed, #a855f7);
}

.recibo-toast--error {
    background: #dc2626;
}

.recibo-toast--info {
    background: #4b5563;
}

.modal.is-open {
    animation: fadeIn 0.25s ease;
}

.modal.is-open .modal__card {
    animation: fadeInUp 0.32s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.field input:focus,
.field textarea:focus,
.field select:focus {
    transform: scale(1.01);
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

@media (max-width: 720px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid .span-2 {
        grid-column: span 1;
    }

    .filter-panel {
        grid-template-columns: 1fr;
    }

    .app-header__inner {
        justify-content: center;
    }

    .app-header__logo {
        margin-right: 0;
        order: -2;
        width: 100%;
        text-align: center;
        height: 36px;
        object-fit: contain;
        object-position: center;
    }
}
