:root {
    --verde: #0f7a4f;
    --verde-oscuro: #075642;
    --verde-profundo: #064439;

    --cafe: #351f18;
    --cafe-oscuro: #24130f;
    --cafe-suave: #f3ebe4;

    --rojo: #9b1235;
    --rojo-vivo: #c92332;
    --rojo-suave: #fff0f3;

    --dorado: #dfa83a;
    --amarillo: #f3c94d;
    --dorado-suave: #fff4ce;

    --crema: #fff8ec;
    --fondo: #eef5f2;
    --azucar: #ffffff;
    --texto: #182d2a;
    --muted: #5f746e;
    --borde: #d6e4de;
    --shadow: 0 14px 34px rgba(17, 58, 48, .08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top right, rgba(223,168,58,.13), transparent 28%),
        linear-gradient(135deg, #f8fbf9 0%, #eef5f2 62%, #ffffff 100%);
    color: var(--texto);
}

a { color: inherit; text-decoration: none; }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 286px 1fr;
}

/* SIDEBAR */
.sidebar {
    background:
        radial-gradient(circle at 10% 0%, rgba(243,201,77,.18), transparent 22%),
        linear-gradient(180deg, #128057 0%, #0b6047 42%, #351f18 100%);
    color: #fff;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(255,255,255,.13);
    margin-bottom: 16px;
}

.brand-line {
    display: flex;
    align-items: center;
    gap: 13px;
}

.brand-mark {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--amarillo), var(--dorado));
    color: var(--cafe);
    display: grid;
    place-items: center;
    font-weight: 950;
    box-shadow: 0 14px 26px rgba(36,19,15,.20);
}

.brand-title {
    color: #fff;
    font-weight: 950;
    text-transform: uppercase;
    letter-spacing: .035em;
    font-size: 18px;
    line-height: 1.05;
}

.brand-subtitle {
    margin-top: 5px;
    color: rgba(255,255,255,.72);
    font-size: 13px;
    line-height: 1.35;
}

.brand-context {
    min-height: 46px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,.18);
    background: rgba(255,255,255,.10);
    color: #fff;
    font-weight: 950;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    margin-bottom: 18px;
}

.brand-context::after {
    content: '›';
    font-size: 24px;
    color: var(--amarillo);
}

.nav {
    display: grid;
    gap: 5px;
}

.nav-section {
    margin: 16px 0 5px;
    color: rgba(255,255,255,.70);
    font-size: 11px;
    font-weight: 950;
    text-transform: uppercase;
    letter-spacing: .17em;
}

.nav a,
.logout-button {
    width: 100%;
    min-height: 40px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: rgba(255,255,255,.86);
    display: flex;
    align-items: center;
    padding: 0 13px;
    font-weight: 850;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
}

.nav a.active,
.nav a:hover,
.logout-button:hover {
    background: rgba(255,255,255,.14);
    color: #fff;
}

.nav a.active {
    box-shadow: inset 4px 0 0 var(--amarillo);
}

.logout-button {
    margin-top: 8px;
    color: #ffe1e1;
}

/* MAIN */
.main {
    padding: 30px 34px;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}

.page-kicker {
    color: var(--rojo);
    text-transform: uppercase;
    letter-spacing: .14em;
    font-weight: 950;
    font-size: 12px;
    margin-bottom: 8px;
}

