/*
  Hialgo Pro Redesign Layer
  Intent: premium OMS / broker terminal composition without changing workflows.
  Scope: Hialgo-prefixed and known module containers only.
*/

:root {
    --pro-ink: #0b1220;
    --pro-rail: #111827;
    --pro-rail-soft: #1f2937;
    --pro-page: #eef3f8;
    --pro-panel: #ffffff;
    --pro-panel-soft: #f7f9fc;
    --pro-line: #d8e1ee;
    --pro-blue: #2563eb;
    --pro-green: #087443;
    --pro-red: #b42318;
    --pro-amber: #b54708;
    --pro-cyan: #0e7490;
    --pro-shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
    --pro-shadow-sm: 0 8px 18px rgba(15, 23, 42, 0.05);
}

body {
    background:
        linear-gradient(180deg, rgba(17, 24, 39, 0.035) 0, rgba(17, 24, 39, 0) 220px),
        var(--pro-page);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
}

.ha-topbar {
    background: var(--pro-ink);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 12px 28px rgba(11, 18, 32, 0.2);
}

.ha-brand-mark {
    background: linear-gradient(135deg, #2563eb, #0e7490);
    border-radius: 10px;
}

.ha-sidebar {
    background: linear-gradient(180deg, #ffffff 0, #f8fafc 100%);
}

.ha-nav-link {
    font-size: 13px;
}

.ha-nav-link.active {
    background: #e9f1ff;
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.08);
}

.ha-content-shell,
.basket-shell,
.orders-wrapper {
    width: min(100%, 1320px);
}

.ha-admin-page-header,
.basket-shell .basket-header {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(216, 225, 238, 0.95);
    background:
        linear-gradient(120deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 255, 0.96)),
        var(--pro-panel);
    box-shadow: var(--pro-shadow);
}

.ha-admin-page-header::before,
.basket-shell .basket-header::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: linear-gradient(180deg, var(--pro-blue), var(--pro-cyan));
}

.ha-admin-page-header h3,
.basket-header h3 {
    color: var(--pro-ink);
    font-size: 24px;
    font-weight: 900;
}

.ha-admin-kicker {
    color: var(--pro-cyan);
}

.ha-admin-card,
.basket-panel,
.hio-panel,
.watchlist-card {
    border: 1px solid var(--pro-line);
    border-radius: 14px;
    background: var(--pro-panel);
    box-shadow: var(--pro-shadow-sm);
}

.ha-admin-card-head {
    background: linear-gradient(180deg, #ffffff, #f9fbfe);
}

.ha-admin-stat-grid,
.hio-metric-grid {
    gap: 12px;
}

.ha-admin-stat,
.hio-metric {
    position: relative;
    overflow: hidden;
    border-color: var(--pro-line);
    border-radius: 14px;
    background:
        linear-gradient(180deg, #ffffff, #f8fafc);
    box-shadow: var(--pro-shadow-sm);
}

.ha-admin-stat::after,
.hio-metric::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 54px;
    height: 54px;
    background: radial-gradient(circle at top right, rgba(37, 99, 235, 0.12), transparent 65%);
    pointer-events: none;
}

.ha-admin-stat strong,
.hio-metric strong,
.hio-num {
    font-variant-numeric: tabular-nums;
}

.ha-groups-table,
.basket-grid,
.orders-table,
.ha-data-table {
    border-collapse: separate;
    border-spacing: 0;
}

.ha-groups-table thead th,
.basket-grid thead th,
.orders-table thead th,
.ha-data-table thead th {
    background: #f3f6fb;
    border-bottom: 1px solid var(--pro-line);
    color: #334155;
    font-size: 11px;
    font-weight: 900;
}

.ha-groups-table tbody td,
.basket-grid tbody td,
.orders-table tbody td,
.ha-data-table tbody td {
    border-color: #edf2f7;
}

.ha-groups-table tbody tr:hover td,
.basket-grid tbody tr:hover td,
.orders-table tbody tr:hover td {
    background-color: #f8fbff;
}

.dataTables_wrapper .ha-dt-toolbar {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-radius: 12px;
    box-shadow: var(--pro-shadow-sm);
    margin: 0 0 14px;
    padding: 9px 10px;
    border: 1px solid rgba(216, 225, 238, 0.95);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.98));
    isolation: isolate;
}

.dataTables_wrapper .ha-dt-toolbar > [class*="col-"] {
    display: flex;
    align-items: center;
    min-height: 34px;
}

