:root {
    color-scheme: light;
    --ink: #17202a;
    --muted: #657184;
    --line: #dbe2ea;
    --panel: #ffffff;
    --canvas: #f3f6f8;
    --nav: #101820;
    --nav-soft: #1d2a34;
    --teal: #0f766e;
    --blue: #2563eb;
    --amber: #b7791f;
    --red: #b42318;
    --green: #15803d;
    --shadow: 0 18px 45px rgba(16, 24, 32, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--canvas);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 15px;
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.auth-page .app-shell {
    display: block;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 18px;
    background: var(--nav);
    color: #f7fafc;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 6px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #f3c969;
    color: #111827;
    font-weight: 800;
}

.brand strong,
.sidebar-card strong {
    display: block;
    font-size: 16px;
}

.brand span,
.sidebar-card span,
.sidebar-card small {
    display: block;
    color: #a8b3bf;
    font-size: 12px;
    margin-top: 3px;
}

.side-nav {
    display: grid;
    gap: 5px;
}

.side-nav a {
    border-radius: 8px;
    padding: 11px 12px;
    color: #d8e0e7;
    font-weight: 650;
}

.side-nav a:hover,
.side-nav a.active {
    background: var(--nav-soft);
    color: #ffffff;
}

.sidebar-card {
    margin-top: auto;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
}

.main-content {
    min-width: 0;
    padding: 26px;
}

.auth-page .main-content {
    max-width: 1120px;
    margin: 0 auto;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--teal);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 8px;
    font-size: 30px;
    line-height: 1.15;
}

h2 {
    margin-bottom: 0;
    font-size: 17px;
}

h3 {
    margin-bottom: 12px;
    font-size: 15px;
}

.subtitle {
    margin-bottom: 0;
    color: var(--muted);
    max-width: 760px;
}

.top-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    border-radius: 999px;
    padding: 6px 11px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
    border: 1px solid transparent;
}

.badge-good {
    color: #075e3a;
    background: #dcfce7;
    border-color: #b7efc5;
}

.badge-warn {
    color: #7a4a00;
    background: #fff4d6;
    border-color: #f3dc9c;
}

.badge-danger {
    color: #7a1a12;
    background: #fee4e2;
    border-color: #f6b4ad;
}

.badge-muted {
    color: #475467;
    background: #eef2f6;
    border-color: #d9e1ea;
}

.badge-info {
    color: #1d4ed8;
    background: #dbeafe;
    border-color: #bfdbfe;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(330px, 0.75fr);
    gap: 18px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.metric {
    min-height: 128px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.metric span,
.field-hint,
.muted {
    color: var(--muted);
}

.metric strong {
    display: block;
    margin: 14px 0 8px;
    font-size: 26px;
    line-height: 1;
}

.metric small {
    color: var(--muted);
}

.metric-good {
    border-top: 4px solid var(--green);
}

.metric-warn {
    border-top: 4px solid var(--amber);
}

.metric-danger {
    border-top: 4px solid var(--red);
}

.metric-info {
    border-top: 4px solid var(--blue);
}

.panel,
.auth-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel {
    margin-bottom: 18px;
    overflow: hidden;
}

.panel-head {
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}

.panel-head span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
}

.panel-body {
    padding: 20px;
}

.code-panel {
    margin: 0;
    padding: 18px 20px;
    max-height: 520px;
    overflow: auto;
    background: #0f1720;
    color: #d8f3dc;
    font-family: "Cascadia Mono", Consolas, monospace;
    font-size: 12px;
    line-height: 1.55;
}

.details-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    overflow: hidden;
}

.details-panel summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0 14px;
    cursor: pointer;
    color: #334155;
    font-weight: 800;
}

.details-panel .code-panel {
    border-top: 1px solid var(--line);
    box-shadow: none;
}

.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    padding: 10px 15px;
    background: var(--ink);
    color: #ffffff;
    font-weight: 800;
    cursor: pointer;
}

.button-ghost {
    background: #ffffff;
    color: var(--ink);
    border: 1px solid var(--line);
}

.button-danger {
    background: var(--red);
}

.button-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-row {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    font-weight: 800;
}

