/* Стили админки по образцу Svod: Bootstrap 5 с собственными токенами, тёмная тема по умолчанию. */
:root,
[data-bs-theme="dark"] {
  --app-bg: #0f1115;
  --sidebar-bg: #0c0f14;
  --surface-1: #171a21;
  --surface-2: #1c2028;
  --surface-hover: #202530;
  --table-bg: #12161d;
  --table-head-bg: #151a22;
  --border-color: #2a303b;
  --border-strong: #3a4250;
  --text-primary: #f3f4f6;
  --text-secondary: #a8b0bd;
  --text-muted: #747e8d;
  --primary: #7c6cff;
  --primary-hover: #9184ff;
  --primary-subtle: rgb(124 108 255 / 14%);
  --success: #45c777;
  --warning: #e8aa32;
  --danger: #ef5b65;
  --focus-ring: rgb(124 108 255 / 42%);
  --bs-body-bg: var(--app-bg);
  --bs-body-color: var(--text-primary);
  --bs-border-color: var(--border-color);
  --bs-secondary-color: var(--text-secondary);
  --bs-tertiary-bg: var(--surface-2);
  --bs-primary: var(--primary);
  --bs-primary-rgb: 124, 108, 255;
  --bs-border-radius: .625rem;
  --bs-border-radius-sm: .5rem;
}

[data-bs-theme="light"] {
  --app-bg: #f4f6fa;
  --sidebar-bg: #fff;
  --surface-1: #fff;
  --surface-2: #f8f9fc;
  --surface-hover: #f0f2f7;
  --table-bg: #fbfcfe;
  --table-head-bg: #f4f6fa;
  --border-color: #e1e5ec;
  --border-strong: #cbd2dc;
  --text-primary: #1c2028;
  --text-secondary: #596273;
  --text-muted: #7b8493;
  --primary: #6757e8;
  --primary-hover: #5747d5;
  --primary-subtle: rgb(103 87 232 / 11%);
  --success: #228b4e;
  --warning: #a96700;
  --danger: #cc3d4a;
  --focus-ring: rgb(103 87 232 / 30%);
  --bs-primary: var(--primary);
  --bs-primary-rgb: 103, 87, 232;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; }
body { margin: 0; color: var(--text-primary); background: var(--app-bg); font-family: Nunito, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 14px; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
:focus-visible { outline: 3px solid var(--focus-ring) !important; outline-offset: 2px; }
.text-muted, .muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ok { color: var(--success); } .warn { color: var(--warning); } .bad { color: var(--danger); }
.btn { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 7px; border-radius: 8px; font-weight: 600; }
.btn-sm { min-height: 34px; }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary-hover); --bs-btn-hover-border-color: var(--primary-hover); --bs-btn-active-bg: var(--primary-hover); --bs-btn-active-border-color: var(--primary-hover); }
.btn-outline-secondary { --bs-btn-color: var(--text-secondary); --bs-btn-border-color: var(--border-strong); --bs-btn-hover-bg: var(--surface-hover); --bs-btn-hover-color: var(--text-primary); --bs-btn-hover-border-color: var(--border-strong); }
.btn-outline-danger { --bs-btn-color: var(--danger); --bs-btn-border-color: color-mix(in srgb, var(--danger) 55%, var(--border-color)); --bs-btn-hover-bg: color-mix(in srgb, var(--danger) 14%, transparent); --bs-btn-hover-color: var(--danger); --bs-btn-hover-border-color: var(--danger); }
.form-control, .form-select { min-height: 42px; color: var(--text-primary); background-color: var(--surface-2); border-color: var(--border-color); }
.form-control:focus, .form-select:focus { color: var(--text-primary); background-color: var(--surface-2); border-color: var(--primary); box-shadow: 0 0 0 .2rem var(--focus-ring); }
.form-control::placeholder { color: var(--text-muted); }
.form-control-sm { min-height: 34px; }
.form-label { color: var(--text-secondary); font-weight: 600; }
[data-bs-theme="dark"] input[type="date"], [data-bs-theme="dark"] input[type="datetime-local"] { color-scheme: dark; }

