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

:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-hover: #20232f;
    --border: #2a2d3e;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --primary: #6366f1;
    --primary-hover: #5254cc;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --buy: #22c55e;
    --sell: #ef4444;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,.4);
}

html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 14px; line-height: 1.5; }

/* Layout */
.app { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar { width: 240px; min-width: 240px; background: var(--bg-card); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 0; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 20px 16px; border-bottom: 1px solid var(--border); }
.brand-icon { width: 36px; height: 36px; background: var(--primary); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-icon svg { width: 20px; height: 20px; color: #fff; }
.brand-name { font-size: 16px; font-weight: 700; color: var(--text); }
.brand-sub { font-size: 11px; color: var(--text-muted); }
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); color: var(--text-muted); text-decoration: none; transition: background .15s, color .15s; font-size: 14px; font-weight: 500; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: rgba(99,102,241,.15); color: var(--primary); }
.nav-item .icon { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }

/* Main area */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.header { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-bottom: 1px solid var(--border); background: var(--bg-card); }
.header-title h1 { font-size: 20px; font-weight: 700; }
.header-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); transition: background .3s; }
.status-dot.connected { background: var(--success); }
.status-dot.error { background: var(--danger); }
.content { flex: 1; overflow-y: auto; padding: 24px; }

/* Cards */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); }
.mt { margin-top: 20px; }
.mt-sm { margin-top: 8px; }

/* Stats */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.small { font-size: 12px; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 12px 16px; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); border-bottom: 1px solid var(--border); font-weight: 600; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(255,255,255,.02); }
.th-actions { width: 80px; text-align: center; }
.empty-cell { text-align: center; color: var(--text-muted); padding: 40px 16px !important; }

/* Badges */
.symbol-badge { background: rgba(99,102,241,.15); color: var(--primary); padding: 4px 10px; border-radius: 4px; font-size: 12px; font-weight: 600; font-family: monospace; }
.action-badge { padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.action-buy { background: rgba(34,197,94,.15); color: var(--buy); }
.action-sell { background: rgba(239,68,68,.15); color: var(--sell); }
.status-badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.status-done { background: rgba(34,197,94,.12); color: var(--success); }
.status-pending { background: rgba(245,158,11,.12); color: var(--warning); }
.status-badge .icon { width: 12px; height: 12px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); border: none; cursor: pointer; font-size: 14px; font-weight: 500; text-decoration: none; transition: background .15s, opacity .15s; white-space: nowrap; }
.btn:hover { opacity: .9; }
.btn .icon { width: 16px; height: 16px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-sm .icon { width: 14px; height: 14px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); opacity: 1; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg-hover); opacity: 1; }
.btn-danger { background: rgba(239,68,68,.15); color: var(--danger); border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover { background: rgba(239,68,68,.25); opacity: 1; }
.btn-icon { padding: 6px; justify-content: center; }

/* Forms */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text); }
.form-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: 16px; align-items: end; padding: 16px 20px; background: rgba(99,102,241,.05); border-bottom: 1px solid var(--border); }
.form-actions { display: flex; gap: 8px; margin-bottom: 0; }
.flex-2 { flex: 2; }
.input { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; color: var(--text); font-size: 14px; width: 100%; outline: none; transition: border-color .15s; }
.input:focus { border-color: var(--primary); }
.input-prefix { display: flex; align-items: center; position: relative; }
.input-prefix .prefix { position: absolute; left: 12px; color: var(--text-muted); font-size: 14px; }
.input-prefix .input { padding-left: 28px; }
.field-hint { font-size: 12px; color: var(--text-muted); }
.hidden { display: none !important; }

/* Webhook URL */
.webhook-url-box { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; }
.webhook-url-box code { flex: 1; font-family: monospace; font-size: 12px; color: var(--text-muted); word-break: break-all; }
.info-box { background: rgba(99,102,241,.08); border: 1px solid rgba(99,102,241,.2); border-radius: var(--radius); padding: 12px 16px; }
.info-box code { font-size: 12px; color: var(--text-muted); }
.info-box p { margin-bottom: 6px; font-size: 13px; }

/* Settings */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-grid .card:last-child { grid-column: 1 / -1; }
.automation-toggle { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.toggle-label { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.toggle-desc { font-size: 13px; color: var(--text-muted); }
.automation-status { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 600; }
.automation-status .icon { width: 16px; height: 16px; }
.status-enabled { background: rgba(34,197,94,.12); color: var(--success); }
.status-disabled { background: rgba(239,68,68,.1); color: var(--danger); }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 48px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider { position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 26px; transition: .2s; }
.switch-slider::before { content: ''; position: absolute; height: 20px; width: 20px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .switch-slider { background: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translateX(22px); }

/* Symbol URL */
.url-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); text-decoration: none; font-size: 12px; font-family: monospace; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.url-link:hover { color: var(--primary); }
.url-link .icon { width: 12px; height: 12px; flex-shrink: 0; }

/* Toast */
.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; font-size: 13px; box-shadow: 0 4px 20px rgba(0,0,0,.5); animation: slide-in .2s ease; max-width: 320px; display: flex; align-items: center; gap: 10px; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
@keyframes slide-in { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }
