:root {
    --incas-dark:     #0D1B2A;
    --incas-panel:    #1B2838;
    --incas-accent:   #2E7D32;
    --incas-accent-2: #43A047;
    --incas-gold:     #C9A227;
    --incas-gold-2:   #E8C547;
    --incas-text:     #E8EDF2;
    --incas-muted:    #8FA3B8;
    --incas-danger:   #E53935;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    width: 100%; height: 100%; overflow: hidden;
    background: transparent !important;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    user-select: none;
}

#cef-app {
    position: fixed; inset: 0; z-index: 2147483000;
    color: var(--incas-text); pointer-events: none;
}

.widget {
    position: fixed;
    right: 24px;
    top: 50%;
    transform: translateY(-50%) translateX(120%);
    width: 306px;
    background: rgba(27, 40, 56, 0.97);
    backdrop-filter: blur(20px);
    border-radius: 24px 12px 24px 24px;
    border: 1px solid rgba(201, 162, 39, 0.25);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), -4px 0 0 0 var(--incas-gold);
    pointer-events: none;
    opacity: 0;
    transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.4s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.widget.visible { transform: translateY(-50%) translateX(0); opacity: 1; }

.widget__head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 18px;
    background: linear-gradient(135deg, #1A237E, var(--incas-dark));
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.widget__logo { font-size: 20px; font-weight: 900; color: var(--incas-gold); letter-spacing: -0.3px; }

.widget__online {
    display: flex; align-items: center; gap: 6px;
    font-size: 10px; font-weight: 800; text-transform: uppercase;
    color: rgba(232, 237, 242, 0.9);
    background: rgba(255,255,255,0.08);
    padding: 5px 11px; border-radius: 20px;
}
.widget__online i {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--incas-accent);
    box-shadow: 0 0 8px rgba(67, 160, 71, 0.6);
    animation: blink 2s infinite;
}
@keyframes blink { 50% { opacity: 0.45; } }

.widget__body { padding: 16px 18px 18px; position: relative; }

