body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', Roboto, sans-serif;
    background-color: #f6f7fb;
    color: #1f1f1f;
    line-height: 1.6;
}

/* === Header === */
header {
    background-color: #fff;
    border-bottom: 1px solid #e5e8ee;
    padding: 12px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1a1a1a;
    text-decoration: none;
}

.brand .bullet {
    color: #007aff;
}

/* === Navigation === */
nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

nav a,
nav button {
    background: none;
    border: none;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    color: #1f1f1f;
    cursor: pointer;
    transition: color 0.2s ease;
}

nav a:hover,
nav button:hover {
    color: #007aff;
}

/* === Logout Button === */
.logout-form--nav {
    display: inline-block;
}

.logout-form--nav button {
    color: #1f1f1f;
}

/* === Main Container === */
.container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

/* === Panels (white cards) === */
.panel {
    background-color: #fff;
    border-radius: 16px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
    padding: 32px;
    margin-bottom: 32px;
}

.panel h2,
.panel h3 {
    margin-top: 0;
}

.panel h2 {
    margin-bottom: 16px;
    font-size: 1.4rem;
}

.panel h3 {
    margin-bottom: 12px;
}

/* === Table === */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.table th {
    text-align: left;
    padding: 10px 0;
    border-bottom: 1px solid #eceef2;
    color: #555;
    font-weight: 600;
}

.table td {
    padding: 10px 0;
    border-bottom: 1px solid #f3f4f6;
}

/* === Badges === */
.badge {
    display: inline-block;
    padding: 4px 10px;
    background-color: #007aff;
    color: white;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* === Buttons === */
.btn {
    background-color: #007aff;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease;
}

.btn:hover {
    background-color: #005fcc;
}

.btn-secondary {
    background-color: #e9efff;
    color: #1a3dbf;
}

.btn-secondary:hover {
    background-color: #dce8ff;
}

/* === Lists and Rows === */
.list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.row-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-top: 1px solid #f0f1f5;
}

.row-between:first-child {
    border-top: none;
}

/* === Layout Grid === */
.grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

/* === Footer === */
.footer {
    text-align: center;
    color: #888;
    font-size: 0.9rem;
    padding: 24px 0;
}

/* === Responsiveness === */
@media (max-width: 900px) {
    .grid {
        grid-template-columns: 1fr;
    }
    nav {
        flex-wrap: wrap;
        gap: 8px;
    }
    .container {
        margin: 20px auto;
    }
}

@media (max-width: 600px) {
    .auth {
        padding: 56px 12px 24px;
    }

    .auth-card {
        padding: 36px 28px;
        gap: 20px;
        border-radius: 18px;
        box-shadow: 0 14px 32px rgba(30, 40, 80, 0.12);
    }

    .auth-actions {
        gap: 8px;
    }
}

/* === Login Page Centering === */
.center {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 120px); /* чтобы было по центру по высоте */
}

.auth {
    padding: 72px 16px 28px;
    background: linear-gradient(160deg, #f7f9ff 0%, #eef2ff 50%, #f9fbff 100%);
}

.center.auth {
    align-items: flex-start;
    min-height: auto;
}

.auth-card {
    width: min(460px, 100%);
    padding: 48px 40px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    text-align: left;
    box-shadow: 0 18px 40px rgba(30, 40, 80, 0.12);
    border-radius: 20px;
    margin-bottom: 0;
}

.auth-card h2 {
    margin: 0;
    font-size: 1.6rem;
    text-align: center;
}

.auth-card .hint {
    text-align: center;
    margin: 0;
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-field label {
    font-weight: 600;
    color: #1f1f1f;
}

/* === Form Inputs === */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"] {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #dcdfe6;
    border-radius: 12px;
    font-size: 1.05rem;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: #fbfcff;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus {
    border-color: #007aff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,122,255,0.15);
}

.auth-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* === Helper Blocks === */
.hint {
    font-size: 0.9rem;
    color: #666;
}

/* === Form Buttons === */
.row {
    display: flex;
    align-items: center;
}

.btn-primary {
    background-color: #007aff;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: #005fcc;
}

/* Pump screener settings */
.pump-settings__form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.pump-settings__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
}

.toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.watchlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

/* Limit to max 2 columns when desired (e.g. EMA page) */
.watchlist-grid--2cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 700px) {
    .watchlist-grid--2cols {
        grid-template-columns: 1fr;
    }
}

.watch-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border: 1px solid #dcdfe6;
    border-radius: 12px;
    background-color: #fbfcff;
}

.watch-card__symbol {
    font-weight: 600;
    letter-spacing: 0.6px;
}

.watchlist-add {
    margin-top: 8px;
    gap: 12px;
    align-items: stretch;
}

.watchlist-add input[type="text"] {
    flex: 1;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.hint--error {
    color: #d14343;
}

.empty-state {
    padding: 18px;
    border-radius: 12px;
    background-color: #f2f4fb;
    margin: 16px 0;
    color: #525866;
}

/* === Portfolio analysis === */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.metric-card {
    border: 1px solid #e5e8ee;
    border-radius: 12px;
    padding: 16px;
    background-color: #fbfcff;
}

.metric-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.metric-card__title {
    font-weight: 700;
}

.metric-card__title-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.metric-card__value {
    font-size: 1.4rem;
    margin: 8px 0 6px;
}

.metric-help {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 1px solid #cfd6e4;
    background-color: #f3f6fc;
    color: #667085;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    cursor: help;
    flex: 0 0 auto;
}

.metric-help__tooltip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%);
    width: min(240px, 70vw);
    padding: 10px 12px;
    border-radius: 10px;
    background-color: #1f2937;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 400;
    line-height: 1.45;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.16s ease, visibility 0.16s ease;
    z-index: 5;
}

.metric-help__tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: #1f2937 transparent transparent transparent;
}

.metric-help:hover .metric-help__tooltip,
.metric-help:focus-visible .metric-help__tooltip {
    opacity: 1;
    visibility: visible;
}

.status-ok {
    background-color: #12b76a;
}

.status-bad {
    background-color: #ef4444;
}

.portfolio-connect__form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.latency-filter {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
}

.latency-filter select {
    min-width: 280px;
    padding: 10px 12px;
    border: 1px solid #dcdfe6;
    border-radius: 10px;
    background-color: #fbfcff;
}

.table--latency th:nth-child(4),
.table--latency td:nth-child(4),
.table--latency th:nth-child(5),
.table--latency td:nth-child(5),
.table--latency th:nth-child(9),
.table--latency td:nth-child(9) {
    display: none;
}

.table--latency td:last-child {
    max-width: 520px;
}

.latency-table-wrap {
    overflow-x: auto;
}

.table--latency {
    min-width: 1280px;
    table-layout: fixed;
}

.table--latency th {
    text-align: center;
    vertical-align: middle;
    white-space: normal;
    word-break: break-word;
    line-height: 1.3;
    padding: 12px 10px;
    border-right: 1px solid #eceef2;
}

.table--latency td {
    padding: 12px 10px;
    vertical-align: top;
    border-right: 1px solid #f3f4f6;
}

.table--latency th:last-child,
.table--latency td:last-child {
    border-right: none;
}

.table--latency th:nth-child(1),
.table--latency td:nth-child(1) {
    width: 130px;
}

.table--latency th:nth-child(2),
.table--latency td:nth-child(2) {
    width: 100px;
}

.table--latency th:nth-child(3),
.table--latency td:nth-child(3) {
    width: 110px;
}

.table--latency th:nth-child(6),
.table--latency td:nth-child(6),
.table--latency th:nth-child(7),
.table--latency td:nth-child(7) {
    width: 130px;
}

.table--latency th:nth-child(8),
.table--latency td:nth-child(8) {
    width: 110px;
}
