:root {
    --geo-blue: #0f5fbf;
    --geo-blue-dark: #0b4384;
    --geo-green: #12834a;
    --geo-red: #c93535;
    --geo-ink: #1f2937;
    --geo-muted: #64748b;
    --geo-line: #d9e2ec;
    --geo-bg: #f6f8fb;
    --geo-soft: #eef4fb;
}

/* Shared, local SVG icon system. */
.app-icon { width: 20px; height: 20px; flex: 0 0 auto; vertical-align: middle; }

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--geo-bg);
    color: var(--geo-ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

a {
    text-decoration: none;
}

.row {
    display: flex;
    flex-wrap: wrap;
}

.g-3 {
    gap: 1rem;
}

.col-12 {
    flex: 0 0 100%;
    max-width: 100%;
}

.col-md-3,
.col-md-4,
.col-md-6,
.col-md-8 {
    flex: 0 0 100%;
    max-width: 100%;
}

.form-label {
    display: block;
    margin-bottom: 0.45rem;
    font-weight: 700;
}

.form-control,
.form-select {
    display: block;
    width: 100%;
    min-height: 42px;
    padding: 0.55rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: var(--geo-ink);
}

textarea.form-control {
    min-height: 110px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0.48rem 0.9rem;
    border: 1px solid transparent;
    cursor: pointer;
}

.app-container {
    max-width: 1180px;
}

.app-main {
    padding: 24px 0 72px;
}

.navbar-brand {
    color: var(--geo-blue-dark);
    font-weight: 800;
    font-size: 0.98rem;
}

.nav-link {
    color: #334155;
    font-weight: 600;
}

.nav-link.active {
    color: var(--geo-blue);
}

.nav-logo,
.login-logo,
.brand-logo {
    object-fit: contain;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.nav-logo {
    width: 36px;
    height: 36px;
}

.login-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
}

.brand-logo-fallback {
    border-radius: 8px;
    background: var(--geo-blue);
    color: #fff;
    font-weight: 800;
    letter-spacing: 0;
}

.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 22px;
}

.page-heading h1 {
    margin: 0;
    font-size: clamp(1.45rem, 2.4vw, 2.25rem);
    font-weight: 800;
    color: #102a43;
}

.page-heading p {
    color: var(--geo-muted);
    margin: 6px 0 0;
}

.heading-actions,
.filter-actions,
.export-actions,
.form-actions,
.action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.summary-grid {
    display: grid;
    grid-template-columns: 2fr repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.summary-card {
    background: #fff;
    border: 1px solid var(--geo-line);
    border-radius: 8px;
    padding: 22px;
    box-shadow: 0 8px 24px rgba(15, 45, 75, 0.06);
}

.summary-card span,
.period-summary span,
.detail-grid span {
    display: block;
    color: var(--geo-muted);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
}

.summary-card strong {
    display: block;
    margin-top: 8px;
    font-size: clamp(1.35rem, 2.4vw, 2.2rem);
    color: #132f4c;
}

.balance-card {
    background: linear-gradient(135deg, #0f5fbf, #1877d5);
    color: #fff;
}

.balance-card span,
.balance-card strong {
    color: #fff;
}

.balance-card.warning {
    background: linear-gradient(135deg, #c93535, #e2574c);
}

.income-card strong,
.income-text {
    color: var(--geo-green);
}

.expense-card strong,
.expense-text {
    color: var(--geo-red);
}

.count-card strong {
    color: var(--geo-blue-dark);
}

.content-block,
.form-shell {
    background: #fff;
    border: 1px solid var(--geo-line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 8px 24px rgba(15, 45, 75, 0.05);
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.section-title h2,
.content-block h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
}

.app-table {
    min-width: 780px;
    margin-bottom: 0;
}

.app-table thead th {
    background: var(--geo-soft);
    color: #274060;
    border-bottom: 1px solid var(--geo-line);
    font-size: 0.78rem;
    text-transform: uppercase;
}

.app-table td {
    border-color: #edf2f7;
}

.description-cell {
    min-width: 240px;
    max-width: 360px;
}

.money {
    white-space: nowrap;
    font-weight: 800;
}

.attachment-thumb {
    width: 54px;
    height: 54px;
    border: 1px solid var(--geo-line);
    border-radius: 8px;
    background: #fff;
    padding: 3px;
    overflow: hidden;
}

.attachment-thumb img,
.attachment-preview img,
.modal-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.attachment-preview {
    display: block;
    width: min(100%, 560px);
    max-height: 520px;
    border: 1px solid var(--geo-line);
    border-radius: 8px;
    background: #fff;
    padding: 8px;
}

.modal-image {
    max-height: 78vh;
}

.filter-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(130px, 1fr)) auto;
    gap: 12px;
    align-items: end;
    background: #fff;
    border: 1px solid var(--geo-line);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 14px;
}

.project-filter,
.dashboard-filter {
    grid-template-columns: minmax(220px, 420px) auto;
}

.period-summary,
.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 14px;
}

.period-summary div,
.detail-grid article {
    background: #fff;
    border: 1px solid var(--geo-line);
    border-radius: 8px;
    padding: 16px;
}

.period-summary strong,
.detail-grid strong {
    display: block;
    margin-top: 6px;
    font-size: 1.18rem;
}

.period-summary .negative strong {
    color: var(--geo-red);
}

.export-actions {
    margin-bottom: 14px;
    justify-content: flex-end;
}

.pagination-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    color: var(--geo-muted);
}

