/* ============================================================
   WeTrade account UI standard
   One shared layer for profile, admin dashboard and business
   dashboard: data tables, stat tiles, cards, forms, spacing.
   Scoped to body.wt-acct so it never leaks into store pages.
   ============================================================ */

.wt-acct {
    --ui-text: #0f172a;
    --ui-body: #334155;
    --ui-muted: #64748b;
    --ui-faint: #94a3b8;
    --ui-border: #e6e9ef;
    --ui-border-soft: #f1f3f6;
    --ui-head: #f8fafc;
    --ui-hover: #fafbfc;
    --ui-surface: #fff;
    --ui-accent: #F47A20;
    --ui-accent-dark: #D2620F;
    --ui-danger: #dc2626;
    --ui-radius: 12px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ============================================================
   1. DATA TABLES — desktop / tablet
   ============================================================ */
.wt-acct .wt-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    line-height: 1.4;
    color: var(--ui-body);
    font-variant-numeric: tabular-nums;
}
.wt-acct .wt-table thead th {
    padding: 9px 14px !important;
    font-size: 11px !important;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--ui-muted);
    background: var(--ui-head);
    border-bottom: 1px solid var(--ui-border);
    white-space: nowrap;
    vertical-align: middle;
    position: sticky;
    top: 0;
    z-index: 2;
}
.wt-acct .wt-table tbody td {
    padding: 10px 14px !important;
    font-size: 13px;
    border-bottom: 1px solid var(--ui-border-soft);
    vertical-align: middle;
    color: var(--ui-body);
}
.wt-acct .wt-table th.text-right { text-align: right; }
.wt-acct .wt-table th.text-center { text-align: center; }
.wt-acct .wt-table tbody tr:last-child td { border-bottom: none; }
.wt-acct .wt-table tbody tr:hover td { background: var(--ui-hover); }
.wt-acct .wt-table .wt-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--ui-body);
    white-space: nowrap;
}
.wt-acct .wt-table .wt-nowrap { white-space: nowrap; }
.wt-acct .wt-table .wt-strong { font-weight: 600; color: var(--ui-text); }
.wt-acct .wt-table .wt-cap { text-transform: capitalize; }
.wt-acct .wt-table .wt-muted { color: var(--ui-muted); }
.wt-acct .wt-clip {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wt-acct .wt-row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: nowrap;
}

/* Scroll containers: tables scroll inside their card, never the page */
.wt-acct .wt-table-wrap,
.wt-acct .tbl-wrap,
.wt-acct .scroll-x {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

@media (min-width: 1024px) {
    /* Flexible text column: takes the spare width and truncates */
    .wt-acct .wt-table td.wt-clip-cell {
        width: 36%;
        min-width: 180px;
        max-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .wt-acct .wt-table td.wt-clip-cell .wt-clip { max-width: 100%; }
}

/* Empty state inside a table */
.wt-acct .wt-empty {
    padding: 28px 16px;
    text-align: center;
    color: var(--ui-faint);
    font-size: 13px;
}
.wt-acct .wt-empty i {
    display: block;
    font-size: 22px;
    margin-bottom: 8px;
    color: #cbd5e1;
}

/* ============================================================
   2. DATA TABLES — phones and tablets: each row is a compact
   record card; cards flow into as many columns as fit.
   Cells are classified by js/account-ui.js:
     .wt-c-primary  headline cell, full width, first
     .wt-c-actions  button row, full width, last
     .wt-c-check    row checkbox, pinned top-right
     .wt-c-index    running number, hidden
     .wt-r-span     row holding one full-width (colspan) cell
   ============================================================ */
@media (max-width: 1023.98px) {
    .wt-acct .wt-table-wrap,
    .wt-acct .tbl-wrap,
    .wt-acct .scroll-x,
    .wt-acct .overflow-x-auto:has(> .wt-table) { overflow-x: visible !important; }

    .wt-acct .wt-table {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
    }
    .wt-acct .wt-table thead { display: none; }
    .wt-acct .wt-table tbody {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
        gap: 8px;
        width: 100%;
        padding: 10px;
    }
    .wt-acct .wt-table tbody tr {
        position: relative;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-content: start;
        gap: 8px 12px;
        padding: 10px 12px;
        margin: 0;
        background: var(--ui-surface);
        border: 1px solid var(--ui-border);
        border-radius: var(--ui-radius);
        box-shadow: none;
    }
    .wt-acct .wt-table tbody tr:hover td { background: transparent; }
    /* Short-value tables opt in to three fields per line */
    .wt-acct .wt-table.wt-cards-3 tbody tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .wt-acct .wt-table tbody td {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-start;
        gap: 2px;
        min-width: 0;
        width: auto;
        max-width: none;
        padding: 0 !important;
        border: none !important;
        font-size: 13px;
        text-align: left !important;
        white-space: normal;
        overflow: visible;
        overflow-wrap: anywhere;
    }
    .wt-acct .wt-table tbody td::before {
        content: attr(data-label);
        font-size: 10px;
        font-weight: 600;
        letter-spacing: .05em;
        text-transform: uppercase;
        color: var(--ui-faint);
        line-height: 1.3;
        margin: 0;
    }
    .wt-acct .wt-table tbody td:not([data-label])::before,
    .wt-acct .wt-table tbody td[data-label=""]::before { display: none; }
    .wt-acct .wt-table tbody td > * { max-width: 100%; }

    /* Headline cell */
    .wt-acct .wt-table tbody td.wt-c-primary {
        grid-column: 1 / -1;
        order: -2;
        font-size: 14px;
        font-weight: 600;
        color: var(--ui-text);
    }
    .wt-acct .wt-table tbody td.wt-c-primary::before { display: none; }
    .wt-acct .wt-table tbody td.wt-c-primary .wt-clip {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    .wt-acct .wt-table tbody tr.wt-r-check td.wt-c-primary { padding-right: 34px !important; }

    /* Row checkbox */
    .wt-acct .wt-table tbody td.wt-c-check {
        position: absolute;
        top: 12px;
        right: 12px;
        width: auto;
        z-index: 1;
    }
    .wt-acct .wt-table tbody td.wt-c-check::before { display: none; }
    .wt-acct .wt-table tbody td.wt-c-check input { width: 18px; height: 18px; min-height: 0; }

    .wt-acct .wt-table tbody td.wt-c-index { display: none; }

    /* Action row */
    .wt-acct .wt-table tbody td.wt-c-actions {
        grid-column: 1 / -1;
        order: 99;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-end;
        gap: 8px;
        padding-top: 8px !important;
        border-top: 1px solid var(--ui-border-soft) !important;
    }
    .wt-acct .wt-table tbody td.wt-c-actions::before { display: none; }
    .wt-acct .wt-table tbody td.wt-c-actions:empty { display: none; }
    .wt-acct .wt-table tbody td.wt-c-actions + td.wt-c-actions {
        order: 100;
        padding-top: 0 !important;
        border-top: none !important;
    }
    .wt-acct .wt-table tbody td.wt-c-actions > div { flex-wrap: wrap; justify-content: flex-end; }
    .wt-acct .wt-row-actions { flex-wrap: wrap; }

    /* Selects inside record cards stay compact */
    .wt-acct .wt-table tbody td .select { width: auto; min-width: 110px; }

    /* Full-width rows: empty states and expandable detail rows */
    .wt-acct .wt-table tbody tr.wt-r-span { display: block; grid-column: 1 / -1; padding: 0; border: none; background: transparent; }
    .wt-acct .wt-table tbody tr.wt-r-span > td { display: block; }
    .wt-acct .wt-table tbody tr.wt-r-span > td::before { display: none; }
    .wt-acct .wt-table tbody tr.wt-r-span > td:empty { display: none; }
}

/* ============================================================
   3. STAT TILES — compact, icon-left
   ============================================================ */
.wt-acct .wt-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.wt-acct .wt-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 12px 14px;
    background: var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
}
.wt-acct .wt-stat-ico {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}
.wt-acct .wt-stat-ico.is-orange { background: #fff1e6; color: var(--ui-accent); }
.wt-acct .wt-stat-ico.is-blue { background: #e8f0fe; color: #2563eb; }
.wt-acct .wt-stat-ico.is-amber { background: #fef4e5; color: #d97706; }
.wt-acct .wt-stat-ico.is-green { background: #e7f8ee; color: #16a34a; }
.wt-acct .wt-stat-body { min-width: 0; }
.wt-acct .wt-stat-value {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.15;
    color: var(--ui-text);
    letter-spacing: -.01em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wt-acct .wt-stat-label {
    font-size: 12px;
    color: var(--ui-muted);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (max-width: 768px) {
    .wt-acct .wt-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
    .wt-acct .wt-stat { padding: 10px 12px; gap: 10px; }
    .wt-acct .wt-stat-ico { width: 32px; height: 32px; font-size: 13px; }
    .wt-acct .wt-stat-value { font-size: 18px; }
}

/* ============================================================
   4. SHARED CONTROLS
   ============================================================ */
/* Card header / toolbar */
.wt-acct .wt-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px 12px;
    flex-wrap: wrap;
    padding: 12px 14px;
    border-bottom: 1px solid var(--ui-border-soft);
}
.wt-acct .wt-card-title { font-size: 14px; font-weight: 700; color: var(--ui-text); line-height: 1.3; }
.wt-acct .wt-card-sub { font-size: 12px; color: var(--ui-muted); margin-top: 1px; }
.wt-acct .wt-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 14px;
    border-top: 1px solid var(--ui-border-soft);
    font-size: 12px;
    color: var(--ui-muted);
}
.wt-acct .wt-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--ui-accent-dark);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.wt-acct .wt-link:hover { text-decoration: underline; }

/* Small buttons used in table rows and pagers */
.wt-acct .wt-btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid var(--ui-border);
    background: var(--ui-surface);
    color: var(--ui-body);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
}
.wt-acct .wt-btn-sm:hover { background: var(--ui-head); border-color: #cbd2dd; }
.wt-acct .wt-btn-sm i { font-size: 11px; }
.wt-acct .wt-btn-sm.is-danger { color: var(--ui-danger); border-color: #f5c6c6; }
.wt-acct .wt-btn-sm.is-danger:hover { background: #fef2f2; }
.wt-acct .wt-btn-sm:disabled { opacity: .45; cursor: default; }

/* Filter chips */
.wt-acct .wt-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
}
.wt-acct .wt-chips::-webkit-scrollbar { display: none; }
.wt-acct .wt-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: #f2f2f2;
    color: #0f0f0f;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
}
.wt-acct .wt-chip:hover { background: #e5e5e5; }
.wt-acct .wt-chip[aria-pressed="true"] { background: #0f0f0f; color: #fff; }
.wt-acct .wt-chip-count { font-weight: 500; opacity: .65; }

/* Touch screens: compact controls keep a comfortable 36px target */
@media (pointer: coarse) {
    .wt-acct .wt-btn-sm,
    .wt-acct .wt-chip { min-height: 36px; min-width: 0; padding-left: 12px; padding-right: 12px; }
    .wt-acct .wt-link { min-height: 36px; min-width: 0; }
    .wt-acct .wt-table td.wt-c-actions button,
    .wt-acct .wt-table td.wt-c-actions a { min-height: 36px; }
}
@media (max-width: 768px) {
    .wt-acct .wt-hide-sm { display: none !important; }
}

/* Status badges: one casing everywhere */
.wt-acct .status-badge,
.wt-acct .pill { text-transform: capitalize; white-space: nowrap; }
.wt-acct .status-badge { padding: 3px 10px; }

/* ============================================================
   5. PROFILE PAGE
   ============================================================ */
.wt-profile .prof-panel > h2 {
    font-size: 1.1rem !important;
    margin-bottom: 14px !important;
    padding-bottom: 10px;
}
.wt-profile .prof-card { overflow: hidden; }
.wt-profile .prof-card.wt-card-pad { padding: 16px; }
.wt-profile .prof-card:hover { box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -18px rgba(15, 23, 42, .18) !important; }

/* Recent-order list rows */
.wt-profile .wt-list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--ui-border-soft);
}
.wt-profile .wt-list-row:last-child { border-bottom: none; }
.wt-profile .wt-list-main { min-width: 0; flex: 1; }
.wt-profile .wt-list-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--ui-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wt-profile .wt-list-meta { font-size: 12px; color: var(--ui-muted); margin-top: 1px; }
.wt-profile .wt-list-empty { padding: 20px 14px; font-size: 13px; color: var(--ui-faint); }

/* Forms */
.wt-profile .wt-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
}
.wt-profile .wt-field { min-width: 0; }
.wt-profile .wt-field.is-wide { grid-column: 1 / -1; }
.wt-profile .wt-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--ui-body);
    margin-bottom: 5px;
}
.wt-profile .wt-field-hint { font-size: 11px; color: var(--ui-faint); margin-top: 4px; }
.wt-profile .wt-form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--ui-border-soft);
}
.wt-profile .wt-two-col {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 16px;
    align-items: start;
}
.wt-profile .wt-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--ui-border-soft);
}
.wt-profile .wt-setting-row:first-child { padding-top: 0; }
.wt-profile .wt-setting-title { font-size: 13px; font-weight: 600; color: var(--ui-text); }
.wt-profile .wt-setting-sub { font-size: 12px; color: var(--ui-muted); margin-top: 1px; }

