/* Shared customer visual system: theme, accessible controls, and no theme flash. */
:root {
    color-scheme: dark;
    --cx-canvas: #07111f;
    --cx-surface: #0f1c2d;
    --cx-surface-raised: #14243a;
    --cx-surface-muted: #0b1727;
    --cx-field: #0a1625;
    --cx-border: #203750;
    --cx-border-strong: #315170;
    --cx-text: #f4f8fc;
    --cx-subtle: #9db0c3;
    --cx-muted: #7a8fa2;
    --cx-brand: #4f8cff;
    --cx-brand-hover: #72a4ff;
    --cx-sidebar: #0a1625;
    --cx-sidebar-muted: #102036;
    --cx-sidebar-text: #f4f8fc;
    --cx-sidebar-subtle: #b9c9da;
    --cx-sidebar-muted-text: #8fa3b8;
    --cx-sidebar-border: rgba(185, 201, 218, .18);
    --cx-sidebar-accent: #8bb8ff;
    --cx-on-brand: #07111f;
    --cx-nav-scrim: rgba(7, 17, 31, .78);
    --cx-nav-border: rgba(157, 176, 195, .16);
    --cx-nav-shadow: 0 18px 70px -40px rgba(0, 0, 0, .88);
    --cx-topbar-scrim: rgba(7, 17, 31, .64);
    --cx-brand-glow: rgba(79, 140, 255, .12);
    --cx-scrollbar-thumb: #1e264f;
    --cx-scrollbar-thumb-hover: #4f8cff;
    --cx-date-picker-invert: .6;
    --cx-scrim: rgba(0, 0, 0, .60);
    --featured-border: var(--cx-border);
    --featured-border-hover: var(--cx-brand);
    --cx-card-shadow: 0 24px 80px -48px rgba(0, 0, 0, .84);
    --cx-focus: 0 0 0 3px rgba(79, 140, 255, .30);
    --cx-info-text: #8bb8ff;
    --cx-info-surface: rgba(79, 140, 255, .12);
    --cx-info-border: rgba(79, 140, 255, .34);
    --cx-success-text: #5eead4;
    --cx-success-surface: rgba(45, 212, 191, .11);
    --cx-success-border: rgba(45, 212, 191, .30);
    --cx-warning-text: #fbbf24;
    --cx-warning-surface: rgba(251, 191, 36, .10);
    --cx-warning-border: rgba(251, 191, 36, .28);
    --cx-danger-text: #fb7185;
    --cx-danger-surface: rgba(251, 113, 133, .10);
    --cx-danger-border: rgba(251, 113, 133, .28);
    --cx-neutral-text: #b4c4d4;
    --cx-neutral-surface: rgba(157, 176, 195, .09);
    --cx-neutral-border: rgba(157, 176, 195, .23);
    --cx-accent-text: #f59e7a;
    --cx-accent-surface: rgba(245, 158, 122, .10);
    --cx-accent-border: rgba(245, 158, 122, .25);
}

/* Theme is selected before first interaction; prevent a saved preference from
   animating every surface through the wrong palette during initial paint. */
html:not([data-theme-ready]) *,
html:not([data-theme-ready]) *::before,
html:not([data-theme-ready]) *::after {
    transition: none !important;
    animation: none !important;
}

