/* =====================================================================
   Global Exchange — sistema de diseño del back-office
   ---------------------------------------------------------------------
   Enfoque "libro mayor" (ledger-flat): bordes en vez de sombras,
   numeración tabular para cifras e identificadores, un solo acento
   (bronce) reservado para acciones primarias y el teal reservado para
   indicar "esto está activo/seleccionado ahora mismo" (cliente activo,
   ítem de navegación actual). Nada de tarjetas-SaaS genéricas.
   ===================================================================== */

:root {
    --ge-ink: #101826;
    --ge-ink-soft: #1c2740;
    --ge-paper: #EEF1F4;
    --ge-surface: #FFFFFF;
    --ge-border: #DDE2E8;
    --ge-text: #1A2333;
    --ge-text-muted: #5B6478;
    --ge-teal: #0E7C7B;
    --ge-teal-soft: #E4F2F1;
    --ge-brass: #B3812E;
    --ge-brass-dark: #8F6623;
    --ge-brass-soft: #F5ECDA;
    --ge-brick: #A8442C;
    --ge-brick-soft: #F7E4DF;
    --ge-radius: 8px;
    --ge-radius-sm: 5px;
    --sidebar-width: 248px;
    --topbar-height: 68px;
}

html, body {
    height: 100%;
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background-color: var(--ge-paper);
    color: var(--ge-text);
    font-size: 15px;
    line-height: 1.5;
}

h1, h2, h3, h4, h5 {
    font-weight: 650;
    letter-spacing: -0.01em;
    color: var(--ge-ink);
}

a {
    color: var(--ge-teal);
}

/* Cifras, identificadores y montos: numeración tabular para que
   columnas de números alineen entre sí, como en un libro contable. */
.ge-num, table td, .ge-app-shell .badge {
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------
   Estructura de la aplicación (shell): sidebar fija + topbar + main
   --------------------------------------------------------------- */
.ge-app-shell {
    display: flex;
    min-height: 100vh;
}

.ge-sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--ge-ink);
    color: #C9D2E3;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.ge-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.ge-sidebar__brand-mark {
    width: 32px;
    height: 32px;
    border-radius: var(--ge-radius-sm);
    background: var(--ge-brass);
    color: var(--ge-ink);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    flex-shrink: 0;
}

.ge-sidebar__brand-text {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
}
.ge-sidebar__brand-text small {
    display: block;
    font-weight: 400;
    font-size: 11px;
    color: #8894AC;
}

.ge-sidebar__section-label {
    padding: 18px 20px 6px;
    font-size: 11px;
    color: #6E7A93;
    font-weight: 600;
}

.ge-sidebar__nav {
    list-style: none;
    margin: 0;
    padding: 4px 10px;
}

.ge-sidebar__link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: var(--ge-radius-sm);
    color: #C9D2E3;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-left: 3px solid transparent;
    margin-bottom: 2px;
}

.ge-sidebar__link i {
    font-size: 16px;
    width: 18px;
    text-align: center;
    color: #8894AC;
}

.ge-sidebar__link:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.ge-sidebar__link.is-active {
    background: rgba(14, 124, 123, 0.25);
    color: #fff;
    border-left-color: var(--ge-teal);
}

.ge-sidebar__link.is-active i {
    color: #6FD6D4;
}

.ge-sidebar__footer {
    margin-top: auto;
    padding: 16px 20px;
    font-size: 12px;
    color: #6E7A93;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* ---------------------------------------------------------------
   Columna principal: topbar + contenido
   --------------------------------------------------------------- */
.ge-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.ge-topbar {
    height: var(--topbar-height);
    background: var(--ge-surface);
    border-bottom: 1px solid var(--ge-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.ge-topbar__toggle {
    display: none;
    border: 1px solid var(--ge-border);
    background: var(--ge-surface);
    border-radius: var(--ge-radius-sm);
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    color: var(--ge-ink);
}

/* Pastilla de contexto: cliente en cuyo nombre se está operando */
.ge-contexto-cliente {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 8px;
    border-radius: 999px;
    background: var(--ge-teal-soft);
    border: 1px solid #BFE0DF;
    color: var(--ge-teal);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}
.ge-contexto-cliente .ge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ge-teal);
    flex-shrink: 0;
}
.ge-contexto-cliente:hover {
    background: #D9EDEC;
    color: var(--ge-teal);
}

/* Cluster de usuario actual */
.ge-usuario-actual {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--ge-text);
    padding: 4px 8px 4px 4px;
    border-radius: 999px;
}
.ge-usuario-actual:hover {
    background: var(--ge-paper);
}
.ge-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--ge-ink);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}
.ge-usuario-actual__nombre {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.2;
}
.ge-usuario-actual__rol {
    font-size: 11.5px;
    color: var(--ge-text-muted);
    line-height: 1.2;
}

