:root {
    --bg: #0f1419;
    --bg-panel: #161d26;
    --border: #2f3336;
    --text: #e7e9ea;
    --muted: #8b98a5;
    --accent: #1d9bf0;
    --google: #4285f4;
    --google-hover: #357ae8;
    --success: #00ba7c;
    --danger: #f4212e;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover { text-decoration: underline; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-panel);
    flex-shrink: 0;
}

.topbar-start {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
}

.brand:hover { text-decoration: none; }

.brand-icon {
    display: block;
    border-radius: 6px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}

.user-email { color: var(--muted); }

.logout-link {
    color: var(--muted);
    font-size: 0.85rem;
}

.profile-link {
    color: var(--muted);
    font-size: 0.85rem;
}

.profile-link:hover,
.logout-link:hover { color: var(--text); }

.page {
    max-width: 64rem;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 3rem;
}

.workspace-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.workspace-page .topbar {
    padding: 0.55rem 0.85rem;
}

.workspace-main {
    max-width: none;
    margin: 0;
    padding: 0;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 18rem;
    gap: 0;
    height: 100%;
}

.workspace-chart {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    border: none;
    border-radius: 0;
    border-right: 1px solid var(--border);
    padding: 0.65rem 0.75rem 0.75rem;
}

.workspace-markup {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border: none;
    border-radius: 0;
    padding: 0;
    background: var(--bg-panel);
}

.markup-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.25rem;
    padding: 0.55rem 0.65rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.workspace-menu__trigger {
    position: relative;
    border-radius: 6px;
}

.workspace-menu__trigger-icon {
    display: block;
    line-height: 1;
}

.workspace-menu__dirty {
    position: absolute;
    top: 0.15rem;
    right: 0.2rem;
    color: var(--accent);
    font-size: 0.55rem;
    line-height: 1;
    pointer-events: none;
}

.markup-tab {
    border: 1px solid var(--border);
    background: #0b0f14;
    color: var(--muted);
    border-radius: 6px;
    padding: 0.38rem 0.35rem;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
}

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

.markup-tab--active {
    border-color: var(--accent);
    background: rgba(29, 155, 240, 0.15);
    color: var(--accent);
}

.markup-tab-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.markup-tab-content[hidden] {
    display: none;
}

.markup-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.markup-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.55rem 0.85rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.markup-tool {
    flex: 1;
    min-width: 4.5rem;
    border: 1px solid var(--border);
    background: #0b0f14;
    color: var(--muted);
    border-radius: 6px;
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

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

.markup-tool--active.markup-tool--impulse {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.markup-tool--active.markup-tool--correction {
    border-color: #eab308;
    background: rgba(234, 179, 8, 0.15);
    color: #facc15;
}

.markup-tool--active.markup-tool--fibonacci {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.markup-tool--active.markup-tool--fibonacci-projection {
    border-color: #d97706;
    background: rgba(217, 119, 6, 0.15);
    color: #fdba74;
}

.markup-tool--active.markup-tool--cursor {
    border-color: var(--accent);
    background: rgba(29, 155, 240, 0.12);
    color: var(--accent);
}

.markup-btn--fib-settings {
    flex-shrink: 0;
    min-width: 2rem;
    padding-inline: 0.45rem;
}

.markup-panel__hint {
    margin: 0;
    padding: 0.45rem 0.85rem;
    font-size: 0.75rem;
    line-height: 1.35;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.deal-panel {
    flex-shrink: 0;
}

.deal-levels {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    border-top: 1px solid var(--border);
}

.deal-levels__title {
    margin: 0;
    padding: 0.55rem 0.85rem 0.35rem;
    font-size: 0.78rem;
    font-weight: 700;
    flex-shrink: 0;
}

.deal-levels__list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 0.85rem 0.75rem;
}

.deal-levels__row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0;
    font-size: 0.72rem;
}

.deal-levels__swatch {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 999px;
    flex-shrink: 0;
}

.deal-levels__label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.deal-levels__label:hover {
    color: var(--accent);
}

.deal-levels__empty {
    margin: 0;
    font-size: 0.72rem;
}

.deal-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 0.85rem 0.35rem;
}

.deal-panel__title {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 700;
}

.deal-panel__side-value {
    border: 1px solid var(--border);
    background: #0b0f14;
    color: var(--muted);
    border-radius: 6px;
    padding: 0.15rem 0.45rem;
    font-size: 0.68rem;
    font-weight: 700;
}

.deal-panel__side-value[data-trade-side="long"] {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
}

.deal-panel__side-value[data-trade-side="short"] {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}

.deal-panel__template {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0 0.85rem 0.5rem;
}

.deal-panel__template-label {
    font-size: 0.68rem;
    color: var(--muted);
    white-space: nowrap;
}

.deal-panel__template-select {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border);
    background: #0b0f14;
    color: var(--text);
    border-radius: 6px;
    padding: 0.15rem 0.3rem;
    font-size: 0.68rem;
    cursor: pointer;
}

.deal-panel__template-select:disabled {
    color: var(--muted);
    cursor: not-allowed;
}

.deal-panel__body {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
    padding: 0 0.85rem 0.65rem;
}

.deal-panel__group {
    min-width: 0;
}

.deal-panel__group-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--deal-role-color, var(--muted));
    margin-bottom: 0.2rem;
}

.deal-panel__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.deal-panel__item {
    font-size: 0.68rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    padding: 0.1rem 0;
}

.deal-panel__item:hover {
    color: var(--accent);
}

.deal-panel__empty {
    margin: 0;
    font-size: 0.68rem;
}

.deal-panel__hint {
    grid-column: 1 / -1;
    margin: 0;
    font-size: 0.68rem;
}

.deal-panel__warning {
    grid-column: 1 / -1;
    margin: 0;
    font-size: 0.68rem;
    color: #fbbf24;
}

.deal-panel__footer {
    padding: 0 0.85rem 0.65rem;
}

.deal-panel__activate {
    width: 100%;
    border: 1px solid #22c55e;
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
    border-radius: 8px;
    padding: 0.45rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.deal-panel__activate:hover:not(:disabled) {
    background: rgba(34, 197, 94, 0.22);
}

.deal-panel__activate:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    border-color: var(--border);
    background: #0b0f14;
    color: var(--muted);
}

.deal-modal {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.deal-modal[hidden] {
    display: none;
}

.deal-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
}

.deal-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(520px, 94vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.deal-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.deal-modal__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.deal-modal__close {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
}

.deal-modal__close:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.deal-modal__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.deal-modal__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.75rem;
    font-size: 0.75rem;
    color: var(--muted);
}

.deal-modal__meta strong {
    color: var(--text);
}

.deal-modal__section-title {
    margin: 0 0 0.4rem;
    font-size: 0.78rem;
    font-weight: 700;
}

