:root {
    --navy: #071b3d;
    --blue: #0879bd;
    --green: #7cc242;
    --orange: #f26b21;
    --ink: #172033;
    --muted: #667085;
    --line: #d8dde7;
    --bg: #f4f7fb;
    --card: #ffffff;
    --danger: #b42318;
    --ok: #16703a;
    --shadow: 0 14px 34px rgba(16, 24, 40, .10);
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    background:
        radial-gradient(circle at top left, rgba(8, 121, 189, .12), transparent 30%),
        radial-gradient(circle at top right, rgba(124, 194, 66, .14), transparent 26%),
        var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    margin: 0;
}

a {
    color: var(--blue);
    font-weight: 700;
    text-decoration: none;
}

button,
.button,
.icon-button {
    align-items: center;
    background: #eef4fb;
    border: 1px solid #cbd7e8;
    color: var(--navy);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-weight: 800;
    justify-content: center;
    min-height: 44px;
    padding: 10px 14px;
    text-align: center;
    border-radius: 14px;
}

button.primary,
.primary {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
    width: 100%;
}

.app-header {
    align-items: center;
    background: var(--navy);
    color: #fff;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 14px 14px calc(14px + env(safe-area-inset-top));
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    align-items: center;
    display: flex;
    gap: 10px;
    min-width: 0;
}

.brand img {
    background: #fff;
    border-radius: 14px;
    height: 42px;
    object-fit: contain;
    padding: 5px;
    width: 42px;
}

.brand strong,
.brand span {
    display: block;
}

.brand span {
    color: #dbe8f6;
    font-size: 12px;
}

.icon-button {
    background: rgba(255, 255, 255, .1);
    border-color: rgba(255, 255, 255, .18);
    color: #fff;
}

.app-shell {
    margin: 0 auto;
    max-width: 980px;
    padding: 14px 14px 92px;
}

.login-card {
    background: #fff;
    border: 1px solid var(--line);
    margin: 38px auto;
    max-width: 420px;
    padding: 22px;
}

.login-card img {
    display: block;
    max-width: 230px;
    width: 80%;
}

.hero-panel,
.card,
.list-card,
.document {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
    margin-bottom: 14px;
    padding: 16px;
}

.hero-panel {
    align-items: center;
    background: linear-gradient(135deg, var(--navy), #0d4f7d 60%, #0b6da8);
    color: #fff;
    display: grid;
    gap: 14px;
    grid-template-columns: 1fr 260px;
    overflow: hidden;
    min-height: 190px;
}

.hero-panel img {
    background: #fff;
    border: 4px solid rgba(255, 255, 255, .28);
    border-radius: 22px;
    height: 150px;
    object-fit: cover;
    width: 100%;
}

.hero-panel p {
    color: #dbe8f6;
}

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

.hero-finance {
    align-items: center;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 20px;
    display: grid;
    gap: 12px;
    justify-items: center;
    padding: 12px;
}

.donut-chart {
    align-items: center;
    aspect-ratio: 1;
    background: conic-gradient(var(--green) 0 var(--paid), var(--orange) var(--paid) 100%);
    border-radius: 50%;
    display: grid;
    justify-items: center;
    max-width: 168px;
    position: relative;
    width: 100%;
}

.donut-chart::after {
    background: #fff;
    border-radius: 50%;
    content: "";
    inset: 20px;
    position: absolute;
}

.donut-chart > div {
    color: var(--navy);
    position: relative;
    text-align: center;
    z-index: 1;
}

.donut-chart span {
    display: block;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.donut-chart strong {
    display: block;
    font-size: 25px;
}

.hero-legend {
    display: grid;
    gap: 8px;
    width: 100%;
}

.hero-legend p {
    align-items: center;
    background: rgba(255, 255, 255, .92);
    border-radius: 14px;
    color: var(--ink);
    display: grid;
    font-size: 12px;
    gap: 7px;
    grid-template-columns: auto 1fr auto;
    margin: 0;
    padding: 8px 10px;
}

.hero-legend strong {
    color: var(--navy);
}

.dot {
    border-radius: 50%;
    display: inline-block;
    height: 10px;
    width: 10px;
}

.dot.paid {
    background: var(--green);
}

.dot.pending {
    background: var(--orange);
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    font-size: 26px;
}

h2 {
    font-size: 18px;
}

p {
    color: var(--muted);
    line-height: 1.45;
}

.metric-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 14px;
}

.metric {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 8px 22px rgba(16, 24, 40, .07);
    padding: 14px;
    position: relative;
    overflow: hidden;
}

.metric::before {
    background: linear-gradient(180deg, var(--blue), var(--green));
    content: "";
    height: 100%;
    left: 0;
    position: absolute;
    top: 0;
    width: 5px;
}

.metric span {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.metric strong {
    display: block;
    font-size: 25px;
    margin-top: 8px;
}

.chart-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 14px;
}

.chart-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 10px 26px rgba(16, 24, 40, .08);
    padding: 14px;
}

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

