:root {
    --bg: #f3f5f9;
    --surface: rgba(255, 255, 255, 0.92);
    --surface-strong: #ffffff;
    --line: rgba(16, 24, 40, 0.1);
    --text: #0f172a;
    --text-muted: #64748b;
    --primary: #0052cc;
    --primary-strong: #003f9e;
    --danger: #ef4444;
    --success: #16a34a;
    --shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "IBM Plex Sans", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}

.page-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(90rem 35rem at -10% -10%, rgba(0, 82, 204, 0.17), transparent 70%),
        radial-gradient(80rem 30rem at 110% 0%, rgba(22, 163, 74, 0.13), transparent 70%),
        linear-gradient(180deg, #edf1f9 0%, #f7f9fc 46%, #eef2f8 100%);
}

.container {
    width: min(1360px, calc(100% - 48px));
    margin: 0 auto;
}

.topbar {
    padding: 26px 0 18px;
}

.topbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 600;
}

h1 {
    margin: 0;
    font-size: clamp(26px, 2vw, 34px);
    letter-spacing: -0.02em;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 98px;
    padding: 9px 16px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14px;
    border: 1px solid transparent;
}

.status-open {
    color: #065f46;
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(16, 185, 129, 0.32);
}

.status-closed {
    color: #991b1b;
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.32);
}

.app-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr) 350px;
    padding-bottom: 28px;
}

.overview-grid {
    grid-column: 1 / -1;
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric-card {
    padding: 18px;
    border-radius: var(--radius-md);
    background: var(--surface-strong);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.metric-card p {
    margin: 0 0 10px;
    color: var(--text-muted);
    font-size: 14px;
}

.metric-card h2 {
    margin: 0;
    font-size: clamp(20px, 1.5vw, 26px);
    letter-spacing: -0.02em;
}

.primary-column,
.sidebar-column {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    backdrop-filter: blur(6px);
}

.tabs-panel {
    padding: 8px;
}

.tabs {
    display: inline-flex;
    background: rgba(148, 163, 184, 0.14);
    border-radius: 999px;
    padding: 4px;
    gap: 4px;
}

.tab {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 700;
    cursor: pointer;
}

.tab:hover {
    color: var(--text);
}

.tab.is-active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}

.panel-header h3 {
    margin: 0;
    font-size: 17px;
}

.search-header {
    align-items: center;
}

.search-row {
    padding: 16px 20px 0;
    display: flex;
    gap: 10px;
}

.search-row input {
    flex: 1;
}

.search-actions {
    display: flex;
    gap: 8px;
}

.inline-actions {
    display: flex;
    gap: 10px;
}

.table-shell {
    overflow-x: auto;
    padding: 4px 14px 12px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 780px;
}

thead th {
    text-align: left;
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 10px 10px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

tbody td {
    padding: 13px 10px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
    font-size: 14px;
    white-space: nowrap;
}

tbody tr {
    transition: background 120ms ease;
}

tbody tr.clickable-row {
    cursor: pointer;
}

tbody tr.clickable-row:hover {
    background: rgba(0, 82, 204, 0.05);
}

tbody tr.selected-row {
    background: rgba(0, 82, 204, 0.08);
}

.stock-name {
    font-weight: 700;
}

.stock-code {
    margin-top: 3px;
    font-size: 12px;
    color: var(--text-muted);
}

.text-right {
    text-align: right;
}

.tag-position {
    color: #92400e;
}

.text-rise {
    color: var(--danger);
    font-weight: 700;
}

.text-fall {
    color: var(--success);
    font-weight: 700;
}

.chart-panel {
    overflow: hidden;
}

.chart-wrap {
    padding: 14px 18px 18px;
    height: 300px;
}

.alerts-panel {
    min-height: 420px;
}

.alerts-list {
    padding: 8px 16px 14px;
    max-height: 560px;
    overflow-y: auto;
}

.alert-item {
    padding: 12px 4px;
    border-bottom: 1px dashed rgba(148, 163, 184, 0.35);
}

.alert-item:last-child {
    border-bottom: 0;
}

.alert-item-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 13px;
}

.alert-item-type {
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 3px;
}

.alert-item-read {
    opacity: 0.58;
}

.empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: 18px 6px;
}

button,
input {
    font-family: inherit;
}

input {
    width: 100%;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: #fff;
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    outline: none;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:focus {
    border-color: rgba(0, 82, 204, 0.7);
    box-shadow: 0 0 0 3px rgba(0, 82, 204, 0.18);
}

.btn,
.text-btn {
    border: 0;
    cursor: pointer;
    font-weight: 700;
}

.btn {
    border-radius: 10px;
    padding: 9px 14px;
    font-size: 14px;
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #0062ff);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-strong), var(--primary));
}

.btn-secondary {
    color: #0f172a;
    background: rgba(148, 163, 184, 0.18);
}

.btn-secondary:hover {
    background: rgba(148, 163, 184, 0.28);
}

.btn-ghost {
    color: var(--text-muted);
    background: transparent;
}

.btn-ghost:hover {
    color: var(--text);
    background: rgba(148, 163, 184, 0.12);
}

.text-btn {
    color: var(--primary);
    background: transparent;
    font-size: 13px;
    padding: 0;
}

.text-btn:hover {
    color: var(--primary-strong);
}

.row-actions {
    display: inline-flex;
    gap: 8px;
}

.row-btn {
    border: 0;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    font-size: 13px;
    padding: 0;
}

.row-btn:hover {
    color: var(--primary-strong);
}

.row-btn.danger {
    color: #dc2626;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(2, 6, 23, 0.52);
    padding: 20px;
    z-index: 60;
}

.modal.is-open {
    display: flex;
}

.modal-dialog {
    width: min(520px, 100%);
    max-height: calc(100vh - 40px);
    overflow: auto;
    background: #fff;
    border-radius: 18px;
    border: 1px solid var(--line);
    box-shadow: 0 26px 56px rgba(15, 23, 42, 0.28);
}

.modal-header,
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
}

.modal-header {
    border-bottom: 1px solid var(--line);
}

.modal-header h4 {
    margin: 0;
    font-size: 18px;
}

.modal-body {
    padding: 16px 18px;
}

.modal-footer {
    border-top: 1px solid var(--line);
    justify-content: flex-end;
}

.modal-close {
    border: 0;
    background: rgba(148, 163, 184, 0.18);
    border-radius: 999px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.form-row {
    margin-bottom: 12px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-row label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
}

.form-row.inline {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.switch-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 700;
}

.switch-row input {
    width: auto;
}

.search-dropdown {
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 12px;
}

.search-option {
    width: 100%;
    border: 0;
    background: #fff;
    text-align: left;
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.search-option:hover {
    background: rgba(0, 82, 204, 0.06);
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    padding: 12px 14px;
    background: #111827;
    color: #fff;
    border-radius: 10px;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 180ms ease, transform 180ms ease;
    pointer-events: none;
    z-index: 100;
    font-size: 14px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.hidden {
    display: none !important;
}

@media (max-width: 1240px) {
    .overview-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .app-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 860px) {
    .container {
        width: min(1360px, calc(100% - 24px));
    }

    .overview-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .tabs {
        width: 100%;
        justify-content: space-between;
    }

    .search-row,
    .form-row.inline {
        flex-direction: column;
    }
}

@media (max-width: 560px) {
    .overview-grid {
        grid-template-columns: 1fr;
    }

    .metric-card h2 {
        font-size: 24px;
    }

    .modal {
        padding: 12px;
    }

    .modal-dialog {
        border-radius: 14px;
    }
}