.widget__success-screen {
    position: absolute; inset: 0; z-index: 100;
    background: linear-gradient(145deg, var(--incas-accent), #1B5E20);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: #fff; opacity: 0; visibility: hidden; transform: translateY(10%);
    transition: all 0.4s ease; text-align: center;
}
.widget__success-screen.show { opacity: 1; visibility: visible; transform: translateY(0); }
.success-icon-wrap {
    width: 64px; height: 64px; border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center; margin-bottom: 16px;
}
.success-title { font-size: 20px; font-weight: 900; margin-bottom: 8px; }
.success-subtitle { font-size: 22px; font-weight: 900; color: var(--incas-gold-2); }

.widget__profile-row {
    display: flex; justify-content: space-between; align-items: center;
    gap: 10px; margin-bottom: 14px;
}
.widget__player { display: flex; align-items: center; gap: 10px; min-width: 0; }
.widget__player-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.widget__player-meta > span:first-child {
    font-size: 14px; font-weight: 800;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.widget__avatar {
    width: 36px; height: 36px; border-radius: 12px;
    background: rgba(201, 162, 39, 0.15); color: var(--incas-gold);
    font-size: 15px; font-weight: 900;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid rgba(201, 162, 39, 0.3);
}
.widget__city { font-size: 10px; font-weight: 700; color: var(--incas-muted); text-transform: uppercase; }
.widget__stage-badge {
    flex-shrink: 0; font-size: 9px; font-weight: 800; text-transform: uppercase;
    color: var(--incas-gold); background: rgba(201, 162, 39, 0.12);
    border: 1px solid rgba(201, 162, 39, 0.25);
    padding: 5px 8px; border-radius: 999px; max-width: 96px; text-align: center;
}

.widget__route-card {
    background: rgba(13, 27, 42, 0.6);
    border-radius: 16px; padding: 14px; margin-bottom: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.route-item { display: flex; align-items: flex-start; gap: 12px; position: relative; }
.route-item:first-child { margin-bottom: 14px; }
.route-item:first-child::after {
    content: ''; position: absolute; left: 5px; top: 16px;
    width: 2px; height: 22px;
    background: linear-gradient(180deg, rgba(255,255,255,0.1), rgba(201, 162, 39, 0.4));
    border-radius: 2px;
}
.route-dot {
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--incas-muted); margin-top: 2px;
    border: 2px solid var(--incas-panel);
}
.route-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.route-label { font-size: 10px; font-weight: 700; color: var(--incas-muted); text-transform: uppercase; }
.route-value { font-size: 13px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.route-item.active .route-dot { background: var(--incas-gold); box-shadow: 0 0 0 3px rgba(201,162,39,0.25); }
.route-item.active .route-value { color: var(--incas-gold); }

.widget__vault {
    background: rgba(13, 27, 42, 0.5); border-radius: 14px; padding: 12px;
    margin-bottom: 14px; border: 1px solid rgba(201, 162, 39, 0.15);
}
.vault-head {
    display: flex; justify-content: space-between; margin-bottom: 8px;
    font-size: 10px; font-weight: 800; text-transform: uppercase; color: var(--incas-muted);
}
.vault-track {
    height: 14px; border-radius: 999px; background: rgba(0,0,0,0.3);
    overflow: hidden; margin-bottom: 8px;
}
.vault-fill {
    height: 100%; width: 0;
    background: linear-gradient(90deg, #1B5E20, #43A047, var(--incas-gold));
    border-right: 2px solid var(--incas-gold);
    transition: width 0.5s ease;
}
.vault-meta {
    display: flex; justify-content: space-between;
    font-size: 11px; font-weight: 700; color: var(--incas-muted);
}
.vault-meta b { color: var(--incas-gold-2); }

.widget__order {
    background: rgba(46, 125, 50, 0.1);
    border: 1px solid rgba(67, 160, 71, 0.2);
    border-radius: 14px; padding: 12px; margin-bottom: 14px;
}
.widget__order.hidden { display: none; }
.order-head {
    display: flex; justify-content: space-between; margin-bottom: 8px;
    font-size: 11px; font-weight: 800; text-transform: uppercase; color: var(--incas-accent-2);
}
.order-pay { font-size: 14px; color: var(--incas-gold); }
.order-row {
    display: flex; justify-content: space-between;
    font-size: 12px; font-weight: 700; margin-bottom: 8px;
}
.order-bar { height: 8px; border-radius: 999px; background: rgba(0,0,0,0.25); overflow: hidden; }
.order-bar__fill {
    height: 100%; width: 0;
    background: linear-gradient(90deg, var(--incas-accent), var(--incas-gold));
    transition: width 0.45s ease;
}

.widget__progress { margin-bottom: 14px; }
.widget__progress-meta {
    display: flex; justify-content: space-between; margin-bottom: 7px;
    font-size: 10px; font-weight: 800; text-transform: uppercase; color: var(--incas-muted);
}
.widget__progress-track { height: 9px; border-radius: 999px; background: rgba(0,0,0,0.25); overflow: hidden; }
.widget__progress-fill {
    height: 100%; border-radius: 999px;
    background: linear-gradient(90deg, var(--incas-accent), var(--incas-gold));
    transition: width 0.5s ease;
}

.widget__timer {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: 14px; margin-bottom: 14px;
    background: rgba(201, 162, 39, 0.12); border: 1px solid rgba(201, 162, 39, 0.25);
    font-size: 12px; font-weight: 700; color: var(--incas-gold);
}
.widget__timer.hidden { display: none; }
.widget__timer.danger { background: rgba(229,57,53,0.15); border-color: rgba(229,57,53,0.35); color: var(--incas-danger); }
.widget__timer b { font: 800 16px/1 Consolas, monospace; }

.widget__hint {
    font-size: 12px; font-weight: 800; line-height: 1.45;
    padding: 13px 14px; border-radius: 14px; margin-bottom: 12px;
    background: linear-gradient(135deg, rgba(26,35,126,0.5), rgba(13,27,42,0.8));
    border: 1px solid rgba(201, 162, 39, 0.2);
    text-align: center; color: var(--incas-text);
}
.widget__hint.pulse { animation: pulse 1.5s infinite; }
.widget__hint.danger { background: var(--incas-danger); color: #fff; border-color: transparent; }
@keyframes pulse {
    50% { box-shadow: 0 0 0 8px rgba(201, 162, 39, 0); }
}

.widget__btn {
    width: 100%; border: none; border-radius: 14px;
    padding: 12px; font-size: 12px; font-weight: 800; cursor: pointer;
    background: linear-gradient(135deg, var(--incas-gold), #A67C00);
    color: var(--incas-dark); box-shadow: 0 6px 16px rgba(201, 162, 39, 0.3);
}
.widget__btn:disabled { opacity: 0.45; }
.widget__btn.hidden { display: none; }
.widget__btn--ghost {
    background: transparent; color: var(--incas-text);
    border: 1px solid rgba(255,255,255,0.15); box-shadow: none;
}

.hidden { display: none !important; }

.modal {
    position: fixed; inset: 0; z-index: 2147483100;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none; opacity: 0; transition: opacity 0.25s ease;
}
.modal.open { pointer-events: auto; opacity: 1; }
.modal.hidden { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.modal__panel {
    position: relative; width: 380px; max-height: 70vh;
    background: var(--incas-panel); border-radius: 20px 10px 20px 20px;
    border: 1px solid rgba(201, 162, 39, 0.2);
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
    display: flex; flex-direction: column; overflow: hidden;
    transform: translateY(12px); transition: transform 0.25s ease;
    color: var(--incas-text);
}
.modal.open .modal__panel { transform: translateY(0); }
.modal__panel--sm { width: 340px; }
.modal__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px;
    background: linear-gradient(135deg, #1A237E, var(--incas-dark));
}
.modal__head h2 { font-size: 16px; font-weight: 900; color: var(--incas-gold); }
.modal__close { border: none; background: transparent; font-size: 24px; cursor: pointer; color: var(--incas-muted); }
.orders-list { padding: 10px; overflow-y: auto; max-height: 340px; display: flex; flex-direction: column; gap: 8px; }
.order-card {
    border: 1px solid rgba(255,255,255,0.08); border-radius: 14px;
    padding: 12px 14px; cursor: pointer;
}
.order-card:hover { border-color: rgba(201,162,39,0.4); background: rgba(26,35,126,0.2); }
.order-card__top { display: flex; justify-content: space-between; margin-bottom: 6px; }
.order-card__name { font-size: 14px; font-weight: 900; }
.order-card__pay { font-size: 14px; font-weight: 900; color: var(--incas-gold); }
.order-card__meta { font-size: 11px; font-weight: 700; color: var(--incas-muted); }
.modal__foot { padding: 12px 18px; border-top: 1px solid rgba(255,255,255,0.06); }
.modal__hint { font-size: 11px; color: var(--incas-muted); }
.sign-body { padding: 16px 18px; font-size: 13px; line-height: 1.5; }
.sign-pay { margin-top: 12px; font-size: 14px; font-weight: 700; }
.sign-pay b { color: var(--incas-gold); font-size: 18px; }
.modal__actions { display: flex; gap: 8px; padding: 0 18px 16px; }
.modal__actions .widget__btn { flex: 1; }