/* Каркас: сайдбар, верхняя панель, контент. */
.app-shell { min-height: 100vh; background: var(--app-bg); }
.app-main { min-width: 0; margin-left: 248px; }
.app-content { width: 100%; max-width: 1680px; margin: 0 auto; padding: 30px 34px 48px; }
.app-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 1045; display: flex; width: 248px; flex-direction: column; padding: 18px 12px; background: var(--sidebar-bg); border-right: 1px solid var(--border-color); transition: transform .2s ease; }
.brand { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px; color: var(--text-primary); font-size: 20px; font-weight: 600; text-decoration: none; }
.brand:hover { color: var(--text-primary); }
.brand-mark { display: grid; width: 30px; height: 30px; flex: 0 0 30px; place-items: center; color: #fff; background: linear-gradient(145deg, var(--primary-hover), var(--primary)); border-radius: 8px; font-size: 15px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding-top: 20px; }
.nav-section { padding: 20px 12px 7px; color: var(--text-muted); font-size: 10px; font-weight: 600; letter-spacing: .08em; }
.sidebar-link { position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; margin: 3px 0; padding: 10px 12px; color: var(--text-secondary); border-radius: 8px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.sidebar-link i { width: 20px; text-align: center; font-size: 18px; }
.sidebar-link:hover { color: var(--text-primary); background: var(--surface-hover); }
.sidebar-link.active { color: var(--primary); background: var(--primary-subtle); }
.sidebar-link.active::before { position: absolute; left: -12px; width: 3px; height: 24px; background: var(--primary); border-radius: 0 3px 3px 0; content: ""; }
.sidebar-footer { padding-top: 12px; border-top: 1px solid var(--border-color); }
.sidebar-button { width: 100%; background: transparent; border: 0; text-align: left; }
.user-card { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 9px 8px 13px; }
.avatar { display: grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; color: #fff; background: var(--primary); border-radius: 50%; font-weight: 700; }
.user-copy { display: grid; min-width: 0; }
.user-name, .user-role { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-name { font-weight: 700; }
.user-role { margin-top: 2px; color: var(--text-muted); font-size: 11px; }
.app-topbar { position: sticky; top: 0; z-index: 1025; display: flex; height: 70px; align-items: center; gap: 16px; padding: 0 34px; background: color-mix(in srgb, var(--app-bg) 94%, transparent); border-bottom: 1px solid var(--border-color); backdrop-filter: blur(14px); }
.topbar-title { flex: 1; font-size: 18px; font-weight: 600; }
.topbar-note { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 12px; font-weight: 600; white-space: nowrap; }
.icon-button { display: grid; width: 40px; height: 40px; place-items: center; padding: 0; color: var(--text-secondary); background: var(--surface-1); border: 1px solid var(--border-color); border-radius: 8px; }
.icon-button:hover { color: var(--text-primary); background: var(--surface-hover); }
.mobile-only { display: none; }
.mobile-overlay { position: fixed; inset: 0; z-index: 1040; display: none; padding: 0; background: rgb(0 0 0 / 58%); border: 0; }

/* Страница: заголовок, панели, таблицы, фильтры. */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; margin: 0; font-size: clamp(27px, 3vw, 34px); font-weight: 600; letter-spacing: -.02em; }
.page-title small { color: var(--text-muted); font-size: 15px; font-weight: 600; letter-spacing: 0; }
.page-subtitle { margin: 7px 0 0; color: var(--text-secondary); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.section-title { margin: 30px 0 12px; font-size: 18px; font-weight: 600; }
.card, .data-panel { margin-bottom: 18px; overflow: hidden; color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--border-color); border-radius: 11px; }
.panel-header { display: flex; min-height: 58px; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border-color); }
.panel-title { margin: 0; font-size: 17px; font-weight: 600; }
.panel-body { padding: 18px; }
.table-responsive { margin: 0; }
.app-table { --bs-table-bg: var(--table-bg); --bs-table-color: var(--text-primary); --bs-table-border-color: var(--border-color); --bs-table-hover-bg: var(--surface-hover); --bs-table-hover-color: var(--text-primary); margin: 0; }
.app-table th { padding: 12px 16px; color: var(--text-muted); background: var(--table-head-bg); font-size: 12px; font-weight: 700; white-space: nowrap; }
.app-table td { padding: 14px 16px; vertical-align: middle; }
.app-table tbody tr:last-child td { border-bottom: 0; }
.app-table .empty-row td { padding: 0; }
.table-title { color: var(--text-primary); font-weight: 700; text-decoration: none; }
.table-title:hover { color: var(--primary); }
.table-note { margin-top: 3px; color: var(--text-muted); font-size: 12px; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 18px; padding: 16px; background: var(--surface-1); border: 1px solid var(--border-color); border-radius: 12px; }
.filter-field { display: grid; min-width: 170px; gap: 6px; margin: 0; color: var(--text-secondary); font-size: 12px; font-weight: 700; }
.filter-grow { flex: 1; min-width: 240px; }
.search-control { position: relative; display: block; }
.search-control > i { position: absolute; z-index: 1; top: 50%; left: 13px; color: var(--text-muted); font-size: 15px; transform: translateY(-50%); }
.search-control .form-control { padding-left: 38px; }
.state-box { display: grid; min-height: 220px; place-items: center; align-content: center; padding: 34px; color: var(--text-secondary); text-align: center; }
.state-icon { display: block; margin-bottom: 12px; color: var(--text-muted); font-size: 30px; }
.state-title { margin: 0; color: var(--text-primary); font-size: 17px; font-weight: 600; }
.state-message { max-width: 520px; margin: 7px 0 0; }
.hint, .form-hint { color: var(--text-muted); font-size: 12px; }
.hint { margin: 12px 0 0; }

/* Метки, статусы, сводка. */
.status-pill { display: inline-flex; align-items: center; gap: 5px; min-height: 25px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status-pill.is-active { color: var(--success); background: color-mix(in srgb, var(--success) 14%, transparent); }
.status-pill.is-warning { color: var(--warning); background: color-mix(in srgb, var(--warning) 15%, transparent); }
.status-pill.is-danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 13%, transparent); }
.status-pill.is-inactive { color: var(--text-secondary); background: var(--surface-hover); }
.role-pill, .tag { display: inline-flex; padding: 3px 8px; color: var(--primary); background: var(--primary-subtle); border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.metric-card { display: flex; min-width: 0; min-height: 118px; align-items: flex-start; gap: 12px; padding: 18px; background: var(--surface-1); border: 1px solid var(--border-color); border-radius: 11px; }
.metric-card > div { display: grid; min-width: 0; }
.metric-icon { display: grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; color: var(--primary); background: var(--primary-subtle); border-radius: 9px; font-size: 18px; }
.metric-icon.is-warning { color: var(--warning); background: color-mix(in srgb, var(--warning) 15%, transparent); }
.metric-icon.is-danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 13%, transparent); }
.metric-label { align-self: center; color: var(--text-secondary); font-size: 12px; }
.metric-value { margin: 10px 0 2px; font-size: 30px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1; }