.chart-title span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.chart-title strong {
    color: var(--navy);
    font-size: 28px;
}

.chart-row {
    display: grid;
    gap: 7px;
    margin-bottom: 12px;
}

.chart-row:last-child {
    margin-bottom: 0;
}

.chart-row div {
    align-items: center;
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.chart-row span {
    color: var(--ink);
    font-size: 12px;
    font-weight: 800;
}

.chart-row strong {
    color: var(--navy);
    font-size: 13px;
}

.chart-row i {
    background: #e8eef6;
    border-radius: 999px;
    display: block;
    height: 10px;
    overflow: hidden;
    position: relative;
}

.chart-row i::before {
    background: linear-gradient(90deg, var(--blue), var(--green));
    border-radius: inherit;
    content: "";
    inset: 0 auto 0 0;
    position: absolute;
    width: var(--bar);
}

.chart-row.quote i::before {
    background: linear-gradient(90deg, var(--orange), var(--blue));
}

.chart-row.client i::before {
    background: linear-gradient(90deg, var(--green), var(--blue));
}

.quick-actions {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 14px;
}

.action-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: 0 10px 26px rgba(16, 24, 40, .08);
    color: var(--navy);
    overflow: hidden;
    position: relative;
    min-height: 92px;
    padding: 18px;
    display: flex;
    align-items: flex-end;
}

.action-card::after {
    background: linear-gradient(135deg, rgba(8, 121, 189, .16), rgba(124, 194, 66, .16));
    content: "";
    height: 70px;
    position: absolute;
    right: -22px;
    top: -22px;
    transform: rotate(35deg);
    width: 92px;
}

.action-card:nth-child(2n)::after {
    background: linear-gradient(135deg, rgba(242, 107, 33, .15), rgba(8, 121, 189, .16));
}

.page-title,
.list-top,
.row-actions,
.money-row,
.print-actions {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: space-between;
    margin-bottom: 12px;
}

.page-title h1 {
    margin: 0;
}

.list-card h2 {
    margin-bottom: 8px;
}

.row-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
    margin-bottom: 0;
}

.row-actions a,
.print-actions a,
.inline-form button {
    background: #eef4fb;
    border: 1px solid #cbd7e8;
    color: var(--navy);
    min-height: 40px;
    padding: 9px 12px;
    border-radius: 12px;
}

.badge {
    background: #eef2f6;
    color: var(--ink);
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    padding: 6px 8px;
    border-radius: 999px;
}

.badge-pendiente,
.badge-vencido {
    background: #fee4e2;
    color: var(--danger);
}

.badge-asignado,
.badge-en_camino,
.badge-abonado,
.badge-borrador,
.badge-enviada {
    background: #fff1d6;
    color: #8a4b00;
}