.ge-content {
    padding: 28px 32px 48px;
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
}

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

.ge-page-header h1 {
    font-size: 22px;
    margin: 0 0 4px;
}
.ge-page-header p {
    color: var(--ge-text-muted);
    margin: 0;
    font-size: 14px;
}

/* ---------------------------------------------------------------
   Tarjetas — bordes, no sombras
   --------------------------------------------------------------- */
.ge-card {
    background: var(--ge-surface);
    border: 1px solid var(--ge-border);
    border-radius: var(--ge-radius);
    padding: 22px;
}

.ge-card + .ge-card {
    margin-top: 18px;
}

.ge-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.ge-card__header h2 {
    font-size: 16px;
    margin: 0;
}

/* ---------------------------------------------------------------
   Botones — un solo acento reservado para la acción primaria
   --------------------------------------------------------------- */
.btn-primary, .ge-btn-primary {
    --bs-btn-bg: var(--ge-brass);
    --bs-btn-border-color: var(--ge-brass);
    --bs-btn-hover-bg: var(--ge-brass-dark);
    --bs-btn-hover-border-color: var(--ge-brass-dark);
    --bs-btn-active-bg: var(--ge-brass-dark);
    --bs-btn-active-border-color: var(--ge-brass-dark);
    color: #fff !important;
    font-weight: 600;
}
.btn-secondary {
    --bs-btn-bg: transparent;
    --bs-btn-color: var(--ge-ink);
    --bs-btn-border-color: var(--ge-border);
    --bs-btn-hover-bg: var(--ge-paper);
    --bs-btn-hover-color: var(--ge-ink);
    --bs-btn-hover-border-color: var(--ge-border);
    font-weight: 600;
}
.btn-danger {
    --bs-btn-bg: var(--ge-brick);
    --bs-btn-border-color: var(--ge-brick);
    --bs-btn-hover-bg: #8B3722;
    --bs-btn-hover-border-color: #8B3722;
    font-weight: 600;
}
.btn-outline-secondary, .btn-info {
    font-weight: 600;
}

.btn, .form-control, .form-select {
    border-radius: var(--ge-radius-sm);
}

/* ---------------------------------------------------------------
   Tablas — estilo libro mayor: borde inferior grueso en encabezado,
   sin fondos de cebra saturados
   --------------------------------------------------------------- */
.ge-card table, table.table {
    margin-bottom: 0;
}
.ge-card table th, table.table th {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ge-text-muted);
    border-bottom: 2px solid var(--ge-ink) !important;
    background: transparent !important;
    padding: 10px 12px;
    white-space: nowrap;
}
.ge-card table td, table.table td {
    padding: 12px;
    vertical-align: middle;
    border-bottom: 1px solid var(--ge-border);
    font-size: 14px;
}
.fila-inactiva {
    color: var(--ge-text-muted);
    background: #FAFAF9;
}

/* ---------------------------------------------------------------
   Badges de estado / segmento / rol
   --------------------------------------------------------------- */
