/**
 * PDS UI Kit — Public Sans, Sneat-inspired, mobile-first.
 * Use root class .pds-ui on page wrappers; tables use .pds-ui-table for responsive cards on small screens.
 */

.pds-ui,
.pds-mso-buy,
.pds-mso-sales,
.pds-mso-pkg,
.pds-mso-ord,
.pds-ext-api,
.wt-hub-page,
.wallet-sneat-page,
.ghbm-commissions-page,
.pds-msf-page,
.orders-sneat-page,
.adm-wallet-page,
#admOmPage {
    font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    max-width: 100%;
}

.pds-ui {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    box-sizing: border-box;
}

.pds-ui *,
.pds-ui *::before,
.pds-ui *::after {
    box-sizing: border-box;
}

/* --- Hero --- */
.pds-ui-hero {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.2rem 1.25rem;
    border-radius: 1rem;
    border: 1px solid #e6e9ef;
    background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
    box-shadow: 0 2px 12px rgba(67, 89, 113, 0.06);
    overflow: hidden;
}

.pds-ui-hero--gold {
    background: linear-gradient(135deg, #fff9e6 0%, #fff 55%, #f8fafc 100%);
    border-color: #fde68a;
}

.pds-ui-hero--gold::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, #ffcc00, #ff9500);
    border-radius: 1rem 0 0 1rem;
}

.pds-ui-hero__brand {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    min-width: 0;
    flex: 1 1 auto;
}

.pds-ui-hero__icon {
    flex-shrink: 0;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #e6e9ef;
    border-radius: 0.75rem;
    box-shadow: 0 2px 8px rgba(67, 89, 113, 0.08);
    padding: 0.35rem;
}

.pds-ui-hero__icon img {
    width: 2rem;
    height: 2rem;
    object-fit: contain;
}

.pds-ui-hero h2,
.pds-ui-hero h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: #233446;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.pds-ui-hero p {
    margin: 0.35rem 0 0;
    font-size: 0.8125rem;
    color: #697a8d;
    line-height: 1.45;
    max-width: 36rem;
}

.pds-ui-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    width: 100%;
}

@media (min-width: 640px) {
    .pds-ui-stats {
        grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr));
        width: auto;
    }
}

.pds-ui-stat {
    border: 1px solid #e6e9ef;
    border-radius: 0.75rem;
    background: #fff;
    padding: 0.7rem 0.8rem;
    min-width: 5rem;
}

.pds-ui-stat span {
    display: block;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #697a8d;
}

.pds-ui-stat strong {
    display: block;
    margin-top: 0.25rem;
    font-size: 1.0625rem;
    font-weight: 700;
    color: #233446;
}

/* --- Panels --- */
.pds-ui-panel {
    border: 1px solid #e6e9ef;
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 1px 3px rgba(67, 89, 113, 0.05);
    overflow: hidden;
}

.pds-ui-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1rem 0.65rem;
    border-bottom: 1px solid #f1f5f9;
}

.pds-ui-panel-head h4 {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 700;
    color: #233446;
}

.pds-ui-panel-head p {
    margin: 0.2rem 0 0;
    font-size: 0.75rem;
    color: #697a8d;
}

.pds-ui-panel-body {
    padding: 1rem;
}

.pds-ui-badge {
    font-size: 0.6875rem;
    font-weight: 700;
    color: #696cff;
    background: rgba(105, 108, 255, 0.1);
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* --- Toggle --- */
.pds-ui-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid #e6e9ef;
    border-radius: 1rem;
    background: #fff;
    box-shadow: 0 1px 3px rgba(67, 89, 113, 0.04);
}

.pds-ui-toggle__text {
    flex: 1;
    min-width: 0;
}

.pds-ui-toggle__text strong {
    display: block;
    font-size: 0.875rem;
    color: #233446;
}

.pds-ui-toggle__text small {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.75rem;
    color: #697a8d;
    line-height: 1.4;
}

.pds-ui-switch {
    position: relative;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}

.pds-ui-switch input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    margin: 0;
}

.pds-ui-switch__track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #cbd5e1;
    transition: background 0.25s ease;
}

