/* ============================================================
   WT Tracker — стили
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #1a1a1a;
    color: #e0e0e0;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container { max-width: 1100px; margin: 0 auto; padding: 0 15px; width: 100%; }

header { background: #2a2a2a; padding: 15px 0; border-bottom: 1px solid #333; margin-bottom: 20px; }
header h1 { font-size: 1.4rem; margin-bottom: 10px; }

nav { display: flex; gap: 10px; flex-wrap: wrap; }
nav a { color: #aaa; text-decoration: none; padding: 6px 12px; border-radius: 5px; transition: background 0.2s, color 0.2s; }
nav a:hover { background: #333; color: #fff; }

main { flex: 1; padding-bottom: 30px; }
footer { text-align: center; padding: 20px 0; color: #666; font-size: 0.9rem; border-top: 1px solid #333; margin-top: 30px; }

h2 { font-size: 1.2rem; margin-bottom: 15px; color: #e0e0e0; }
h3 { font-size: 1rem; color: #e0e0e0; }

.card { background: #2a2a2a; border-radius: 10px; padding: 20px; margin-bottom: 20px; border: 1px solid #333; }
.card h2 { margin-bottom: 15px; }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-bottom: 20px; }
.summary-item { background: #2a2a2a; padding: 15px; border-radius: 10px; border: 1px solid #333; }
.summary-item .label { font-size: 0.85rem; color: #888; margin-bottom: 5px; }
.summary-item .value { font-size: 1.3rem; font-weight: bold; color: #4a9eff; word-break: break-word; }

button, .btn { background: #4a9eff; color: #fff; border: none; padding: 10px 20px; border-radius: 5px; font-size: 1rem; cursor: pointer; text-decoration: none; display: inline-block; transition: background 0.2s; font-family: inherit; }
button:hover, .btn:hover { background: #3a8eef; }
.btn-danger { background: #e74c3c; }
.btn-danger:hover { background: #d73c2c; }
.btn-secondary { background: #555; color: #fff; text-decoration: none; padding: 10px 20px; border-radius: 5px; display: inline-block; transition: background 0.2s; border: none; cursor: pointer; font-size: 1rem; font-family: inherit; }
.btn-secondary:hover { background: #666; }
.btn-small { padding: 5px 12px; font-size: 0.85rem; }

input, select { background: #1a1a1a; color: #e0e0e0; border: 1px solid #444; padding: 10px 15px; border-radius: 5px; font-size: 1rem; width: 100%; font-family: inherit; }
input:focus, select:focus { outline: none; border-color: #4a9eff; }

.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; color: #aaa; font-size: 0.9rem; }
.form-row { display: flex; gap: 15px; align-items: flex-end; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 150px; margin-bottom: 0; }

.filter-section { display: flex; flex-direction: column; gap: 15px; }
.filter-group label { display: block; margin-bottom: 8px; color: #888; font-size: 0.85rem; text-transform: uppercase; }

.tabs { display: flex; gap: 5px; flex-wrap: wrap; }
.tabs-small .tab { padding: 5px 10px; font-size: 0.85rem; }
.tab { background: #333; color: #aaa; border: 1px solid #444; padding: 8px 16px; border-radius: 5px; cursor: pointer; text-decoration: none; font-size: 0.95rem; transition: background 0.2s, color 0.2s; font-family: inherit; display: inline-block; }
.tab:hover { background: #3a3a3a; color: #fff; }
.tab.active { background: #4a9eff; color: #fff; border-color: #4a9eff; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px; text-align: left; border-bottom: 1px solid #333; }
th { color: #888; font-size: 0.85rem; text-transform: uppercase; font-weight: normal; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #333; }
.value-small { color: #4a9eff; font-weight: bold; }

.progress-bar { background: #333; border-radius: 5px; overflow: hidden; height: 8px; margin: 10px 0; }
.progress-fill { background: linear-gradient(90deg, #4a9eff, #6ab0ff); height: 100%; transition: width 0.3s; border-radius: 5px; }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }

.tank-item { padding: 15px 0; border-bottom: 1px solid #333; }
.tank-item:last-child { border-bottom: none; }
.tank-card { padding: 15px 20px; }
.tank-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; flex-wrap: wrap; gap: 10px; }
.tank-header a { color: #4a9eff; text-decoration: none; font-size: 1.05rem; }
.tank-header a:hover { text-decoration: underline; }
.nation { color: #888; font-size: 0.9rem; }
.tank-stats { display: flex; justify-content: space-between; font-size: 0.9rem; color: #aaa; flex-wrap: wrap; gap: 10px; }
.tank-info { margin-top: 15px; color: #888; font-size: 0.9rem; }
.tank-info div { margin-bottom: 5px; }
.tank-actions { margin-top: 15px; display: flex; gap: 10px; flex-wrap: wrap; }

.nation-group { margin-bottom: 25px; }
.nation-title { color: #4a9eff; font-size: 1rem; margin-bottom: 10px; padding-left: 5px; letter-spacing: 1px; }

.empty { color: #666; font-style: italic; text-align: center; padding: 20px; }
.empty a { color: #4a9eff; text-decoration: none; }
.empty a:hover { text-decoration: underline; }

#results { margin-top: 15px; }
#results table { margin-top: 10px; }

/* ============================================================
   АНАЛИТИКА
   ============================================================ */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 15px;
}