.page-title {
    margin: 0;
    color: #083440;
    font-size: clamp(36px, 4vw, 50px);
    line-height: 1.02;
    letter-spacing: -.045em;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-filter,
.user-pill {
    background: #fff;
    border: 1px solid var(--borde);
    border-radius: 999px;
    padding: 11px 16px;
    color: #0b3151;
    font-weight: 900;
    white-space: nowrap;
    box-shadow: 0 8px 20px rgba(17, 58, 48, .06);
}

.brand-filter::before {
    content: '•';
    color: var(--verde);
    margin-right: 8px;
}

/* BRAND SWITCHER */
.brand-switcher {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.brand-chip {
    min-height: 74px;
    border-radius: 18px;
    padding: 14px 16px;
    border: 1px solid var(--borde);
    background: #fff;
    box-shadow: 0 10px 26px rgba(17, 58, 48, .06);
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-left-width: 7px;
}

.brand-chip strong {
    display: block;
    font-size: 16px;
    color: var(--texto);
    line-height: 1.1;
}

.brand-chip span {
    margin-top: 5px;
    font-size: 13px;
    color: var(--muted);
    font-weight: 700;
}

.brand-chip-green { border-left-color: var(--verde); }
.brand-chip-red { border-left-color: var(--rojo); }
.brand-chip-coffee { border-left-color: var(--cafe); }
.brand-chip-gold { border-left-color: var(--dorado); }

/* MODULE CARDS */
.module-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.module-card {
    position: relative;
    min-height: 104px;
    background: #fff;
    border: 1px solid #cfe0da;
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 17px 16px;
    display: grid;
    grid-template-columns: 52px 1fr 30px;
    align-items: center;
    gap: 13px;
    overflow: hidden;
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.module-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 18px;
    bottom: 18px;
    width: 5px;
    border-radius: 0 999px 999px 0;
    background: var(--verde);
}

.module-card::after {
    content: '';
    position: absolute;
    width: 72px;
    height: 72px;
    right: -26px;
    bottom: -28px;
    border-radius: 999px;
    opacity: .16;
    background: var(--verde);
}

.module-card:hover {
    transform: translateY(-2px);
    border-color: rgba(15,122,79,.34);
    box-shadow: 0 18px 42px rgba(17, 58, 48, .12);
}

.module-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    border: 1px solid #d6e4de;
    background: #f7fbf9;
    color: var(--verde-oscuro);
    display: grid;
    place-items: center;
    font-weight: 950;
    font-size: 18px;
}

.module-body h3 {
    margin: 0 0 4px;
    color: #062f3e;
    font-size: 20px;
    line-height: 1.08;
    letter-spacing: -.02em;
}

.module-body p {
    margin: 0;
    color: #526e80;
    font-size: 14px;
    line-height: 1.28;
}

.module-arrow {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: #f0f7f4;
    color: var(--verde-oscuro);
    display: grid;
    place-items: center;
    font-size: 24px;
    font-weight: 950;
    z-index: 1;
}

.module-card.tone-green::before,
.module-card.tone-green::after { background: var(--verde); }
.module-card.tone-green .module-icon,
.module-card.tone-green .module-arrow {
    color: var(--verde-oscuro);
    background: #f0f8f4;
}

.module-card.tone-red::before,
.module-card.tone-red::after { background: var(--rojo); }
.module-card.tone-red .module-icon,
.module-card.tone-red .module-arrow {
    color: var(--rojo);
    background: var(--rojo-suave);
}

.module-card.tone-gold::before,
.module-card.tone-gold::after { background: var(--dorado); }
.module-card.tone-gold .module-icon,
.module-card.tone-gold .module-arrow {
    color: var(--cafe);
    background: var(--dorado-suave);
}

.module-card.tone-coffee::before,
.module-card.tone-coffee::after { background: var(--cafe); }
.module-card.tone-coffee .module-icon,
.module-card.tone-coffee .module-arrow {
    color: var(--cafe);
    background: var(--cafe-suave);
}

/* BASE CARDS */
.card {
    background: #fff;
    border: 1px solid #cfe0da;
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 22px;
}

.compact-card {
    max-width: 980px;
}

.card-title {
    margin: 0 0 16px;
    color: #062f3e;
    font-size: 24px;
    line-height: 1.1;
}

.feature-list {
    display: grid;
    gap: 12px;
}

.feature-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    border: 1px solid #d6e4de;
    border-radius: 16px;
    background: #f9fcfb;
    padding: 14px;
}

.feature-item span {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: var(--verde);
    box-shadow: 0 0 0 5px rgba(15,122,79,.11);
    margin-top: 5px;
    flex: 0 0 auto;
}

.feature-item p {
    margin: 0;
    color: var(--texto);
    line-height: 1.45;
    font-weight: 700;
}

.grid {
    display: grid;
    gap: 16px;
}

.kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
}

.kpi-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 850;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 32px;
    line-height: 1;
    color: var(--cafe);
    font-weight: 950;
}

.brand-list {
    display: grid;
    gap: 12px;
}

.brand-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border: 1px solid #d6e4de;
    border-radius: 16px;
    padding: 15px;
    background: #fffaf0;
}

.brand-row strong {
    display: block;
    color: var(--cafe);
    margin-bottom: 3px;
}

.brand-row span {
    color: var(--muted);
    font-size: 14px;
}

.badge {
    border-radius: 999px;
    padding: 7px 10px;
    background: #faedc9;
    color: var(--cafe);
    font-size: 11px;
    font-weight: 950;
    text-transform: uppercase;
    letter-spacing: .06em;
    white-space: nowrap;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th, td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid #d6e4de;
}

th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
}

td {
    color: var(--texto);
    font-weight: 650;
}

/* LOGIN */
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(460px, 100%);
    background: rgba(255,255,255,.96);
    border: 1px solid var(--borde);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 30px;
}

.auth-card .brand-title { color: var(--cafe); }
.auth-card .brand-subtitle { color: var(--muted); }

.auth-card h1 {
    font-size: 32px;
    line-height: 1.05;
    margin: 24px 0 8px;
    color: var(--cafe);
}

.auth-card p {
    color: var(--muted);
    margin: 0 0 24px;
    line-height: 1.55;
}

.form-group { margin-bottom: 16px; }

label {
    display: block;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 7px;
    color: var(--cafe);
}

input {
    width: 100%;
    height: 48px;
    border: 1px solid rgba(53,31,24,.20);
    border-radius: 14px;
    padding: 0 14px;
    font-size: 15px;
    outline: none;
    background: #fff;
}

input:focus {
    border-color: var(--dorado);
    box-shadow: 0 0 0 4px rgba(223,168,58,.18);
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    margin: 16px 0 20px;
}

