:root {
    --bg: #050607;
    --panel: #090b0c;
    --panel-2: #0d1011;
    --line: #292d2f;
    --line-strong: #404648;
    --text: #f0eee5;
    --muted: #9da3a3;
    --amber: #ffb000;
    --amber-soft: #6b4b00;
    --green: #2fd27e;
    --red: #ff5e68;
    --cyan: #58c7e8;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-width: 320px;
    background: var(--bg);
    color: var(--text);
    font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.35;
}
button, input, select { font: inherit; }
a { color: inherit; }

.terminal-shell {
    min-height: 100vh;
    background:
        linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.014) 1px, transparent 1px),
        var(--bg);
    background-size: 24px 24px;
}

.command-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 14px;
    border-bottom: 1px solid var(--line-strong);
    background: rgba(5, 6, 7, .97);
    backdrop-filter: blur(12px);
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    white-space: nowrap;
}
.brand-mark {
    display: grid;
    place-items: center;
    min-width: 40px;
    height: 36px;
    padding: 0 7px;
    color: #080900;
    background: var(--amber);
    font-weight: 700;
}
.brand > span:nth-child(2) { color: var(--text); }
.brand b {
    padding-left: 12px;
    border-left: 1px solid var(--line-strong);
    color: var(--amber);
    font-size: 18px;
}
.command-status {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    white-space: nowrap;
}
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--amber);
    box-shadow: 0 0 12px rgba(255,176,0,.65);
}
.status-dot.live {
    background: var(--green);
    box-shadow: 0 0 12px rgba(47,210,126,.55);
}
.status-dot.error {
    background: var(--red);
    box-shadow: 0 0 12px rgba(255,94,104,.55);
}
.divider, .clock-zone { color: var(--line-strong); }

.market-rail {
    height: 74px;
    overflow: hidden;
    border-bottom: 1px solid var(--line);
    background: #07090a;
}
.market-rail .tradingview-widget-container,
.market-rail .tradingview-widget-container__widget { height: 100%; }

.instrument-tabs {
    display: flex;
    gap: 0;
    overflow-x: auto;
    border-bottom: 1px solid var(--line-strong);
    background: #070809;
    scrollbar-width: thin;
}
.instrument-tabs button {
    min-height: 48px;
    flex: 0 0 auto;
    padding: 8px 16px;
    border: 0;
    border-right: 1px solid var(--line);
    color: var(--muted);
    background: transparent;
    cursor: pointer;
    font-weight: 700;
}
.instrument-tabs button span {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    margin-right: 6px;
    border: 1px solid var(--line-strong);
    color: var(--muted);
}
.instrument-tabs button:hover { color: var(--text); background: #101314; }
.instrument-tabs button.active {
    color: #070800;
    background: var(--amber);
}
.instrument-tabs button.active span {
    color: #070800;
    border-color: rgba(0,0,0,.45);
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    gap: 1px;
    min-height: 690px;
    border-bottom: 1px solid var(--line-strong);
    background: var(--line);
}
.panel {
    min-width: 0;
    background: rgba(9,11,12,.98);
}
.panel-bar {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--panel-2);
    color: var(--muted);
}
.panel-bar > div:first-child {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.panel-bar strong {
    overflow: hidden;
    color: var(--text);
    text-overflow: ellipsis;
    white-space: nowrap;
}
.panel-code {
    display: inline-block;
    padding: 3px 7px;
    color: #070800;
    background: var(--amber);
    font-weight: 700;
}
.panel-actions {
    display: flex;
    gap: 14px;
    white-space: nowrap;
}
.panel-actions a {
    color: var(--cyan);
    text-decoration: none;
}
.panel-actions a:hover { text-decoration: underline; }

.primary-chart {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 690px;
}
.tradingview-chart {
    min-height: 640px;
    position: relative;
    overflow: hidden;
}
.tradingview-chart iframe { width: 100% !important; height: 100% !important; }
.loading-line {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--amber);
    background: #080a0b;
}

.right-column {
    display: grid;
    grid-template-rows: auto minmax(300px, 1fr) auto;
    gap: 1px;
    background: var(--line);
}
.snapshot-panel { background: #080a0b; }
.spot-block {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 12px;
    border-bottom: 1px solid var(--line);
}
.spot-block span, .stat-grid span, .alert-form label > span {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
}
.spot-block strong {
    display: block;
    color: var(--amber);
    font-size: clamp(30px, 3vw, 44px);
    line-height: 1;
}
.spot-block b { font-size: 20px; }
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
}
.stat-grid > div {
    min-height: 74px;
    padding: 10px 12px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}