.badge-en_proceso,
.badge-proyecto_nuevo {
    background: #d8edff;
    color: #075985;
}

.badge-terminado,
.badge-cerrado,
.badge-pagado,
.badge-pagado_completo,
.badge-aprobada,
.badge-convertida {
    background: #dcfce7;
    color: var(--ok);
}

.form-stack {
    display: grid;
    gap: 14px;
}

label {
    color: var(--ink);
    display: grid;
    font-size: 13px;
    font-weight: 800;
    gap: 6px;
}

input,
select,
textarea {
    background: #fff;
    border: 1px solid #cbd5e1;
    color: var(--ink);
    font: inherit;
    min-height: 44px;
    padding: 10px;
    width: 100%;
    border-radius: 14px;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

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

.check {
    align-items: center;
    display: flex;
    gap: 8px;
}

.check input {
    min-height: auto;
    width: auto;
}

.upload-box {
    background: #f8fafc;
    border: 1px dashed #98a2b3;
    border-radius: 18px;
    padding: 14px;
}

.upload-box span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.quote-item {
    display: grid;
    gap: 8px;
    grid-template-columns: 1fr 80px 110px;
    margin-bottom: 8px;
}

.doc-header {
    align-items: center;
    border-bottom: 3px solid var(--green);
    display: flex;
    gap: 14px;
    margin-bottom: 16px;
    padding-bottom: 12px;
}

.doc-header img {
    max-height: 62px;
    max-width: 170px;
    object-fit: contain;
}

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

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

.doc-table th,
.doc-table td {
    border-bottom: 1px solid var(--line);
    padding: 9px 6px;
    text-align: left;
}

.totals {
    margin-left: auto;
    max-width: 320px;
}

.totals p {
    display: flex;
    justify-content: space-between;
}

.totals .grand {
    color: var(--ink);
    font-size: 20px;
    font-weight: 900;
}

.evidence-grid {
    display: grid;
    gap: 8px;
}

.evidence-grid a {
    background: #eef4fb;
    border: 1px solid #cbd7e8;
    border-radius: 12px;
    padding: 10px;
}

.activity-item {
    border-bottom: 1px solid var(--line);
    padding: 10px 0;
}

.activity-item:last-child {
    border-bottom: 0;
}

.activity-item span {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 700;
}

.flash {
    border: 1px solid var(--line);
    margin-bottom: 12px;
    padding: 12px;
}

.flash-success {
    background: #ecfdf3;
    border-color: #abefc6;
}

.flash-error {
    background: #fff1f3;
    border-color: #fecdd3;
}

.bottom-nav {
    background: #fff;
    border-top: 1px solid var(--line);
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    left: 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    position: fixed;
    right: 0;
    z-index: 30;
}

.bottom-nav a {
    color: var(--muted);
    font-size: 12px;
    border-radius: 14px;
    padding: 9px 4px;
    text-align: center;
}

.bottom-nav a.active {
    background: #eef7fb;
    color: var(--blue);
}

.inline-form {
    display: inline;
}

@media (max-width: 640px) {
    .hero-panel {
        grid-template-columns: 1fr;
    }

    .hero-finance {
        grid-template-columns: 132px 1fr;
        justify-items: stretch;
    }

    .two,
    .quote-item,
    .doc-grid {
        grid-template-columns: 1fr;
    }

    .quick-actions {
        grid-template-columns: 1fr;
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .print-actions,
    .money-row {
        align-items: stretch;
        flex-direction: column;
    }

    .print-actions .button,
    .print-actions .primary,
    .print-actions form,
    .print-actions button {
        width: 100%;
    }
}

@media print {
    body {
        background: #fff;
    }

    .app-header,
    .bottom-nav,
    .print-actions,
    .flash {
        display: none !important;
    }

    .app-shell {
        max-width: none;
        padding: 0;
    }

    .document {
        border: 0;
        margin: 0;
    }
}