.check-row input {
    width: 16px;
    height: 16px;
}

.btn {
    border: 0;
    border-radius: 999px;
    height: 48px;
    padding: 0 20px;
    font-weight: 950;
    letter-spacing: .05em;
    text-transform: uppercase;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--amarillo), var(--dorado));
    color: var(--cafe);
    width: 100%;
}

.error-box {
    background: #fff0f3;
    border: 1px solid rgba(155,18,53,.18);
    color: var(--rojo);
    border-radius: 16px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-weight: 800;
    font-size: 14px;
}

@media (max-width: 1380px) {
    .module-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .brand-switcher {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: relative;
        height: auto;
    }

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

    .module-grid,
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .main {
        padding: 24px 18px;
    }
}

@media (max-width: 640px) {
    .nav,
    .module-grid,
    .kpi-grid,
    .brand-switcher {
        grid-template-columns: 1fr;
    }

    .topbar,
    .top-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .module-card {
        grid-template-columns: 46px 1fr 28px;
        min-height: 96px;
        padding: 15px;
    }

    .module-body h3 {
        font-size: 18px;
    }

    .module-body p {
        font-size: 13px;
    }

    .page-title {
        font-size: 36px;
    }
}

.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.filters-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 1;
}

.filters-form input,
.filters-form select,
.app-form input,
.app-form select,
.app-form textarea {
    width: 100%;
    border: 1px solid #cfe0da;
    border-radius: 13px;
    background: #fff;
    color: var(--texto);
    font: inherit;
    outline: none;
}

.filters-form input,
.filters-form select,
.app-form input,
.app-form select {
    min-height: 42px;
    padding: 0 13px;
}

.app-form textarea {
    padding: 13px;
    resize: vertical;
}

.filters-form input:focus,
.filters-form select:focus,
.app-form input:focus,
.app-form select:focus,
.app-form textarea:focus {
    border-color: var(--dorado);
    box-shadow: 0 0 0 4px rgba(223,168,58,.16);
}

.btn-mini {
    min-height: 42px;
    padding: 0 15px;
    border-radius: 999px;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 950;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-primary-mini {
    background: var(--verde);
    color: #fff;
}

.btn-gold {
    background: var(--dorado);
    color: var(--cafe);
}

.btn-light {
    background: #fff;
    color: var(--cafe);
    border-color: #d6e4de;
}

.success-box {
    margin-bottom: 14px;
    border: 1px solid rgba(15,122,79,.18);
    background: #ecf8f1;
    color: var(--verde-oscuro);
    padding: 13px 15px;
    border-radius: 15px;
    font-weight: 800;
}

.section-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.count-pill {
    border-radius: 999px;
    background: var(--dorado-suave);
    color: var(--cafe);
    padding: 8px 12px;
    font-weight: 950;
    font-size: 13px;
}

.muted {
    color: var(--muted);
    font-weight: 650;
}

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

.action-link {
    border-radius: 999px;
    min-height: 32px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    font-weight: 950;
}

.action-link.green {
    background: #ecf8f1;
    color: var(--verde-oscuro);
}

.action-link.gold {
    background: var(--dorado-suave);
    color: var(--cafe);
}

.form-card {
    max-width: 1080px;
}

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

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.pagination-wrap {
    margin-top: 14px;
}

.pagination-wrap nav > div:first-child {
    display: none;
}

.pagination-wrap nav span,
.pagination-wrap nav a {
    display: inline-flex;
    min-width: 36px;
    min-height: 36px;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    border: 1px solid #d6e4de;
    background: #fff;
    color: var(--cafe);
    font-weight: 800;
}

@media (max-width: 860px) {
    .action-bar,
    .filters-form,
    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

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

.strong-link {
    color: var(--verde-oscuro);
    font-weight: 950;
}

.action-link.coffee {
    background: var(--cafe-suave);
    color: var(--cafe);
}

.form-section-title {
    margin: 22px 0 12px;
    color: var(--cafe);
    font-size: 15px;
    font-weight: 950;
    text-transform: uppercase;
    letter-spacing: .10em;
}

.form-section-title:first-of-type {
    margin-top: 0;
}

.form-group small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-weight: 700;
}

.form-wide {
    grid-column: 1 / -1;
}

.customer-profile-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr);
    gap: 16px;
    margin-bottom: 16px;
}

.detail-list {
    display: grid;
    gap: 12px;
}

.detail-list div {
    border: 1px solid #d6e4de;
    background: #f9fcfb;
    border-radius: 15px;
    padding: 13px 14px;
}

.detail-list span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 5px;
}

.detail-list strong {
    color: var(--texto);
    font-size: 15px;
}

.profile-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.empty-state {
    border: 1px dashed #cfe0da;
    background: #f9fcfb;
    border-radius: 16px;
    padding: 18px;
    color: var(--muted);
    font-weight: 750;
}

.notes-text {
    color: var(--texto);
    line-height: 1.6;
    margin: 0;
}

@media (max-width: 980px) {
    .customer-profile-grid {
        grid-template-columns: 1fr;
    }
}