/* Карточка подписки и формы. */
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 28px; margin: 0; padding: 20px; }
.detail-grid > div { display: grid; align-content: start; gap: 5px; }
.detail-grid dt { color: var(--text-muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.form-field { display: grid; align-content: start; gap: 6px; margin: 0; color: var(--text-secondary); font-weight: 600; }
.copy-field { display: flex; gap: 8px; }
.copy-field .form-control { min-width: 0; }
.copy-field .btn { flex: 0 0 auto; }
.form-section { margin: 22px 0 0; padding: 18px 0 0; border-top: 1px solid var(--border-color); }
.form-section-title { float: none; width: auto; margin: 0 0 14px; font-size: 15px; font-weight: 600; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 18px; }
.inline-form { display: flex; align-items: center; gap: 6px; }
.inline-form .form-control { width: 110px; }
.inline-form .form-select { width: auto; }
.price-line { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.price-line .table-note { margin-top: 0; }
.alert { margin-bottom: 18px; border-radius: 10px; }
.alert-success { color: var(--success); background: color-mix(in srgb, var(--success) 12%, var(--surface-1)); border-color: color-mix(in srgb, var(--success) 35%, var(--border-color)); }
.alert-danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 11%, var(--surface-1)); border-color: color-mix(in srgb, var(--danger) 35%, var(--border-color)); }

/* Вход. */
.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 20%, var(--primary-subtle), transparent 34%), var(--app-bg); }
.auth-theme-toggle { position: fixed; top: 20px; right: 20px; }
.auth-card { width: min(440px, 100%); padding: 32px; background: var(--surface-1); border: 1px solid var(--border-color); border-radius: 14px; }
.auth-brand { margin-bottom: 28px; }
.auth-brand .brand { min-height: auto; padding: 0; margin-bottom: 22px; }
.auth-brand h1 { margin: 0; font-size: 28px; font-weight: 600; letter-spacing: -.01em; }
.auth-description { margin: 9px 0 0; color: var(--text-secondary); }
.auth-card .alert { padding: 11px 13px; }

@media (min-width: 768px) and (max-width: 1199px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767.98px) {
  .mobile-only { display: grid; }
  .app-main { margin-left: 0; }
  .app-sidebar { width: min(304px, 88vw); transform: translateX(-102%); }
  .app-shell.is-menu-open .app-sidebar { transform: translateX(0); box-shadow: 14px 0 34px rgb(0 0 0 / 34%); }
  .app-shell.is-menu-open .mobile-overlay { display: block; }
  .app-topbar { height: 64px; padding: 0 14px; }
  .topbar-note { display: none; }
  .app-content { padding: 22px 14px 40px; }
  .page-header { flex-direction: column; }
  .filter-field, .filter-grow, .filter-bar .btn { width: 100%; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric-card { min-height: auto; padding: 14px; }
  .metric-value { font-size: 24px; }
  .detail-grid { grid-template-columns: 1fr; }
}
