/* Базовые стили панели. Без сборщиков и препроцессоров — обычный CSS. */

:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --border: #dfe4ec;
    --text: #1d2430;
    --muted: #6b7688;
    --primary: #2f6fdb;
    --primary-dark: #2559b0;
    --success: #1f8a52;
    --warning: #b8791a;
    --danger: #c33b3b;
    --admin: #35405a;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 12px rgba(20, 30, 50, .05);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 .6em; line-height: 1.25; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

.muted { color: var(--muted); font-size: .9em; }

/* Шапка */

.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 24px;
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

/* Полоса режима просмотра: администратор работает в кабинете клиента.
   Намеренно кричащая — перепутать контуры нельзя. */
.impersonation-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 10px 24px;
    background: var(--warning);
    color: #fff;
    font-size: .92rem;
}
.impersonation-bar .btn { border-color: rgba(255, 255, 255, .6); color: #fff; }
.impersonation-bar .btn:hover { background: rgba(255, 255, 255, .15); }

.topbar--admin { background: var(--admin); border-bottom-color: #26304a; }
.topbar--admin .topbar__brand,
.topbar--admin .topbar__link,
.topbar--admin .topbar__email { color: #e8ecf5; }
.topbar--admin .topbar__link.is-active { color: #fff; border-bottom-color: #fff; }
/* Значок роли берёт цвет от родителя — на тёмной шапке он должен быть светлым,
   иначе тёмный текст на тёмном фоне не читается. */
.topbar--admin .badge--muted { color: #e8ecf5; }

.topbar__brand { font-weight: 600; color: var(--text); white-space: nowrap; }
.topbar__brand:hover { text-decoration: none; }

.topbar__nav { display: flex; gap: 18px; flex: 1; overflow-x: auto; }

.topbar__link {
    color: var(--muted);
    padding: 17px 0;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
}
.topbar__link:hover { color: var(--text); text-decoration: none; }
.topbar__link.is-active { color: var(--primary); border-bottom-color: var(--primary); }

.topbar__user { display: flex; align-items: center; gap: 10px; }
.topbar__email { color: var(--muted); font-size: .9em; }

/* Контейнеры */

.container { max-width: 960px; margin: 0 auto; padding: 24px; }
.container--wide { max-width: 1360px; }

.page--centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}

.card--narrow { max-width: 520px; width: 100%; text-align: center; }

.hero { margin-bottom: 24px; }
.hero h1 { margin-bottom: .2em; }

/* Таблицы */

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-weight: 600; white-space: nowrap; }
.table tbody tr:last-child th,
.table tbody tr:last-child td { border-bottom: none; }
.table--fixed { table-layout: fixed; }

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

/* Кнопки */

.btn {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-size: .95rem;
    font-family: inherit;
    line-height: 1.4;
    cursor: pointer;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn--sm { padding: 5px 11px; font-size: .875rem; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); }
.btn--ghost { border-color: var(--border); color: var(--muted); }
.btn--ghost:hover { color: var(--text); border-color: var(--muted); }
.btn--danger { background: var(--danger); color: #fff; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.inline-form { display: inline; }

/* Формы */

.field { margin-bottom: 16px; }
.field__label { display: block; margin-bottom: 5px; font-size: .9rem; font-weight: 500; }
.field__hint { margin-top: 4px; }

.input, .select, .textarea {
    width: 100%;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .95rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
}
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47, 111, 219, .12);
}
.textarea { min-height: 120px; resize: vertical; }

.btn--block { display: block; width: 100%; text-align: center; }

.checkbox { display: flex; gap: 9px; align-items: flex-start; font-size: .92rem; cursor: pointer; }
.checkbox input { margin-top: 3px; flex-shrink: 0; }

.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

.code {
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: .85em;
    background: #f2f4f8;
    padding: 1px 5px;
    border-radius: 4px;
    word-break: break-all;
}

/* Страницы входа и регистрации */

.auth-box { width: 100%; max-width: 420px; }
.auth-box__brand {
    display: block;
    text-align: center;
    margin-bottom: 16px;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
}
.auth-box__brand:hover { text-decoration: none; }
.auth-box .card { margin-bottom: 0; }
.auth-box h1 { font-size: 1.35rem; }
.auth-links { text-align: center; margin: 16px 0 0; }

/* Сообщения */

.alert {
    padding: 11px 14px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    margin-bottom: 16px;
}
.alert--success { background: #e8f6ee; border-color: #bfe3ce; color: #146a3f; }
.alert--error   { background: #fdeceb; border-color: #f5c6c3; color: #9d2c2c; }
.alert--warning { background: #fdf4e3; border-color: #f0dcb0; color: #8a5c12; }
.alert--info    { background: #eaf1fd; border-color: #c6d8f7; color: #23508f; }

/* Значки и статусы */

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    background: #eef2f8;
    color: var(--text);
    font-size: .85rem;
    font-weight: 500;
    white-space: nowrap;
}
.badge--muted { background: transparent; border: 1px solid currentColor; color: inherit; opacity: .7; }

.status { font-weight: 500; }
.status--ok { color: var(--success); }
.status--error { color: var(--danger); }
.status--warning { color: var(--warning); }

/* Плитки показателей */

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

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.stat__label { color: var(--muted); font-size: .85rem; margin-bottom: 4px; }
.stat__value { font-size: 1.5rem; font-weight: 600; line-height: 1.2; }
.stat__value--sm { font-size: 1.05rem; }
.stat__hint { color: var(--muted); font-size: .8rem; margin-top: 4px; }

.is-positive { color: var(--success); }
.is-negative { color: var(--danger); }
.is-warning { color: var(--warning); }

/* Баланс */

.balance-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.balance-summary__amount { font-size: 2rem; font-weight: 600; line-height: 1.15; }

/* Фильтры и формы в строку */

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}
.filters__item { min-width: 140px; }
.filters__item--grow { flex: 1; min-width: 220px; }
.filters__item--actions { display: flex; gap: 8px; }
.filters .field__label { margin-bottom: 4px; }

.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form-row .field { margin-bottom: 0; min-width: 160px; }
.form-row .field--grow { flex: 1; min-width: 220px; }
.form-row .field--submit { min-width: 0; }

.textarea--sm { min-height: 64px; }

/* Карточки тарифов в форме заказа */

.tariffs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

.tariff {
    display: block;
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    cursor: pointer;
    background: var(--surface);
}
.tariff:hover { border-color: var(--muted); }
.tariff.is-selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 111, 219, .12); }
.tariff input { position: absolute; top: 14px; right: 14px; }

.tariff__body { display: block; padding-right: 24px; }
.tariff__name { display: block; font-weight: 600; margin-bottom: 2px; }
.tariff__price { display: block; font-size: 1.3rem; font-weight: 600; margin-bottom: 8px; }
.tariff__price .muted { font-size: .8rem; font-weight: 400; }
.tariff__specs { display: block; font-size: .9rem; margin-bottom: 4px; }
.tariff__meta { display: block; font-size: .82rem; }
.tariff__description { display: block; font-size: .85rem; margin-top: 6px; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.page-head h1, .page-head__title { margin: 0; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Прочее */

.ta-right { text-align: right; }
.nowrap { white-space: nowrap; }

.pagination { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.pagination__link {
    padding: 5px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    font-size: .9rem;
}
.pagination__link:hover { text-decoration: none; color: var(--text); }
.pagination__link.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Страницы ошибок */

.error-code { font-size: 4rem; margin: 0; color: var(--muted); }
.error-message { font-size: 1.15rem; margin-bottom: 20px; }

.debug-box {
    text-align: left;
    background: #fbfbfd;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}
.debug-box__title { font-weight: 600; margin: 0 0 4px; }
.debug-box__message { margin: 0 0 8px; color: var(--danger); }
.debug-box__trace {
    max-height: 320px;
    overflow: auto;
    font-size: .8rem;
    line-height: 1.45;
    background: #f2f4f8;
    padding: 12px;
    border-radius: 6px;
    margin: 8px 0 0;
}

/* Ширина подвала повторяет ширину контейнера страницы, иначе он висит
   левее содержимого: в кабинете колонка 960px, в админке — 1360px. */
.footer {
    max-width: 960px;
    margin: 0 auto;
    padding: 16px 24px 32px;
    color: var(--muted);
    font-size: .85rem;
}
.footer--wide { max-width: 1360px; }

/* Графики нагрузки (SVG рисуется в app/Support/RrdChart.php) */
.chart { width: 100%; height: 200px; display: block; }
.chart-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.chart-block__title { font-size: .9rem; font-weight: 600; margin: 0 0 4px; }
/* Подзаголовок внутри карточки, отбитый от предыдущего блока */
.section-title { margin-top: 20px; }

.chart-legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); margin-top: 4px; }
.chart-legend__item { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend__swatch { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
/* Цвета совпадают с линиями графика в app/Support/RrdChart.php */
.chart-legend__swatch--netin { background: #2f6fdb; }
.chart-legend__swatch--netout { background: #d97706; }
.chart-legend__swatch--cpu { background: #2f6fdb; }
.chart-legend__swatch--mem { background: #1f9d63; }

/* Переписка в тикетах */
.message {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 12px;
    background: var(--surface);
}
.message--client { border-left: 3px solid var(--primary); }
.message--staff { border-left: 3px solid var(--success); background: #f7fbf8; }
.message--system { border-left: 3px solid var(--border); color: var(--muted); }
.message--internal { border-left: 3px solid var(--warning); background: #fdf9ef; }
.message__head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; font-size: .9rem; }
.message__body { white-space: pre-wrap; word-break: break-word; }

/* Панель управления сервером */
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { display: inline; }
.danger-zone { border-color: #f0cdcb; }
.danger-zone h2 { color: var(--danger); }

/* Консоль сервера: страница занимает весь экран, место нужно самой машине */

.page--console { height: 100vh; margin: 0; background: #12151c; overflow: hidden; }

.console { display: flex; flex-direction: column; height: 100vh; }

.console__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 10px 16px;
    background: var(--admin);
    color: #fff;
    flex-shrink: 0;
}
.console__bar .muted { color: #a9b2c6; }
.console__title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.console__back { color: #cdd6e6; }
.console__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.console__actions .btn { border-color: rgba(255, 255, 255, .45); color: #fff; }
.console__actions .btn:hover:not(:disabled) { background: rgba(255, 255, 255, .12); }
.console__actions .btn:disabled { opacity: .5; cursor: default; }

.console__status { font-size: .9rem; color: #cdd6e6; }
.console__status--ok { color: #86d9a8; }
.console__status--error { color: #f2a0a0; }

/* Библиотека noVNC сама вставляет сюда canvas и растягивает его */
.console__screen { flex: 1; min-height: 0; background: #000; outline: none; }

@media (max-width: 720px) {
    .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 12px; }
    .topbar__nav { order: 3; width: 100%; padding-bottom: 4px; }
    .topbar__link { padding: 6px 0; }
    .container { padding: 16px; }
    .card { padding: 16px; }
}
