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

:root {
    --system-blue: #007aff;
    --system-green: #34c759;
    --system-red: #ff3b30;
    --system-orange: #ff9500;
    --system-indigo: #5856d6;
    --system-gray: #8e8e93;
    --system-light-gray: #f2f2f7;
    --system-background: #f5f5f7;
    --card-background: rgba(255, 255, 255, 0.95);
    --text-primary: #1c1c1e;
    --text-secondary: #636366;
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--system-background);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 24px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
}

header {
    background: var(--card-background);
    padding: 28px;
    border-radius: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
}

header h1 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.api-config {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.api-config input,
input[type="text"],
input[type="number"],
input[type="password"],
textarea {
    flex: 1;
    min-width: 150px;
    padding: 12px 16px;
    background: var(--system-light-gray);
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: 15px;
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s ease;
}

.api-config input:focus,
input:focus,
textarea:focus {
    background: #fff;
    border-color: var(--system-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

textarea {
    width: 100%;
    resize: vertical;
    font-family: inherit;
}

button {
    padding: 12px 22px;
    background: var(--system-blue);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: transform 0.15s ease, background 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.25);
}

button:hover {
    background: #0062cc;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 122, 255, 0.32);
}

button:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--system-indigo);
    box-shadow: 0 2px 8px rgba(88, 86, 214, 0.25);
}

.btn-primary:hover {
    background: #4644b8;
}

.btn-success {
    background: var(--system-green);
    box-shadow: 0 2px 8px rgba(52, 199, 89, 0.25);
}

.btn-success:hover {
    background: #2cb14b;
}

.btn-warning {
    background: var(--system-orange);
    color: white;
    box-shadow: 0 2px 8px rgba(255, 149, 0, 0.25);
}

.btn-warning:hover {
    background: #e08500;
}

.btn-danger {
    background: var(--system-red);
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.25);
}

.btn-danger:hover {
    background: #d63029;
}

.dashboard {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.section {
    background: var(--card-background);
    padding: 28px;
    border-radius: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.section h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    letter-spacing: -0.3px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.card {
    background: #fff;
    padding: 24px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.card h3 {
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 18px;
    font-weight: 700;
}

.input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: end;
}

.input-group input {
    flex: 1;
    min-width: 140px;
}

.data-display {
    background: var(--system-light-gray);
    padding: 18px;
    border-radius: 16px;
    min-height: 100px;
    max-height: 420px;
    overflow-y: auto;
    font-size: 14px;
}

.data-display pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: "SF Mono", "Menlo", "Monaco", "Courier New", monospace;
    font-size: 13px;
    color: var(--text-primary);
}

.data-display p {
    color: var(--text-secondary);
    font-style: italic;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.metric-box {
    background: linear-gradient(145deg, #ffffff 0%, #f9f9fb 100%);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 18px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.metric-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 600;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

.positions-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.positions-table th,
.positions-table td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.positions-table th {
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

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

.positions-table tr:hover td {
    background: rgba(0, 0, 0, 0.015);
}

.signal-buy {
    color: var(--system-green);
    font-weight: 700;
}

.signal-sell {
    color: var(--system-red);
    font-weight: 700;
}

.signal-hold {
    color: var(--system-gray);
    font-weight: 700;
}

.empty {
    color: var(--text-secondary);
    font-style: italic;
}

.error {
    color: var(--system-red);
    font-weight: 700;
}

.field-description {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 16px;
    line-height: 1.5;
}

.field-with-label {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 200px;
    margin-bottom: 12px;
}

.field-with-label label {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    font-size: 14px;
}

.field-with-label .help-text {
    color: var(--text-secondary);
    font-size: 12px;
    margin-top: 6px;
    line-height: 1.4;
    font-style: normal;
}

input[type="checkbox"] {
    accent-color: var(--system-blue);
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
}

@media (max-width: 768px) {
    body {
        padding: 16px;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .input-group {
        flex-direction: column;
    }

    .api-config {
        flex-direction: column;
        align-items: stretch;
    }

    header h1 {
        font-size: 26px;
    }
}
