/* Signal Reader admin dashboard — plain CSS, no build step. */

:root {
    --bg: #0b0f16;
    --bg-elevated: #121826;
    --bg-input: #0e141f;
    --border: #222c3d;
    --border-strong: #2f3b52;
    --text: #e6ecf5;
    --text-dim: #8d9bb2;
    --text-faint: #5d6b81;
    --accent: #4f8cff;
    --accent-dim: #24365c;
    --win: #21c07a;
    --loss: #f2585b;
    --warn: #e8a33d;
    --neutral: #7b8aa3;
    --radius: 10px;
    --radius-sm: 7px;
    --shadow: 0 12px 32px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: Inter, -apple-system, "Segoe UI", Tahoma, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; }

/* ------------------------------------------------------------------ topbar */

.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    padding: 16px 28px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar__brand h1 { font-size: 17px; letter-spacing: -.2px; }

.topbar__brand p {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--text-faint);
}

.topbar__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--win);
    box-shadow: 0 0 0 4px rgba(33, 192, 122, .16);
}

.topbar__status {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-inline-start: auto;
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-input);
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
}

.pill b { color: var(--text); font-weight: 500; }
.pill--ok    { border-color: rgba(33, 192, 122, .4); }
.pill--stale { border-color: rgba(232, 163, 61, .45); color: var(--warn); }
.pill--off   { border-color: rgba(242, 88, 91, .4); color: var(--loss); }

/* ------------------------------------------------------------- form pieces */

.btn {
    padding: 8px 15px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    transition: background .12s, border-color .12s;
}

.btn:hover { background: #172033; border-color: #3b4a66; }

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    font-weight: 500;
}

.btn--primary:hover { background: #3f7cf0; border-color: #3f7cf0; }
.btn--ghost { background: transparent; }

.switch {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: var(--text-dim);
    cursor: pointer;
    user-select: none;
}

.switch input { accent-color: var(--accent); width: 15px; height: 15px; }

/* -------------------------------------------------------------------- page */

.page {
    max-width: 1560px;
    margin: 0 auto;
    padding: 22px 28px 60px;
}

/* ------------------------------------------------------------------- cards */

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}

.card {
    padding: 14px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.card__label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-faint);
}

.card__value {
    margin-top: 6px;
    font-size: 23px;
    font-weight: 600;
    letter-spacing: -.5px;
    font-variant-numeric: tabular-nums;
}

.card__hint {
    margin-top: 3px;
    font-size: 12px;
    color: var(--text-dim);
}

.is-win  { color: var(--win); }
.is-loss { color: var(--loss); }
.is-flat { color: var(--neutral); }

/* -------------------------------------------------------------------- tabs */

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: -1px;
}

.tab {
    padding: 9px 17px;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    background: transparent;
    color: var(--text-dim);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.tab:hover { color: var(--text); }

.tab.is-active {
    background: var(--bg-elevated);
    border-color: var(--border);
    color: var(--text);
    font-weight: 500;
}

/* ------------------------------------------------------------------- panel */

.panel {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 0 var(--radius) var(--radius) var(--radius);
    overflow: hidden;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 128px;
}

.field--grow { flex: 1 1 200px; }

.field--actions {
    flex-direction: row;
    align-items: flex-end;
    gap: 8px;
    margin-inline-start: auto;
}

.field label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-faint);
}

.field select,
.field input {
    padding: 8px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font: inherit;
    font-size: 13px;
}

.field select:focus,
.field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.field [hidden] { display: none; }

/* ------------------------------------------------------------------- table */

.table-wrap { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-faint);
    background: #0f1420;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 11px 14px;
    border-bottom: 1px solid rgba(34, 44, 61, .6);
    vertical-align: middle;
    white-space: nowrap;
}

.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: rgba(79, 140, 255, .06); }
.table td.num { font-variant-numeric: tabular-nums; text-align: right; }
.table td.wrap { white-space: normal; min-width: 320px; max-width: 620px; }

.mono {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 12.5px;
}

.empty {
    padding: 44px;
    text-align: center;
    color: var(--text-faint);
}

/* ------------------------------------------------------------------- chips */

