* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

header h1 {
    color: #2c3e50;
    font-size: 1.5rem;
}

nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    flex: 1;
}

nav a {
    text-decoration: none;
    color: #666;
    padding: 8px 16px;
    border-radius: 4px;
    transition: all 0.2s;
}

nav a:hover {
    background: #f0f0f0;
}

nav a.active {
    background: #3498db;
    color: #fff;
}

.updated {
    color: #999;
    font-size: 0.85rem;
}

.logout-form {
    margin: 0;
}

.logout-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #666;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: #f0f0f0;
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    text-align: center;
}

.card h2 {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
    margin-bottom: 10px;
}

.card .value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #2c3e50;
}

.card.total .value { color: #3498db; }
.card.uplink .value { color: #e74c3c; }
.card.downlink .value { color: #27ae60; }
.card.users .value { color: #9b59b6; }
.card.active-now .value { color: #16a085; }

.health-banner {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffe69c;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.active-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ecc71;
    margin-left: 4px;
    vertical-align: middle;
}

section {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

section h2 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

table {
    width: 100%;
    border-collapse: collapse;
}

/* Таблица на Outbounds всего 2 колонки — на широком экране растягивать её
   на всю ширину контейнера смысла нет, между именем и значением был бы
   огромный разрыв. */
.outbounds-table table {
    width: auto;
    max-width: 480px;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    user-select: none;
}

th:hover {
    background: #e9ecef;
}

tr:hover {
    background: #f8f9fa;
}

#search {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 1rem;
}

#search:focus {
    outline: none;
    border-color: #3498db;
}

.chart-container {
    height: 400px;
    position: relative;
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
    }

    nav {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        width: 100%;
        gap: 8px;
    }

    nav a {
        padding: 8px 12px;
        font-size: 0.9rem;
        text-align: center;
    }

    .logout-form {
        width: 100%;
    }

    .logout-btn {
        width: 100%;
    }

    table {
        font-size: 0.85rem;
    }

    th, td {
        padding: 8px;
    }
}

.period-switch {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.period-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.period-btn:hover {
    background: #f0f0f0;
}

.period-btn.active {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
}

.user-traffic-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.user-traffic-controls label {
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
}

#userSelect {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    background: #fff;
    min-width: 180px;
}

#userSelect:focus {
    outline: none;
    border-color: #3498db;
}

.custom-period {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    width: 100%;
}

.custom-period label {
    font-size: 0.85rem;
    color: #666;
}

.custom-period input[type="date"] {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
}

.custom-period input[type="date"]:focus {
    outline: none;
    border-color: #3498db;
}

.custom-period button {
    padding: 6px 14px;
    border: 1px solid #3498db;
    background: #3498db;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.custom-period button:hover {
    background: #2980b9;
}

.traffic-table-wrapper {
    margin-top: 15px;
    overflow-x: auto;
}

#userTrafficTable th {
    cursor: default;
}

#userTrafficTable tbody tr:hover {
    background: #f0f7ff;
}

#userTrafficTable tr.total-row td {
    font-weight: 700;
    border-top: 2px solid #333;
    background: #eef4fa;
}

/* ─── Landing / sign-in page ──────────────────────────────────────────────── */

.login-body {
    min-height: 100vh;
    background: #f5f7fa;
}

.landing-wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.landing-header {
    padding: 24px 0;
}

.landing-logo {
    font-size: 1.3rem;
    font-weight: 700;
    color: #2c3e50;
}

.landing-main {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 40px;
    padding: 20px 0 40px;
}

.landing-hero {
    flex: 1 1 320px;
}

.landing-hero h1 {
    font-size: 2.1rem;
    color: #2c3e50;
    margin-bottom: 12px;
}

.landing-tagline {
    color: #666;
    font-size: 1.05rem;
    margin-bottom: 20px;
}

