:root {
    --bg: #f4efe7;
    --surface: #fffdf8;
    --surface-2: #f8f1e6;
    --line: #ded1bf;
    --text: #1f1a17;
    --muted: #76695c;
    --accent: #c4632d;
    --accent-dark: #8f431c;
    --green: #1f7a4d;
    --red: #b43a2f;
    --shadow: 0 12px 30px rgba(76, 48, 26, 0.10);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    background:
        radial-gradient(circle at top left, rgba(196, 99, 45, 0.10), transparent 30%),
        linear-gradient(180deg, #f7f1e8 0%, #efe4d4 100%);
    color: var(--text);
}

.page {
    width: min(1500px, calc(100% - 24px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.topbar,
.panel,
.login-card,
.stat-card {
    background: rgba(255, 253, 248, 0.94);
    backdrop-filter: blur(6px);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.topbar {
    border-radius: 24px;
    padding: 24px 28px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.eyebrow {
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 12px;
    color: var(--accent-dark);
}

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

.subtle,
.panel-head p,
small,
.muted {
    color: var(--muted);
}

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

.user-chip {
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--line);
}

.logout-link,
.btn {
    text-decoration: none;
    border: 0;
    cursor: pointer;
    border-radius: 12px;
    padding: 10px 14px;
    font: inherit;
}

.logout-link,
.btn.primary,
.btn {
    background: var(--accent);
    color: #fff;
}

.logout-link:hover,
.btn:hover {
    background: var(--accent-dark);
}

.btn.secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--line);
}

.btn.secondary:hover {
    background: #eadbc7;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.stat-card {
    border-radius: 20px;
    padding: 20px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    margin-bottom: 8px;
}

.stat-card strong {
    font-size: 34px;
}

.panel {
    border-radius: 24px;
    padding: 24px;
}

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

.filters-form label {
    display: grid;
    gap: 8px;
    font-size: 14px;
    color: var(--muted);
}

.filters-form input,
.filters-form select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    background: #fff;
    color: var(--text);
    font: inherit;
}

.filters-search {
    grid-column: span 2;
}

.filters-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 12px;
    align-items: center;
}

.panel-head {
    margin-bottom: 16px;
}

.panel-head-split {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.panel-subtitle {
    margin: -4px 0 16px;
    color: var(--muted);
}

.inline-nav-link {
    white-space: nowrap;
}

.detail-panel {
    display: grid;
    gap: 18px;
}

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

.detail-card {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
}

.detail-card span {
    display: block;
    color: var(--muted);
    margin-bottom: 8px;
    font-size: 13px;
}

.detail-card strong {
    display: block;
    font-size: 16px;
    line-height: 1.4;
}

.detail-sections {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 16px;
}

.detail-block {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
}

.detail-block h3 {
    margin-top: 0;
    margin-bottom: 12px;
}

.detail-block p,
.detail-block pre {
    margin: 0;
}

.detail-block pre {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 13px;
    line-height: 1.55;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 0;
    table-layout: fixed;
}

th,
td {
    padding: 14px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    overflow-wrap: anywhere;
}

th {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.status,
.action-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.status.new {
    background: #fff1c9;
    color: #866500;
}

.status.acknowledged {
    background: #dff4e8;
    color: #145c39;
}

.action-pill.buy {
    background: #dff4e8;
    color: var(--green);
}

.action-pill.long,
.action-pill.al_sinyal {
    background: #dff4e8;
    color: var(--green);
}

.action-pill.sell {
    background: #fde1dc;
    color: var(--red);
}

.action-pill.short,
.action-pill.atla {
    background: #fde1dc;
    color: var(--red);
}

.action-pill.info {
    background: #ece2d5;
    color: #5b4c3f;
}

.action-pill {
    background: #ece2d5;
    color: #5b4c3f;
}

.message-cell {
    max-width: none;
    line-height: 1.45;
}

.summary-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.metric-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--text);
    font-size: 12px;
    line-height: 1.3;
}

.tv-inline-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fffaf2;
    color: var(--accent-dark);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
}