.deal-modal__levels {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.deal-modal__level-row {
    display: grid;
    grid-template-columns: 4.5rem 1fr auto;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.72rem;
    padding: 0.25rem 0;
}

.deal-modal__level-role {
    font-weight: 600;
}

.deal-modal__level-role--entry {
    color: #4ade80;
}

.deal-modal__level-role--stop {
    color: #f87171;
}

.deal-modal__level-role--take_profit {
    color: #60a5fa;
}

.deal-modal__level-price {
    font-variant-numeric: tabular-nums;
}

.deal-modal__level-end {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.1rem;
}

.deal-modal__volumes {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.deal-modal__risk-row {
    display: grid;
    grid-template-columns: 1fr 6rem;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.55rem;
    font-size: 0.72rem;
    color: var(--muted);
}

.deal-modal__risk-row input {
    border: 1px solid var(--border);
    background: #0b0f14;
    color: var(--text);
    border-radius: 6px;
    padding: 0.3rem 0.45rem;
    font-size: 0.72rem;
    width: 100%;
}

.deal-modal__volume-row {
    display: grid;
    grid-template-columns: 1fr 6rem;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.72rem;
}

.deal-modal__volume-row input {
    border: 1px solid var(--border);
    background: #0b0f14;
    color: var(--text);
    border-radius: 6px;
    padding: 0.3rem 0.45rem;
    font-size: 0.72rem;
    width: 100%;
}

.deal-modal__volume-row input:focus-visible {
    border-color: var(--accent);
    outline: none;
}

.deal-plan-panel__side {
    font-size: 0.75rem;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.deal-plan-panel__side strong {
    color: var(--text);
}

.deal-plan-panel__section-title {
    margin: 0.75rem 0 0.4rem;
    font-size: 0.78rem;
    font-weight: 700;
}

.deal-plan-panel__levels.deal-panel__body {
    padding: 0;
}

.deal-plan-panel__rr,
.deal-modal__rr {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
}

.deal-plan-panel__rr-empty {
    margin: 0;
    font-size: 0.72rem;
    color: var(--muted);
}

.deal-plan-panel__rr-row {
    display: grid;
    grid-template-columns: 7.5rem 1fr auto;
    gap: 0.45rem;
    align-items: baseline;
    font-size: 0.72rem;
}

.deal-plan-panel__rr-row--total,
.deal-plan-panel__rr-row--ratio {
    margin-top: 0.2rem;
    padding-top: 0.35rem;
    border-top: 1px solid var(--border);
    font-weight: 600;
}

.deal-plan-panel__rr-label {
    color: var(--muted);
}

.deal-plan-panel__rr-row--stop .deal-plan-panel__rr-label {
    color: #f87171;
}

.deal-plan-panel__rr-row--tp .deal-plan-panel__rr-label {
    color: #60a5fa;
}

.deal-plan-panel__rr-meta {
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.deal-plan-panel__value {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.deal-plan-panel__value--pos {
    color: #4ade80;
}

.deal-plan-panel__value--neg {
    color: #f87171;
}

.deal-plan-panel__rr-fees {
    margin: 0.2rem 0 0;
    font-size: 0.65rem;
    color: var(--muted);
}

.deal-modal__row {
    display: flex;
    gap: 0.75rem;
}

.deal-modal__field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1;
}

.deal-modal__label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted);
}

.deal-modal__textarea,
.deal-modal__select {
    border: 1px solid var(--border);
    background: #0b0f14;
    color: var(--text);
    border-radius: 6px;
    padding: 0.4rem 0.55rem;
    font-size: 0.75rem;
    font-family: inherit;
    resize: vertical;
}

.deal-modal__textarea:focus-visible,
.deal-modal__select:focus-visible {
    border-color: var(--accent);
    outline: none;
}

.deal-modal__note {
    margin: 0;
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 8px;
    background: rgba(245, 158, 11, 0.1);
    padding: 0.45rem 0.6rem;
    font-size: 0.72rem;
    color: #fbbf24;
}

.deal-modal__error {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 3;
    transform: translate(-50%, -50%);
    margin: 0;
    max-width: min(86%, 22rem);
    padding: 0.7rem 0.9rem;
    border: 1px solid rgba(248, 113, 113, 0.45);
    border-radius: 10px;
    background: rgba(28, 12, 12, 0.94);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    font-size: 0.82rem;
    line-height: 1.35;
    color: #fca5a5;
    text-align: center;
}

.deal-modal__error[hidden] {
    display: none !important;
}

.deal-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.deal-modal__cancel,
.deal-modal__submit {
    border-radius: 8px;
    padding: 0.45rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}

.deal-modal__cancel {
    border: 1px solid var(--border);
    background: #0b0f14;
    color: var(--muted);
}

.deal-modal__cancel:hover {
    color: var(--text);
    border-color: var(--accent);
}

.deal-modal__submit {
    border: 1px solid #f59e0b;
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.deal-modal__submit:hover:not(:disabled) {
    background: rgba(245, 158, 11, 0.28);
}

.deal-modal__submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.markup-line__role {
    flex-shrink: 0;
    border: 1px solid var(--border);
    background: #0b0f14;
    color: var(--text);
    border-radius: 4px;
    font-size: 0.65rem;
    padding: 0.1rem 0.2rem;
    max-width: 4.2rem;
    cursor: pointer;
}

.markup-line__role:hover,
.markup-line__role:focus-visible {
    border-color: var(--accent);
    outline: none;
}

.level-line-label--trade-role {
    font-weight: 700;
}

.markup-btn {
    border: 1px solid var(--border);
    background: #0b0f14;
    color: var(--muted);
    border-radius: 6px;
    padding: 0.25rem 0.55rem;
    font-size: 0.8rem;
    cursor: pointer;
}

.markup-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}

.markup-btn--icon {
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
}

.markup-btn--danger:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.markup-layer {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.55rem;
    overflow: hidden;
    background: #0b0f14;
}

.markup-layer--active {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(29, 155, 240, 0.2);
}

.markup-layer--inactive {
    opacity: 0.58;
}

.markup-layer--inactive .markup-layer__lines {
    pointer-events: none;
}

.markup-layer__head {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.5rem;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border);
}

.markup-layer__name {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.15rem 0.25rem;
    border-radius: 4px;
}

.markup-layer__name:focus {
    outline: 1px solid var(--accent);
}

.markup-layer__toggle,
.markup-layer__delete {
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    font-size: 0.85rem;
    border-radius: 4px;
}

.markup-layer__toggle:hover,
.markup-layer__delete:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.markup-layer__delete:hover {
    color: var(--danger);
}

.markup-layer__lines {
    list-style: none;
    margin: 0;
    padding: 0.25rem 0;
}

.markup-line {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.55rem;
    font-size: 0.75rem;
    cursor: pointer;
}

.markup-line:hover {
    background: rgba(255, 255, 255, 0.03);
}

.markup-line--generated .markup-line__label {
    font-style: italic;
}

.markup-line__swatch {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 999px;
    flex-shrink: 0;
}

.markup-line__swatch--impulse {
    background: #3b82f6;
}

.markup-line__swatch--correction {
    background: #eab308;
}

.markup-line__swatch--fibonacci {
    background: #f59e0b;
}

.markup-line__swatch--fibonacci-projection {
    background: #d97706;
}

.markup-line__label {
    flex: 1;
    min-width: 0;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.markup-line__delete {
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 0.1rem 0.3rem;
    font-size: 0.9rem;
    border-radius: 4px;
    line-height: 1;
}

.markup-line__delete:hover {
    color: var(--danger);
}

.markup-line__settings {
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.1rem 0.25rem;
    border-radius: 4px;
}

.markup-line__settings:hover {
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.12);
}

.markup-panel__header h2 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.markup-panel__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.75rem 0.85rem;
}

.markup-panel__empty {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.45;
}

.chart-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.chart-toolbar__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    width: min(400px, 100%);
    margin: 4rem auto;
    background: var(--bg-panel);
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.login-logo {
    display: block;
    margin: 0 auto 0.75rem;
    border-radius: 16px;
}

.login-container h1 {
    margin: 0 0 0.75rem;
    font-size: 1.75rem;
}

.google-btn {
    display: inline-block;
    background: var(--google);
    color: #fff;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    margin-top: 1.25rem;
    text-decoration: none;
}

.google-btn:hover {
    background: var(--google-hover);
    text-decoration: none;
}

.hero {
    margin-bottom: 2rem;
}

.eyebrow {
    margin: 0 0 0.5rem;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero h1 {
    margin: 0 0 0.75rem;
    font-size: 2rem;
}

.hero-lead {
    max-width: 38rem;
    margin: 0;
    line-height: 1.5;
}

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

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

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
}

.panel--wide {
    grid-column: 1 / -1;
}

.panel--chart {
    min-height: 0;
}

.chart-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.chart-menu {
    position: relative;
}

