/*
   Sandexam — hoja de estilos principal.
   Paleta crema + verde inglés. Serif para titulares, sans para body.
*/

:root {
    --crema:        #fafaf7;
    --crema-2:      #f3f1eb;
    --linea:        #e8e6df;
    --tinta:        #1a3a3a;
    --tinta-soft:   #2a4a4a;
    --texto:        #2c2c2a;
    --texto-soft:   #6a6a64;
    --acento:       #8a7d5e;
    --positivo:     #3B6D11;
    --negativo:     #993C1D;
    --aviso:        #BA7517;
    --radio:        4px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--crema);
    color: var(--texto);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--tinta); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 {
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 400;
    color: var(--tinta);
    letter-spacing: -0.5px;
}

.serif { font-family: 'Fraunces', Georgia, serif; }
.eyebrow {
    font-size: 11px;
    color: var(--acento);
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* ------------------------- Header / Navegación ------------------------- */

.nav {
    padding: 22px 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 0.5px solid var(--linea);
    background: var(--crema);
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--tinta);
}
.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--tinta);
    color: var(--crema);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Fraunces', Georgia, serif;
    font-size: 16px;
}
.brand-name {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 19px;
    letter-spacing: 0.3px;
}
.nav-links {
    display: flex;
    align-items: center;
    gap: 28px;
    font-size: 14px;
    color: #555;
}

/* ---------------------------- Botones ---------------------------- */

.btn {
    display: inline-block;
    padding: 11px 22px;
    font-size: 13px;
    border-radius: var(--radio);
    border: 0.5px solid var(--tinta);
    background: transparent;
    color: var(--tinta);
    cursor: pointer;
    text-decoration: none;
    letter-spacing: 0.4px;
    transition: background 0.15s ease, color 0.15s ease;
    font-family: inherit;
}
.btn:hover { text-decoration: none; background: var(--tinta); color: var(--crema); }

.btn-primary {
    background: var(--tinta);
    color: var(--crema);
    border-color: var(--tinta);
}
.btn-primary:hover { background: var(--tinta-soft); border-color: var(--tinta-soft); }

.btn-block { display: block; width: 100%; text-align: center; }

/* ----------------------------- Hero ----------------------------- */

.hero {
    padding: 80px 48px 64px;
    text-align: center;
    background: linear-gradient(180deg, var(--crema) 0%, var(--crema-2) 100%);
}
.hero h1 {
    font-size: 44px;
    line-height: 1.15;
    margin: 18px 0 18px;
}
.hero p {
    font-size: 16px;
    color: var(--texto-soft);
    max-width: 540px;
    margin: 0 auto 32px;
    line-height: 1.7;
}
.hero-actions {
    display: inline-flex;
    gap: 12px;
}

/* --------------------------- Servicios --------------------------- */

.section { padding: 64px 48px; }
.section-title {
    text-align: center;
    margin-bottom: 40px;
}
.services-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 22px;
    max-width: 880px;
    margin: 0 auto;
}
.service {
    background: #fff;
    padding: 22px 24px;
    border-radius: var(--radio);
    border: 0.5px solid var(--linea);
}
.service-icon {
    font-size: 24px;
    color: var(--tinta);
    margin-bottom: 12px;
}
.service h3 {
    font-size: 18px;
    margin: 0 0 6px;
}
.service p {
    font-size: 13px;
    color: var(--texto-soft);
    margin: 0;
    line-height: 1.6;
}

/* --------------------------- Cita / Cierre --------------------------- */

.quote {
    padding: 56px 48px;
    background: var(--crema-2);
    text-align: center;
    border-top: 0.5px solid var(--linea);
    border-bottom: 0.5px solid var(--linea);
}
.quote blockquote {
    font-family: 'Fraunces', Georgia, serif;
    font-style: italic;
    font-size: 22px;
    color: var(--tinta);
    line-height: 1.5;
    margin: 0 auto 12px;
    max-width: 580px;
}

/* -------------------------- Footer -------------------------- */