html[data-theme="light"] {
    color-scheme: light;
    --cx-canvas: #f3f7fb;
    --cx-surface: #fffdf8;
    --cx-surface-raised: #ffffff;
    --cx-surface-muted: #eaf1f7;
    --cx-field: #f8fbfd;
    --cx-border: #d5e0ea;
    --cx-border-strong: #b9c9d8;
    --cx-text: #10243a;
    --cx-subtle: #50667b;
    --cx-muted: #566b7f;
    --cx-brand: #1b6287;
    --cx-brand-hover: #144c6a;
    --cx-sidebar: #0b1a2d;
    --cx-sidebar-muted: #122843;
    --cx-sidebar-text: #f4f8fc;
    --cx-sidebar-subtle: #b9c9da;
    --cx-sidebar-muted-text: #8fa3b8;
    --cx-sidebar-border: rgba(185, 201, 218, .20);
    --cx-sidebar-accent: #8bb8ff;
    --cx-on-brand: #ffffff;
    --cx-nav-scrim: rgba(255, 253, 248, .88);
    --cx-nav-border: rgba(27, 98, 135, .16);
    --cx-nav-shadow: 0 20px 60px -44px rgba(30, 63, 94, .52);
    --cx-topbar-scrim: rgba(243, 247, 251, .82);
    --cx-brand-glow: rgba(27, 98, 135, .10);
    --cx-scrollbar-thumb: #c7b7a2;
    --cx-scrollbar-thumb-hover: #1b6287;
    --cx-date-picker-invert: 0;
    --cx-scrim: rgba(0, 0, 0, .45);
    --cx-card-shadow: 0 20px 54px -38px rgba(30, 63, 94, .42);
    --cx-focus: 0 0 0 3px rgba(36, 95, 214, .24);
    --cx-info-text: #1b6287;
    --cx-info-surface: rgba(27, 98, 135, .10);
    --cx-info-border: rgba(27, 98, 135, .30);
    --cx-success-text: #146b57;
    --cx-success-surface: rgba(20, 107, 87, .10);
    --cx-success-border: rgba(20, 107, 87, .27);
    --cx-warning-text: #855807;
    --cx-warning-surface: rgba(133, 88, 7, .10);
    --cx-warning-border: rgba(133, 88, 7, .28);
    --cx-danger-text: #a13c48;
    --cx-danger-surface: rgba(161, 60, 72, .09);
    --cx-danger-border: rgba(161, 60, 72, .27);
    --cx-neutral-text: #50667b;
    --cx-neutral-surface: rgba(80, 102, 123, .08);
    --cx-neutral-border: rgba(80, 102, 123, .22);
    --cx-accent-text: #69459a;
    --cx-accent-surface: rgba(105, 69, 154, .09);
    --cx-accent-border: rgba(105, 69, 154, .22);
}

html[data-theme="light"] body {
    background-image:
        radial-gradient(760px 520px at 100% -12%, rgba(27, 98, 135, .10), transparent 66%),
        linear-gradient(145deg, var(--cx-canvas) 0%, var(--cx-surface-muted) 56%, var(--cx-field) 100%);
    background-attachment: fixed;
}

/* All content cards share the same quiet elevation; navigation and small controls stay flat. */
html[data-theme="light"] .cx-fill-surface {
    border-color: var(--cx-border);
    box-shadow: var(--cx-card-shadow);
}

/* Ô inset (card con chọn gói, badge) và input: viền đậm hơn để có ranh giới rõ. */

/* Chỉ CTA và trạng thái đã chọn dùng xanh đậm; phần còn lại để nền trung tính. */

html[data-theme="light"] .accent-brand {
    accent-color: var(--cx-brand);
}

/* Keyboard focus is owned centrally and works in both themes, so page
   stylesheets never restate it. */
:focus-visible {
    outline: 2px solid var(--cx-brand);
    outline-offset: 2px;
}

/* Chế độ Sáng dùng một ngôn ngữ xuyên suốt: thanh điều hướng sáng hơn canvas,
   tab hiện hành mới có nền xanh nhạt để không tạo cảm giác nửa sáng nửa tối. */

/* Third-party platform colours stay on their icons; in the light theme card
   interaction is one calm brand. Higher specificity beats the base rule, so
   no !important is involved. */
html[data-theme="light"] .featured-card {
    border-color: var(--cx-border);
}

html[data-theme="light"] .featured-card:hover,
html[data-theme="light"] .featured-card:focus-within {
    border-color: var(--cx-brand);
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--cx-canvas);
}

::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background: var(--cx-scrollbar-thumb);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--cx-scrollbar-thumb-hover);
}

input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    filter: invert(var(--cx-date-picker-invert));
}

.customer-preferences {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 80;
    font-family: 'Plus Jakarta Sans Variable', sans-serif;
}

.customer-preferences__trigger {
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--cx-border-strong);
    border-radius: 15px;
    background: var(--cx-surface);
    color: var(--cx-text);
    box-shadow: 0 14px 34px rgba(2, 6, 23, .28);
    cursor: pointer;
    transition: transform .18s ease, border-color .18s ease, background-color .18s ease;
}

.customer-preferences__trigger:hover {
    transform: translateY(-2px);
    border-color: var(--cx-brand);
    background: var(--cx-surface-muted);
}

.customer-preferences__trigger:focus-visible,
.customer-preferences__choice:focus-visible {
    outline: none;
    box-shadow: var(--cx-focus);
}