input,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid #cfd8e3;
    border-radius: 8px;
    padding: 10px 12px;
    background: #ffffff;
    color: var(--ink);
    font: inherit;
}

input:focus,
select:focus {
    outline: 3px solid rgba(37, 99, 235, 0.14);
    border-color: var(--blue);
}

.notice {
    display: grid;
    gap: 4px;
    padding: 14px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid;
}

.notice-info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e3a8a;
}

.notice-good {
    background: #ecfdf3;
    border-color: #b7efc5;
    color: #075e3a;
}

.notice-warn {
    background: #fffbeb;
    border-color: #fde68a;
    color: #7a4a00;
}

.notice-danger {
    background: #fff1f0;
    border-color: #fecaca;
    color: #7a1a12;
}

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 11px 12px;
    text-align: left;
    font-size: 13px;
    white-space: nowrap;
}

th {
    background: #f8fafc;
    color: #475467;
    font-weight: 850;
}

.auth-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 460px;
    gap: 24px;
    align-items: stretch;
}

.auth-hero,
.auth-card {
    min-height: 520px;
}

.auth-hero {
    border-radius: 8px;
    padding: 32px;
    background: #101820;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}

.auth-hero h2 {
    max-width: 620px;
    font-size: 34px;
    line-height: 1.15;
}

.auth-hero p {
    color: #d8e0e7;
    max-width: 620px;
}

.auth-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.auth-stats div {
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.06);
}

.auth-stats strong {
    display: block;
    font-size: 20px;
}

.auth-stats span {
    color: #a8b3bf;
    font-size: 12px;
}

.auth-card {
    padding: 24px;
}

.stack {
    display: grid;
    gap: 18px;
}

.quote-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.quote-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: #ffffff;
}

.trade-desk {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(340px, 0.55fr);
    gap: 18px;
}

.session-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.session-item,
.trade-card,
.rule-card,
.empty-state {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.session-item {
    padding: 14px;
}

.session-item span,
.trade-card span,
.rule-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
}

.session-item strong {
    display: block;
    margin-top: 8px;
    font-size: 18px;
}

.chart-panel {
    padding: 18px 20px 22px;
    background: #fbfdff;
}

.chart-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.chart-toolbar strong {
    display: block;
    font-size: 17px;
}

.chart-toolbar span {
    color: var(--muted);
    font-size: 13px;
}