.movement-form .form-control,
.movement-form .form-select,
.filter-bar .form-control,
.filter-bar .form-select,
.login-card .form-control {
    border-color: #cbd5e1;
}

.form-actions {
    justify-content: flex-end;
    margin-top: 22px;
}

.current-attachment {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--geo-muted);
    overflow-wrap: anywhere;
}

.detail-grid {
    grid-template-columns: repeat(4, 1fr);
}

.detail-description {
    color: #334155;
    line-height: 1.6;
}

.floating-action {
    display: none;
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    background: var(--geo-blue);
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    box-shadow: 0 12px 30px rgba(15, 95, 191, 0.32);
    z-index: 1000;
}

.login-body {
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(15, 95, 191, 0.12), rgba(18, 131, 74, 0.08)),
        var(--geo-bg);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(100%, 430px);
    background: #fff;
    border: 1px solid var(--geo-line);
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 24px 70px rgba(15, 45, 75, 0.12);
}

.admin-card {
    width: min(100%, 520px);
}

.login-brand {
    text-align: center;
    margin-bottom: 24px;
}

.login-brand h1 {
    margin: 0;
    color: #102a43;
    font-size: 1.45rem;
    font-weight: 800;
}

.ios-install-hint {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 1200;
    background: #102a43;
    color: #fff;
    border-radius: 8px;
    padding: 12px 14px;
    text-align: center;
    box-shadow: 0 12px 30px rgba(16, 42, 67, 0.28);
}

.mobile-file-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.offline-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff8e6;
    border: 1px solid #f2d083;
    color: #704c00;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 14px;
}

.sync-status {
    min-height: 31px;
    display: inline-flex;
    align-items: center;
}

.offline-toast,
.pwa-update-prompt {
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: 14px;
    z-index: 1300;
    border-radius: 8px;
    padding: 12px 14px;
    color: #fff;
    background: #102a43;
    box-shadow: 0 14px 38px rgba(16, 42, 67, 0.25);
}

.offline-toast {
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.offline-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.offline-toast.warning {
    background: #8a5b00;
}

.offline-toast.danger {
    background: #9f1d1d;
}

.pwa-update-prompt {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.project-state {
    min-width: 72px;
}

.state-activo {
    background: #dff7ea;
    color: #0b6b3c;
}

.state-cerrado {
    background: #eef2f7;
    color: #344256;
}

.state-inactivo {
    background: #fde7e7;
    color: #9f1d1d;
}

.offline-shell {
    min-height: 100vh;
}

.offline-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: var(--geo-bg);
}

.offline-panel {
    width: min(92vw, 430px);
    text-align: center;
    background: #fff;
    border: 1px solid var(--geo-line);
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 16px 42px rgba(15, 45, 75, 0.1);
}

.offline-logo {
    width: 72px;
    height: 72px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.offline-panel h1 {
    font-size: 1.45rem;
    margin: 0 0 8px;
}

.offline-panel p {
    color: var(--geo-muted);
    margin: 0;
}

.btn {
    border-radius: 8px;
    font-weight: 700;
}

.btn-primary {
    background: var(--geo-blue);
    border-color: var(--geo-blue);
}

.btn-primary:hover {
    background: var(--geo-blue-dark);
    border-color: var(--geo-blue-dark);
}

@media (max-width: 991.98px) {
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .balance-card {
        grid-column: 1 / -1;
    }

    .filter-bar {
        grid-template-columns: repeat(2, 1fr);
    }

    .project-filter,
    .dashboard-filter {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        grid-column: 1 / -1;
    }

    .detail-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .col-md-3 {
        flex: 0 0 calc(25% - 1rem);
        max-width: calc(25% - 1rem);
    }

    .col-md-4 {
        flex: 0 0 calc(33.333% - 1rem);
        max-width: calc(33.333% - 1rem);
    }

    .col-md-6 {
        flex: 0 0 calc(50% - 1rem);
        max-width: calc(50% - 1rem);
    }

    .col-md-8 {
        flex: 0 0 calc(66.666% - 1rem);
        max-width: calc(66.666% - 1rem);
    }
}

@media (max-width: 575.98px) {
    .app-main {
        padding-top: 18px;
    }

    .navbar-brand span {
        max-width: 210px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

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

    .page-heading .btn {
        width: 100%;
    }

    .summary-grid,
    .period-summary,
    .detail-grid,
    .filter-bar {
        grid-template-columns: 1fr;
    }

    .summary-card {
        padding: 18px;
    }

    .content-block,
    .form-shell,
    .filter-bar {
        padding: 14px;
    }

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

    .form-actions,
    .export-actions,
    .heading-actions,
    .user-menu,
    .mobile-file-actions,
    .offline-info,
    .pwa-update-prompt {
        flex-direction: column;
        align-items: stretch;
    }

    .form-actions .btn,
    .export-actions .btn,
    .heading-actions .btn,
    .user-menu .btn {
        width: 100%;
    }

    .floating-action {
        display: flex;
    }
}
