:root {
    --bg-primary: #0f1923;
    --bg-secondary: #1a2633;
    --bg-panel: #1e2d3d;
    --bg-input: #253545;
    --accent: #4fc3f7;
    --accent-hover: #81d4fa;
    --green: #66bb6a;
    --red: #ef5350;
    --yellow: #ffa726;
    --gray: #78909c;
    --text: #eceff1;
    --text-secondary: #90a4ae;
    --border: #2c3e50;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text);
    min-height: 100vh;
}

.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

header h1 {
    font-size: 1.4em;
    color: var(--accent);
    white-space: nowrap;
}

.tabs {
    display: flex;
    gap: 4px;
}

.tab {
    padding: 8px 20px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
}

.tab:hover { background: var(--bg-panel); color: var(--text); }
.tab.active { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }

main { flex: 1; }

.tab-content { display: none; }
.tab-content.active { display: block; }

.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.panel h2 {
    font-size: 1.1em;
    margin-bottom: 15px;
    color: var(--accent);
}

.add-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
    padding: 12px;
    background: var(--bg-panel);
    border-radius: var(--radius);
}

.stock-form { flex-direction: column; align-items: stretch; }
.stock-form .form-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

label {
    font-size: 0.85em;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
}

input, select {
    padding: 6px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-size: 0.9em;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

input:disabled { opacity: 0.5; }

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

button {
    padding: 6px 16px;
    background: var(--accent);
    color: #000;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    transition: background 0.2s;
}

button:hover { background: var(--accent-hover); }

button.secondary {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
}

button.secondary:hover { background: var(--border); }

button.danger { background: var(--red); color: #fff; }
button.danger:hover { opacity: 0.8; }

button.small {
    padding: 3px 10px;
    font-size: 0.8em;
}

.btn-group { display: flex; gap: 8px; }

/* Monitor cards */
.monitors-list { display: flex; flex-direction: column; gap: 8px; }

.monitor-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-panel);
    border-radius: var(--radius);
    border-left: 3px solid var(--gray);
}

.monitor-card.active { border-left-color: var(--green); }
.monitor-card.inactive { border-left-color: var(--red); }

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.green { background: var(--green); }
.status-dot.red { background: var(--red); }
.status-dot.yellow { background: var(--yellow); }
.status-dot.gray { background: var(--gray); }

.monitor-info { flex: 1; }

.monitor-info .name {
    font-weight: 600;
    font-size: 0.95em;
}

.monitor-info .details {
    font-size: 0.8em;
    color: var(--text-secondary);
    margin-top: 3px;
}

.monitor-info .conditions {
    font-size: 0.8em;
    color: var(--yellow);
    margin-top: 2px;
}

.monitor-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* Autocomplete */
.autocomplete-wrapper {
    position: relative;
    display: inline-block;
}

.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.suggestions.show { display: block; }

.suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.85em;
    border-bottom: 1px solid var(--border);
}

.suggestion-item:hover { background: var(--bg-input); }
.suggestion-item:last-child { border-bottom: none; }

/* Market status */
.market-status {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.market-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-panel);
    border-radius: var(--radius);
    font-size: 0.85em;
}

/* API Keys */
.key-group { margin-bottom: 20px; }
.key-group h3 { font-size: 0.95em; margin-bottom: 10px; color: var(--text-secondary); }

.keys-list { display: flex; flex-direction: column; gap: 6px; }

.key-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-panel);
    border-radius: 4px;
    font-size: 0.85em;
}

.key-item .key-active { color: var(--green); }
.key-item .key-inactive { color: var(--gray); }

/* Log panel */
.log-panel {
    margin-top: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.log-panel h3 {
    font-size: 0.95em;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

.log-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.82em;
}

.log-item:last-child { border-bottom: none; }

.log-item .log-status { flex-shrink: 0; }
.log-item .log-time { color: var(--text-secondary); flex-shrink: 0; width: 70px; }
.log-item .log-source {
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--bg-input);
    color: var(--accent);
    font-size: 0.9em;
    flex-shrink: 0;
}
.log-item .log-title { flex: 1; }

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.panel-desc {
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
}

.panel-desc a { color: var(--accent); text-decoration: none; }

/* Preset buttons */
.preset-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
    padding: 0 12px;
}

.preset-label {
    font-size: 0.8em;
    color: var(--text-secondary);
}

.preset-btn {
    padding: 3px 10px;
    font-size: 0.78em;
    background: var(--bg-input);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
}

.preset-btn:hover { background: var(--border); }

/* Stock selected display */
.stock-selected {
    font-size: 0.85em;
    padding: 6px 12px;
    background: var(--bg-input);
    border-radius: 4px;
    color: var(--accent);
}

/* Auth Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 30px;
    width: 360px;
}

.modal h2 {
    color: var(--accent);
    margin-bottom: 20px;
    text-align: center;
}

#auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#auth-form input {
    width: 100%;
    padding: 10px;
    font-size: 0.95em;
}

#auth-form button {
    width: 100%;
    padding: 10px;
    font-size: 1em;
}

.auth-error {
    color: var(--red);
    font-size: 0.85em;
    min-height: 1.2em;
}

.auth-switch {
    text-align: center;
    font-size: 0.85em;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--accent);
    text-decoration: none;
    margin-left: 4px;
}

/* User info in header */
.user-info {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85em;
    color: var(--text-secondary);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: var(--radius);
    color: #fff;
    font-size: 0.9em;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
.toast.info { background: var(--accent); color: #000; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
    header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .tabs { flex-wrap: wrap; }
    .add-form { flex-direction: column; align-items: stretch; }
    .form-row { flex-direction: column; }
}
