/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: transparent;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    padding: 30px;
    max-width: 600px;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    font-size: 28px;
    color: #333;
}

/* Controls */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

label {
    font-weight: 600;
    color: #555;
    font-size: 14px;
}

select {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: border-color 0.3s;
    background: white;
}

select:hover {
    border-color: #667eea;
}

select:focus {
    outline: none;
    border-color: #667eea;
}

.btn-refresh {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
}

.btn-refresh:hover {
    background: #5568d3;
}

.btn-refresh:active {
    transform: scale(0.95);
}

.btn-refresh:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-refresh svg {
    transition: transform 0.6s;
}

.btn-refresh.refreshing svg {
    animation: rotate 1s linear infinite;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Messages */
.error-message {
    background: #fee;
    border: 2px solid #fcc;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 20px;
    color: #c33;
    font-size: 14px;
}

.last-updated {
    text-align: center;
    font-size: 12px;
    color: #888;
    margin-bottom: 15px;
}

.chart-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.chart-tab {
    border: 1px solid #d3d8df;
    background: #f6f8fb;
    color: #334155;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.chart-tab.active {
    background: #0f766e;
    color: #fff;
    border-color: #0f766e;
}

/* Chart Container */
.chart-container {
    min-height: 320px;
    position: relative;
}

.trend-container {
    min-height: 320px;
}

.trend-header h3 {
    font-size: 18px;
    color: #1f2937;
    margin-bottom: 3px;
}

.trend-header p {
    color: #6b7280;
    font-size: 12px;
    margin-bottom: 12px;
}

.trend-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    margin-bottom: 12px;
}

.trend-actions {
    margin-bottom: 10px;
}

.btn-show-all {
    background: #0f766e;
    color: #fff;
    border: none;
    border-radius: 7px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.btn-show-all:disabled {
    background: #b8c2cc;
    cursor: not-allowed;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #374151;
    border: 1px solid #d6dce3;
    background: #ffffff;
    border-radius: 999px;
    padding: 4px 8px;
    cursor: pointer;
}

.legend-item.active {
    border-color: #0f766e;
    background: #e7f7f4;
}

.legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.trend-chart-wrap {
    border: 1px solid #e5e7eb;
    border-left: none;
    border-radius: 0 10px 10px 0;
    background: #fff;
    overflow: auto;
    flex: 1;
}

.trend-chart-layout {
    display: flex;
    align-items: stretch;
}

.trend-y-axis-wrap {
    width: 64px;
    border: 1px solid #e5e7eb;
    border-right: none;
    border-radius: 10px 0 0 10px;
    background: #fff;
    flex: 0 0 64px;
}

.trend-y-axis-svg {
    display: block;
}

.trend-svg {
    width: 100%;
    height: auto;
    display: block;
}

.axis-line {
    stroke: #9ca3af;
    stroke-width: 1;
}

.grid-line {
    stroke: #eceff3;
    stroke-width: 1;
}

.hover-line {
    stroke: #475569;
    stroke-width: 1;
    stroke-dasharray: 4 3;
    pointer-events: none;
}

.hover-time-bg {
    fill: #111827;
    opacity: 0.9;
    pointer-events: none;
}

.hover-time-label {
    fill: #ffffff;
    font-size: 10px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    pointer-events: none;
}

.hover-power-bg {
    fill: #0f766e;
    opacity: 0.92;
    pointer-events: none;
}

.hover-power-label {
    fill: #ffffff;
    font-size: 10px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    pointer-events: none;
}

.axis-label {
    fill: #6b7280;
    font-size: 11px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.axis-title {
    fill: #374151;
    font-size: 12px;
    font-weight: 600;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 16px;
}

/* Currency Chart */
.currency-chart {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.currency-row {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.currency-row:hover {
    background-color: #f5f5f5;
}

.currency-label {
    font-weight: 700;
    font-size: 14px;
    color: #333;
    width: 40px;
    text-align: left;
    flex-shrink: 0;
}

.bar-container {
    flex: 1;
    height: 24px;
    background: #e8e8e8;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.bar {
    height: 100%;
    background: #4caf50;
    border-radius: 4px;
    transition: width 0.6s ease-out;
    position: relative;
}

.strength-value {
    font-size: 11px;
    font-weight: 600;
    color: #333;
    width: 40px;
    text-align: right;
    flex-shrink: 0;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 20px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .control-group {
        justify-content: space-between;
    }
}

/* Calculation Details */
.calculation-details {
    margin-top: 30px;
    padding: 20px;
    background: #f9f9f9;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.details-header h3 {
    font-size: 18px;
    color: #333;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}

.close-btn:hover {
    background-color: #e0e0e0;
    color: #333;
}

.details-content {
    font-size: 14px;
}

.calc-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.summary-item {
    background: white;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.summary-item .label {
    font-weight: 600;
    color: #666;
}

.summary-item .value {
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

.calc-info {
    background: white;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    margin-bottom: 20px;
}

.calc-info p {
    margin: 8px 0;
    color: #555;
    line-height: 1.6;
}

.pairs-table {
    margin-bottom: 20px;
}

.pairs-table h4 {
    font-size: 16px;
    margin-bottom: 10px;
    color: #333;
}

.pairs-table table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 6px;
    overflow: hidden;
    font-size: 13px;
}

.pairs-table thead {
    background: #667eea;
    color: white;
}

.pairs-table th {
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
}

.pairs-table td {
    padding: 8px;
    border-top: 1px solid #e0e0e0;
}

.pairs-table tr:hover {
    background: #f5f5f5;
}

.pair-name {
    font-weight: 600;
    color: #333;
}

.position {
    color: #666;
    font-size: 12px;
    text-transform: capitalize;
}

.positive {
    color: #4caf50;
    font-weight: 600;
}

.negative {
    color: #f44336;
    font-weight: 600;
}

.movement-icon {
    font-size: 14px;
}

.movement-icon.up {
    color: #4caf50;
}

.movement-icon.down {
    color: #f44336;
}

.movement-icon.flat {
    color: #999;
}

.calc-explanation {
    background: #fff9e6;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #ffe4a3;
}

.calc-explanation h4 {
    font-size: 14px;
    margin-bottom: 10px;
    color: #333;
}

.calc-explanation ul {
    margin: 0;
    padding-left: 20px;
}

.calc-explanation li {
    margin: 6px 0;
    color: #555;
    line-height: 1.6;
}

@media (max-width: 800px) {
    .pairs-table {
        overflow-x: auto;
    }
    
    .pairs-table table {
        font-size: 11px;
    }
    
    .pairs-table th,
    .pairs-table td {
        padding: 6px 4px;
    }
}