.stat-grid > div:nth-child(2n) { border-right: 0; }
.stat-grid > div:nth-last-child(-n+2) { border-bottom: 0; }
.stat-grid strong { color: var(--text); }

.technical-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}
.technical-widget,
.technical-widget .tradingview-widget-container,
.technical-widget .tradingview-widget-container__widget { min-height: 300px; height: 100%; }

.alert-panel { background: #080a0b; }
.alert-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px;
}
.alert-form label { min-width: 0; }
.alert-form .email-field { grid-column: 1 / -1; }
.alert-form select,
.alert-form input,
.alert-form button {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line-strong);
    border-radius: 0;
    outline: none;
}
.alert-form select,
.alert-form input {
    padding: 8px 10px;
    color: var(--text);
    background: #050607;
}
.alert-form select:focus,
.alert-form input:focus { border-color: var(--amber); }
.alert-form button {
    grid-column: 1 / -1;
    color: #070800;
    background: var(--amber);
    border-color: var(--amber);
    cursor: pointer;
    font-weight: 700;
}
.alert-form button:hover { filter: brightness(1.08); }
.form-status {
    min-height: 26px;
    padding: 0 10px 10px;
    color: var(--muted);
}

.secondary-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(360px, .85fr) minmax(390px, .9fr);
    gap: 1px;
    min-height: 410px;
    background: var(--line);
    border-bottom: 1px solid var(--line-strong);
}
.secondary-grid .panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 410px;
}
.canvas-wrap {
    position: relative;
    min-height: 350px;
    padding: 12px;
}
.canvas-wrap canvas { width: 100% !important; height: 100% !important; }
.range-tabs {
    display: flex !important;
    gap: 0 !important;
}
.range-tabs button {
    min-height: 32px;
    padding: 3px 8px;
    border: 1px solid var(--line-strong);
    border-right: 0;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}
.range-tabs button:last-child { border-right: 1px solid var(--line-strong); }
.range-tabs button.active {
    color: #070800;
    background: var(--amber);
    border-color: var(--amber);
}
.calendar-widget,
.calendar-widget .tradingview-widget-container,
.calendar-widget .tradingview-widget-container__widget { min-height: 350px; height: 100%; }

.desk-bar {
    display: flex;
    align-items: center;
    gap: 0;
    overflow-x: auto;
    min-height: 56px;
    border-bottom: 1px solid var(--line-strong);
    background: #060708;
    white-space: nowrap;
}
.desk-label,
.desk-bar a,
.desk-note {
    min-height: 56px;
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-right: 1px solid var(--line);
}
.desk-label {
    color: #070800;
    background: var(--amber);
}
.desk-bar a {
    color: var(--cyan);
    text-decoration: none;
}
.desk-bar a:hover { color: var(--text); background: #101314; }
.desk-note { color: var(--muted); }

.up { color: var(--green) !important; }
.down { color: var(--red) !important; }
.neutral { color: var(--muted) !important; }

@media (max-width: 1180px) {
    .workspace { grid-template-columns: minmax(0, 1fr) 350px; }
    .secondary-grid { grid-template-columns: 1fr 1fr; }
    .calendar-panel { grid-column: 1 / -1; }
}

@media (max-width: 860px) {
    body { font-size: 18px; }
    .command-bar { align-items: flex-start; }
    .brand b { display: none; }
    .command-status .divider,
    .command-status .clock-zone { display: none; }
    .workspace { grid-template-columns: 1fr; }
    .primary-chart { min-height: 600px; }
    .tradingview-chart { min-height: 550px; }
    .right-column { grid-template-rows: auto 390px auto; }
    .secondary-grid { grid-template-columns: 1fr; }
    .calendar-panel { grid-column: auto; }
}

@media (max-width: 560px) {
    .command-bar { padding: 8px; }
    .brand { gap: 8px; }
    .brand-mark { min-width: 36px; }
    .brand > span:nth-child(2) { max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
    .command-status #feedStatus { display: none; }
    .market-rail { height: 82px; }
    .instrument-tabs button { padding: 8px 12px; }
    .panel-actions span { display: none; }
    .primary-chart { min-height: 520px; }
    .tradingview-chart { min-height: 470px; }
    .right-column { grid-template-rows: auto 420px auto; }
    .secondary-grid .panel { min-height: 390px; }
    .canvas-wrap { min-height: 330px; }
    .desk-note { display: none; }
}
