:root {
    --ink: #16212b;
    --muted: #687581;
    --line: #dce3e7;
    --surface: #ffffff;
    --canvas: #f3f6f7;
    --nav: #17252b;
    --nav-soft: #22343b;
    --teal: #087f78;
    --green: #178657;
    --red: #c43d4b;
    --amber: #b87912;
    --blue: #2867a8;
    --radius: 7px;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 14px 16px; color: #dbe7e9; background: var(--nav); }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 24px; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid #557078; border-radius: 6px; color: #fff; font-size: 13px; font-weight: 800; }
.brand strong, .identity strong { display: block; color: #fff; font-size: 14px; }
.brand small, .identity small { display: block; margin-top: 2px; color: #8fa7ae; font-size: 11px; }
.nav-list { display: grid; gap: 5px; }
.nav-item { display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 0 12px; border-radius: 6px; color: #aebfc4; font-size: 14px; }
.nav-item:hover, .nav-item.active { background: var(--nav-soft); color: #fff; }
.nav-item.active { box-shadow: inset 3px 0 var(--teal); }
.sidebar-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding: 16px 8px 0; border-top: 1px solid #30444b; }
.identity { display: flex; align-items: center; gap: 9px; min-width: 0; }
.avatar { flex: 0 0 auto; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #31505a; font-size: 12px; font-weight: 700; }
.icon-button { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 1px solid transparent; border-radius: 6px; color: #aebfc4; background: transparent; cursor: pointer; }
.icon-button:hover { color: #fff; border-color: #496169; }

.main { min-width: 0; }
.topbar { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 32px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 3px 0 0; font-size: 24px; line-height: 1.2; letter-spacing: 0; }
.eyebrow { margin: 0; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.market-pill { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.market-pill span { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px #dff1e9; }
.content { padding: 26px 32px 48px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { padding: 17px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.metric-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.metric-label svg { width: 16px; color: var(--teal); }
.metric strong { display: block; margin-top: 10px; font-size: 24px; letter-spacing: 0; }
.metric small { color: var(--muted); font-size: 11px; }

.grid-two { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .75fr); gap: 18px; margin-bottom: 18px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel + .panel { margin-top: 18px; }
.panel-head { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.panel-title { margin: 0; font-size: 15px; letter-spacing: 0; }
.panel-subtitle { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.panel-body { padding: 18px; }
.panel-body.flush { padding: 0; }

.status-line { display: flex; align-items: center; gap: 10px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #9aa5ac; }
.status-dot.running { background: var(--green); box-shadow: 0 0 0 4px #dff1e9; }
.status-dot.error { background: var(--red); box-shadow: 0 0 0 4px #fae4e7; }
.status-copy strong { display: block; font-size: 14px; }
.status-copy small { color: var(--muted); font-size: 11px; }
.runtime-message { margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.55; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 14px; color: #63717a; background: #f7f9fa; border-bottom: 1px solid var(--line); font-size: 11px; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid #edf1f3; font-size: 12px; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfc; }
.empty { padding: 28px !important; color: var(--muted); text-align: center; }
.positive { color: var(--green); font-weight: 700; }
.negative { color: var(--red); font-weight: 700; }
.badge { display: inline-flex; align-items: center; min-height: 23px; padding: 0 8px; border-radius: 999px; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.badge.open, .badge.active, .badge.running { color: #0e6845; background: #ddf3e8; }
.badge.closed, .badge.stopped { color: #59646c; background: #e9eef0; }
.badge.error, .badge.inactive { color: #a52936; background: #fae3e6; }
.badge.buy { color: #176ea0; background: #e1f0f8; }
.badge.sell { color: #a84b12; background: #faeadf; }

.log-console { height: 320px; overflow: auto; padding: 15px 17px; background: #101a1f; color: #c4d6d9; font: 12px/1.7 Consolas, monospace; white-space: pre-wrap; }
.log-line { display: grid; grid-template-columns: 140px 58px minmax(0, 1fr); gap: 10px; padding: 3px 0; border-bottom: 1px solid #1d2a30; }
.log-time { color: #708b92; }
.log-level { color: #5ac2bc; font-weight: 700; }
.log-level.error { color: #f07b86; }
.log-level.warning { color: #e9b45d; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)); gap: 12px; }
.field { display: grid; gap: 6px; }
.field label { color: var(--muted); font-size: 11px; font-weight: 700; }
.control { min-height: 40px; width: 100%; padding: 8px 10px; color: var(--ink); background: #fff; border: 1px solid #cfd8dc; border-radius: 5px; outline: 0; }
.control:focus { border-color: var(--teal); box-shadow: 0 0 0 3px #dcefed; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 13px; border: 1px solid transparent; border-radius: 5px; font-weight: 700; font-size: 12px; cursor: pointer; }
.button.primary { color: #fff; background: var(--teal); }
.button.secondary { color: var(--ink); background: #fff; border-color: #cfd8dc; }
.button.danger { color: var(--red); background: #fff; border-color: #e5bcc1; }
.button:hover { filter: brightness(.97); }
.notice { margin-bottom: 16px; padding: 11px 13px; border: 1px solid #b8ddd6; border-radius: 5px; color: #176a61; background: #e8f5f2; font-size: 12px; }

.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(380px, .85fr); background: #eef3f4; }
.login-brand { position: relative; display: flex; flex-direction: column; justify-content: flex-end; min-height: 100vh; padding: 56px; color: #fff; background: #17252b; overflow: hidden; }
.login-brand::after { content: ""; position: absolute; inset: 0; background: linear-gradient(145deg, transparent 20%, rgba(8,127,120,.35)); }
.login-brand-content { position: relative; z-index: 1; max-width: 560px; }
.login-brand h1 { margin: 14px 0; max-width: 520px; font-size: 44px; line-height: 1.08; letter-spacing: 0; }
.login-brand p { max-width: 500px; color: #b6c7cb; line-height: 1.6; }
.login-side { display: grid; place-items: center; padding: 28px; background: #fff; }
.login-box { width: min(390px, 100%); }
.login-box h2 { margin: 0 0 7px; font-size: 25px; }
.login-box > p { margin: 0 0 28px; color: var(--muted); font-size: 13px; }
.login-box .field { margin-bottom: 15px; }
.login-box .button { width: 100%; min-height: 44px; margin-top: 5px; }
.login-error { margin-bottom: 16px; padding: 10px 12px; color: #a52936; background: #fae3e6; border-radius: 5px; font-size: 12px; }

@media (max-width: 1020px) {
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-two { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { position: static; width: 100%; height: auto; padding: 12px; }
    .brand { padding: 2px 4px 12px; }
    .nav-list { grid-template-columns: repeat(3, 1fr); }
    .nav-item { justify-content: center; min-height: 40px; padding: 0 8px; }
    .sidebar-footer { display: none; }
    .topbar { min-height: 78px; padding: 16px 18px; }
    .topbar h1 { font-size: 20px; }
    .market-pill { display: none; }
    .content { padding: 16px 14px 34px; }
    .metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
    .metric { padding: 14px; }
    .metric strong { font-size: 20px; }
    .field-row { grid-template-columns: 1fr; }
    .login-page { display: block; background: #fff; }
    .login-brand { min-height: 250px; padding: 28px 24px; justify-content: center; }
    .login-brand h1 { font-size: 30px; }
    .login-side { padding: 34px 22px; }
    .log-line { grid-template-columns: 1fr; gap: 0; }
}