.pds-ui-switch__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.15);
    transition: transform 0.25s ease;
}

.pds-ui-switch input:checked + .pds-ui-switch__track {
    background: #696cff;
}

.pds-ui-switch input:checked + .pds-ui-switch__track + .pds-ui-switch__thumb {
    transform: translateX(20px);
}

/* --- Forms --- */
.pds-ui-form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
}

@media (min-width: 640px) {
    .pds-ui-form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 900px) {
    .pds-ui-form-grid--3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.pds-ui-field label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #697a8d;
    margin-bottom: 0.35rem;
}

.pds-ui-field input,
.pds-ui-field select,
.pds-ui-field textarea {
    width: 100%;
    min-height: 2.75rem;
    border: 1px solid #e6e9ef;
    border-radius: 0.625rem;
    padding: 0 0.75rem;
    font: inherit;
    font-size: 0.875rem;
    color: #233446;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.pds-ui-field textarea {
    min-height: 5rem;
    padding: 0.65rem 0.75rem;
    resize: vertical;
}

.pds-ui-field input:focus,
.pds-ui-field select:focus,
.pds-ui-field textarea:focus {
    outline: 0;
    border-color: #696cff;
    box-shadow: 0 0 0 3px rgba(105, 108, 255, 0.12);
}

.pds-ui-field--wide {
    grid-column: 1 / -1;
}

.pds-ui-note {
    margin: 0.75rem 0 0;
    font-size: 0.8125rem;
    color: #697a8d;
    line-height: 1.5;
}

.pds-ui-note code {
    font-size: 0.75rem;
    background: #f1f5f9;
    padding: 0.1rem 0.35rem;
    border-radius: 0.25rem;
}

/* --- Buttons --- */
.pds-ui-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.pds-ui-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 2.75rem;
    padding: 0 1.1rem;
    border: 0;
    border-radius: 0.625rem;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.pds-ui-btn--primary {
    background: #696cff;
    color: #fff;
    box-shadow: 0 4px 14px rgba(105, 108, 255, 0.28);
}

.pds-ui-btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(105, 108, 255, 0.34);
}

.pds-ui-btn--outline {
    background: #fff;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.pds-ui-btn--outline:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.pds-ui-btn--muted {
    background: #f1f5f9;
    color: #475569;
}

.pds-ui-btn--danger {
    background: #fff;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.pds-ui-btn--ghost {
    background: transparent;
    color: #696cff;
    border: 1px solid #e0e7ff;
    min-height: 2.25rem;
    padding: 0 0.85rem;
    font-size: 0.8125rem;
}

.pds-ui-btn--block {
    width: 100%;
}

.pds-ui-btn--gradient {
    background: linear-gradient(135deg, #696cff, #5a5de8);
    color: #fff;
    box-shadow: 0 6px 18px rgba(105, 108, 255, 0.28);
}

/* --- Pills --- */
.pds-ui-pill,
.pds-mso-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 700;
    white-space: nowrap;
}

.pds-ui-pill--done,
.pds-mso-pill--done {
    background: rgba(16, 185, 129, 0.12);
    color: #047857;
}

.pds-ui-pill--pending,
.pds-mso-pill--pending {
    background: rgba(245, 158, 11, 0.12);
    color: #b45309;
}

.pds-ui-pill--failed,
.pds-mso-pill--failed {
    background: rgba(244, 63, 94, 0.12);
    color: #be123c;
}

.pds-ui-pill--neutral,
.pds-mso-pill--neutral {
    background: #f1f5f9;
    color: #64748b;
}

.pds-ui-pill--api,
.pds-mso-pill--api {
    background: rgba(105, 108, 255, 0.12);
    color: #4f46e5;
}

/* --- List items (mobile history cards) --- */
.pds-ui-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding: 0 1rem 1rem;
}

.pds-ui-list-item {
    border: 1px solid #e6e9ef;
    border-radius: 0.875rem;
    padding: 0.85rem 0.9rem;
    background: #fafbfd;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.pds-ui-list-item:hover {
    border-color: #d8dee9;
    box-shadow: 0 4px 12px rgba(67, 89, 113, 0.06);
}