.tv-inline-link:hover {
    background: #f3e2cc;
}

th:nth-child(1),
td:nth-child(1) {
    width: 4%;
}

th:nth-child(2),
td:nth-child(2) {
    width: 6%;
}

th:nth-child(3),
td:nth-child(3) {
    width: 6%;
}

th:nth-child(4),
td:nth-child(4) {
    width: 10%;
}

th:nth-child(5),
td:nth-child(5) {
    width: 7%;
}

th:nth-child(6),
td:nth-child(6) {
    width: 5%;
}

th:nth-child(7),
td:nth-child(7) {
    width: 36%;
}

th:nth-child(8),
td:nth-child(8) {
    width: 10%;
}

th:nth-child(9),
td:nth-child(9) {
    width: 8%;
}

th:nth-child(10),
td:nth-child(10) {
    width: 8%;
}

td:nth-child(4) strong,
td:nth-child(7) div,
td:nth-child(7) small {
    display: block;
}

td:nth-child(5),
td:nth-child(7),
td:nth-child(8) {
    font-size: 15px;
}

.empty-state {
    padding: 28px;
    border-radius: 18px;
    background: var(--surface-2);
    border: 1px dashed var(--line);
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(460px, 100%);
    border-radius: 28px;
    padding: 28px;
}

.login-form {
    display: grid;
    gap: 16px;
    margin-top: 20px;
}

.login-form label {
    display: grid;
    gap: 8px;
}

.login-form input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    background: #fff;
    font: inherit;
}

.error-box {
    margin-top: 16px;
    border: 1px solid #efb4ad;
    background: #ffe8e4;
    color: #8f2b22;
    padding: 12px 14px;
    border-radius: 14px;
}

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

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

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

    .panel-head-split {
        flex-direction: column;
        align-items: flex-start;
    }

    .filters-search {
        grid-column: span 2;
    }

    .detail-grid,
    .detail-sections {
        grid-template-columns: 1fr;
    }

    .inline-detail-layout,
    .inline-detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .page {
        width: calc(100% - 20px);
        padding-top: 20px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .panel,
    .topbar,
    .login-card {
        padding: 18px;
        border-radius: 18px;
    }

    .filters-form {
        grid-template-columns: 1fr;
    }

    .filters-search {
        grid-column: span 1;
    }

    .filters-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .expanded-alert-cell {
        padding: 14px;
    }

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

    table {
        table-layout: auto;
        min-width: 980px;
    }
}

.chart-block {
    overflow: hidden;
}

.chart-block h3 {
    margin-bottom: 12px;
}

.chart-container {
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: #fff;
}

#tv-chart {
    min-height: 500px;
}

.expanded-alert-row td {
    padding: 0;
    border-bottom: 1px solid var(--line);
    background: rgba(248, 241, 230, 0.55);
}

.expanded-alert-cell {
    padding: 18px 18px 22px;
}

.inline-detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.9fr) minmax(320px, 0.9fr);
    gap: 18px;
    align-items: start;
}

.inline-chart-block,
.inline-side-panel {
    min-width: 0;
}

.inline-block-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: baseline;
    margin-bottom: 12px;
}

.inline-block-head h3,
.inline-side-panel h3 {
    margin-bottom: 0;
}

.inline-block-head p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.inline-chart-container {
    position: relative;
    width: 100%;
    min-height: 460px;
}

.inline-chart-container > div {
    width: 100%;
    min-height: 460px;
}

.inline-chart-container iframe,
.inline-chart-container > div > iframe {
    width: 100%;
    height: 460px;
    border: 0;
}

.inline-side-panel {
    display: grid;
    gap: 16px;
}

.inline-detail-cards {
    display: grid;
    gap: 14px;
}

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

.inline-detail-card {
    background: #fffaf2;
}