.footer {
    background: var(--tinta);
    color: #d4cfc1;
    padding: 24px 48px;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ---------------------------- Login ---------------------------- */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--crema);
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 380px;
    padding: 40px 36px;
    background: #fff;
    border: 0.5px solid var(--linea);
    border-radius: 6px;
}
.login-card .brand {
    flex-direction: column;
    text-align: center;
    margin-bottom: 28px;
    gap: 10px;
}
.login-card h2 {
    font-size: 22px;
    text-align: center;
    margin: 0 0 6px;
}
.login-card .subtitle {
    text-align: center;
    color: var(--texto-soft);
    font-size: 13px;
    margin: 0 0 28px;
}
.field {
    margin-bottom: 16px;
}
.field label {
    display: block;
    font-size: 12px;
    color: var(--texto-soft);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}
.field input {
    width: 100%;
    padding: 11px 12px;
    border: 0.5px solid var(--linea);
    border-radius: var(--radio);
    font-size: 14px;
    background: var(--crema);
    color: var(--texto);
    font-family: inherit;
}
.field input:focus {
    outline: 2px solid var(--tinta);
    outline-offset: -1px;
    background: #fff;
}
.error {
    background: #fbeceb;
    color: #7a1f15;
    border: 0.5px solid #e6b7b1;
    padding: 10px 14px;
    font-size: 13px;
    border-radius: var(--radio);
    margin-bottom: 16px;
}
.login-foot {
    text-align: center;
    margin-top: 22px;
    font-size: 12px;
    color: var(--texto-soft);
}

/* -------------------------- Panel: layout general -------------------------- */

.nav-panel {
    padding: 14px 32px;
    background: #fff;
}
.nav-panel .ejercicio {
    font-size: 12px;
    color: var(--texto-soft);
}
.nav-panel .ejercicio strong {
    color: var(--tinta);
    font-weight: 500;
}

.panel-shell {
    max-width: 1100px;
    margin: 0 auto;
    padding: 36px 32px 60px;
}
.panel-shell.wide { max-width: 1180px; }

.panel-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.panel-header h1 {
    font-size: 30px;
    font-weight: 400;
}

/* Selectores año/mes */
.year-selector { display: flex; gap: 4px; }
.year-pill {
    padding: 7px 14px;
    border: 0.5px solid var(--linea);
    border-radius: var(--radio);
    font-size: 13px;
    color: var(--texto-soft);
    background: #fff;
}
.year-pill.active {
    background: var(--tinta);
    color: var(--crema);
    border-color: var(--tinta);
}
.year-pill:hover { text-decoration: none; }

.month-selector select {
    padding: 9px 14px;
    border: 0.5px solid var(--linea);
    border-radius: var(--radio);
    background: #fff;
    color: var(--texto);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='none' stroke='%231a3a3a' stroke-width='1.2' d='M1 1l4 4 4-4'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 30px;
}

/* -------------------------- KPIs -------------------------- */

.kpis-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}
.kpi-card {
    background: #fff;
    border: 0.5px solid var(--linea);
    border-radius: var(--radio);
    padding: 16px 18px;
}
.kpi-label {
    font-size: 11px;
    color: var(--acento);
    letter-spacing: 1.2px;
    text-transform: uppercase;
    margin: 0 0 8px;
}
.kpi-value {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 24px;
    color: var(--tinta);
    margin: 0;
    font-weight: 400;
    letter-spacing: -0.3px;
}
.kpi-foot {
    font-size: 11px;
    color: var(--texto-soft);
    margin: 6px 0 0;
}

.text-positivo { color: var(--positivo); }
.text-negativo { color: var(--negativo); }
.text-aviso    { color: var(--aviso); }

/* -------------------------- Vista general (overview) -------------------------- */

.negocios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
}
.negocio-card {
    display: block;
    background: #fff;
    border: 0.5px solid var(--linea);
    border-radius: 6px;
    padding: 20px 22px;
    color: var(--texto);
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.negocio-card:hover {
    border-color: var(--tinta);
    text-decoration: none;
    transform: translateY(-1px);
}
.negocio-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    gap: 10px;
}
.negocio-card-head h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 400;
}
.negocio-sector {
    font-size: 10px;
    color: var(--acento);
    letter-spacing: 1.2px;
    text-transform: uppercase;
    text-align: right;
    line-height: 1.4;
    flex-shrink: 0;
    max-width: 110px;
}
.negocio-margen-block {
    padding: 12px 0;
    border-top: 0.5px solid var(--linea);
    border-bottom: 0.5px solid var(--linea);
    margin-bottom: 12px;
}
.negocio-margen-label {
    font-size: 11px;
    color: var(--texto-soft);
    margin: 0 0 4px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.negocio-margen-value {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 22px;
    margin: 0;
    font-weight: 500;
}
.negocio-mini-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
}
.mini-label {
    display: block;
    font-size: 10px;
    color: var(--texto-soft);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 2px;
}
.mini-value {
    font-size: 14px;
    color: var(--texto);
    font-weight: 500;
}
.negocio-card-link {
    display: block;
    font-size: 12px;
    color: var(--tinta);
    margin-top: 4px;
}

