/* ELAN Kimiya — тёмная премиум-тема финансового терминала */

:root {
    --bg:         #14181d;
    --bg-soft:    #181d23;
    --surface:    #1c2228;
    --surface-2:  #222932;
    --border:     #2b333d;
    --border-soft:#242c35;
    --text:       #e8e6e1;
    --text-2:     #b8bfc7;
    --muted:      #7d8590;
    --gold:       #d4a843;
    --gold-soft:  rgba(212, 168, 67, 0.12);
    --green:      #3fa876;
    --green-soft: rgba(63, 168, 118, 0.12);
    --red:        #d9584f;
    --red-soft:   rgba(217, 88, 79, 0.12);
    --yellow:     #d4b04a;
    --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow:     0 4px 18px rgba(0, 0, 0, 0.35);
    --shadow-lg:  0 16px 48px rgba(0, 0, 0, 0.5);
    --radius:     12px;
    --radius-sm:  8px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Все цифры — табличные */
.num, .kpi-value, .table td, .sync-info {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum';
}

/* === Navbar === */
header {
    background: rgba(20, 24, 29, 0.88);
    backdrop-filter: saturate(160%) blur(10px);
    -webkit-backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid var(--border-soft);
    position: sticky;
    top: 0;
    z-index: 50;
}
.nav {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 32px;
    max-width: 1440px;
    margin: 0 auto;
}
.nav .brand {
    font-weight: 700;
    font-size: 17px;
    color: var(--text);
    text-decoration: none;
    margin-right: 26px;
    letter-spacing: -0.01em;
    white-space: nowrap;
}
.nav .brand:hover { color: var(--gold); }
.nav > a:not(.brand) {
    color: var(--text-2);
    text-decoration: none;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.12s ease;
    white-space: nowrap;
}
.nav > a:not(.brand):hover { background: var(--surface-2); color: var(--text); }
.nav .spacer { flex: 1; }
.sync-form { margin: 0; }
.sync-form button {
    background: var(--surface);
    color: var(--text-2);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.12s ease;
}
.sync-form button:hover { background: var(--gold); color: #14181d; border-color: var(--gold); }
.sync-form button:disabled { opacity: 0.5; cursor: wait; }
.sync-info { color: var(--muted); font-size: 11px; margin-left: 8px; white-space: nowrap; }
.sync-info.warn { color: var(--red); }
.logout-btn { background: transparent !important; }
.logout-btn:hover { background: var(--red) !important; color: #fff !important; border-color: var(--red) !important; }

main {
    max-width: 1440px;
    margin: 0 auto;
    padding: 34px 32px 80px;
}

/* === Typography === */
h1 {
    font-weight: 700;
    font-size: 30px;
    letter-spacing: -0.02em;
    margin: 0 0 4px 0;
    color: var(--text);
}
.page-sub { color: var(--muted); margin: 0 0 28px 0; font-size: 13px; }
h2 {
    margin-top: 0;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 16px;
}
h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px 0; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.strong { font-weight: 600; color: var(--text); }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* === Cards === */
.card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4col { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-2col > .card, .grid-3col > .card, .grid-4col > .card { margin-bottom: 0; }
.grid-2col, .grid-3col, .grid-4col { margin-bottom: 20px; }
@media (max-width: 1000px) {
    .grid-2col, .grid-3col, .grid-4col { grid-template-columns: 1fr; }
    main { padding: 24px 18px; }
    h1 { font-size: 24px; }
    .nav { padding: 12px 16px; flex-wrap: wrap; }
}

/* === KPI === */
.kpi {
    background: linear-gradient(150deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}
.kpi-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    margin-bottom: 8px;
}
.kpi-value {
    font-weight: 700;
    font-size: 28px;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--text);
}
.kpi-sub { color: var(--muted); font-size: 12px; margin-top: 5px; }
.kpi-gold .kpi-value { color: var(--gold); }
.kpi-value.pos { color: var(--green); }
.kpi-value.neg { color: var(--red); }

/* === Alerts === */
.alert {
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 10px;
    border: 1px solid transparent;
}
.alert-warn {
    background: rgba(212, 176, 74, 0.1);
    border-color: rgba(212, 176, 74, 0.35);
    color: var(--yellow);
}
.alert-danger {
    background: var(--red-soft);
    border-color: rgba(217, 88, 79, 0.4);
    color: #e8837b;
}

/* === Tables === */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    padding: 10px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-soft);
    font-size: 13px;
}
.table th {
    font-weight: 600;
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom-color: var(--border);
}
.table th.right { text-align: right; }
.table tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
.table tfoot td {
    border-top: 2px solid var(--border);
    border-bottom: none;
    font-weight: 600;
    color: var(--text);
}
.table .section-row td {
    background: var(--surface-2);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 7px 10px;
}
.table .section-row.income td { color: var(--green); }
.table .section-row.expense td { color: var(--red); }
.cell-usd { display: block; color: var(--muted); font-size: 11px; margin-top: 1px; }
.table-scroll { overflow-x: auto; }

/* === Charts === */
.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 360px; }
.chart-box.doughnut { height: 280px; }