.chip {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.chip--long      { background: rgba(33, 192, 122, .16); color: var(--win); }
.chip--short     { background: rgba(242, 88, 91, .16);  color: var(--loss); }
.chip--win       { background: rgba(33, 192, 122, .16); color: var(--win); }
.chip--loss      { background: rgba(242, 88, 91, .16);  color: var(--loss); }
.chip--breakeven { background: rgba(123, 138, 163, .18); color: var(--neutral); }
.chip--open      { background: rgba(79, 140, 255, .16); color: var(--accent); }
.chip--pending   { background: rgba(232, 163, 61, .16); color: var(--warn); }
.chip--closed    { background: rgba(123, 138, 163, .18); color: var(--neutral); }
.chip--cancelled { background: rgba(123, 138, 163, .12); color: var(--text-faint); }
.chip--untracked { background: rgba(232, 163, 61, .12); color: var(--warn); }

.tp-track {
    display: inline-flex;
    gap: 3px;
    vertical-align: middle;
}

.tp-track i {
    width: 7px;
    height: 14px;
    border-radius: 2px;
    background: #26314513;
    border: 1px solid var(--border-strong);
}

.tp-track i.is-hit { background: var(--win); border-color: var(--win); }

.warn-dot {
    display: inline-block;
    margin-inline-start: 6px;
    color: var(--warn);
    cursor: help;
}

/* ------------------------------------------------------------------- pager */

.pager {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-dim);
}

.pager__spacer { margin-inline-start: auto; }

/* ------------------------------------------------------------------ drawer */

.drawer { position: fixed; inset: 0; z-index: 50; }

.drawer__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 7, 12, .66);
}

.drawer__panel {
    position: absolute;
    inset-block: 0;
    inset-inline-end: 0;
    width: min(680px, 100%);
    display: flex;
    flex-direction: column;
    background: var(--bg-elevated);
    border-inline-start: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.drawer__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.drawer__header h2 { font-size: 16px; margin-inline-end: auto; }

.drawer__body {
    padding: 20px;
    overflow-y: auto;
}

.section { margin-bottom: 26px; }

.section > h3 {
    margin-bottom: 10px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-faint);
}

.kv {
    display: grid;
    grid-template-columns: minmax(140px, auto) 1fr;
    gap: 7px 16px;
    font-size: 13px;
}

.kv dt { color: var(--text-dim); }

.kv dd {
    margin: 0;
    font-variant-numeric: tabular-nums;
}

.raw {
    margin: 0;
    padding: 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 12.5px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 340px;
    overflow: auto;
}

.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    border-inline-start: 2px solid var(--border);
}

.timeline li {
    position: relative;
    padding: 0 0 16px 18px;
}

.timeline li::before {
    content: "";
    position: absolute;
    inset-inline-start: -6px;
    top: 5px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--neutral);
}

.timeline li[data-type="target_hit"]::before   { background: var(--win); }
.timeline li[data-type="stop_hit"]::before     { background: var(--loss); }
.timeline li[data-type="entry_filled"]::before { background: var(--accent); }
.timeline li[data-type="stop_moved"]::before   { background: var(--warn); }

.timeline b { font-size: 13px; }

.timeline time {
    display: block;
    font-size: 11.5px;
    color: var(--text-faint);
}

.timeline p { margin: 3px 0 0; font-size: 12.5px; color: var(--text-dim); }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }

.tag {
    padding: 3px 9px;
    border: 1px solid rgba(232, 163, 61, .4);
    border-radius: var(--radius-sm);
    background: rgba(232, 163, 61, .1);
    color: var(--warn);
    font-size: 11.5px;
}

@media (max-width: 720px) {
    .topbar, .page { padding-inline: 16px; }
    .topbar__status { order: 3; width: 100%; margin-inline-start: 0; }
    .field--actions { margin-inline-start: 0; width: 100%; }
}

/* ------------------------------------------------------------------- login */

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: min(400px, 100%);
    padding: 28px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.login-card__brand { margin-bottom: 22px; }

.login-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-form label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-faint);
}

.login-form input {
    padding: 14px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font: inherit;
    font-size: 22px;
    letter-spacing: .35em;
    text-align: center;
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.login-form .btn { margin-top: 10px; width: 100%; padding: 11px; }

.login-error {
    margin: 0 0 16px;
    padding: 10px 12px;
    border: 1px solid rgba(242, 88, 91, .4);
    border-radius: var(--radius-sm);
    background: rgba(242, 88, 91, .1);
    color: var(--loss);
    font-size: 13px;
}
