* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0f1117;
    color: #e0e0e0;
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 200px;
    min-width: 200px;
    background: #161b22;
    border-right: 1px solid #21262d;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-size: 16px;
    font-weight: 600;
    color: #f0f6fc;
    border-bottom: 1px solid #21262d;
}

.sidebar-menu {
    flex: 1;
    padding: 12px 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: #8b949e;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    color: #f0f6fc;
    background: #1c2128;
}

.nav-link.active {
    color: #f0f6fc;
    background: #1c2128;
    border-left-color: #58a6ff;
}

.nav-link .icon {
    width: 20px;
    margin-right: 10px;
    text-align: center;
    font-size: 15px;
}

/* Main content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
}

.page-header {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 600;
    color: #f0f6fc;
}

.page-header p {
    margin-top: 0;
}

.page-header .desc {
    flex: 1;
}

.block-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.block-info-label {
    color: #484f58;
    margin-left: 12px;
}

.block-info-value {
    color: #8b949e;
    font-family: monospace;
}

.page-header p {
    font-size: 13px;
    color: #8b949e;
    margin-top: 4px;
}

/* Stats cards */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 8px;
    padding: 16px 20px;
}

.stat-card .label {
    font-size: 12px;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .value {
    font-size: 24px;
    font-weight: 700;
    margin-top: 4px;
}

/* Table toolbar */
.table-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    position: relative;
}

.csv-export-btn {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 6px;
    color: #8b949e;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
}

.csv-export-btn:hover {
    background: #1c2128;
    color: #f0f6fc;
}

.limit-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.limit-label {
    font-size: 12px;
    color: #8b949e;
}

.limit-slider {
    -webkit-appearance: none;
    width: 140px;
    height: 4px;
    background: #21262d;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.limit-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: #c9d1d9;
    border: 2px solid #8b949e;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.limit-slider::-webkit-slider-thumb:hover {
    background: #f0f6fc;
    border-color: #c9d1d9;
}

.limit-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: #c9d1d9;
    border: 2px solid #8b949e;
    border-radius: 50%;
    cursor: pointer;
}

.limit-slider::-moz-range-track {
    background: #21262d;
    height: 4px;
    border-radius: 2px;
    border: none;
}

.limit-value {
    font-size: 12px;
    color: #8b949e;
    font-family: monospace;
    min-width: 24px;
    text-align: center;
}

.col-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 6px;
    color: #8b949e;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
}

.col-toggle-btn:hover {
    background: #1c2128;
    color: #f0f6fc;
}

.preset-wrapper {
    position: relative;
}

.preset-active {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 6px;
    color: #8b949e;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
}

.preset-active:hover {
    background: #1c2128;
    color: #f0f6fc;
}

.preset-list {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: #1c2128;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 4px;
    z-index: 999;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    min-width: 140px;
}

.preset-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: 4px;
    color: #c9d1d9;
    font-size: 12px;
    cursor: pointer;
}

.preset-item:hover {
    background: #21262d;
}

.preset-item-active {
    background: #1f3a5f;
    color: #58a6ff;
}

.preset-item-del {
    color: #484f58;
    font-size: 14px;
    padding: 0 2px;
    cursor: pointer;
}

.preset-item-del:hover {
    color: #f85149;
}

.col-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    margin-bottom: 4px;
    border-bottom: 1px solid #21262d;
    font-size: 11px;
    color: #484f58;
}

.save-preset-btn {
    padding: 3px 8px;
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 4px;
    color: #8b949e;
    font-size: 11px;
    cursor: pointer;
}

.save-preset-btn:hover {
    background: #30363d;
    color: #f0f6fc;
}

.col-panel {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: #1c2128;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 8px;
    z-index: 999;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    min-width: 140px;
}

.col-panel label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    color: #c9d1d9;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
}

.col-panel label:hover {
    background: #21262d;
}

.col-panel input[type="checkbox"] {
    accent-color: #58a6ff;
}

.col-item {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: grab;
}

.col-item:active {
    cursor: grabbing;
}

.col-drag-handle {
    color: #484f58;
    margin-right: 4px;
    font-size: 12px;
    user-select: none;
}

/* Table */
.table-wrapper {
    overflow-x: auto;
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    background: #0d1117;
    padding: 10px 16px;
    text-align: left;
    font-weight: 600;
    color: #8b949e;
    border-bottom: 1px solid #21262d;
    white-space: nowrap;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    user-select: none;
}

.sort-arrow {
    font-size: 10px;
    opacity: 0.5;
}

td {
    padding: 10px 16px;
    border-bottom: 1px solid #21262d;
    white-space: nowrap;
    color: #c9d1d9;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background: #1c2128;
}

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

.text-muted {
    color: #484f58;
    font-size: 12px;
}

.text-green {
    color: #3fb950;
}

.text-red {
    color: #f85149;
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.tag-ok {
    background: #12261e;
    color: #3fb950;
}

.tag-timeout {
    background: #2d1414;
    color: #f85149;
}

.link {
    color: #58a6ff;
    text-decoration: none;
}

.link:hover {
    text-decoration: underline;
}

.de-price-cell {
    cursor: pointer;
    border-bottom: 1px dashed #484f58;
}

.de-price-new {
    color: #d73a49;
}

.tooltip {
    position: fixed;
    background: #1c2128;
    border: 1px solid #30363d;
    color: #c9d1d9;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-family: monospace;
    white-space: nowrap;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    pointer-events: none;
}

.no-data {
    text-align: center;
    padding: 40px;
    color: #484f58;
}

/* Chart placeholder */
.chart-box {
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
    min-height: 300px;
}

.chart-box h3 {
    font-size: 14px;
    color: #f0f6fc;
    margin-bottom: 16px;
}

.data-source-trigger {
    display: inline-block;
    font-size: 16px;
    color: #58a6ff;
    cursor: pointer;
    margin-left: 6px;
    vertical-align: middle;
}

.data-source-trigger:hover {
    color: #79c0ff;
}

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-box {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    width: 780px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #21262d;
}

.modal-header h2 {
    font-size: 16px;
    color: #f0f6fc;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: #8b949e;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
}

.modal-close:hover {
    color: #f0f6fc;
}

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

.info-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-bottom: 16px;
    table-layout: fixed;
}

.info-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8b949e;
    border-bottom: 1px solid #21262d;
    background: #0d1117;
}

.info-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #21262d;
    color: #c9d1d9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
}

.info-table td:first-child code {
    background: #1c2128;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: #79c0ff;
}

.info-table td:nth-child(2) {
    white-space: nowrap;
    color: #58a6ff;
    font-family: monospace;
}

.info-note {
    font-size: 12px;
    color: #8b949e;
    padding: 8px 12px;
    background: #1c2128;
    border-radius: 6px;
    border-left: 3px solid #58a6ff;
}

.section-label {
    font-size: 14px;
    font-weight: 600;
    color: #f0f6fc;
    margin-bottom: 8px;
}

.account-row {
    cursor: pointer;
}

.account-row.selected {
    background: #1f3a5f;
}

.account-row.selected td:first-child {
    box-shadow: inset 3px 0 0 #58a6ff;
}

.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    margin-bottom: 8px;
    background: #161b22;
    border: 1px solid #21262d;
    border-radius: 6px;
    font-size: 12px;
    color: #8b949e;
}

.filter-bar .filter-clear {
    color: #58a6ff;
    text-decoration: none;
    font-size: 12px;
}

.filter-bar .filter-clear:hover {
    color: #79c0ff;
    text-decoration: underline;
}