.badge-segmento {
    display: inline-block;
    padding: 3px 9px;
    background: var(--ge-paper);
    color: var(--ge-text-muted);
    border: 1px solid var(--ge-border);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge-activo {
    display: inline-block;
    padding: 3px 9px;
    background: var(--ge-teal-soft);
    color: var(--ge-teal);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.ge-form-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.ge-form-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ge-form-control {
    background: var(--ge-surface);
    border: 1px solid var(--ge-border);
    border-radius: var(--ge-radius-sm);
    min-height: 42px;
    padding: 10px 12px;
    color: var(--ge-text);
}

.ge-form-control:focus {
    border-color: var(--ge-teal);
    box-shadow: 0 0 0 0.15rem rgba(14, 124, 123, 0.15);
    outline: none;
}

.ge-result-panel {
    border-left: 3px solid var(--ge-brass);
}

.ge-stat-box {
    background: var(--ge-paper);
    border: 1px solid var(--ge-border);
    border-radius: var(--ge-radius-sm);
    padding: 16px 14px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 6px;
}

.ge-stat-box small {
    color: var(--ge-text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ge-stat-box strong {
    font-size: 1.05rem;
    color: var(--ge-ink);
    word-break: break-word;
}

.ge-stat-box--accent {
    background: var(--ge-brass-soft);
    border-color: rgba(179, 129, 46, 0.35);
}

.ge-note {
    color: var(--ge-text-muted);
    font-size: 13px;
}

.ge-empty-state {
    border: 1px dashed var(--ge-border);
    background: var(--ge-paper);
    border-radius: var(--ge-radius-sm);
    color: var(--ge-text-muted);
    padding: 18px;
}

.operation-summary {
    border-top: 1px solid var(--ge-border);
}

.operation-summary__row {
    display: grid;
    grid-template-columns: minmax(145px, 40%) minmax(0, 1fr);
    align-items: baseline;
    column-gap: 24px;
    padding: 14px 0;
    border-bottom: 1px solid var(--ge-border);
}

.operation-summary__label {
    color: var(--ge-text-muted);
    display: block;
}

.operation-summary__value {
    color: var(--ge-ink);
    display: block;
    font-variant-numeric: tabular-nums;
    text-align: right;
    overflow-wrap: anywhere;
}

.operation-summary__row--total {
    border-bottom: 0;
    padding-bottom: 0;
}

.operation-summary__row--total strong {
    color: var(--ge-brass-dark);
    font-size: 1.35rem;
}

.operation-expiry {
    padding: 10px 12px;
    border: 1px solid rgba(179, 129, 46, 0.35);
    border-radius: var(--ge-radius-sm);
    background: var(--ge-brass-soft);
    color: var(--ge-brass-dark);
    font-size: 13px;
}

@media (max-width: 575.98px) {
    .operation-summary__row {
        grid-template-columns: 1fr;
        row-gap: 4px;
    }

    .operation-summary__value {
        text-align: left;
    }
}
.badge-inactivo {
    display: inline-block;
    padding: 3px 9px;
    background: var(--ge-brick-soft);
    color: var(--ge-brick);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge-usuario {
    display: inline-block;
    padding: 2px 8px;
    background: var(--ge-surface);
    color: var(--ge-text);
    border: 1px solid var(--ge-border);
    border-radius: 5px;
    font-size: 11.5px;
    margin: 1px;
}

/* ---------------------------------------------------------------
   Métodos de pago — superficie operativa y estados claros
   --------------------------------------------------------------- */
.ge-eyebrow {
    display: block;
    color: var(--ge-text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.ge-payment-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px 20px;
}
.ge-payment-summary strong {
    display: block;
    color: var(--ge-ink);
    font-size: 25px;
    line-height: 1.1;
}
.ge-payment-summary__hint {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--ge-text-muted);
    font-size: 13px;
}
.ge-payment-summary__hint i {
    color: var(--ge-teal);
    font-size: 18px;
}
.ge-payment-card {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 20px;
    border-top: 3px solid transparent;
}
.ge-payment-card.is-default {
    border-top-color: var(--ge-teal);
}
.ge-payment-card__topline,
.ge-payment-card__identity,
.ge-payment-card__actions {
    display: flex;
    align-items: center;
}
.ge-payment-card__topline {
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.ge-payment-card__identity {
    gap: 12px;
    min-width: 0;
}
.ge-payment-card__icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: var(--ge-radius-sm);
    background: var(--ge-brass-soft);
    color: var(--ge-brass-dark);
    font-size: 19px;
}
.ge-payment-card h2 {
    overflow: hidden;
    margin: 2px 0 0;
    color: var(--ge-ink);
    font-size: 16px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ge-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}
.ge-status--active {
    background: var(--ge-teal-soft);
    color: var(--ge-teal);
}
.ge-payment-card__details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 22px 0;
    padding: 14px 0;
    border-top: 1px solid var(--ge-border);
    border-bottom: 1px solid var(--ge-border);
}
.ge-payment-card__details div:first-child {
    grid-column: 1 / -1;
}
.ge-payment-card__details span,
.ge-payment-card__details strong {
    display: block;
}
.ge-payment-card__details span {
    margin-bottom: 2px;
    color: var(--ge-text-muted);
    font-size: 11px;
}
.ge-payment-card__details strong {
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ge-payment-card__actions {
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
    margin-top: auto;
    flex-wrap: wrap;
}
.ge-empty-state {
    padding: 42px 24px;
    text-align: center;
}
.ge-empty-state__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    margin-bottom: 14px;
    border-radius: 50%;
    background: var(--ge-teal-soft);
    color: var(--ge-teal);
    font-size: 22px;
}
.ge-empty-state h2,
.ge-confirm-card h2 {
    margin-bottom: 6px;
    font-size: 18px;
}
.ge-empty-state p {
    max-width: 430px;
    margin: 0 auto 20px;
    color: var(--ge-text-muted);
}
.ge-payment-form {
    max-width: 720px;
}
.ge-form-section {
    margin-bottom: 22px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--ge-border);
}
.ge-form-section > .ge-eyebrow {
    margin-bottom: 12px;
    color: var(--ge-teal);
}
.ge-default-option {
    padding: 13px 14px;
    border: 1px solid var(--ge-border);
    border-radius: var(--ge-radius-sm);
    background: var(--ge-paper);
}
.ge-form-actions {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--ge-border);
}
.ge-confirm-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 14px 16px;
    max-width: 680px;
}
.ge-confirm-card__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--ge-brick-soft);
    color: var(--ge-brick);
    font-size: 18px;
}
.ge-confirm-card .ge-form-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Formularios Django renderizados con {{ form.as_p }}: no traen
   clases de Bootstrap propias, así que se estilan por atributo. */