.pds-ui-list-item__main {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.65rem;
}

.pds-ui-list-item__title strong {
    display: block;
    font-size: 0.875rem;
    font-weight: 700;
    color: #233446;
}

.pds-ui-list-item__title span {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.75rem;
    color: #697a8d;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.pds-ui-list-item__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px dashed #e6e9ef;
    font-size: 0.75rem;
    color: #697a8d;
}

.pds-ui-list-item__foot strong {
    font-size: 0.9375rem;
    color: #233446;
}

/* --- Tables: desktop + mobile card rows --- */
.pds-ui-table-card {
    border: 1px solid #e6e9ef;
    border-radius: 1rem;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(67, 89, 113, 0.05);
}

.pds-ui-table-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
    flex-wrap: wrap;
}

.pds-ui-table-head h4,
.pds-ui-table-head h5 {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 700;
    color: #233446;
}

.pds-ui-table-head small {
    display: block;
    font-size: 0.75rem;
    color: #697a8d;
    margin-top: 0.15rem;
}

.pds-ui-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.pds-ui-table,
.pds-mso-table,
.pds-mso-pkg-table,
.pds-mso-ord-table,
.wt-hub-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.pds-ui-table th,
.pds-mso-table th,
.pds-mso-pkg-table th,
.pds-mso-ord-table th,
.wt-hub-table thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    background: #f8fafc;
    color: #697a8d;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #f1f5f9;
    white-space: nowrap;
}

.pds-ui-table td,
.pds-mso-table td,
.pds-mso-pkg-table td,
.pds-mso-ord-table td,
.wt-hub-table td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    color: #334155;
    border-bottom: 1px solid #f1f5f9;
}

.pds-ui-table tbody tr:hover td,
.pds-mso-table tbody tr:hover td,
.pds-mso-pkg-table tbody tr:hover td,
.pds-mso-ord-table tbody tr:hover td,
.wt-hub-table tbody tr:hover td {
    background: #fafbfd;
}

.pds-ui-table-cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0 1rem 1rem;
}

@media (min-width: 768px) {
    .pds-ui-table-cards {
        display: none;
    }

    .pds-ui-table-wrap,
    .pds-mso-table-wrap,
    .pds-mso-pkg-table-wrap,
    .pds-mso-ord-table-wrap {
        display: block;
    }
}