.candle-stage {
    position: relative;
    height: 300px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(#edf2f7 1px, transparent 1px) 0 0 / 100% 20%,
        linear-gradient(90deg, #edf2f7 1px, transparent 1px) 0 0 / 12.5% 100%,
        #ffffff;
    overflow: hidden;
}

.candle-track {
    position: absolute;
    inset: 18px 14px 28px;
    display: flex;
    align-items: stretch;
    gap: 5px;
}

.candle {
    position: relative;
    flex: 1;
    min-width: 5px;
}

.candle .wick {
    position: absolute;
    left: 50%;
    width: 1px;
    transform: translateX(-50%);
    background: #64748b;
    border-radius: 99px;
}

.candle .body {
    position: absolute;
    left: 50%;
    width: min(16px, 64%);
    min-height: 3px;
    transform: translateX(-50%);
    border-radius: 3px;
}

.candle.up .body {
    background: #16a34a;
}

.candle.down .body {
    background: #dc2626;
}

.fvg-zone {
    position: absolute;
    left: 0;
    right: 0;
    background: rgba(37, 99, 235, 0.13);
    border-top: 1px solid rgba(37, 99, 235, 0.45);
    border-bottom: 1px solid rgba(37, 99, 235, 0.45);
}

.chart-empty {
    height: 300px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: var(--muted);
    background: #f8fafc;
    text-align: center;
    padding: 24px;
}

.live-chart-shell {
    position: relative;
    height: 430px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fbfdff;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.paper-candle-canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: auto;
}

.chart-empty-overlay {
    position: absolute;
    inset: 0;
    height: auto;
    border: 0;
    border-radius: 0;
    background: rgba(248, 250, 252, 0.92);
}

.chart-tooltip {
    position: absolute;
    z-index: 4;
    min-width: 148px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(15, 23, 32, 0.94);
    color: #ffffff;
    box-shadow: 0 12px 28px rgba(15, 23, 32, 0.18);
    pointer-events: none;
}

.chart-tooltip strong,
.chart-tooltip span {
    display: block;
    font-size: 12px;
    line-height: 1.45;
}

.chart-tooltip span {
    color: #dbeafe;
}

.trade-card {
    padding: 18px;
}

.trade-card strong {
    display: block;
    margin-top: 8px;
    font-size: 22px;
}

.trade-card .trade-symbol {
    margin-bottom: 16px;
}

.trade-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.progress-shell {
    height: 10px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
    margin-top: 12px;
}

.progress-bar {
    display: block;
    height: 100%;
    width: var(--progress, 0%);
    background: var(--green);
}

.rule-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.rule-card {
    padding: 14px;
}

.rule-card strong {
    display: block;
    margin-top: 6px;
}

.empty-state {
    min-height: 220px;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 26px;
}

.empty-state strong {
    display: block;
    font-size: 20px;
    margin-bottom: 8px;
}

.activity-feed {
    display: grid;
    gap: 10px;
}

.activity-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    background: #ffffff;
}

.activity-item small {
    display: block;
    color: var(--muted);
    margin-bottom: 5px;
}

.value-good {
    color: var(--green);
}

.value-danger {
    color: var(--red);
}

.tick-up {
    color: var(--green) !important;
    animation: tickUpFlash 0.85s ease;
}

.tick-down {
    color: var(--red) !important;
    animation: tickDownFlash 0.85s ease;
}

@keyframes tickUpFlash {
    0% {
        background: rgba(22, 163, 74, 0.18);
    }
    100% {
        background: transparent;
    }
}

@keyframes tickDownFlash {
    0% {
        background: rgba(220, 38, 38, 0.18);
    }
    100% {
        background: transparent;
    }
}

.confluence-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.confluence-head span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
}

.confluence-head strong {
    display: block;
    margin-top: 4px;
    font-size: 28px;
    line-height: 1;
}

.factor-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.factor-item {
    position: relative;
    min-height: 112px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 13px 13px 13px 46px;
    background: #ffffff;
}

.factor-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    min-height: 22px;
    border-radius: 999px;
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 850;
}

.factor-item::before {
    content: "";
    position: absolute;
    left: 13px;
    top: 14px;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    display: grid;
    place-items: center;
    color: #ffffff;
    font-size: 15px;
    font-weight: 900;
}

.factor-item strong,
.factor-item small {
    display: block;
}

.factor-item strong {
    font-size: 13px;
}

.factor-item small {
    margin-top: 5px;
    color: var(--muted);
    line-height: 1.35;
}

.factor-item.pass {
    border-color: #86efac;
    background: #f0fdf4;
}

.factor-item.pass .factor-status {
    color: var(--green);
    background: #dcfce7;
}

.factor-item.pass::before {
    content: "\2713";
    background: var(--green);
}

.factor-item.fail {
    border-color: #fecaca;
    background: #fff1f0;
}

.factor-item.fail .factor-status {
    color: var(--red);
    background: #fee4e2;
}

.factor-item.fail::before {
    content: "\00d7";
    background: var(--red);
}

.compact-empty {
    min-height: 160px;
}

.quote-card h3 {
    margin-bottom: 4px;
}

.quote-price {
    display: block;
    margin: 14px 0;
    font-size: 28px;
    font-weight: 850;
}

.quote-kv {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.quote-kv span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.quote-kv strong {
    display: block;
    margin-top: 2px;
}

@media (max-width: 1120px) {
    .app-shell,
    .dashboard-grid,
    .auth-layout,
    .trade-desk {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    .side-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .quote-grid,
    .session-strip {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 680px) {
    .main-content {
        padding: 16px;
    }

    .topbar {
        display: grid;
    }

    .top-actions {
        justify-content: flex-start;
    }

    .metric-grid,
    .form-grid,
    .auth-stats,
    .side-nav,
    .quote-grid,
    .session-strip,
    .trade-grid,
    .rule-grid,
    .factor-grid {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 25px;
    }
}