.ge-plain-form p {
    margin-bottom: 14px;
}
.ge-plain-form label {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ge-text);
    margin-bottom: 5px;
}
.ge-plain-form input[type="text"],
.ge-plain-form input[type="email"],
.ge-plain-form input[type="number"],
.ge-plain-form input[type="password"],
.ge-plain-form select,
.ge-plain-form textarea {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--ge-border);
    border-radius: var(--ge-radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--ge-text);
}
.ge-plain-form input:focus,
.ge-plain-form select:focus,
.ge-plain-form textarea:focus {
    outline: none;
    border-color: var(--ge-teal);
    box-shadow: 0 0 0 3px var(--ge-teal-soft);
}
.ge-plain-form ul.errorlist {
    color: var(--ge-brick);
    font-size: 12.5px;
    font-weight: 600;
    list-style: none;
    padding-left: 0;
    margin: 4px 0 0;
}

.contenedor-filtro {
    margin-bottom: 18px;
    padding: 14px 16px;
    background: var(--ge-surface);
    border: 1px solid var(--ge-border);
    border-radius: var(--ge-radius);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.select-segmento {
    padding: 6px 10px;
    border-radius: var(--ge-radius-sm);
    border: 1px solid var(--ge-border);
    background: #fff;
    font-size: 14px;
}

/* ---------------------------------------------------------------
   Landing pública (usuario no autenticado)
   --------------------------------------------------------------- */
.ge-hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.ge-hero__top {
    padding: 22px 32px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ge-ink);
    font-weight: 700;
}
.ge-hero__body {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 32px;
}
.ge-hero__grid {
    max-width: 1080px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 56px;
    align-items: center;
    width: 100%;
}
.ge-hero h1 {
    font-size: 40px;
    line-height: 1.15;
    max-width: 16ch;
    margin-bottom: 16px;
}
.ge-hero p.ge-lead {
    font-size: 16.5px;
    color: var(--ge-text-muted);
    max-width: 46ch;
    margin-bottom: 26px;
}
.ge-ticker {
    background: var(--ge-ink);
    border-radius: 12px;
    padding: 22px;
    color: #C9D2E3;
}
.ge-ticker__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.ge-ticker__row:last-child {
    border-bottom: none;
}
.ge-ticker__par {
    font-weight: 700;
    color: #fff;
    font-size: 14px;
}
.ge-ticker__label {
    font-size: 11.5px;
    color: #8894AC;
}
.ge-ticker__valor {
    font-weight: 700;
    color: #6FD6D4;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 992px) {
    .ge-sidebar { position: fixed; left: 0; z-index: 40; transform: translateX(-100%); transition: transform .18s ease; }
    .ge-sidebar.is-open { transform: translateX(0); box-shadow: 0 0 0 2000px rgba(0,0,0,.35); }
    .ge-topbar__toggle { display: inline-flex; }
    .ge-hero__grid { grid-template-columns: 1fr; }
    .ge-content { padding: 20px; }
}

@media (max-width: 576px) {
    .ge-page-header .btn { width: 100%; }
    .ge-payment-summary { align-items: flex-start; flex-direction: column; }
    .ge-payment-card__topline { flex-direction: column; }
    .ge-payment-card__actions { align-items: stretch; flex-direction: column; }
    .ge-payment-card__actions > div,
    .ge-payment-card__actions form,
    .ge-payment-card__actions button { width: 100%; }
    .ge-payment-card__actions a { flex: 1; }
    .ge-confirm-card { grid-template-columns: 1fr; }
    .ge-confirm-card .ge-form-actions { align-items: stretch; flex-direction: column; }
    .ge-confirm-card .ge-form-actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .ge-sidebar { transition: none; }
}