.chart-menu__trigger {
    border: 1px solid var(--border);
    background: #0b0f14;
    color: var(--muted);
    border-radius: 999px;
    width: 2rem;
    height: 2rem;
    padding: 0;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.chart-menu__trigger:hover,
.chart-menu__trigger[aria-expanded="true"] {
    color: var(--text);
    border-color: var(--accent);
}

.chart-menu__panel {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    z-index: 20;
    min-width: 11rem;
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-panel);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.chart-menu__item {
    display: block;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    border-radius: 6px;
    padding: 0.55rem 0.75rem;
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
}

.chart-menu__item[hidden] {
    display: none;
}

.chart-menu__item:hover {
    background: rgba(29, 155, 240, 0.12);
    color: var(--accent);
}

.chart-menu__item:disabled {
    opacity: 0.45;
    cursor: default;
}

.chart-menu__item:disabled:hover {
    background: transparent;
    color: var(--text);
}

.chart-menu__sep {
    height: 1px;
    margin: 0.35rem 0.25rem;
    background: var(--border);
}

.chart-menu__label {
    padding: 0.35rem 0.75rem 0.2rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.chart-menu__item--nested {
    padding-left: 1.1rem;
    font-size: 0.82rem;
}

.chart-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.chart-tab {
    border: 1px solid var(--border);
    background: #0b0f14;
    color: var(--muted);
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}

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

.chart-tab--active {
    background: rgba(29, 155, 240, 0.18);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 0 1px rgba(29, 155, 240, 0.25);
}

.chart-tab--active:hover {
    background: rgba(29, 155, 240, 0.25);
    color: var(--accent);
}

.chart-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 0 0 0.5rem;
    flex-shrink: 0;
}

.chart-status {
    font-size: 0.78rem;
    flex-shrink: 0;
}

.chart-status-row .chart-status {
    margin: 0;
    min-width: 0;
    flex: 1;
}

.chart-status--error {
    color: var(--danger);
}

.chart-stage {
    position: relative;
    flex: 1;
    width: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chart-stage__veil {
    position: absolute;
    inset: 0;
    z-index: 20;
    background: #0b0f14;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.32s ease;
}

.chart-stage--preparing .chart-stage__veil {
    opacity: 1;
    pointer-events: auto;
    transition: none;
}

.chart-stage--revealing .chart-stage__veil {
    opacity: 0;
    pointer-events: none;
}

.chart-stage__dirty {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: rgba(11, 15, 20, 0.85);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.chart-stage__dirty:not([hidden]) {
    opacity: 1;
}

.chart-stage__dirty-icon {
    display: block;
    font-size: 0.85rem;
    line-height: 1;
    color: var(--muted);
    transition: color 0.2s ease, text-shadow 0.2s ease;
}

.chart-stage__dirty--active {
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(29, 155, 240, 0.35);
    animation: chart-stage-dirty-glow 2s ease-in-out infinite;
}

.chart-stage__dirty--active .chart-stage__dirty-icon {
    color: var(--accent);
    text-shadow: 0 0 6px rgba(29, 155, 240, 0.8);
}

@keyframes chart-stage-dirty-glow {
    0%, 100% {
        box-shadow: 0 0 8px rgba(29, 155, 240, 0.3);
    }
    50% {
        box-shadow: 0 0 14px rgba(29, 155, 240, 0.55);
    }
}

.chart-container {
    position: relative;
    flex: 1;
    width: 100%;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #0b0f14;
}

.markup-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
}

.markup-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
    pointer-events: auto;
    cursor: pointer;
    touch-action: none;
}

.markup-handle--impulse {
    background: #3b82f6;
}

.markup-handle--correction {
    background: #eab308;
}

.markup-handle--fibonacci {
    background: #f59e0b;
}

.markup-handle--fibonacci-projection {
    background: #d97706;
}

.fib-labels-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    overflow: hidden;
}