/* === Прогноз: методика / disclaimer === */
.disclaimer {
    background: rgba(212, 176, 74, 0.08);
    border: 1px solid rgba(212, 176, 74, 0.3);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    color: var(--yellow);
    font-size: 13px;
    margin-bottom: 20px;
}
.method-list { margin: 0; padding-left: 0; list-style: none; }
.method-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-2);
    font-size: 13px;
}
.method-list li:last-child { border-bottom: none; }
.method-list b { color: var(--text); }

/* === Login === */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: var(--bg); padding: 16px;
    background-image:
        radial-gradient(at 15% 5%, rgba(212, 168, 67, 0.07) 0%, transparent 45%),
        radial-gradient(at 85% 95%, rgba(63, 168, 118, 0.05) 0%, transparent 50%);
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 42px 38px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.login-brand { font-size: 34px; margin-bottom: 6px; }
.login-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.login-sub { margin: 6px 0 26px 0; color: var(--muted); font-size: 13px; }
.login-hint { color: var(--text-2); font-size: 13px; margin: 0 0 18px 0; }
.login-hint strong { color: var(--gold); font-weight: 600; }
.login-error {
    background: var(--red-soft);
    border: 1px solid rgba(217, 88, 79, 0.4);
    color: #e8837b;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 18px;
    text-align: left;
}
.login-info {
    background: var(--green-soft);
    border: 1px solid rgba(63, 168, 118, 0.35);
    color: var(--green);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 18px;
    text-align: left;
}
.login-card form { display: flex; flex-direction: column; gap: 16px; }
.login-card label {
    display: flex; flex-direction: column; gap: 6px;
    font-size: 11px; color: var(--muted); text-align: left;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
}
.login-card input {
    padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 14px; font-family: inherit; background: var(--bg-soft);
    color: var(--text);
    transition: all 0.15s ease;
}
.login-card input:focus {
    outline: none; border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(212, 168, 67, 0.15);
}
.otp-input {
    text-align: center;
    font-size: 24px !important;
    letter-spacing: 0.45em;
    font-variant-numeric: tabular-nums;
}
.login-card button[type="submit"] {
    padding: 12px 16px; background: var(--gold); color: #14181d;
    border: none; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px;
    font-weight: 700; margin-top: 6px; font-family: inherit;
    transition: all 0.15s ease;
}
.login-card button[type="submit"]:hover { background: #e0b856; transform: translateY(-1px); }
.login-resend { margin-top: 16px; }
.link-btn {
    background: none !important; border: none; color: var(--muted) !important;
    font-size: 12px; cursor: pointer; font-family: inherit;
    text-decoration: underline; text-underline-offset: 3px;
    padding: 4px !important; margin: 0 auto;
}
.link-btn:hover { color: var(--gold) !important; transform: none !important; }

/* === Empty state === */
.empty { text-align: center; padding: 36px 20px; color: var(--muted); }

/* --- Выравнивание таблиц: числовые ячейки строго вправо (учётный стандарт) --- */
.table td.right { text-align: right; }
.table tfoot td.right { text-align: right; }

/* --- Раскрывающиеся entity-строки (Отчёт A) --- */
.entity-row { cursor: pointer; user-select: none; }
.entity-row .caret {
    display: inline-block; width: 14px; margin-right: 4px;
    color: var(--muted, #7d8590); transition: transform .15s ease;
}
.entity-row.open .caret { transform: rotate(90deg); }
.acct-row td {
    background: rgba(255, 255, 255, 0.015);
    color: #8b95a1; font-size: 12px; padding-top: 7px; padding-bottom: 7px;
}
.acct-row td:first-child { padding-left: 36px; }

/* --- Вкладка «Уточнения» --- */
.q-card { margin-bottom: 14px; border-left: 3px solid #d4a843; }
.q-card.q-confirmed, .q-card.q-resolved { border-left-color: #3fa876; opacity: .85; }
.q-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.q-id { font-size: 11px; font-weight: 700; color: #7d8590; background: rgba(255,255,255,.05);
        padding: 2px 8px; border-radius: 999px; }
.q-topic { margin: 0; font-size: 15px; flex: 1; }
.q-status { font-size: 11px; font-weight: 700; white-space: nowrap; }
.q-status-open { color: #d4a843; }
.q-status-confirmed, .q-status-resolved { color: #3fa876; }
.q-context { color: #8b95a1; font-size: 13px; margin: 0 0 12px; line-height: 1.5; }
.q-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .q-grid { grid-template-columns: 1fr; } }
.q-label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #7d8590; margin-bottom: 4px; }
.q-value { font-size: 13px; line-height: 1.5; }
.q-resolution { margin-top: 12px; padding: 10px 12px; background: rgba(63,168,118,.08);
                border-radius: 8px; font-size: 13px; color: #3fa876; }
.q-meta { margin-top: 10px; font-size: 11px; color: #7d8590; }
