:root {
    --bg: #0d1117;
    --bg-elevated: #161b22;
    --bg-card: #1a2130;
    --border: #2a3241;
    --text: #e6edf3;
    --text-dim: #8b98a8;
    --gold: #d4a94e;
    --green: #2ecc71;
    --red: #e74c3c;
    --blue: #4a90d9;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

/* ---------- Auth screen ---------- */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
}
.brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 6px; }
.brand-mark {
    background: linear-gradient(135deg, var(--gold), #a8792f);
    color: #1a1a1a;
    font-weight: 700;
    font-size: 20px;
    width: 48px; height: 48px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.brand h1 { font-size: 18px; margin: 0; text-align: center; }
.auth-sub { color: var(--text-dim); text-align: center; font-size: 14px; margin: 4px 0 20px; }
.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-form label { font-size: 13px; color: var(--text-dim); margin-top: 8px; }

/* ---------- Alerts ---------- */
.alert { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.alert-error { background: rgba(231,76,60,0.15); color: #ff8577; border: 1px solid rgba(231,76,60,0.35); }
.alert-success { background: rgba(46,204,113,0.15); color: #7ee8a3; border: 1px solid rgba(46,204,113,0.35); }

/* ---------- Inputs ---------- */
input, select, textarea {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 16px;
    width: 100%;
    margin-bottom: 4px;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold);
}
label { display: block; font-size: 13px; color: var(--text-dim); margin: 12px 0 6px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 12px 18px;
    border-radius: 8px;
    border: none;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn-primary { background: var(--gold); color: #1a1a1a; }
.btn-primary:active { opacity: 0.85; }
.btn-secondary { background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: rgba(231,76,60,0.15); color: #ff8577; border: 1px solid rgba(231,76,60,0.35); }
.btn-block { width: 100%; margin-top: 18px; }
.btn-sm { padding: 8px 12px; font-size: 13px; }

/* ---------- App shell ---------- */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-logout { color: var(--text-dim); font-size: 20px; text-decoration: none; padding: 4px 8px; }

.app-main {
    flex: 1;
    padding: 16px;
    padding-bottom: 90px;
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
}

.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    display: flex;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    padding: 6px 0 max(6px, env(safe-area-inset-bottom));
    z-index: 10;
}
.nav-item {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 11px;
    padding: 6px 0;
}
.nav-item.active { color: var(--gold); }
.nav-icon { font-size: 20px; }

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}
.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 12px;
}

/* ---------- Row / grid helpers ---------- */
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.direction-toggle { display: flex; gap: 8px; margin-top: 4px; }
.direction-toggle button {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-dim);
    font-weight: 600;
    cursor: pointer;
}
.direction-toggle button.active.long { background: rgba(46,204,113,0.18); color: var(--green); border-color: var(--green); }
.direction-toggle button.active.short { background: rgba(231,76,60,0.18); color: var(--red); border-color: var(--red); }

/* ---------- Result panel ---------- */
.result-panel {
    background: linear-gradient(135deg, rgba(212,169,78,0.12), rgba(212,169,78,0.03));
    border: 1px solid rgba(212,169,78,0.4);
    border-radius: var(--radius);
    padding: 18px;
    text-align: center;
    margin-top: 4px;
}
.result-lot {
    font-size: 34px;
    font-weight: 700;
    color: var(--gold);
    line-height: 1.1;
}
.result-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.result-details {
    display: flex;
    justify-content: space-around;
    margin-top: 14px;
    font-size: 13px;
    color: var(--text-dim);
}
.result-details b { color: var(--text); display: block; font-size: 15px; margin-top: 2px; }
.warning-text { color: #ffb454; font-size: 12px; margin-top: 10px; }

/* ---------- List rows (accounts / history) ---------- */
.list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
.list-row-main { flex: 1; }
.list-row-title { font-weight: 600; font-size: 15px; }
.list-row-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 20px;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-prop { background: rgba(74,144,217,0.18); color: var(--blue); }
.badge-personal { background: rgba(139,152,168,0.18); color: var(--text-dim); }

.empty-state { text-align: center; color: var(--text-dim); padding: 40px 20px; font-size: 14px; }

.top-actions { display: flex; justify-content: flex-end; margin-bottom: 12px; }

.instrument-settings-row {
    display: grid;
    grid-template-columns: 70px 1fr 1fr 1fr;
    gap: 8px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.instrument-settings-row:last-child { border-bottom: none; }
.instrument-settings-row input { padding: 8px; font-size: 13px; margin-bottom: 0; }
.instrument-settings-row .sym { font-weight: 600; }

a { color: var(--gold); }