.dataTables_wrapper .ha-dt-toolbar > [class*="col-"]:last-child {
    justify-content: flex-end;
}

.dataTables_wrapper .ha-dt-search {
    flex: 1 1 280px;
    min-width: 220px;
}

.dataTables_wrapper .ha-dt-actions {
    display: flex;
    flex: 0 1 auto;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 0;
}

.dataTables_wrapper .dataTables_filter {
    width: 100%;
}

.dataTables_wrapper .dataTables_filter label {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin: 0;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
}

.dataTables_wrapper .dataTables_filter input {
    width: min(310px, 100%) !important;
    height: 32px;
    margin-left: 0 !important;
    border-radius: 9px;
    border-color: var(--pro-line);
    background: #fff;
    font-size: 12px;
}

.dataTables_wrapper .dt-buttons {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    float: none;
}

.dataTables_wrapper .dt-buttons .btn,
.dataTables_wrapper .dt-button {
    min-height: 30px;
    padding: 5px 10px;
    border-radius: 999px !important;
    border: 1px solid #c9d6e6 !important;
    background: #fff !important;
    color: #334155 !important;
    font-size: 11px;
    font-weight: 900;
    box-shadow: none !important;
}

.dataTables_wrapper .dataTables_info {
    padding-top: 10px !important;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
}

.dataTables_wrapper .dataTables_length {
    float: none;
}

.dataTables_wrapper .dataTables_length label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.dataTables_wrapper .dataTables_length select {
    width: auto;
    min-width: 68px;
    height: 32px;
    border-radius: 9px;
    border-color: var(--pro-line);
    font-size: 12px;
    font-weight: 800;
}

.dataTables_wrapper .dataTables_scroll {
    position: relative;
    z-index: 0;
    clear: both;
}

.dataTables_wrapper .dataTables_paginate {
    padding-top: 8px !important;
}

.dataTables_wrapper .pagination {
    gap: 4px;
    margin: 0;
}

.dataTables_wrapper .page-link {
    min-width: 30px;
    border-radius: 8px !important;
    border-color: var(--pro-line);
    color: #334155;
    font-size: 12px;
    font-weight: 800;
}

.dataTables_wrapper .page-item.active .page-link {
    border-color: var(--pro-blue);
    background: var(--pro-blue);
    color: #fff;
}

.ha-admin-status,
.ha-count-pill,
.hio-chip,
.ha-status-pill,
.status-pill {
    font-weight: 900;
    letter-spacing: 0;
}

.btn {
    font-weight: 750;
}

.ha-action-group .btn,
.hio-action-row .btn {
    min-height: 30px;
}

.hio-auth-page {
    background:
        radial-gradient(circle at 20% 20%, rgba(37, 99, 235, 0.2), transparent 30%),
        linear-gradient(135deg, #07111f, #111827 58%, #0b1220);
}

.hio-auth-panel {
    border-radius: 18px;
}

.ha-command-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.85fr);
    gap: 14px;
    align-items: start;
}

.ha-command-stack {
    display: grid;
    gap: 14px;
}

.ha-quick-actions {
    display: grid;
    gap: 8px;
}

.ha-quick-actions .btn {
    justify-content: space-between;
    min-height: 40px;
}

.ha-system-strip {
    display: grid;
    gap: 8px;
}

.ha-system-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 11px;
    border: 1px solid var(--pro-line);
    border-radius: 10px;
    background: var(--pro-panel-soft);
    color: #475467;
    font-size: 13px;
}

.ha-copytrade-page .ha-admin-card,
.ha-groups-page .ha-admin-card,
.ha-broker-page .ha-admin-card {
    backdrop-filter: none;
}

.ha-copytrade-page .follower-row td:first-child {
    width: 72px;
}

.ha-copytrade-page .multiplier {
    max-width: 112px;
    font-variant-numeric: tabular-nums;
}

.basket-shell {
    display: grid;
    gap: 14px;
}

.basket-shell .basket-panel {
    border-radius: 14px;
}

.basket-weight-meter {
    border-radius: 999px;
    border: 1px solid var(--pro-line);
    background: #f8fbff;
    color: #334155;
    font-weight: 900;
}

.basket-grid input.form-control-sm,
.basket-grid select.form-select-sm,
.portfolio-live-row input.form-control-sm {
    font-size: 12px;
}

.portfolio-live-row td {
    font-variant-numeric: tabular-nums;
}

.portfolio-pnl-cell,
.portfolio-unrealized-cell,
.portfolio-mtm-cell {
    font-weight: 900;
}

.watchlist-card {
    overflow: hidden;
}

.wl-tabs .tab,
.ha-nav-link,
.btn {
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid rgba(37, 99, 235, 0.48);
    outline-offset: 2px;
}

#orderModal .modal-content,
#multiOrderModal .modal-content {
    border: 1px solid rgba(216, 225, 238, 0.5);
}

#orderModal .ha-order-header,
#multiOrderModal .modal-header {
    background: linear-gradient(90deg, #0b1220, #111827);
}

#orderModal .ha-order-section {
    background: #fff;
}

.ha-modal-kicker {
    color: #93c5fd;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#orderModal .modal-dialog {
    max-width: min(980px, calc(100vw - 20px));
}

#orderModal .ha-order-modal {
    box-shadow: 0 24px 62px rgba(11, 18, 32, 0.24);
}

#orderModal .ha-order-body {
    background: #eef3f8;
}

#orderModal .ha-order-section {
    border-radius: 10px;
    border-color: #dce5f0;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.035);
}

#orderModal .ha-side-option,
#orderModal .ha-tab-option {
    min-height: 28px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 900;
}

#orderModal .ha-quote-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

#orderModal .ha-quote-card,
#orderModal .ha-quote-pill {
    min-height: 38px;
    border: 1px solid #dce5f0;
    border-radius: 9px;
    background: #f8fbff;
    padding: 5px 8px;
}

#orderModal .ha-quote-card span,
#orderModal .ha-quote-label {
    color: #64748b;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
}

#orderModal .ha-quote-card strong,
#orderModal .ha-quote-value {
    color: var(--pro-ink);
    font-size: 13px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

#orderModal .ha-quote-card small {
    color: #94a3b8;
    font-size: 10px;
}

#multiOrderModal .modal-dialog {
    max-width: min(1240px, calc(100vw - 18px));
}

#multiOrderModal .modal-content {
    overflow: hidden;
    border-radius: 14px;
    box-shadow: 0 26px 70px rgba(11, 18, 32, 0.26);
}

#multiOrderModal .modal-header {
    padding: 11px 14px;
    color: #fff;
}

#multiOrderModal .modal-header small {
    color: #cbd5e1;
}

#multiOrderModal .btn-close {
    filter: invert(1) grayscale(1);
    opacity: 0.8;
}

#multiOrderModal .modal-body {
    padding: 11px;
    background: #eef3f8;
}

#multiOrderModal .modal-footer {
    padding: 9px 12px;
    border-top: 1px solid #dce5f0;
    background: #fff;
}

.ha-multi-command {
    display: grid;
    grid-template-columns: minmax(260px, 0.8fr) minmax(300px, 1.2fr) auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid #dce5f0;
    border-radius: 11px;
    background: #fff;
    box-shadow: var(--pro-shadow-sm);
}

.ha-multi-command .form-label,
#multiOrderModal .form-label {
    margin-bottom: 4px;
    color: #64748b;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.ha-multi-command .form-select,
.multi-order-table .form-control,
.multi-order-table .form-select {
    min-height: 30px;
    padding-top: 4px;
    padding-bottom: 4px;
    border-radius: 8px;
    border-color: #d6e0ed;
    font-size: 12px;
    font-weight: 750;
}

.ha-multi-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    color: #475569;
    font-size: 11px;
    font-weight: 800;
}

.ha-multi-summary span {
    padding: 5px 8px;
    border: 1px solid #dce5f0;
    border-radius: 999px;
    background: #f8fbff;
}

.ha-multi-actions {
    display: flex;
    justify-content: flex-end;
}

.multi-order-shell {
    border: 1px solid #dce5f0;
    border-radius: 11px;
    background: #fff;
    box-shadow: var(--pro-shadow-sm);
}

.multi-order-table {
    margin-bottom: 0;
}

.multi-order-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 1px solid #dce5f0;
    background: #f3f6fb;
    color: #334155;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.multi-order-table tbody td {
    border-bottom: 1px solid #edf2f7;
    background: #fff;
    vertical-align: middle;
}

.multi-order-table tbody tr:hover td {
    background: #f8fbff;
}

.multi-order-table .multi-ltp {
    color: var(--pro-ink);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.multi-order-table .multi-bid-ask {
    display: block;
    font-size: 10px;
    white-space: nowrap;
}

.multi-order-table .multi-remove-row {
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 8px;
    font-size: 17px;
    line-height: 1;
}

#multiOrderResultPanel {
    max-height: 180px;
    overflow: auto;
    border-radius: 11px;
    background: #fff !important;
}

.ha-exec-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 6px;
    padding: 8px 10px;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 800;
}

.basket-shell .basket-panel > .d-flex:first-child,
.basket-shell .basket-panel > h5:first-child {
    padding-bottom: 8px;
    border-bottom: 1px solid #edf2f7;
}

.basket-shell .basket-panel .form-label {
    color: #64748b;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.basket-shell .basket-panel .form-control,
.basket-shell .basket-panel .form-select {
    border-radius: 9px;
    border-color: #d6e0ed;
    font-weight: 750;
}

.basket-shell .basket-panel .table-responsive {
    border: 1px solid #edf2f7;
    border-radius: 12px;
    background: #fff;
}

#basketPreviewPanel,
#rebalancePanel,
#basketExecutionResultPanel,
#rebalanceResultPanel {
    border-color: rgba(37, 99, 235, 0.24);
}

#basketPreviewPanel .basket-grid thead th,
#rebalancePanel .basket-grid thead th {
    background: #eef5ff;
}

.basket-account-check,
.rebalance-account-check {
    width: 18px;
    height: 18px;
}

.portfolio-holding-row .badge,
.portfolio-position-row .badge {
    border-radius: 999px;
    padding: 5px 8px;
    font-weight: 900;
}

.portfolio-order-btn,
.link-basket-btn,
.portfolio-squareoff-btn {
    min-height: 28px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 900;
}

.portfolio-ltp-cell,
.portfolio-value-cell,
.portfolio-pnl-cell,
.portfolio-mtm-cell,
.portfolio-unrealized-cell {
    font-variant-numeric: tabular-nums;
}

.ha-broker-page .ha-admin-card,
.ha-copytrade-page .ha-admin-card,
.ha-groups-page .ha-admin-card {
    box-shadow: var(--pro-shadow-sm);
}

.ha-broker-page .ha-admin-card .btn,
.ha-copytrade-page .ha-admin-card .btn,
.ha-groups-page .ha-admin-card .btn {
    border-radius: 999px;
}

.watchlist-card,
.left-panel .watchlist-card,
.right-panel .watchlist-card {
    border-radius: 14px;
    box-shadow: var(--pro-shadow-sm);
}

.watchlist-workspace {
    max-width: 1480px;
    margin: 0 auto;
}

.watchlist-workspace .left-panel,
.watchlist-workspace .right-panel {
    border: 1px solid var(--pro-line);
    box-shadow: var(--pro-shadow-sm);
}

.watchlist-workspace .right-panel {
    min-width: 0;
}

.wl-tabs {
    gap: 6px;
}

.wl-tabs .tab {
    border-radius: 999px;
    font-size: 11px;
    font-weight: 900;
}

.ha-side-option,
.ha-tab-option {
    box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.04);
}

@media (max-width: 1100px) {
    .ha-command-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .ha-admin-page-header,
    .basket-shell .basket-header {
        border-radius: 12px;
    }

    .ha-admin-page-header h3,
    .basket-header h3 {
        font-size: 20px;
    }

    .dataTables_wrapper .ha-dt-toolbar {
        position: static;
        padding: 8px;
    }

    .dataTables_wrapper .ha-dt-search,
    .dataTables_wrapper .ha-dt-actions {
        flex: 1 1 100%;
        width: 100%;
    }

    .dataTables_wrapper .ha-dt-actions {
        justify-content: flex-start;
    }

    .dataTables_wrapper .ha-dt-toolbar > [class*="col-"],
    .dataTables_wrapper .ha-dt-toolbar > [class*="col-"]:last-child {
        justify-content: stretch;
    }

    .dataTables_wrapper .dataTables_filter label,
    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
    }

    .dataTables_wrapper .dt-buttons {
        justify-content: flex-start;
        margin-top: 8px;
    }

    #orderModal .modal-dialog,
    #multiOrderModal .modal-dialog {
        max-width: 100%;
        margin: 0;
    }

    #orderModal .modal-content,
    #multiOrderModal .modal-content {
        min-height: 100vh;
        border-radius: 0;
    }

    #orderModal .ha-quote-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ha-multi-command {
        grid-template-columns: 1fr;
    }

    .ha-multi-actions {
        justify-content: stretch;
    }

    .ha-multi-actions .btn {
        width: 100%;
    }

    .multi-order-shell {
        max-height: 58vh;
        overflow: auto;
    }
}