.landing-features {
    list-style: none;
    color: #555;
    font-size: 0.95rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.landing-features li::before {
    content: "✓ ";
    color: #27ae60;
    font-weight: 700;
}

.landing-signin {
    background: #fff;
    padding: 32px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    width: 100%;
    max-width: 340px;
    flex: 0 0 auto;
}

.landing-signin h2 {
    font-size: 1.1rem;
    color: #2c3e50;
    margin-bottom: 16px;
}

.landing-footer {
    display: flex;
    gap: 16px;
    padding: 20px 0;
    color: #999;
    font-size: 0.85rem;
}

.landing-footer a {
    color: #999;
    text-decoration: none;
}

.landing-footer a:hover {
    text-decoration: underline;
}

@media (max-width: 640px) {
    .landing-main {
        flex-direction: column;
        align-items: stretch;
        gap: 28px;
        padding-top: 8px;
    }

    .landing-signin {
        max-width: none;
    }
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-form label {
    font-size: 0.85rem;
    color: #555;
    font-weight: 600;
    margin-top: 8px;
}

.login-form input {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.login-form input:focus {
    outline: none;
    border-color: #3498db;
}

.login-form button {
    margin-top: 16px;
    padding: 10px;
    border: none;
    background: #3498db;
    color: #fff;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.login-form button:hover {
    background: #2980b9;
}

.login-error {
    background: #fdecea;
    color: #c0392b;
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

/* ─── Мониторинг IP ──────────────────────────────────────────────────────── */

.card.ip-unique .value { color: #16a085; }
.card.ip-over .value { color: #e67e22; }
.card.ip-violations .value { color: #c0392b; }
.card.ip-violations-recent .value { color: #e74c3c; }

/* Карточка нарушений на дашборде — ссылка, но выглядит как остальные карточки. */
a.card {
    text-decoration: none;
    color: inherit;
    display: block;
}
a.card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.hint {
    font-size: 13px;
    font-weight: normal;
    color: #7f8c8d;
    margin: 4px 0 12px;
}

.no-data {
    text-align: center;
    padding: 20px;
    color: #999;
}

.muted { color: #aaa; }

/* Статус читается взглядом, а не вычитывается из цифр. */
.status-pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    white-space: nowrap;
}
.status-pill.status-ok { background: #eafaf1; color: #27ae60; }
.status-pill.status-watch { background: #fdf3e3; color: #d68910; }
.status-pill.status-violation { background: #fdedec; color: #c0392b; }

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 4px;
    vertical-align: middle;
}
.status-dot.status-watch { background: #e67e22; }
.status-dot.status-violation { background: #c0392b; }

.ip-addr {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
}
.ip-geo {
    display: block;
    font-size: 12px;
    color: #7f8c8d;
}

/* ─── Лента нарушений ───────────────────────────────────────────────────── */

.violations-feed { margin-top: 30px; }

.violation {
    border: 1px solid #e6e6e6;
    border-left: 3px solid #bdc3c7;
    border-radius: 4px;
    padding: 12px 16px;
    margin-bottom: 10px;
    background: #fff;
}

/* Уведомлений наружу нет, поэтому свежесть выделяется прямо в ленте. */
.violation-recent { border-left-color: #c0392b; background: #fffafa; }

.violation header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.violation header time { font-size: 13px; color: #7f8c8d; }

.violation-user { font-weight: 600; }

.badge-new {
    background: #c0392b;
    color: #fff;
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 8px;
}

.violation-meta { font-size: 13px; color: #555; margin: 0 0 8px; }

.violation-ips {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
}
.violation-ips li { min-width: 200px; }

/* ─── Карточка пользователя ─────────────────────────────────────────────── */

.ip-user-header { margin-bottom: 20px; }
.ip-user-header h2 { margin-bottom: 4px; }
.ip-user-header p { margin: 0 0 12px; font-size: 14px; }

.ip-user-chart, .ip-geo-breakdown, .ip-events { margin-top: 30px; }

@media (max-width: 700px) {
    .violation-ips { flex-direction: column; gap: 4px; }
    .ip-geo { display: inline; margin-left: 6px; }
}