/* -------------------------- Vista negocio (detalle) -------------------------- */

.panel-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    max-width: 1180px;
    margin: 0 auto;
    min-height: calc(100vh - 60px);
}
.sidebar {
    background: var(--crema-2);
    border-right: 0.5px solid var(--linea);
    padding: 14px 0;
}
.sidebar-link {
    display: block;
    padding: 9px 18px;
    font-size: 13px;
    color: var(--texto-soft);
    border-left: 2px solid transparent;
}
.sidebar-link:hover { background: rgba(26, 58, 58, 0.04); text-decoration: none; }
.sidebar-link.active {
    background: #fff;
    color: var(--tinta);
    border-left-color: var(--tinta);
    font-weight: 500;
}
.panel-main {
    padding: 32px 36px 60px;
}

/* Charts */
.charts-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 14px;
    margin-bottom: 22px;
}
.chart-card {
    background: #fff;
    border: 0.5px solid var(--linea);
    border-radius: var(--radio);
    padding: 18px 20px;
}
.chart-title {
    font-size: 11px;
    color: var(--acento);
    letter-spacing: 1.2px;
    text-transform: uppercase;
    margin: 0 0 16px;
}

/* Categorías como barras */
.cat-list { display: flex; flex-direction: column; gap: 12px; }
.cat-row-head {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 12px;
}
.cat-name { color: var(--texto); }
.cat-amount { color: var(--texto-soft); font-family: 'Inter', monospace; font-size: 11px; }
.cat-bar {
    height: 4px;
    background: var(--crema-2);
    border-radius: 2px;
    overflow: hidden;
}
.cat-bar-fill {
    height: 100%;
    background: var(--tinta);
    border-radius: 2px;
}

/* Movimientos */
.movs-card {
    background: #fff;
    border: 0.5px solid var(--linea);
    border-radius: var(--radio);
    padding: 18px 20px;
}
.movs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.movs-table th {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 0.5px solid var(--linea);
    font-size: 11px;
    color: var(--acento);
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 500;
}
.movs-table th.right { text-align: right; }
.movs-table td {
    padding: 9px 10px;
    border-bottom: 0.5px solid #f0eee7;
}
.movs-table tr:last-child td { border-bottom: 0; }
.movs-table td.right { text-align: right; }
.movs-table td.mono { font-variant-numeric: tabular-nums; }

.cat-pill {
    display: inline-block;
    background: var(--crema-2);
    color: var(--tinta);
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    letter-spacing: 0.2px;
}

/* -------------------------- Panel placeholder (sin datos) -------------------------- */

.panel-card {
    background: #fff;
    border: 0.5px solid var(--linea);
    padding: 32px;
    border-radius: 6px;
    margin-top: 18px;
}
.panel-card ul {
    margin: 12px 0 0 0;
    padding-left: 20px;
    color: var(--texto-soft);
}
.panel-card li { padding: 4px 0; }

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--crema-2);
    border-radius: 999px;
    font-size: 12px;
    color: var(--tinta);
}

/* -------------------------- Responsive -------------------------- */