.fib-level-label {
    position: absolute;
    transform: translate(0, -50%);
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.2;
    padding: 0.12rem 0.35rem;
    border-radius: 4px;
    background: rgba(11, 15, 20, 0.88);
    border: 1px solid var(--fib-color, #94a3b8);
    color: var(--fib-color, #e2e8f0);
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.fib-level-label--interactive {
    pointer-events: auto;
    cursor: pointer;
    transition: background 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

.fib-level-label--interactive:hover {
    background: rgba(11, 15, 20, 0.96);
    box-shadow: 0 0 0 1px var(--fib-color, #94a3b8), 0 2px 8px rgba(0, 0, 0, 0.4);
}

.fib-level-label--interactive:focus-visible {
    outline: 2px solid var(--fib-color, #f59e0b);
    outline-offset: 2px;
}

.fib-level-label--pinned {
    background: rgba(245, 158, 11, 0.18);
    box-shadow: 0 0 0 2px var(--fib-color, #f59e0b), 0 2px 8px rgba(0, 0, 0, 0.35);
}

.level-labels-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    overflow: hidden;
}

.level-line-label {
    position: absolute;
    transform: translate(0, -50%);
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.2;
    padding: 0.12rem 0.35rem;
    border-radius: 4px;
    background: rgba(11, 15, 20, 0.88);
    border: 1px solid var(--level-color, #22d3ee);
    color: var(--level-color, #22d3ee);
    white-space: nowrap;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.markup-tool--active.markup-tool--horizontal-level {
    border-color: #22d3ee;
    background: rgba(34, 211, 238, 0.15);
    color: #67e8f9;
}

.markup-layer__name:read-only {
    cursor: default;
    color: var(--muted);
}

.markup-line__swatch--horizontal-level {
    background: #22d3ee;
}

.markup-handle--horizontal-level {
    background: #22d3ee;
}

.fib-settings-modal {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.fib-settings-modal[hidden] {
    display: none;
}

.fib-settings-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
}

.fib-settings-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(480px, 94vw);
    max-height: min(640px, 90vh);
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.fib-settings-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
}

.fib-settings-modal__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.fib-settings-modal__close {
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 1.35rem;
    line-height: 1;
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
}

.fib-settings-modal__close:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.fib-settings-modal__body {
    padding: 1rem;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.fib-settings-modal__hint {
    margin: 0;
    font-size: 0.78rem;
}

.fib-settings-modal__section {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.fib-settings-modal__section-title {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
}

.fib-settings-modal__presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.fib-settings-modal__preset {
    padding: 0.25rem 0.55rem;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #0b0f14;
    color: inherit;
    cursor: pointer;
}

.fib-settings-modal__preset:hover {
    border-color: #f59e0b;
    color: #fbbf24;
}

.fib-settings-modal__preset--active,
.fib-settings-modal__preset--active:hover {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.16);
    color: #fbbf24;
    box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.35);
}

.fib-settings-modal__field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.fib-settings-modal__label {
    font-size: 0.75rem;
    color: var(--muted);
}

.fib-settings-modal__input,
.fib-settings-modal__anchor select {
    width: 100%;
    padding: 0.45rem 0.55rem;
    font-size: 0.82rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #0b0f14;
    color: inherit;
    box-sizing: border-box;
}

.fib-settings-modal__input:focus,
.fib-settings-modal__anchor select:focus {
    outline: none;
    border-color: #f59e0b;
}

.fib-settings-modal__anchors {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
}

.fib-settings-modal__anchor {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--muted);
}

.fib-settings-modal__swap {
    grid-column: 1 / -1;
    padding: 0.45rem 0.65rem;
    font-size: 0.78rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: rgba(245, 158, 11, 0.08);
    color: #fbbf24;
    cursor: pointer;
}

.fib-settings-modal__swap:hover {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.15);
}

.fib-settings-modal__note {
    margin: 0;
    font-size: 0.72rem;
    line-height: 1.4;
}

body.fib-settings-open {
    overflow: hidden;
}

.markup-line--selected {
    background: rgba(29, 155, 240, 0.1);
}

.markup-collapse {
    padding: 0.5rem 0.85rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.markup-collapse__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.markup-collapse__count {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
}

.markup-btn--small {
    width: 1.4rem;
    height: 1.4rem;
    padding: 0;
    font-size: 0.9rem;
    line-height: 1;
}

.markup-collapse__types {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.markup-figure-btn {
    flex: 1 1 calc(50% - 0.15rem);
    min-width: 5rem;
    border: 1px solid var(--border);
    background: #0b0f14;
    color: var(--muted);
    border-radius: 5px;
    padding: 0.3rem 0.4rem;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}

.markup-figure-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}

.markup-figure-btn--impulse { border-color: rgba(59, 130, 246, 0.4); }
.markup-figure-btn--leading-diagonal { border-color: rgba(139, 92, 246, 0.4); }
.markup-figure-btn--ending-diagonal { border-color: rgba(168, 85, 247, 0.4); }
.markup-figure-btn--zigzag { border-color: rgba(6, 182, 212, 0.4); }
.markup-figure-btn--flat { border-color: rgba(249, 115, 22, 0.4); }
.markup-figure-btn--triangle { border-color: rgba(236, 72, 153, 0.4); }

.markup-figure {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.45rem;
    border-radius: 5px;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    margin-bottom: 0.25rem;
    cursor: pointer;
}

.markup-figure--valid {
    border-color: rgba(34, 197, 94, 0.45);
    background: rgba(34, 197, 94, 0.06);
}

.markup-figure--warn {
    border-color: rgba(234, 179, 8, 0.55);
    background: rgba(234, 179, 8, 0.1);
}

.markup-figure--invalid {
    border-color: rgba(244, 33, 46, 0.4);
    background: rgba(244, 33, 46, 0.06);
}

.figure-modal__title--valid {
    color: #22c55e;
}

.figure-modal__title--warn {
    color: #facc15;
}

.figure-modal__title--invalid {
    color: #f4212e;
}

.markup-figure__swatch {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 2px;
    flex-shrink: 0;
}

.markup-figure__swatch--valid { background: #22c55e; }
.markup-figure__swatch--warn { background: #eab308; }
.markup-figure__swatch--invalid { background: #ef4444; }

.markup-figure__label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.markup-figure__expand,
.markup-figure__delete {
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 0 0.2rem;
    font-size: 0.85rem;
    line-height: 1;
}

.markup-figure__expand:hover {
    color: var(--accent);
}

.markup-figure__delete:hover {
    color: var(--danger);
}

.markup-figure--selected {
    border-color: var(--accent);
    background: rgba(29, 155, 240, 0.08);
}

.figure-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.figure-modal[hidden] {
    display: none;
}

.figure-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
}

.figure-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(1120px, 94vw);
    height: min(720px, 90vh);
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.figure-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.figure-modal__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.figure-modal__close {
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 1.35rem;
    line-height: 1;
    padding: 0.15rem 0.35rem;
    border-radius: 6px;
}

.figure-modal__close:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.figure-modal__content {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.figure-modal__chart-pane {
    min-width: 0;
    min-height: 0;
    border-right: 1px solid var(--border);
    background: #0b0f14;
    display: flex;
    flex-direction: column;
    min-height: 320px;
}

.figure-modal__chart-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
}

.figure-modal__chart {
    width: 100%;
    height: 100%;
    min-height: 280px;
}

.figure-modal__labels {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 5;
}

.deal-history-level-label {
    z-index: 2;
}

.figure-wave-badge {
    position: absolute;
    transform: translate(-50%, -50%);
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    padding: 0.2rem 0.45rem;
    border-radius: 999px;
    border: 2px solid var(--wave-color, #8b98a5);
    background: rgba(11, 15, 20, 0.92);
    pointer-events: auto;
    cursor: default;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.figure-wave-badge--active {
    transform: translate(-50%, -50%) scale(1.08);
    box-shadow: 0 0 0 2px rgba(29, 155, 240, 0.35);
    z-index: 2;
}

.figure-wave-badge__wave {
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 1;
    color: var(--wave-color, #e7e9ea);
}

.figure-wave-badge__leg {
    font-size: 0.62rem;
    font-weight: 600;
    line-height: 1;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.figure-modal__legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    padding: 0.55rem 0.75rem;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    flex-shrink: 0;
}

.figure-modal__legend-title {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 0.25rem;
}

.figure-wave-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.45rem;
    border-radius: 999px;
    border: 1px solid var(--wave-color, #8b98a5);
    background: rgba(11, 15, 20, 0.85);
    cursor: pointer;
}

.figure-wave-chip--compact {
    font-size: 0.72rem;
}

.figure-wave-chip--active {
    box-shadow: 0 0 0 2px rgba(29, 155, 240, 0.35);
    background: rgba(29, 155, 240, 0.12);
}

.figure-wave-chip__wave {
    font-weight: 800;
    color: var(--wave-color, #e7e9ea);
}

.figure-wave-chip__leg {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 600;
}

.figure-detail__row {
    border-left: 3px solid var(--wave-color, transparent);
}

.figure-detail__row--active {
    background: rgba(29, 155, 240, 0.08);
}

.figure-detail__wave-name .figure-wave-chip {
    vertical-align: middle;
}

.figure-modal__chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    margin: 0;
    padding: 1rem;
    text-align: center;
    font-size: 0.85rem;
}

.figure-modal__table-pane {
    min-width: 0;
    min-height: 0;
    overflow: auto;
    padding: 1rem 1.1rem;
}

.figure-detail__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.figure-detail__table th,
.figure-detail__table td {
    padding: 0.28rem 0.25rem;
    text-align: left;
    border-bottom: 1px solid rgba(47, 51, 54, 0.7);
}

.figure-detail__table th {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.figure-detail__wave-name {
    font-weight: 700;
    color: var(--text);
    width: 2rem;
}

.figure-detail__leg-label {
    font-size: 0.75rem;
    white-space: nowrap;
}

.figure-detail__intro {
    margin: 0 0 0.75rem;
    font-size: 0.78rem;
    line-height: 1.4;
}

.figure-detail__metrics-title {
    margin: 1rem 0 0.45rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
}

.figure-detail__price {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.figure-detail__length {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-weight: 600;
    color: var(--text);
}

.figure-detail__extra {
    font-size: 0.68rem;
    white-space: nowrap;
}

.figure-detail__metrics {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.figure-detail__metric {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.8rem;
    padding: 0.35rem 0.45rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.02);
}

.figure-detail__metric--ok .figure-detail__metric-value {
    color: var(--success);
}

.figure-detail__metric--bad .figure-detail__metric-value {
    color: var(--danger);
}

.figure-detail__metric--warn .figure-detail__metric-value {
    color: #facc15;
}

.figure-detail__metric--warn {
    background: rgba(234, 179, 8, 0.08);
    border: 1px solid rgba(234, 179, 8, 0.2);
}

.figure-detail__metric-label {
    color: var(--muted);
}

.figure-detail__metric-value {
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.figure-detail__empty {
    margin: 0;
    font-size: 0.75rem;
}

body.figure-modal-open {
    overflow: hidden;
}

@media (max-width: 900px) {
    .figure-modal__content {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(220px, 1fr) minmax(220px, 1fr);
    }

    .figure-modal__chart-pane {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
}

.panel h2 {
    margin: 0 0 0.35rem;
    font-size: 1.05rem;
}

.panel p {
    margin: 0 0 1rem;
    font-size: 0.9rem;
}

.panel-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 10rem;
    border: 1px dashed var(--border);
    border-radius: 8px;
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.switch-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.switch-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.switch-list li:last-child { border-bottom: none; }

.badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}

.badge--on {
    background: rgba(0, 186, 124, 0.15);
    color: var(--success);
}

.badge--off {
    background: rgba(139, 152, 165, 0.15);
    color: var(--muted);
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    font-size: 0.8rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: rgba(29, 155, 240, 0.12);
    color: var(--accent);
}

.log-preview {
    margin: 0;
    padding: 0.85rem 1rem;
    background: #0b0f14;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--muted);
    font-size: 0.82rem;
    overflow-x: auto;
}

@media (max-width: 900px) {
    .workspace {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) auto;
    }

    .workspace-chart {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .workspace-markup {
        max-height: 14rem;
    }

    .chart-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .chart-toolbar__actions {
        margin-left: 0;
        justify-content: space-between;
    }
}

@media (max-width: 720px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .topbar-user {
        flex-direction: column;
        align-items: flex-end;
        gap: 0.25rem;
    }

    .history-item {
        grid-template-columns: 1fr;
        gap: 0.35rem;
    }

    .history-item__meta {
        text-align: left;
    }
}

/* ── Workspace navigation ── */

.workspace-topbar {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    min-height: 2rem;
}

.workspace-nav {
    display: flex;
    gap: 0.25rem;
    padding: 0;
    border-bottom: none;
    background: transparent;
    flex-shrink: 0;
}

.workspace-nav__tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2rem;
    padding: 0 0.75rem;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.workspace-nav__tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.workspace-nav__tab--active {
    color: var(--text);
    background: rgba(29, 155, 240, 0.12);
    border-color: rgba(29, 155, 240, 0.35);
}

.workspace-nav__stats {
    margin-left: auto;
    flex-shrink: 0;
}

.topbar,
.topbar-start {
    overflow: visible;
}

#workspace-topbar-actions,
.workspace-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
    margin-left: 0.35rem;
    padding-left: 0.5rem;
    border-left: 1px solid var(--border);
    z-index: 30;
}

#workspace-topbar-actions.workspace-topbar-actions--hidden {
    visibility: hidden;
    pointer-events: none;
}

.workspace-menu__back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--border);
    background: #0b0f14;
    color: var(--muted);
    border-radius: 999px;
    width: 2rem;
    height: 2rem;
    padding: 0;
    font-size: 0;
    line-height: 0;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.workspace-menu__back::before {
    content: "←";
    font-size: 1.1rem;
    line-height: 1;
    transform: translateY(-1px);
}

.workspace-menu__back:hover {
    color: var(--text);
    border-color: var(--accent);
    background: rgba(29, 155, 240, 0.08);
}

.workspace-menu__back[hidden] {
    display: none !important;
}

.workspace-menu {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    min-width: 2rem;
}

.workspace-menu--hidden {
    visibility: hidden;
    pointer-events: none;
}

.workspace-view {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.workspace-view[hidden] {
    display: none !important;
}

.workspace-view--history,
.workspace-view--deal,
.workspace-view--statistics {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.workspace-view--draft,
.workspace-view--deal {
    position: relative;
    display: flex;
    flex-direction: column;
}

.workspace-view--draft .workspace,
.workspace-view--deal .workspace {
    flex: 1;
    min-height: 0;
}

.workspace-view--deal .workspace {
    grid-template-columns: minmax(0, 1fr) clamp(22rem, 36vw, 42rem);
}

/* ── Ideas panel (list tab) ── */

.ideas-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    border: none;
    border-radius: 0;
    padding: 0;
    background: var(--bg);
}

.ideas-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.ideas-panel__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.ideas-panel__actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.filter-combo {
    position: relative;
    min-width: 9.5rem;
}

.filter-combo__field {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    min-height: 2rem;
    padding: 0.25rem 0.55rem 0.25rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #0b0f14;
    color: var(--text);
    font: inherit;
    font-size: 0.8rem;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s;
}

.filter-combo__field:hover {
    border-color: rgba(29, 155, 240, 0.4);
}

.filter-combo--open .filter-combo__field,
.filter-combo__field:focus-visible {
    outline: none;
    border-color: rgba(29, 155, 240, 0.55);
    box-shadow: 0 0 0 2px rgba(29, 155, 240, 0.12);
}

.filter-combo__field--filled {
    color: var(--text);
}

.filter-combo__value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-combo__value--placeholder {
    color: var(--muted);
}

.filter-combo__chevron {
    flex-shrink: 0;
    color: var(--muted);
    font-size: 0.7rem;
    line-height: 1;
}

.filter-combo--open .filter-combo__chevron {
    transform: rotate(180deg);
    color: var(--accent);
}

.filter-combo__list {
    position: absolute;
    top: calc(100% + 0.3rem);
    left: 0;
    right: 0;
    z-index: 20;
    min-width: 100%;
    max-height: 14rem;
    overflow-y: auto;
    padding: 0.3rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-panel);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.filter-combo__list[hidden] {
    display: none;
}

.filter-combo__option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.4rem 0.55rem;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.8rem;
    text-align: left;
    cursor: pointer;
}

.filter-combo__option:hover {
    background: rgba(29, 155, 240, 0.1);
}

.filter-combo__option--on {
    color: #8fd4ff;
    background: rgba(29, 155, 240, 0.12);
}

.filter-combo__check {
    width: 0.9rem;
    flex-shrink: 0;
    color: var(--accent);
    font-size: 0.75rem;
    text-align: center;
}


.ideas-panel__actions .filter-combo {
    min-width: 10.5rem;
    max-width: 14rem;
}

.history-panel__actions .filter-combo {
    min-width: 10.5rem;
    max-width: 14rem;
}


.ideas-item__tags {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.35rem;
}

.idea-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1.3;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.idea-tag:hover {
    color: var(--text);
    border-color: rgba(29, 155, 240, 0.4);
    background: rgba(29, 155, 240, 0.08);
}

.idea-tag--on {
    background: rgba(29, 155, 240, 0.18);
    border-color: rgba(29, 155, 240, 0.5);
    color: #6ec8ff;
}

.idea-tag--on:hover {
    background: rgba(29, 155, 240, 0.26);
    border-color: rgba(29, 155, 240, 0.65);
    color: #8fd4ff;
}

.idea-tag__x {
    font-size: 0.85rem;
    line-height: 1;
    opacity: 0.7;
}

.idea-tag--on:hover .idea-tag__x {
    opacity: 1;
}

.idea-tag--add {
    width: 1.45rem;
    height: 1.45rem;
    padding: 0;
    justify-content: center;
    border-style: dashed;
    color: var(--muted);
    border-color: var(--border);
    background: transparent;
    font-size: 0.9rem;
}

.idea-tag--add:hover {
    color: var(--accent);
    border-color: rgba(29, 155, 240, 0.45);
    background: rgba(29, 155, 240, 0.08);
}

.idea-tag-picker {
    position: absolute;
    top: calc(100% + 0.3rem);
    left: 0;
    z-index: 8;
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    max-width: min(18rem, 70vw);
    padding: 0.4rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-panel);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.idea-tag-picker[hidden] {
    display: none;
}

.ideas-panel__refresh {
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
}

.ideas-panel__refresh:hover {
    color: var(--text);
    border-color: var(--accent);
}

.ideas-panel__new {
    padding: 0.35rem 0.7rem;
    border: 1px solid rgba(29, 155, 240, 0.35);
    border-radius: 6px;
    background: rgba(29, 155, 240, 0.12);
    color: var(--accent);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
}

.ideas-panel__status {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.ideas-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.ideas-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
}

.ideas-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem 1rem;
    align-items: center;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-panel);
    cursor: pointer;
    text-align: left;
    width: 100%;
    color: inherit;
    font: inherit;
    transition: border-color 0.15s, background 0.15s;
}

.ideas-item:hover {
    border-color: rgba(29, 155, 240, 0.45);
    background: rgba(29, 155, 240, 0.06);
}

.ideas-item__main {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.ideas-item__title {
    font-weight: 600;
    font-size: 0.92rem;
}

.ideas-item__details {
    font-size: 0.82rem;
    color: var(--muted);
}

.ideas-item__description {
    font-size: 0.82rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ideas-item__meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.2rem;
    flex-shrink: 0;
}

.ideas-item__date {
    font-size: 0.78rem;
    color: var(--muted);
    white-space: nowrap;
}

.ideas-item__title-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.ideas-item__badge {
    flex-shrink: 0;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--accent);
    border: 1px solid rgba(29, 155, 240, 0.35);
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
}

.ideas-item__author {
    font-size: 0.78rem;
    color: var(--muted);
}

.idea-modal__parent {
    margin: 0 0 0.75rem;
    font-size: 0.85rem;
}

.idea-tree-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.idea-tree-modal[hidden] {
    display: none;
}

.idea-tree-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.idea-tree-modal__dialog {
    position: relative;
    width: min(520px, calc(100vw - 2rem));
    max-height: min(70vh, 640px);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-panel);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.idea-tree-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.idea-tree-modal__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.idea-tree-modal__close {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
}

.idea-tree-modal__close:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.idea-tree-modal__body {
    overflow-y: auto;
    padding: 0.5rem;
}

.idea-tree-modal__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    border-radius: 6px;
    padding: 0.55rem 0.75rem;
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
}

.idea-tree-modal__item:hover {
    background: rgba(29, 155, 240, 0.12);
    color: var(--accent);
}

.idea-tree-modal__item--active {
    background: rgba(29, 155, 240, 0.08);
    color: var(--accent);
    font-weight: 600;
    cursor: default;
}

.idea-tree-modal__item--active:hover {
    background: rgba(29, 155, 240, 0.08);
    color: var(--accent);
}

.idea-tree-modal__item-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.idea-tree-modal__item-meta {
    flex-shrink: 0;
    font-size: 0.75rem;
}

.idea-tree-modal__empty {
    margin: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

/* ── Idea modal ── */

.idea-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.idea-modal[hidden] {
    display: none;
}

.idea-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

.idea-modal__dialog {
    position: relative;
    width: min(440px, calc(100vw - 2rem));
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-panel);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.idea-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
}

.idea-modal__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.idea-modal__close {
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
}

.idea-modal__close:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.idea-modal__body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.idea-modal__field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.idea-modal__label {
    font-size: 0.85rem;
    font-weight: 500;
}

.idea-modal__input,
.idea-modal__textarea {
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    resize: vertical;
}

.idea-modal__input:focus,
.idea-modal__textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.idea-modal__error {
    margin: 0;
    font-size: 0.85rem;
    color: var(--danger);
}

.idea-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
}

.idea-modal__btn {
    padding: 0.45rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.88rem;
    cursor: pointer;
}

.idea-modal__btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.idea-modal__btn--primary:hover {
    opacity: 0.9;
}

/* ── History panel ── */

.history-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
    border: none;
    border-radius: 0;
    padding: 0;
    background: var(--bg);
}

.history-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.history-panel__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}


.history-panel__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.history-panel__refresh {
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
}

.history-panel__refresh:hover {
    color: var(--text);
    border-color: var(--accent);
}

.history-panel__status {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.history-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
}

/* ── Statistics panel (widget board) ── */

.statistics-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
    border: none;
    border-radius: 0;
    padding: 0;
    background: var(--bg);
}

.statistics-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.statistics-panel__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.statistics-panel__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.statistics-panel__error {
    margin: 0;
    padding: 0.5rem 1rem 0;
    color: #ef4444;
    font-size: 0.85rem;
}

.statistics-panel__error[hidden] {
    display: none;
}

.statistics-panel__empty {
    margin: 0;
    padding: 2.5rem 1rem;
    text-align: center;
}

.statistics-add {
    position: relative;
}

.statistics-panel__add {
    border: 1px solid var(--border);
    background: #0b0f14;
    color: var(--text);
    border-radius: 8px;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.statistics-panel__add:hover {
    border-color: var(--accent);
}

.statistics-add__menu {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    min-width: 10rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.35rem;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    z-index: 20;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.statistics-add__menu[hidden] {
    display: none;
}

.statistics-add__item {
    border: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
    padding: 0.45rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
}

.statistics-add__item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.statistics-board {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 1rem;
    gap: 1rem;
}

.statistics-board[hidden] {
    display: none;
}

.stat-widget {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    gap: 0.65rem;
    width: 100%;
    min-height: 0;
    height: auto;
    position: relative;
    z-index: 0;
    padding: 1rem;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.stat-widget__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.stat-widget__head--compact {
    min-height: 0;
    margin: 0;
    padding: 0;
}

.stat-widget__title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.4rem;
    line-height: 1.2;
}

.stat-widget__title-meta {
    font-size: 0.78rem;
    font-weight: 500;
}

.stat-widget__remove {
    border: 0;
    background: transparent;
    color: var(--muted);
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
}

.stat-widget__remove:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.stat-widget__value {
    margin: 0;
    font-size: 2rem;
    font-weight: 650;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.stat-widget__hint {
    margin: 0;
    font-size: 0.8rem;
}

.stat-widget__foot {
    margin-top: auto;
}

.stat-widget__action {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    border-radius: 6px;
    padding: 0.3rem 0.55rem;
    font-size: 0.8rem;
    cursor: pointer;
}

.stat-widget__action:hover {
    color: var(--text);
    border-color: var(--accent);
}

.stat-widget__note {
    width: 100%;
    min-height: 5.5rem;
    resize: vertical;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #0b0f14;
    color: var(--text);
    padding: 0.6rem 0.7rem;
    font: inherit;
    font-size: 0.9rem;
    line-height: 1.4;
}

.stat-widget__note:focus {
    outline: none;
    border-color: var(--accent);
}

.stat-widget--wide {
    width: 100%;
    grid-column: auto;
}

.stat-widget__head-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stat-widget__period {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    margin-right: 0.15rem;
}

.stat-widget__period .stat-widget__action {
    min-width: 1.7rem;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
}

.stat-pnl-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

.stat-pnl-summary__item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #0b0f14;
}

.stat-pnl-summary__item strong {
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
}

.stat-pnl-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 18rem;
    overflow-y: auto;
    min-height: 0;
}

.stat-pnl-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.45rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.stat-pnl-row__main {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.stat-pnl-row__main strong {
    font-size: 0.85rem;
}

.stat-pnl-row__main .muted {
    font-size: 0.75rem;
}

.stat-pnl-row__value {
    flex-shrink: 0;
    font-size: 0.9rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.stat-pnl-row__value--profit,
.stat-pnl-summary__net.stat-pnl-row__value--profit {
    color: #22c55e;
}

.stat-pnl-row__value--loss,
.stat-pnl-summary__net.stat-pnl-row__value--loss {
    color: #ef4444;
}

.stat-pnl-row__value--neutral,
.stat-pnl-summary__net.stat-pnl-row__value--neutral {
    color: var(--muted);
}

.stat-pnl-empty {
    margin: 0;
    padding: 0.75rem 0.25rem;
    text-align: center;
    font-size: 0.85rem;
}

.stat-pnl-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    min-height: 4.5rem;
    padding: 0.75rem 0.25rem;
    font-size: 0.85rem;
}

.stat-pnl-loading__spinner {
    width: 1.1rem;
    height: 1.1rem;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: stat-spin 0.7s linear infinite;
    flex-shrink: 0;
}

.stat-widget.is-loading .stat-widget__action[data-action="refresh"] {
    animation: stat-spin 0.7s linear infinite;
    pointer-events: none;
}

@keyframes stat-spin {
    to {
        transform: rotate(360deg);
    }
}

.stat-week-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.5rem;
    width: 100%;
    min-height: 0;
}

.stat-week-grid .stat-pnl-loading {
    grid-column: 1 / -1;
}

.stat-week-card {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-height: 7.25rem;
    padding: 0.65rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #0b0f14;
}

.stat-week-card--today {
    border-color: rgba(29, 155, 240, 0.55);
    box-shadow: inset 0 0 0 1px rgba(29, 155, 240, 0.2);
}

.stat-week-card--profit {
    background: linear-gradient(180deg, rgba(34, 197, 94, 0.1), transparent 70%);
}

.stat-week-card--loss {
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.1), transparent 70%);
}

.stat-week-card--empty {
    opacity: 0.55;
}

.stat-week-card__head {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.stat-week-card__weekday {
    font-size: 0.8rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-week-card__date {
    font-size: 0.72rem;
}

.stat-week-card__net {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.stat-week-card__split {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin-top: auto;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 1100px) {
    .stat-week-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .stat-week-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stat-week-card {
        min-height: 6.5rem;
    }
}

.stat-month-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.4rem;
    width: 100%;
    min-height: 0;
}

.stat-month-grid .stat-pnl-loading {
    grid-column: 1 / -1;
}

.stat-month-weekday {
    text-align: center;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.15rem 0 0.1rem;
}

.stat-month-card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-height: 5.75rem;
    padding: 0.45rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #0b0f14;
}

.stat-month-card--outside {
    min-height: 5.75rem;
    border-style: dashed;
    opacity: 0.28;
    background: transparent;
}

.stat-month-card--today {
    border-color: rgba(29, 155, 240, 0.55);
    box-shadow: inset 0 0 0 1px rgba(29, 155, 240, 0.2);
}

.stat-month-card--profit {
    background: linear-gradient(180deg, rgba(34, 197, 94, 0.1), transparent 70%);
}

.stat-month-card--loss {
    background: linear-gradient(180deg, rgba(239, 68, 68, 0.1), transparent 70%);
}

.stat-month-card--empty {
    opacity: 0.55;
}

.stat-month-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-month-card__day {
    font-size: 0.8rem;
    font-weight: 650;
    line-height: 1;
}

.stat-month-card__net {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.stat-month-card__split {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    margin-top: auto;
    font-size: 0.68rem;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 1100px) {
    .stat-month-card {
        min-height: 5.25rem;
        padding: 0.4rem 0.3rem;
    }

    .stat-month-card__net {
        font-size: 0.82rem;
    }
}

@media (max-width: 720px) {
    .stat-month-grid {
        gap: 0.3rem;
    }

    .stat-month-card,
    .stat-month-card--outside {
        min-height: 4.75rem;
    }

    .stat-month-card__split {
        font-size: 0.62rem;
    }
}

.history-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem 1rem;
    align-items: center;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-panel);
    cursor: pointer;
    text-align: left;
    width: 100%;
    color: inherit;
    font: inherit;
    transition: border-color 0.15s, background 0.15s;
}

.history-item:hover {
    border-color: rgba(29, 155, 240, 0.45);
    background: rgba(29, 155, 240, 0.06);
}

.history-item__main {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.history-item__symbol {
    font-weight: 600;
    font-size: 0.92rem;
}

.history-item__details {
    font-size: 0.82rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item__comment {
    font-size: 0.8rem;
    color: var(--muted);
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item__orders {
    font-size: 0.78rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item__meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    flex-shrink: 0;
}

.history-item__side {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
}

.history-item__side--long {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.12);
}

.history-item__side--short {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
}

.history-item__status {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    color: var(--danger);
    background: rgba(244, 33, 46, 0.12);
}

.history-item__date {
    font-size: 0.78rem;
    color: var(--muted);
}

.history-item__rr {
    font-size: 0.78rem;
    color: var(--accent);
}

.deal-idea-link-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.deal-idea-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.deal-idea-link:hover {
    text-decoration: underline;
}

.history-item .deal-idea-link-wrap {
    font-size: 0.82rem;
}

/* ── Deal view ── */

.deal-history-view__details {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--bg-panel);
    padding: 0;
}

.deal-history-view__head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.deal-history-view__title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.deal-history-view__status {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    color: var(--danger);
    background: rgba(244, 33, 46, 0.12);
}

.deal-history-view__tabs {
    display: flex;
    gap: 0.15rem;
    padding: 0.45rem 0.75rem 0;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.deal-history-view__tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.85rem;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.88rem;
    cursor: pointer;
}

.deal-history-view__tab:hover:not(:disabled) {
    color: var(--text);
}

.deal-history-view__tab--active {
    color: var(--text);
    border-bottom-color: var(--accent);
}

.deal-history-view__tab-badge {
    min-width: 1.15rem;
    padding: 0.05rem 0.35rem;
    border-radius: 999px;
    background: rgba(29, 155, 240, 0.18);
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
}

.deal-history-view__details-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.85rem 1rem;
}

.deal-history-view__panel {
    display: none;
    flex-direction: column;
    gap: 0.85rem;
}

.deal-history-view__panel--active {
    display: flex;
}

.deal-history-view__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 0.88rem;
    color: var(--muted);
}

.deal-history-view__meta strong {
    color: var(--text);
}

.deal-history-view__comments-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.deal-history-view__comments-empty {
    margin: 0;
    font-size: 0.88rem;
}

.deal-history-view__comment-card {
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
}

.deal-history-view__comment-date {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.78rem;
    color: var(--muted);
}

.deal-history-view__comment-text {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.deal-history-view__section-title {
    margin: 0 0 0.45rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.deal-history-view__levels {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.deal-history-view__level-row {
    display: grid;
    grid-template-columns: 3.5rem 1fr auto;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.88rem;
}

.deal-history-view__level-role {
    font-size: 0.78rem;
    font-weight: 600;
}

.deal-history-view__level-role--entry { color: #22c55e; }
.deal-history-view__level-role--stop { color: #ef4444; }
.deal-history-view__level-role--take_profit { color: #3b82f6; }

.deal-history-view__level-end {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.1rem;
}

.deal-history-view__level-price {
    font-variant-numeric: tabular-nums;
    font-size: 0.85rem;
}

.deal-history-view__level-pnl {
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

.deal-history-view__level-pnl--profit { color: #22c55e; }
.deal-history-view__level-pnl--loss { color: #ef4444; }
.deal-history-view__level-pnl--neutral { color: var(--muted); }

.deal-history-view__volumes {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.deal-history-view__volume-row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.88rem;
    color: var(--muted);
}

.deal-history-view__volume-row strong {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.deal-history-view__orders {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.deal-history-view__order-row {
    display: grid;
    grid-template-columns: 4.5rem minmax(0, 1fr) auto;
    gap: 0.5rem;
    align-items: baseline;
    font-size: 0.82rem;
}

.deal-history-view__order-label {
    color: var(--muted);
}

.deal-history-view__order-id,
.deal-history-view__level-end .deal-history-view__order-id {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.78rem;
    color: var(--accent);
    word-break: break-all;
}

.deal-history-view__order-status {
    font-size: 0.75rem;
    text-transform: lowercase;
}

.deal-history-view__order-status--filled {
    color: #22c55e;
}

.deal-history-view__order-status--active {
    color: var(--accent);
}

.deal-history-view__order-status--cancelled {
    color: #ef4444;
}

.deal-history-view__order-status--neutral {
    color: var(--muted);
}

.deal-history-view__exchange-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.deal-history-view__exchange-updated {
    font-size: 0.78rem;
}

.deal-history-view__exchange-refresh {
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font-size: 0.82rem;
    cursor: pointer;
}

.deal-history-view__exchange-refresh:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.deal-history-view__exchange-refresh:disabled {
    opacity: 0.6;
    cursor: default;
}

.deal-history-view__position {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.deal-history-view__position-row {
    display: grid;
    grid-template-columns: 7rem minmax(0, 1fr);
    gap: 0.5rem;
    align-items: baseline;
    font-size: 0.84rem;
}

.deal-history-view__position-label {
    color: var(--muted);
}

.deal-history-view__position-value {
    font-variant-numeric: tabular-nums;
}

.deal-history-view__orders-table {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.deal-history-view__orders-grid {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.deal-history-view__orders-grid-head,
.deal-history-view__orders-grid-row {
    display: grid;
    grid-template-columns: 4.5rem minmax(0, 1.4fr) 4.5rem 4.5rem minmax(0, 1fr);
    gap: 0.45rem;
    align-items: center;
    font-size: 0.8rem;
}

.deal-history-view__order-qty-input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--border);
    background: #0b0f14;
    color: var(--text);
    border-radius: 6px;
    padding: 0.2rem 0.35rem;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

.deal-history-view__order-qty-input:focus-visible {
    border-color: var(--accent);
    outline: none;
}

.deal-history-view__orders-grid-head {
    color: var(--muted);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.deal-history-view__row {
    display: flex;
    gap: 1rem;
}

.deal-history-view__field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
}

.deal-history-view__label {
    font-size: 0.82rem;
    color: var(--muted);
}

.deal-history-view__risk-reward {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
}

.deal-history-view__textarea {
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: 0.88rem;
    resize: vertical;
    min-height: 8rem;
}

.deal-history-view__textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.deal-history-view__error {
    margin: 0;
    font-size: 0.85rem;
    color: var(--danger);
}

.deal-history-view__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-panel);
}

.deal-history-view__cancel,
.deal-history-view__cancel-deal,
.deal-history-view__save {
    padding: 0.5rem 0.9rem;
    border-radius: 6px;
    font-size: 0.88rem;
    cursor: pointer;
    border: 1px solid var(--border);
}

.deal-history-view__cancel-deal {
    margin-right: auto;
    background: transparent;
    color: var(--danger);
    border-color: rgba(244, 33, 46, 0.35);
}

.deal-history-view__cancel-deal:hover:not(:disabled) {
    background: rgba(244, 33, 46, 0.12);
}

.deal-history-view__cancel-deal[hidden] {
    display: none;
}

.deal-history-view__cancel-deal:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.deal-history-view__cancel {
    background: transparent;
    color: var(--muted);
}

.deal-history-view__cancel:hover {
    color: var(--text);
    border-color: var(--muted);
}

.deal-history-view__save {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.deal-history-view__save:hover:not(:disabled) {
    filter: brightness(1.1);
}

.deal-history-view__save[hidden] {
    display: none;
}

.deal-history-view__save:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

@media (max-width: 900px) {
    .workspace-view--deal .workspace {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(0, 1fr) auto;
    }

    .workspace-view--deal .deal-history-view__details {
        max-height: 42vh;
    }

    .deal-history-view__tabs {
        overflow-x: auto;
    }
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.topbar-nav a {
    color: var(--muted);
    text-decoration: none;
}

.topbar-nav a:hover {
    color: var(--text);
    text-decoration: none;
}

.profile-page {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.profile-header h1 {
    margin: 0 0 0.35rem;
    font-size: 1.75rem;
}

.profile-layout {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.profile-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.75rem;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.profile-nav__item {
    display: block;
    width: 100%;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
}

.profile-nav__item:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
}

.profile-nav__item.is-active {
    color: var(--text);
    background: rgba(29, 155, 240, 0.12);
    border-color: rgba(29, 155, 240, 0.35);
}

.profile-content {
    min-width: 0;
}

.profile-section {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
}

.profile-section__head h2 {
    margin: 0 0 0.35rem;
    font-size: 1.15rem;
}

.profile-section__head {
    margin-bottom: 1.25rem;
}

.profile-keys-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.profile-empty {
    margin: 0;
    padding: 1rem;
    border: 1px dashed var(--border);
    border-radius: 8px;
    text-align: center;
}

.profile-key-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
}

.profile-key-card__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.profile-key-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.profile-key-card__actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.profile-badge {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(29, 155, 240, 0.15);
    color: var(--accent);
}

.profile-key-form {
    border-top: 1px solid var(--border);
    padding-top: 1.25rem;
}

.profile-form-title {
    margin: 0 0 1rem;
    font-size: 1rem;
}

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

.profile-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.profile-field--checkbox {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    padding-top: 1.6rem;
}

.profile-label {
    font-size: 0.85rem;
    color: var(--muted);
}

.profile-field input[type="text"],
.profile-field input[type="password"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.profile-field input:focus-visible {
    outline: 2px solid rgba(29, 155, 240, 0.45);
    outline-offset: 1px;
}

.profile-form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.profile-btn {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.55rem 1rem;
    font: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    background: transparent;
    color: var(--text);
}

.profile-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

.profile-btn--primary:hover:not(:disabled) {
    filter: brightness(1.05);
}

.profile-btn--ghost:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.profile-btn--danger {
    color: var(--danger);
    border-color: rgba(244, 33, 46, 0.35);
}

.profile-btn--danger:hover:not(:disabled) {
    background: rgba(244, 33, 46, 0.12);
}

.profile-form-error {
    margin: 0.75rem 0 0;
    color: var(--danger);
    font-size: 0.9rem;
}

.deal-templates-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

.deal-templates-aside__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.deal-templates-aside__head .profile-form-title {
    margin: 0;
}

.deal-templates-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.deal-template-card {
    display: flex;
    align-items: stretch;
    gap: 0.35rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    overflow: hidden;
}

.deal-template-card.is-active {
    border-color: rgba(29, 155, 240, 0.45);
    background: rgba(29, 155, 240, 0.08);
}

.deal-template-card__select {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 0.7rem 0.85rem;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.deal-template-card .profile-btn {
    border: 0;
    border-left: 1px solid var(--border);
    border-radius: 0;
    padding: 0 0.75rem;
}

.deal-template-editor__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.deal-template-name-field {
    flex: 1 1 220px;
    min-width: 0;
}

.deal-templates-status {
    font-size: 0.85rem;
    min-height: 1.2em;
}

.deal-template-grids {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.deal-grid {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.02);
}

.deal-grid__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid var(--border);
}

.deal-grid__levels {
    list-style: none;
    margin: 0;
    padding: 0;
}

.deal-grid__row {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.deal-grid__row:last-child {
    border-bottom: 0;
}

.deal-grid__line {
    display: grid;
    grid-template-columns: 4.5rem 2rem minmax(0, 1fr);
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
    padding: 0.55rem 0.9rem;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.deal-grid__add {
    align-self: center;
    width: 1.6rem;
    height: 1.6rem;
    margin-right: 0.5rem;
    padding: 0;
    border: 1px solid color-mix(in srgb, var(--role-color, var(--border)) 50%, var(--border));
    border-radius: 6px;
    background: transparent;
    color: var(--role-color, inherit);
    font: inherit;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.deal-grid__add:hover {
    background: color-mix(in srgb, var(--role-color, transparent) 20%, transparent);
}

.deal-grid__line:hover {
    background: rgba(255, 255, 255, 0.04);
}

.deal-grid__row.is-assigned {
    background: color-mix(in srgb, var(--role-color) 12%, transparent);
}

.deal-grid__row.is-assigned .deal-grid__line:hover {
    background: color-mix(in srgb, var(--role-color) 18%, transparent);
}

.deal-grid__ratio {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.deal-grid__point {
    color: var(--muted);
    font-size: 0.8rem;
}

.deal-grid__role {
    justify-self: end;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--role-color, var(--muted));
}

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

@media (max-width: 860px) {
    .profile-layout {
        grid-template-columns: 1fr;
    }

    .profile-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .profile-nav__item {
        width: auto;
    }

    .deal-templates-layout,
    .deal-template-grids {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .profile-form-grid {
        grid-template-columns: 1fr;
    }

    .profile-field--checkbox {
        padding-top: 0;
    }

    .profile-key-card {
        flex-direction: column;
        align-items: stretch;
    }

    .profile-key-card__actions {
        justify-content: flex-end;
    }

    .deal-grid__line {
        grid-template-columns: 3.5rem 1.5rem minmax(0, 1fr);
        gap: 0.35rem;
        padding: 0.5rem 0.7rem;
    }
}