@media (max-width: 767px) {
    .pds-ui-table-wrap--mobile-stack,
    .wt-hub-table-wrap,
    .wallet-table-wrap,
    .commission-table-wrap,
    #admOmPage .orders-table-scroll {
        overflow: visible;
    }

    .pds-ui-table--mobile-stack thead,
    .wt-hub-table thead,
    .wallet-table.pds-ui-table--mobile-stack thead,
    .commission-transactions-table.pds-ui-table--mobile-stack thead,
    .orders-mgmt-datatable.pds-ui-table--mobile-stack thead {
        display: none;
    }

    .pds-ui-table--mobile-stack tbody tr,
    .wt-hub-table tbody tr,
    .wallet-table.pds-ui-table--mobile-stack tbody tr,
    .commission-transactions-table.pds-ui-table--mobile-stack tbody tr,
    .orders-mgmt-datatable.pds-ui-table--mobile-stack tbody tr {
        display: block;
        margin-bottom: 0.65rem;
        border: 1px solid #e6e9ef;
        border-radius: 0.875rem;
        background: #fafbfd;
        overflow: hidden;
    }

    .pds-ui-table--mobile-stack tbody tr:hover td,
    .wt-hub-table tbody tr:hover td,
    .wallet-table.pds-ui-table--mobile-stack tbody tr:hover td,
    .commission-transactions-table.pds-ui-table--mobile-stack tbody tr:hover td,
    .orders-mgmt-datatable.pds-ui-table--mobile-stack tbody tr:hover td {
        background: transparent;
    }

    .pds-ui-table--mobile-stack td,
    .wt-hub-table td,
    .wallet-table.pds-ui-table--mobile-stack td,
    .commission-transactions-table.pds-ui-table--mobile-stack td,
    .orders-mgmt-datatable.pds-ui-table--mobile-stack td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0.55rem 0.85rem;
        border-bottom: 1px solid #f1f5f9;
        font-size: 0.8125rem;
        text-align: right;
    }

    .pds-ui-table--mobile-stack td:last-child,
    .wt-hub-table td:last-child,
    .wallet-table.pds-ui-table--mobile-stack td:last-child,
    .commission-transactions-table.pds-ui-table--mobile-stack td:last-child,
    .orders-mgmt-datatable.pds-ui-table--mobile-stack td:last-child {
        border-bottom: 0;
    }

    .pds-ui-table--mobile-stack td::before,
    .wt-hub-table td::before,
    .wallet-table.pds-ui-table--mobile-stack td::before,
    .commission-transactions-table.pds-ui-table--mobile-stack td::before,
    .orders-mgmt-datatable.pds-ui-table--mobile-stack td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #697a8d;
        font-size: 0.6875rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        text-align: left;
        flex-shrink: 0;
    }

    .pds-ui-table--mobile-stack td[data-label='']::before,
    .wt-hub-table td[data-label='']::before,
    .wallet-table.pds-ui-table--mobile-stack td[data-label='']::before,
    .commission-transactions-table.pds-ui-table--mobile-stack td[data-label='']::before,
    .orders-mgmt-datatable.pds-ui-table--mobile-stack td[data-label='']::before {
        content: none;
    }

    .wallet-table.pds-ui-table--mobile-stack td[data-label='Details'],
    .commission-transactions-table.pds-ui-table--mobile-stack td[data-label='Details'] {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
    }

    #admOmPage .orders-table-scroll-hint {
        display: none;
    }

    .pds-mso-table-wrap,
    .pds-mso-pkg-table-wrap,
    .pds-mso-ord-table-wrap {
        display: none;
    }

    .pds-mso-cards,
    .pds-mso-pkg-cards,
    .pds-mso-ord-cards {
        display: flex;
    }
}

/* --- Empty / messages --- */
.pds-ui-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2rem 1rem;
    color: #697a8d;
}

.pds-ui-empty i {
    font-size: 2rem;
    color: #c7cdd4;
    margin-bottom: 0.5rem;
}

.pds-ui-empty p {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.45;
    max-width: 18rem;
}

.pds-ui-msg {
    margin: 0.85rem 0 0;
    padding: 0.65rem 0.85rem;
    border-radius: 0.625rem;
    font-size: 0.8125rem;
    font-weight: 500;
}

.pds-ui-msg--ok {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.pds-ui-msg--err {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

/* --- Filters --- */
.pds-ui-filters {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    padding: 1rem;
    border: 1px solid #e6e9ef;
    border-radius: 1rem;
    background: #fff;
}

@media (min-width: 768px) {
    .pds-ui-filters {
        grid-template-columns: 1.2fr repeat(3, minmax(0, 1fr)) auto auto;
        align-items: end;
    }
}

.pds-ui-filters label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 700;
    color: #697a8d;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.pds-ui-filters input,
.pds-ui-filters select {
    width: 100%;
    min-height: 2.5rem;
    border: 1px solid #e6e9ef;
    border-radius: 0.5rem;
    padding: 0 0.65rem;
    font: inherit;
    font-size: 0.875rem;
}

/* --- App shell fixes --- */
.pds-app-page-content--embedded .pds-ui,
.pds-app-page-content--embedded .pds-mso-buy,
.pds-app-page-content--embedded .wt-hub-page {
    overflow-x: hidden;
}

.pds-app-shell.pds-theme-dark .pds-ui-panel,
.pds-app-shell.pds-theme-dark .pds-ui-hero,
.pds-app-shell.pds-theme-dark .pds-ui-list-item,
.pds-app-shell.pds-theme-dark .pds-ui-table-card {
    background: #2b2c40;
    border-color: #444564;
}

.pds-app-shell.pds-theme-dark .pds-ui-hero h2,
.pds-app-shell.pds-theme-dark .pds-ui-hero h3,
.pds-app-shell.pds-theme-dark .pds-ui-panel-head h4,
.pds-app-shell.pds-theme-dark .pds-ui-list-item__title strong {
    color: #e7e7ff;
}