.analytics-item {
    background: #1f1f1f;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.analytics-label {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.analytics-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: #4a9eff;
    word-break: break-word;
}

.forecast-box {
    background: linear-gradient(135deg, #1f2a1f, #2a251f);
    border: 2px solid #ff9800;
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
    text-align: center;
}

.forecast-box.done {
    background: linear-gradient(135deg, #1f2a1f, #1f2a1f);
    border-color: #4caf50;
}

.forecast-label {
    font-size: 0.85rem;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.forecast-value {
    font-size: 1.1rem;
    color: #e0e0e0;
}

.forecast-value strong {
    color: #ff9800;
    font-size: 1.3rem;
}

.forecast-box.done .forecast-value strong {
    color: #4caf50;
}

.forecast-value a {
    color: #4a9eff;
    text-decoration: none;
}

.forecast-value a:hover {
    text-decoration: underline;
}

.forecast-date {
    color: #888;
    font-size: 0.9rem;
}

/* График */
.chart {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 120px;
    padding: 10px 0;
    border-bottom: 1px solid #333;
    margin-bottom: 8px;
}

.chart-bar {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: flex-end;
    cursor: pointer;
    position: relative;
}

.chart-bar-fill {
    width: 100%;
    background: linear-gradient(to top, #4a9eff, #6ab0ff);
    border-radius: 2px 2px 0 0;
    min-height: 2px;
    transition: background 0.2s;
}

.chart-bar:hover .chart-bar-fill {
    background: linear-gradient(to top, #ff9800, #ffb74d);
}

.chart-bar-fill.chart-bar-negative {
    background: linear-gradient(to top, #e74c3c, #ff6b5b);
}

.chart-legend {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #666;
}

/* ============================================================
   СВОРАЧИВАЕМЫЕ БЛОКИ (COLLAPSE)
   ============================================================ */
.collapsible {
    position: relative;
}

.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 5px 0;
    margin: -5px 0 10px 0;
    transition: color 0.2s;
}

.collapsible-header:hover {
    color: #4a9eff;
}

.collapsible-header h2 {
    margin: 0;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.collapsible-arrow {
    font-size: 0.8rem;
    color: #888;
    transition: transform 0.2s;
    margin-left: 10px;
}

.collapsible.collapsed .collapsible-arrow {
    transform: rotate(-90deg);
}

.collapsible.collapsed .collapsible-body {
    display: none;
}

.collapsible-body {
    transition: opacity 0.2s;
}

/* ============================================================
   ДЕРЕВО ИССЛЕДОВАНИЯ
   ============================================================ */
.tree-legend { display: flex; gap: 20px; flex-wrap: wrap; padding: 12px 20px; align-items: center; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; color: #aaa; }

.status-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid transparent; }
.status-dot.status-purchased { background: #4caf50; }
.status-dot.status-progress { background: #ff9800; }
.status-dot.status-locked { background: #555; }
.group-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: #4a9eff; border: 2px solid #2a2a2a; }
.reserve-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: #444; border: 2px solid #2a2a2a; }

.tree-card { padding: 10px; }
.tree-grid-wrap { overflow-x: auto; overflow-y: visible; padding-bottom: 10px; }
.tree-table { border-collapse: separate; border-spacing: 8px; min-width: max-content; }
.rank-header { background: transparent; border: none; }
.branch-header, .premium-header { background: #1f1f1f; color: #888; font-size: 0.7rem; text-transform: uppercase; padding: 8px 6px; text-align: center; border-radius: 6px 6px 0 0; font-weight: normal; letter-spacing: 0.5px; }
.premium-header { color: #ffc107; background: #2a2510; }
.rank-cell { background: #1f1f1f; color: #4a9eff; font-weight: bold; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; text-align: center; vertical-align: middle; padding: 10px 8px; border-radius: 6px; border: 1px solid #333; min-width: 70px; white-space: nowrap; }
.branch-cell { vertical-align: top; padding: 4px; min-width: 130px; max-width: 150px; }
.premium-cell { vertical-align: top; padding: 4px; min-width: 140px; max-width: 160px; border-left: 2px dashed #444; background: rgba(255, 193, 7, 0.03); }

.tree-node { background: #252525; border: 2px solid #444; border-radius: 6px; padding: 8px 10px; margin-bottom: 4px; text-align: center; transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s; cursor: pointer; position: relative; }
.tree-node:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4); }
.tree-node.status-locked { border-color: #444; background: #1f1f1f; opacity: 0.75; }
.tree-node.status-active { border-color: #ff9800; background: #2a251f; box-shadow: 0 0 10px rgba(255, 152, 0, 0.25); }
.tree-node.status-done { border-color: #4caf50; background: #1f2a1f; }
.tree-node.group-node { border-color: #4a9eff; background: #1f242a; }
.tree-node.group-node:hover { box-shadow: 0 4px 14px rgba(74, 158, 255, 0.3); }
.reserve-node { border-color: #555 !important; background: #1a1a1a !important; opacity: 0.6; }
.reserve-node:hover { opacity: 0.9; }
.premium-node { border-color: #ffc107 !important; background: #2a2510 !important; position: relative; }
.premium-node::before { content: "⭐"; position: absolute; top: 3px; right: 5px; font-size: 0.7rem; opacity: 0.9; }
.premium-node:hover { box-shadow: 0 4px 14px rgba(255, 193, 7, 0.3) !important; }

.node-name { font-size: 0.75rem; font-weight: bold; color: #e0e0e0; line-height: 1.2; word-wrap: break-word; overflow-wrap: break-word; margin-bottom: 2px; }
.node-sub { font-size: 0.65rem; color: #888; }
.node-badge { position: absolute; bottom: 3px; right: 5px; font-size: 0.6rem; background: #444; color: #aaa; padding: 1px 5px; border-radius: 3px; text-transform: uppercase; }
.done-badge { background: #4caf50 !important; color: #fff !important; }
.progress-badge { background: #ff9800 !important; color: #fff !important; }
.node-progress { height: 3px; background: #333; border-radius: 2px; overflow: hidden; margin-top: 4px; }
.node-progress-fill { height: 100%; background: #ff9800; border-radius: 2px; transition: width 0.3s; }

/* ============ Модальное окно ============ */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.7); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal-content { background: #2a2a2a; border-radius: 10px; border: 1px solid #444; max-width: 600px; width: 100%; max-height: 80vh; overflow-y: auto; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-bottom: 1px solid #333; }
.modal-header h3 { color: #4a9eff; font-size: 1.1rem; }
.modal-close { background: none; border: none; color: #aaa; font-size: 1.5rem; cursor: pointer; padding: 0 5px; line-height: 1; }
.modal-close:hover { color: #fff; }
#modal-body { padding: 15px 20px; }
#modal-body .status-locked { color: #888; }
#modal-body .status-progress { color: #ff9800; font-weight: bold; }
#modal-body .status-purchased { color: #4caf50; }

/* ============ Адаптив ============ */
@media (max-width: 768px) {
    .rank-cell { min-width: 50px; font-size: 0.65rem; padding: 6px 4px; }
    .branch-cell { min-width: 100px; max-width: 110px; }
    .premium-cell { min-width: 110px; max-width: 120px; }
    .node-name { font-size: 0.7rem; }
    .node-sub { font-size: 0.6rem; }
    .premium-header { font-size: 0.6rem; padding: 6px 4px; }
}

@media (max-width: 600px) {
    header h1 { font-size: 1.2rem; }
    nav { gap: 5px; }
    nav a { padding: 5px 10px; font-size: 0.9rem; }
    .summary { grid-template-columns: 1fr; }
    .summary-item .value { font-size: 1.1rem; }
    .card { padding: 15px; }
    .form-row { flex-direction: column; align-items: stretch; }
    .form-row .form-group { width: 100%; }
    .form-row button { width: 100%; }
    table { font-size: 0.85rem; }
    th, td { padding: 8px 5px; }
    .tank-header { flex-direction: column; align-items: flex-start; }
    .tank-stats { flex-direction: column; align-items: flex-start; }
    .page-header { flex-direction: column; align-items: stretch; }
    .page-header .btn { width: 100%; text-align: center; }
    .tab { padding: 6px 12px; font-size: 0.85rem; }
    .tree-legend { gap: 10px; font-size: 0.8rem; }
    .analytics-grid { grid-template-columns: repeat(2, 1fr); }
    .analytics-value { font-size: 0.95rem; }
    .chart { height: 80px; }
    .collapsible-header h2 { font-size: 1rem; }
    .collapsible-header { padding: 8px 0; margin: -5px 0 8px 0; }
}

/* ============ Скроллбар ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #1a1a1a; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ============================================================
   КНОПКИ ДАТ, РЕДАКТИРОВАНИЕ, БЫСТРОЕ ДОБАВЛЕНИЕ
   ============================================================ */
.date-buttons {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.date-btn {
    background: #333;
    color: #aaa;
    border: 1px solid #444;
    padding: 6px 14px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s, color 0.2s;
}

.date-btn:hover {
    background: #4a9eff;
    color: #fff;
    border-color: #4a9eff;
}

.edit-battle-btn {
    margin-right: 5px;
}

/* Кнопка быстрого добавления на узле дерева */
.quick-battle-btn {
    position: absolute;
    top: 3px;
    left: 5px;
    width: 18px;
    height: 18px;
    padding: 0;
    background: #4a9eff;
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s, background 0.2s;
}

.quick-battle-btn:hover {
    opacity: 1;
    background: #ff9800;
}

@media (min-width: 1024px) {
    .quick-battle-btn {
        display: flex;
    }
}

@media (max-width: 600px) {
    .quick-battle-btn {
        width: 16px;
        height: 16px;
        font-size: 0.75rem;
        top: 2px;
        left: 3px;
    }

    .date-btn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
}

/* ============ Страница настроек ============ */
.settings-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #333;
}

.settings-section:last-child {
    border-bottom: none;
}

.settings-section h3 {
    font-size: 1rem;
    margin-bottom: 15px;
    color: #4a9eff;
}

.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    cursor: pointer;
    color: #e0e0e0;
    font-size: 0.95rem;
}

.checkbox-label input,
.radio-label input {
    width: auto;
    margin: 0;
    cursor: pointer;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ============ Страница наций ============ */
.table-scroll {
    overflow-x: auto;
}

.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bar-item {
    display: grid;
    grid-template-columns: 100px 1fr 100px;
    gap: 10px;
    align-items: center;
}

.bar-label {
    font-size: 0.85rem;
    color: #aaa;
}

.bar-container {
    background: #333;
    border-radius: 5px;
    height: 20px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a9eff, #6ab0ff);
    border-radius: 5px;
    transition: width 0.3s;
}

.bar-fill.progress {
    background: linear-gradient(90deg, #4caf50, #66bb6a);
}

.bar-value {
    font-size: 0.85rem;
    color: #4a9eff;
    text-align: right;
}

/* ============ Настройки дерева ============ */
body.tree-view-bar .node-percent,
body.tree-view-bar .node-sub-count {
    display: none;
}

body.tree-view-percent .node-sub-count {
    display: none;
}

body.hide-percent .node-percent {
    display: none;
}

body.hide-count .node-sub-count {
    display: none;
}

/* ============ Настройки отображения прогнозов и графиков ============ */
body.hide-forecast-open .forecast-open-block {
    display: none;
}

body.hide-forecast-buy .forecast-buy-block {
    display: none;
}

body.hide-charts .charts-block {
    display: none;
}

/* ============================================================
   ИНДИКАТОР СИНХРОНИЗАЦИИ (онлайн / офлайн)
   ============================================================ */
.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.header-inner h1 {
    margin-bottom: 0;
}

.sync-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    background: #1f1f1f;
    border: 1px solid #333;
    transition: background 0.2s, border-color 0.2s;
    user-select: none;
    cursor: default;
}

.sync-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4caf50;
    transition: background 0.2s;
}

.sync-status-text {
    color: #aaa;
    font-weight: 500;
}

/* Онлайн — зелёный */
.sync-status.status-online .sync-status-dot {
    background: #4caf50;
    box-shadow: 0 0 6px rgba(76, 175, 80, 0.6);
}

.sync-status.status-online .sync-status-text {
    color: #4caf50;
}

/* Офлайн — красный */
.sync-status.status-offline {
    background: #2a1a1a;
    border-color: #5a2a2a;
}

.sync-status.status-offline .sync-status-dot {
    background: #e74c3c;
    box-shadow: 0 0 6px rgba(231, 76, 60, 0.6);
}

.sync-status.status-offline .sync-status-text {
    color: #e74c3c;
}

/* Синхронизация — жёлтый, мигает */
.sync-status.status-syncing {
    background: #2a2510;
    border-color: #5a4a10;
}

.sync-status.status-syncing .sync-status-dot {
    background: #ffc107;
    box-shadow: 0 0 6px rgba(255, 193, 7, 0.6);
    animation: sync-pulse 1s infinite;
}

.sync-status.status-syncing .sync-status-text {
    color: #ffc107;
}

@keyframes sync-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Ошибка — красный жирный */
.sync-status.status-error {
    background: #2a1a1a;
    border-color: #5a2a2a;
}

.sync-status.status-error .sync-status-dot {
    background: #e74c3c;
    box-shadow: 0 0 6px rgba(231, 76, 60, 0.8);
}

.sync-status.status-error .sync-status-text {
    color: #e74c3c;
    font-weight: bold;
}

/* ============================================================
   ИНДИКАТОР "СТРАНИЦА ИЗ КЭША"
   ============================================================ */

.header-status {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.cache-status {
    display: none; /* скрыт по умолчанию */
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    background: #2a2510;
    border: 1px solid #5a4a10;
    transition: background 0.2s;
    user-select: none;
    cursor: default;
}

body.page-from-cache .cache-status {
    display: inline-flex;
}

.cache-status-icon {
    font-size: 0.9rem;
}

.cache-status-text {
    color: #ffc107;
    font-weight: 500;
}

@media (max-width: 600px) {
    .header-inner h1 { font-size: 1.1rem; }
    .sync-status { font-size: 0.7rem; padding: 3px 8px; }
    .cache-status { font-size: 0.7rem; padding: 3px 8px; }
    .bar-item {
        grid-template-columns: 80px 1fr 80px;
        font-size: 0.8rem;
    }
}

/* ============================================================
   КНОПКА "СИНХРОНИЗИРОВАТЬ СЕЙЧАС"
   ============================================================ */
.sync-now-btn {
    background: #2a2a2a;
    color: #4a9eff;
    border: 1px solid #444;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.3s;
    line-height: 1;
}

.sync-now-btn:hover {
    background: #3a3a3a;
    transform: scale(1.05);
}

.sync-now-btn:active {
    background: #4a9eff;
    color: #fff;
}

.sync-now-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sync-now-btn.spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (max-width: 600px) {
    .sync-now-btn {
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }
}

/* ============================================================
   СТРАНИЦА "ОЖИДАЮТ СИНХРОНИЗАЦИИ" (#8)
   ============================================================ */

.pending-list-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pending-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    background: #1f1f1f;
    border: 1px solid #333;
    border-radius: 8px;
    flex-wrap: wrap;
}

.pending-item-info {
    flex: 1;
    min-width: 200px;
}

.pending-item-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    font-size: 0.95rem;
}

.pending-item-action {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pending-item-summary {
    font-size: 0.85rem;
    color: #4a9eff;
    margin-bottom: 4px;
    word-break: break-word;
}

.pending-item-date {
    font-size: 0.75rem;
    color: #666;
}

.pending-item-cancel {
    flex-shrink: 0;
}

.btn.spinning {
    animation: spin 1s linear infinite;
}

/* ============================================================
   ДЕМО: МОБИЛЬНАЯ ОПТИМИЗАЦИЯ ДЕРЕВА (#19)
   Применяется только к .tree-mobile-v2
   ============================================================ */

.branch-nav-v2 {
    display: none;
    gap: 5px;
    margin-bottom: 12px;
    flex-wrap: wrap;
    padding: 5px 0;
    align-items: center;
}

@media (max-width: 768px) {
    .branch-nav-v2 {
        display: flex;
    }
}

.branch-nav-v2 .branch-nav-btn {
    background: #333;
    color: #aaa;
    border: 1px solid #444;
    padding: 5px 14px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: bold;
    min-width: 36px;
    font-family: inherit;
    transition: background 0.2s, color 0.2s;
}

.branch-nav-v2 .branch-nav-btn:hover,
.branch-nav-v2 .branch-nav-btn.active {
    background: #4a9eff;
    color: #fff;
    border-color: #4a9eff;
}

/* Мобильная версия дерева — только .tree-mobile-v2 */
@media (max-width: 768px) {
    .tree-mobile-v2 .rank-cell {
        position: sticky;
        left: 0;
        z-index: 10;
        background: #1f1f1f;
        min-width: 45px;
        font-size: 0.6rem;
        padding: 6px 3px;
        box-shadow: 2px 0 4px rgba(0, 0, 0, 0.4);
    }

    .tree-mobile-v2 .branch-cell {
        min-width: 85px;
        max-width: 95px;
        padding: 3px;
    }

    .tree-mobile-v2 .premium-cell {
        min-width: 95px;
        max-width: 105px;
        padding: 3px;
    }

    .tree-mobile-v2 .node-name {
        font-size: 0.6rem;
        line-height: 1.15;
    }

    .tree-mobile-v2 .node-sub {
        font-size: 0.55rem;
    }

    .tree-mobile-v2 .node-badge {
        font-size: 0.5rem;
        padding: 1px 3px;
    }

    .tree-mobile-v2 .premium-header,
    .tree-mobile-v2 .branch-header {
        font-size: 0.55rem;
        padding: 5px 3px;
    }

    .tree-mobile-v2 .tree-table {
        border-spacing: 5px;
    }
}

/* ============================================================
   СТРАНИЦА ОТЧЁТА (/report)
   ============================================================ */

/* Переключатель периода */
.period-tabs {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-bottom: 15px;
    align-items: center;
}

.period-tabs .tab {
    padding: 8px 16px;
}

/* Свой период */
.custom-period {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-top: 10px;
    padding: 15px;
    background: #1f1f1f;
    border: 1px solid #333;
    border-radius: 8px;
}

.custom-period .form-group {
    margin-bottom: 0;
    min-width: 140px;
}

/* Сводка — красивые карточки с акцентом */
.report-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.report-card {
    position: relative;
    background: linear-gradient(160deg, #2a2a2a 0%, #232323 100%);
    border: 1px solid #333;
    border-radius: 12px;
    padding: 18px 16px 16px;
    text-align: center;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
    overflow: hidden;
}

.report-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #4a9eff;
    opacity: 0.9;
}

.report-card.positive::before { background: #4caf50; }
.report-card.negative::before { background: #e74c3c; }
.report-card.neutral::before  { background: #ffc107; }

.report-card:hover {
    transform: translateY(-2px);
    border-color: #444;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.report-card .icon {
    font-size: 1.6rem;
    line-height: 1;
    margin-bottom: 10px;
    display: block;
    opacity: 0.95;
}

.report-card .value {
    font-size: 1.55rem;
    font-weight: 700;
    color: #e0e0e0;
    margin-bottom: 6px;
    line-height: 1.15;
    word-break: break-word;
}

.report-card.positive .value { color: #4caf50; }
.report-card.negative .value { color: #e74c3c; }
.report-card.neutral  .value { color: #ffc107; }

.report-card .label {
    font-size: 0.78rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 8px;
}

.report-card .sub {
    font-size: 0.72rem;
    color: #666;
    line-height: 1.35;
}

@media (max-width: 700px) {
    .report-summary {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .report-card { padding: 14px 12px; }
    .report-card .value { font-size: 1.25rem; }
    .report-card .icon { font-size: 1.35rem; margin-bottom: 6px; }
    .report-card .label { font-size: 0.7rem; margin-bottom: 5px; }
    .report-card .sub { font-size: 0.68rem; }
}

@media (max-width: 420px) {
    .report-summary {
        grid-template-columns: 1fr;
    }
}

/* Топ-5 дней */
.top-days-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .top-days-grid {
        grid-template-columns: 1fr;
    }
}

.top-day-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: #1f1f1f;
    border: 1px solid #333;
    border-radius: 6px;
    margin-bottom: 6px;
}

.top-day-item .date {
    color: #aaa;
    font-size: 0.9rem;
}

.top-day-item .amount {
    font-weight: bold;
    color: #4a9eff;
}

.top-day-item .amount.sl {
    color: #4caf50;
}

/* Прогресс по нациям */
.nations-progress-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nation-progress-item {
    display: grid;
    grid-template-columns: 120px 1fr 120px;
    gap: 10px;
    align-items: center;
}

@media (max-width: 600px) {
    .nation-progress-item {
        grid-template-columns: 80px 1fr 80px;
        font-size: 0.85rem;
    }
}

.nation-progress-item .name {
    color: #aaa;
    font-size: 0.9rem;
}

.nation-progress-item .bar {
    background: #333;
    border-radius: 5px;
    height: 18px;
    overflow: hidden;
}

.nation-progress-item .bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a9eff, #6ab0ff);
    border-radius: 5px;
    transition: width 0.3s;
}

.nation-progress-item .value {
    text-align: right;
    color: #4a9eff;
    font-weight: bold;
    font-size: 0.9rem;
}

/* Таблица изученной техники */
.tanks-done-table .category-icon {
    font-size: 1.1rem;
    margin-right: 5px;
}

/* ============================================================
   ЖУРНАЛ ПО ДНЯМ (/silver/journal)
   ============================================================ */

.journal-filters {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.journal-filters .form-group {
    margin-bottom: 0;
    min-width: 140px;
    flex: 0 0 auto;
}

.journal-filters .form-group label {
    font-size: 0.85rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #333;
    flex-wrap: wrap;
}

.pagination-info {
    color: #aaa;
    font-size: 0.9rem;
    font-weight: 500;
}

.pagination .btn-secondary.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

@media (max-width: 600px) {
    .journal-filters {
        flex-direction: column;
        align-items: stretch;
    }
    .journal-filters .form-group {
        width: 100%;
    }
    .pagination {
        gap: 10px;
    }
    .pagination-info {
        font-size: 0.85rem;
    }
}

/* ============================================================
   РАНДОМАЙЗЕР (/randomizer)
   ============================================================ */

.br-toggle {
    display: flex;
    gap: 15px;
    margin-bottom: 8px;
}

.br-fields {
    display: flex;
    align-items: center;
    gap: 10px;
}

.br-fields input {
    width: 90px;
}

.br-fields span {
    color: #888;
}

.br-slider-wrap {
    position: relative;
    display: flex;
    gap: 10px;
    padding: 10px 0;
}

.br-slider-wrap input[type="range"] {
    width: 100%;
}

.result-view-toggle {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
}

/* Карточки техники */
.random-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.random-card {
    background: linear-gradient(160deg, #2a2a2a, #232323);
    border: 1px solid #333;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: transform 0.15s, border-color 0.15s;
}

.random-card:hover {
    transform: translateY(-2px);
    border-color: #4a9eff;
}

.random-card-icon {
    font-size: 2rem;
}

.random-card-name {
    font-weight: bold;
    color: #e0e0e0;
    font-size: 0.95rem;
}

.random-card-info {
    font-size: 0.8rem;
    color: #888;
}

.random-card-actions {
    margin-top: 5px;
}

/* Карточки наций */
.random-nations {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
}

.random-nation {
    background: linear-gradient(160deg, #2a2a2a, #232323);
    border: 1px solid #333;
    border-radius: 10px;
    padding: 15px;
}

.random-nation-name {
    color: #4a9eff;
    font-size: 1.1rem;
    margin-bottom: 10px;
    margin-top: 0;
}

.random-nation-vehicles {
    list-style: none;
    padding: 0;
    margin: 0;
}

.random-nation-vehicles li {
    padding: 5px 0;
    font-size: 0.9rem;
    border-bottom: 1px solid #333;
}

.random-nation-vehicles li:last-child {
    border-bottom: none;
}

.random-nation-vehicles a {
    color: #4a9eff;
    text-decoration: none;
}

.random-nation-vehicles a:hover {
    text-decoration: underline;
}

@media (max-width: 600px) {
    .random-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    .random-card-icon {
        font-size: 1.5rem;
    }
    .random-card-name {
        font-size: 0.85rem;
    }
    .br-slider-wrap {
        flex-direction: column;
    }
}