.customer-preferences__panel {
    position: absolute;
    right: 0;
    bottom: 56px;
    width: min(304px, calc(100vw - 32px));
    /* The panel grows downward from a bottom-anchored trigger, so on a short viewport it would
       otherwise run off the top of the screen with no way to reach the hidden controls. */
    max-height: calc(100dvh - 96px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px;
    border: 1px solid var(--cx-border-strong);
    border-radius: 20px;
    background: var(--cx-surface);
    color: var(--cx-text);
    box-shadow: 0 24px 70px rgba(2, 6, 23, .42);
    transform-origin: bottom right;
    animation: customer-preferences-in .18s ease-out;
}

.customer-preferences__panel[hidden] {
    display: none;
}

.customer-preferences__heading {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 14px;
}

.customer-preferences__heading-icon {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 11px;
    background: var(--cx-info-surface);
    color: var(--cx-info-text);
}

.customer-preferences__title {
    display: block;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.2;
}

.customer-preferences__description {
    display: block;
    margin-top: 3px;
    color: var(--cx-muted);
    font-size: 11px;
    line-height: 1.35;
}

.customer-preferences__group + .customer-preferences__group {
    margin-top: 13px;
}

.customer-preferences__label {
    display: block;
    margin: 0 0 7px;
    color: var(--cx-muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .10em;
    text-transform: uppercase;
}

.customer-preferences__choices {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.customer-preferences__choices--locale,
.customer-preferences__choices--currency {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.customer-preferences__choice {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 8px;
    border: 1px solid var(--cx-border);
    border-radius: 11px;
    background: var(--cx-surface-muted);
    color: var(--cx-subtle);
    font-size: 11px;
    font-weight: 750;
    cursor: pointer;
    transition: border-color .16s ease, background-color .16s ease, color .16s ease;
}

.customer-preferences__choice:hover {
    border-color: var(--cx-info-border);
    color: var(--cx-text);
}

.customer-preferences__choice.is-selected {
    border-color: var(--cx-brand);
    background: var(--cx-info-surface);
    color: var(--cx-info-text);
}

@keyframes customer-preferences-in {
    from { opacity: 0; transform: translateY(8px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 640px) {
    .customer-preferences__trigger {
        width: 44px;
        height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-sidebar__links a,
    .customer-preferences__trigger,
    .customer-preferences__choice {
        transition: none;
    }

    .customer-preferences__panel {
        animation: none;
    }
}

/* ════════════════════════════════════════════════════════════════
   APP SHELL — sidebar, topbar and profile chrome shared by every
   signed-in customer page. One owner; pages add content only.
   ════════════════════════════════════════════════════════════════ */

/* Order workspace: a calm three-stage purchasing flow with one clear summary owner. */
.app-page {
    min-height: 100vh;
    background:
        radial-gradient(760px 500px at 92% -10%, var(--cx-brand-glow), transparent 68%),
        var(--cx-canvas);
    color: var(--cx-text);
}

/* The sidebar and the preference panel are permanently dark navy chrome in BOTH themes, so they
   re-declare the dark ramp locally. Every descendant -- including markup injected by JS -- then
   resolves against navy instead of against the light card ramp, which would render navy-on-navy. */
.app-sidebar,
.customer-preferences {
    --cx-text: #f4f8fc;
    --cx-subtle: #b9c9da;
    --cx-muted: #8fa3b8;
    --cx-brand: #8bb8ff;
    --cx-border: var(--cx-sidebar-border);
    --cx-border-strong: rgba(185, 201, 218, .34);
    --cx-surface: var(--cx-sidebar);
    --cx-surface-muted: var(--cx-sidebar-muted);
    --cx-info-text: #8bb8ff;
    --cx-info-surface: rgba(139, 184, 255, .14);
    --cx-info-border: rgba(139, 184, 255, .34);
    --cx-success-text: #5eead4;
    --cx-warning-text: #fbbf24;
    --cx-danger-text: #fb7185;
    --cx-neutral-text: #b4c4d4;
    /* The light-theme focus ring is a dark blue that disappears on navy. */
    --cx-focus: 0 0 0 3px rgba(139, 184, 255, .42);
}

.app-sidebar {
    width: 264px;
    border-right: 1px solid var(--cx-sidebar-border);
    background: var(--cx-sidebar);
    color: var(--cx-sidebar-text);
}

.app-sidebar__brand {
    min-height: 76px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--cx-sidebar-border);
}

.app-brand {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--cx-sidebar-text);
    font-size: 14px;
    font-weight: 900;
    letter-spacing: -.035em;
    white-space: nowrap;
}

.app-brand__mark {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border: 1px solid rgba(79, 140, 255, .38);
    border-radius: 10px;
    background: linear-gradient(145deg, rgba(79, 140, 255, .26), rgba(45, 212, 191, .10));
    color: var(--cx-sidebar-accent);
}

/* These two only exist on small screens. The shell owns that rule itself instead
   of setting display and then relying on a utility class to undo it. */
.app-sidebar__close,
.app-topbar__menu {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--cx-border);
    border-radius: 12px;
    color: var(--cx-subtle);
}

@media (min-width: 768px) {
    .app-sidebar__close,
    .app-topbar__menu {
        display: none;
    }
}

.app-sidebar__nav {
    flex: 1;
    padding: 24px 14px;
    display: grid;
    align-content: start;
    gap: 30px;
    overflow-y: auto;
}

.app-sidebar__label {
    margin: 0 10px 10px;
    color: var(--cx-sidebar-muted-text);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.app-sidebar__links {
    display: grid;
    gap: 3px;
}

.app-sidebar__links a,
.app-sidebar__footer a {
    min-height: 46px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--cx-sidebar-subtle);
    font-size: 12px;
    font-weight: 800;
    transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}

.app-sidebar__links a:hover,
.app-sidebar__footer a:hover {
    background: var(--cx-sidebar-muted);
    color: var(--cx-sidebar-text);
}

.app-sidebar__links a.is-active {
    border-color: var(--cx-info-border);
    background: var(--cx-info-surface);
    color: var(--cx-info-text);
}

.app-sidebar__links i {
    width: 18px;
    color: var(--cx-sidebar-muted-text);
    text-align: center;
}

.app-sidebar__links a.is-active i {
    color: var(--cx-info-text);
}

.app-sidebar__support {
    padding: 17px 12px;
    border: 1px solid var(--cx-sidebar-border);
    border-radius: 16px;
    background: var(--cx-sidebar-muted);
}

.app-sidebar__support .app-sidebar__label {
    margin-inline: 0;
}

.app-sidebar__support a {
    min-width: 0;
    margin-top: 10px;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    column-gap: 8px;
    align-items: center;
    color: var(--cx-subtle);
    font-size: 10px;
}

.app-sidebar__support a i {
    grid-row: span 2;
    color: var(--cx-success-text);
}

.app-sidebar__support a strong {
    overflow: hidden;
    color: var(--cx-text);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-sidebar__footer {
    padding: 14px;
    border-top: 1px solid var(--cx-border);
}

.app-sidebar__footer a {
    color: var(--cx-danger-text);
}

.app-main {
    min-width: 0;
    height: 100vh;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    min-height: 76px;
    padding: 12px clamp(18px, 3vw, 38px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 1px solid var(--cx-border);
    background: var(--cx-topbar-scrim);
    backdrop-filter: blur(18px);
    position: sticky;
    top: 0;
    z-index: 40;
}

.app-topbar__title {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 13px;
}

.app-topbar__eyebrow {
    display: block;
    color: var(--cx-info-text);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.app-topbar h1 {
    margin-top: 4px;
    overflow: hidden;
    color: var(--cx-text);
    font-size: 17px;
    font-weight: 900;
    letter-spacing: -.025em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-profile {
    flex: 0 0 auto;
}

.app-profile__card {
    min-height: 42px;
    padding: 5px 10px 5px 6px;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--cx-border);
    border-radius: 13px;
    background: var(--cx-surface);
}

.app-profile__avatar {
    width: 31px;
    height: 31px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--cx-info-surface);
    color: var(--cx-info-text);
    font-size: 10px;
    font-weight: 900;
}

.app-profile__details {
    min-width: 0;
    display: none;
}

@media (min-width: 640px) {
    .app-profile__details {
        display: block;
    }
}

.app-profile__name {
    overflow: hidden;
    color: var(--cx-text);
    font-size: 11px;
    font-weight: 850;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-profile__role {
    margin-top: 1px;
    color: var(--cx-info-text);
    font-size: 9px;
    font-weight: 900;
}

.app-profile__balance {
    margin-top: 2px;
    color: var(--cx-muted);
    font-size: 9px;
}

/* The only scrolling region on a signed-in page: .app-main is clamped to the viewport so the
   sidebar and topbar stay put while this column scrolls. Pages own their own padding here. */
.app-scroll {
    flex: 1;
    overflow-y: auto;
}

html[data-theme="light"] .app-sidebar__support,
html[data-theme="light"] .order-step-block,
html[data-theme="light"] .order-summary-card,
html[data-theme="light"] .app-profile__card,
html[data-theme="light"] .order-balance-card,
html[data-theme="light"] .order-platform-grid button,
html[data-theme="light"] .order-group-filters button,
html[data-theme="light"] .order-service-option {
    box-shadow: var(--cx-card-shadow);
}

/* Shared entrance motion. Pages bind their own selectors to these. */
@keyframes fade-in {
    from { opacity: 0; transform: scale(.95); }
    to { opacity: 1; transform: scale(1); }
}

.animate-fade-in {
    animation: fade-in .2s ease-out forwards;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ════════════════════════════════════════════════════════════════
   SEMANTIC UTILITIES — the only way markup may reference colour.
   Each one resolves through a token, so both themes follow without
   any !important repaint of Tailwind palette classes.
   ════════════════════════════════════════════════════════════════ */

.cx-text { color: var(--cx-text); }
.cx-text-subtle { color: var(--cx-subtle); }
.cx-text-muted { color: var(--cx-muted); }
.cx-hover-text:hover { color: var(--cx-text); }
.cx-on-brand { color: var(--cx-on-brand); }

.cx-success { color: var(--cx-success-text); }
.cx-warning { color: var(--cx-warning-text); }
.cx-danger { color: var(--cx-danger-text); }
.cx-info { color: var(--cx-info-text); }
.cx-neutral { color: var(--cx-neutral-text); }
.cx-accent { color: var(--cx-accent-text); }

.cx-fill-raised { background-color: var(--cx-surface-raised); }
.cx-fill-muted { background-color: var(--cx-surface-muted); }
.cx-hover-fill:hover { background-color: var(--cx-surface-muted); }
.cx-scrim { background-color: var(--cx-scrim); }

.cx-fill-success { background-color: var(--cx-success-surface); }
.cx-fill-warning { background-color: var(--cx-warning-surface); }
.cx-fill-danger { background-color: var(--cx-danger-surface); }
.cx-fill-info { background-color: var(--cx-info-surface); }
.cx-fill-neutral { background-color: var(--cx-neutral-surface); }
.cx-hover-fill-success:hover { background-color: var(--cx-success-surface); }
.cx-hover-fill-info:hover { background-color: var(--cx-info-surface); }
.cx-hover-fill-brand:hover { background-color: var(--cx-brand-hover); }

.cx-edge { border-color: var(--cx-border); }
.cx-edge-success { border-color: var(--cx-success-border); }
.cx-edge-warning { border-color: var(--cx-warning-border); }
.cx-edge-danger { border-color: var(--cx-danger-border); }
.cx-edge-info { border-color: var(--cx-info-border); }
.cx-edge-neutral { border-color: var(--cx-neutral-border); }

.cx-placeholder::placeholder { color: var(--cx-muted); }

/* The QR tile is deliberately theme-independent: a phone camera needs real
   white behind real black, so these three never follow the theme. */
.cx-qr-surface { background-color: #ffffff; }
.cx-qr-text { color: #000000; }
.cx-qr-edge { border-color: var(--cx-muted); }

/* Surface, brand and edge utilities. These replace the Tailwind config colours
   (dark/panel/border/brand) in markup so both themes resolve from tokens. */
.cx-fill-canvas { background-color: var(--cx-canvas); }
.cx-fill-surface { background-color: var(--cx-surface); }
.cx-fill-field { background-color: var(--cx-field); }
/* A solid brand fill carries its own readable text colour, so callers never
   have to remember a second class. */
.cx-fill-brand {
    background-color: var(--cx-brand);
    color: var(--cx-on-brand);
}
.cx-brand-text { color: var(--cx-brand); }
.cx-hover-edge-brand:hover { border-color: var(--cx-brand); }
.cx-divide > * + * { border-color: var(--cx-border); }
.cx-shadow-brand { box-shadow: 0 18px 42px -26px var(--cx-brand); }
.cx-gradient-brand { background-image: linear-gradient(135deg, var(--cx-info-surface), transparent); }

.cx-focus-edge:focus {
    border-color: var(--cx-brand);
    box-shadow: var(--cx-focus);
    outline: none;
    outline-offset: 0;
}