/* Contact channels */
.wt-profile .wt-contact {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
}
.wt-profile .wt-contact-ico {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: #e7f8ee;
    color: #16a34a;
}
.wt-profile .wt-contact-main { flex: 1; min-width: 0; }
.wt-profile .wt-contact-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 9px;
    background: #16a34a;
    color: #fff;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
}
.wt-profile .wt-contact-cta:hover { background: #15803d; }

@media (min-width: 769px) {
    .wt-profile .prof-main {
        max-width: none !important;
        padding-left: 28px !important;
        padding-right: 28px !important;
        box-sizing: border-box;
    }
    .wt-profile .prof-panel { max-width: 1040px; width: 100%; margin: 0 auto; }
    .wt-profile .prof-panel .wt-narrow { max-width: 720px; }
}
@media (min-width: 769px) and (max-width: 1024px) {
    .wt-profile .prof-main { padding-left: 18px !important; padding-right: 18px !important; }
    .wt-profile .wt-two-col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 768px) {
    .wt-profile .prof-layout {
        padding: 12px 12px 0 !important;
    }
    .wt-profile .prof-panel > h2 { margin-bottom: 10px !important; padding-bottom: 8px; }
    .wt-profile .prof-card.wt-card-pad { padding: 14px; }
    /* Identity card: overview only, compact */
    .wt-profile .mobile-profile-header {
        padding: 12px 14px;
        margin-bottom: 12px;
        border-radius: 14px;
        gap: 12px;
    }
    .wt-profile .mobile-profile-avatar { width: 44px; height: 44px; font-size: 1.1rem; }
    .wt-profile .mobile-profile-name { font-size: 1rem; }
    .wt-profile .wt-two-col { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    /* Short fields stay paired on phones; long ones take the full row */
    .wt-profile .wt-form-grid { gap: 12px; }
    .wt-profile .wt-field.is-wide-sm { grid-column: 1 / -1; }
    .wt-profile .prof-main input:not([type="checkbox"]):not([type="radio"]),
    .wt-profile .prof-main select,
    .wt-profile .prof-main textarea {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
        font-size: 16px; /* prevents iOS auto-zoom */
    }
    .wt-profile .wt-form-actions > button { flex: 1; }
    .wt-profile .wt-card-head { padding: 10px 12px; }
    .wt-profile .wt-contact { flex-wrap: wrap; }
    .wt-profile .wt-contact-cta { flex: 1 1 100%; justify-content: center; }
}

/* ============================================================
   6. ADMIN + BUSINESS DASHBOARDS
   ============================================================ */
/* Wide admin tables scroll inside their card instead of crushing columns */
@media (min-width: 1024px) {
    .wt-dash .wt-table { min-width: 760px; }
    .wt-dash #usersTable { min-width: 900px; }
    .wt-dash .wt-table td .select { min-width: 92px; }
}

/* Off-canvas sidebars: no shadow bleeding onto the page while closed */
@media (max-width: 1023.98px) {
    .wt-acct #sidebar:not(.open) { box-shadow: none; }
}

/* Chip rows scroll sideways; chips never squash */
.wt-acct .chip-row { min-width: 0; }
.wt-acct .chip-row > * { flex: 0 0 auto; }

/* Progress bars are spans — they need a box to show their fill */
.wt-acct .prog-fill { display: block; }

.wt-dash .card-head { padding: 12px 14px; }
.wt-dash .stat-card.card { padding: 12px 14px !important; gap: 12px; }

/* The fixed sidebar's account card must not cover the last nav links */
.wt-dash #sidebar nav { min-height: 0; padding-bottom: 12px; }

@media (max-width: 768px) {
    .wt-dash #view-container { padding: 12px; }
    .wt-dash main > header > div { padding: 8px 12px; }
    .wt-dash #page-title { font-size: 1rem; }

    /* List toolbars: search on its own row, everything else wraps tidily */
    .wt-dash #view-container .card > .flex.flex-wrap {
        padding: 10px 12px;
        gap: 8px;
    }
    .wt-dash #view-container .card > .flex.flex-wrap > .input,
    .wt-dash #view-container .card > .flex.flex-wrap > .select {
        max-width: none;
        flex: 1 1 100%;
    }
    .wt-dash #view-container .card > .flex.flex-wrap > label.ml-auto { margin-left: 0; margin-right: auto; }

    /* Stat rows: two-up and compact instead of one tall card per row */
    .wt-dash .wt-stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 8px !important; }
    .wt-dash .wt-stat-row > .card { padding: 12px !important; }
    .wt-dash .wt-stat-row > .card .text-3xl { font-size: 1.35rem; line-height: 1.2; }
    .wt-dash .wt-stat-row > .card .w-12 { width: 34px; height: 34px; }
    .wt-dash .wt-stat-row > .card .w-12 i { font-size: .9rem; }
    .wt-dash .wt-stat-row > .stat-card .w-12 { display: none; }
    .wt-dash .wt-stat-row > .stat-card p.text-2xl { font-size: 1.2rem; }

    .wt-dash #view-container .space-y-6 > * + * { margin-top: 12px; }
    .wt-dash #view-container .card > .p-5 { padding: 12px; }
    .wt-dash #view-container .card > .p-5 h3.text-lg { font-size: .95rem; }

    .wt-acct .tbl .thumb { width: 40px; height: 40px; }
    .wt-acct .card-head > .chip-row { flex: 1 1 100%; }
    .wt-acct .card-head { padding: 10px 12px; gap: 8px; }
}

/* Statuses the pages did not colour yet */
.wt-acct .status-delivered { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.wt-acct .status-refunded { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }

/* Admin sidebar: drawer + backdrop below 1024px, always docked from 1024px up */
.wt-dash #sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(15, 23, 42, .45);
}
@media (max-width: 1023.98px) {
    .wt-dash #sidebar.open + #sidebar-backdrop { display: block; }
    .wt-dash #sidebar.open { box-shadow: 4px 0 26px rgba(15, 23, 42, .16); }
}
@media (min-width: 1024px) {
    .wt-dash #sidebar { transform: none !important; }
}