@media (max-width: 720px) {
    .nav { padding: 16px 20px; flex-wrap: wrap; gap: 12px; }
    .nav-links { gap: 14px; font-size: 13px; flex-wrap: wrap; }
    .hero { padding: 56px 20px 48px; }
    .hero h1 { font-size: 32px; }
    .section { padding: 40px 20px; }
    .services-grid { grid-template-columns: 1fr; }
    .quote { padding: 40px 20px; }
    .quote blockquote { font-size: 18px; }
    .footer { padding: 18px 20px; flex-direction: column; gap: 8px; text-align: center; }

    .panel-shell { padding: 24px 16px 40px; }
    .panel-header h1 { font-size: 22px; }
    .panel-layout { grid-template-columns: 1fr; }
    .sidebar {
        border-right: none;
        border-bottom: 0.5px solid var(--linea);
        padding: 8px 4px;
        display: flex;
        overflow-x: auto;
        gap: 2px;
    }
    .sidebar-link {
        white-space: nowrap;
        padding: 8px 14px;
        border-left: none;
        border-bottom: 2px solid transparent;
    }
    .sidebar-link.active {
        background: transparent;
        border-bottom-color: var(--tinta);
    }
    .panel-main { padding: 24px 16px 40px; }
    .charts-row { grid-template-columns: 1fr; }
}

/* -------------------------- Admin -------------------------- */

.nav-admin {
    background: linear-gradient(180deg, #fff 0%, #f8f6ee 100%);
    border-bottom-color: var(--linea);
}
.nav-link-soft {
    font-size: 13px;
    color: var(--texto-soft);
}
.user-pill-admin {
    background: rgba(186, 117, 23, 0.10);
    color: var(--aviso);
}

.admin-shell {
    max-width: 880px;
    margin: 0 auto;
    padding: 36px 32px 60px;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin: 24px 0 28px;
}
.admin-stat {
    background: var(--crema-2);
    border-radius: var(--radio);
    padding: 14px 18px;
}
.admin-stat-value {
    display: block;
    font-family: 'Fraunces', Georgia, serif;
    font-size: 22px;
    color: var(--tinta);
}
.admin-stat-label {
    font-size: 11px;
    color: var(--texto-soft);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Dropzone */
.dropzone {
    background: #fff;
    border: 1.5px dashed var(--linea);
    border-radius: 8px;
    padding: 48px 32px;
    text-align: center;
    transition: border-color 0.15s ease, background 0.15s ease;
    cursor: default;
}
.dropzone.drag-over {
    border-color: var(--tinta);
    background: var(--crema);
}
.dropzone-inner svg { color: var(--tinta); margin-bottom: 16px; opacity: 0.7; }
.dropzone-title {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 18px;
    color: var(--tinta);
    margin: 0 0 8px;
}
.dropzone-subtitle {
    font-size: 12px;
    color: var(--texto-soft);
    margin: 8px 0 14px;
    text-transform: lowercase;
}
.dropzone-hint {
    font-size: 11px;
    color: var(--texto-soft);
    margin: 18px 0 0;
}

/* Estado tras la subida */
.upload-status {
    margin-top: 18px;
    padding: 16px 20px;
    border-radius: var(--radio);
    font-size: 14px;
    line-height: 1.6;
}
.upload-status.status-loading {
    background: var(--crema-2);
    color: var(--texto-soft);
    border: 0.5px solid var(--linea);
}
.upload-status.status-success {
    background: #eef5e8;
    color: #27500A;
    border: 0.5px solid #c2dba2;
}
.upload-status.status-error {
    background: #fbeceb;
    color: #7a1f15;
    border: 0.5px solid #e6b7b1;
}
.upload-status .btn { padding: 8px 14px; font-size: 12px; }

/* Spinner sencillo */
.spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 1.5px solid var(--linea);
    border-top-color: var(--tinta);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: -2px;
    margin-right: 6px;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Tabla de uploads */
.uploads-card {
    background: #fff;
    border: 0.5px solid var(--linea);
    border-radius: var(--radio);
    overflow: hidden;
}
.uploads-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.uploads-table th {
    text-align: left;
    padding: 10px 16px;
    background: var(--crema-2);
    border-bottom: 0.5px solid var(--linea);
    font-size: 11px;
    color: var(--acento);
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 500;
}
.uploads-table th.right { text-align: right; }
.uploads-table th.center { text-align: center; }
.uploads-table td {
    padding: 10px 16px;
    border-bottom: 0.5px solid #f0eee7;
}
.uploads-table tr:last-child td { border-bottom: 0; }
.uploads-table td.right { text-align: right; }
.uploads-table td.center { text-align: center; }
.uploads-table td.mono { font-variant-numeric: tabular-nums; }
