/* =============================================================================
   Over-Cloud Billing — единая дизайн-система (лендинг, кабинет, админка).
   ========================================================================== */
:root {
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --brand-light: #eff6ff;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f1f5f9;
    --card: #ffffff;
    --ok: #16a34a;
    --ok-bg: #f0fdf4;
    --warn: #d97706;
    --warn-bg: #fffbeb;
    --err: #dc2626;
    --err-bg: #fef2f2;
    --info: #0891b2;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-lg: 0 20px 40px rgba(15, 23, 42, .12);
    --sidebar-w: 250px;
}

* { box-sizing: border-box; }

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

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 650; line-height: 1.25; }

/* ------------------------------ Раскладка --------------------------------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: #0f172a;
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar .brand {
    padding: 20px 22px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar .brand .logo {
    width: 30px; height: 30px; border-radius: 8px;
    background: linear-gradient(135deg, var(--brand), #7c3aed);
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-size: 15px;
}
.sidebar nav { padding: 12px 0; flex: 1; }
.sidebar nav .group-label {
    font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
    color: #64748b; padding: 14px 22px 6px;
}
.sidebar nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 22px; color: #cbd5e1; font-size: 14.5px;
    border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: rgba(37, 99, 235, .15); color: #fff; border-left-color: var(--brand); }
.sidebar nav a .ic { width: 18px; text-align: center; opacity: .85; font-size: 17px; line-height: 1; }
.sidebar .foot { padding: 16px 22px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 12px; color: #64748b; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    padding: 14px 28px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 20;
}
.topbar .page-title { font-size: 18px; font-weight: 650; }
.topbar .user { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.topbar .avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--brand-light); color: var(--brand);
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
}
.content { padding: 28px; width: 100%; }

/* ------------------------------ Карточки ---------------------------------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.card-head {
    padding: 16px 20px; border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between;
}
.card-head h3 { margin: 0; font-size: 16px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

/* ----------------------------- Метрики (KPI) ------------------------------ */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-bottom: 22px; }
.stat {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px 20px; box-shadow: var(--shadow);
}
.stat .label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.stat .value { font-size: 26px; font-weight: 700; }
.stat .sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.stat.accent { border-left: 3px solid var(--brand); }

/* ------------------------------- Таблицы ---------------------------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); }
table.data th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; background: #f8fafc; }
table.data tbody tr:hover { background: #f8fafc; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------- Бейджи ----------------------------------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.green { background: var(--ok-bg); color: var(--ok); }
.badge.gray  { background: #f1f5f9; color: var(--muted); }
.badge.red   { background: var(--err-bg); color: var(--err); }
.badge.amber { background: var(--warn-bg); color: var(--warn); }
.badge.blue  { background: var(--brand-light); color: var(--brand); }

/* -------------------------------- Формы ----------------------------------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; color: #334155; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.input,
input:not([type]),
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=datetime-local], input[type=time], input[type=tel],
input[type=url], input[type=search],
select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
    font-size: 14.5px; font-family: inherit; line-height: 1.4; background: #fff; color: var(--ink);
    -webkit-appearance: none; appearance: none;
}
select {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%2364748b' d='M6 8 0 2l1.4-1.4L6 5.2 10.6.6 12 2z'/></svg>");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px;
}
.input:focus, input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .13);
}
input[type=checkbox], input[type=radio] {
    width: 16px; height: 16px; margin-right: 6px; vertical-align: -2px;
    accent-color: var(--brand); cursor: pointer;
}
input:disabled, select:disabled, textarea:disabled { background: #f1f5f9; color: var(--muted); cursor: not-allowed; }
input::placeholder, textarea::placeholder { color: #94a3b8; }
textarea { min-height: 110px; resize: vertical; }
.field.error input, .field.error select, .field.error textarea { border-color: var(--err); }
.field .err-msg { color: var(--err); font-size: 12.5px; margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }

/* -------------------------------- Кнопки ---------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; border-radius: 9px; font-size: 14.5px; font-weight: 600;
    border: 1px solid transparent; cursor: pointer; background: var(--brand); color: #fff;
    text-decoration: none; transition: background .15s, box-shadow .15s;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: #f8fafc; }
.btn.success { background: var(--ok); }
.btn.danger { background: var(--err); }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* -------------------------------- Алерты ---------------------------------- */
.alert { padding: 12px 16px; border-radius: 10px; font-size: 14px; margin-bottom: 18px; border: 1px solid transparent; }
.alert.success { background: var(--ok-bg); color: var(--ok); border-color: #bbf7d0; }
.alert.error { background: var(--err-bg); color: var(--err); border-color: #fecaca; }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }
.alert.info { background: #ecfeff; color: var(--info); border-color: #a5f3fc; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* ------------------------- Аутентификация / центр -------------------------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
    background: linear-gradient(160deg, #1e293b, #0f172a); }
.auth-card { background: #fff; width: 100%; max-width: 420px; border-radius: 16px; padding: 34px; box-shadow: var(--shadow-lg); }
.auth-card .brand { text-align: center; margin-bottom: 22px; }
.auth-card .brand .name { font-size: 20px; font-weight: 700; }
.auth-card .brand .sub { font-size: 13px; color: var(--muted); }
.auth-card h2 { text-align: center; font-size: 18px; margin-bottom: 20px; }
.auth-links { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }

/* -------------------------------- Утилиты --------------------------------- */
.row { display: flex; gap: 12px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 12px; } .mb-2 { margin-bottom: 12px; }
.mt-3 { margin-top: 20px; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .ic { font-size: 40px; opacity: .4; margin-bottom: 10px; }
.divider { height: 1px; background: var(--line); margin: 20px 0; }
.pill-nav { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.pill-nav a { padding: 9px 16px; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.pill-nav a.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* ------------------------------ Адаптив ----------------------------------- */
@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s; z-index: 50; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .form-grid { grid-template-columns: 1fr; }
    .menu-toggle { display: inline-flex !important; }
}
.menu-toggle { display: none; background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--ink); }

/* ------------------------ Тулбар / заголовок раздела ---------------------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar form { display: flex; gap: 8px; align-items: center; margin: 0; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* -------------------------------- Пагинатор ------------------------------- */
.pager { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-top: 1px solid var(--line); }
.pager-links { display: flex; gap: 4px; }
.pager-links a { min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font-size: 14px; padding: 0 8px; }
.pager-links a:hover { background: #f8fafc; text-decoration: none; }
.pager-links a.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ------------------------- Карточки «ключ-значение» ----------------------- */
.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
.kv td { padding: 9px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.kv td:first-child { color: var(--muted); width: 42%; }
.kv tr:last-child td { border-bottom: 0; }
.detail-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .detail-grid { grid-template-columns: 1fr; } }

/* ------------------------------ Каталог/заказ ----------------------------- */
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; margin-bottom: 26px; }
.product-tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.product-tile h4 { font-size: 17px; margin: 0 0 6px; }
.product-tile .type { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.product-tile .desc { font-size: 13.5px; color: var(--muted); margin-bottom: 14px; flex: 1; }
.product-tile .price { font-size: 22px; font-weight: 700; }
.product-tile .price small { font-size: 13px; font-weight: 500; color: var(--muted); }
.product-tile .featured { align-self: flex-start; margin-bottom: 8px; }
.section-title-lg { font-size: 16px; font-weight: 650; margin: 6px 0 14px; }
.chat { display: flex; flex-direction: column; gap: 14px; }
.msg { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.msg.staff { background: var(--brand-light); border-color: #bfdbfe; }
.msg.internal { background: var(--warn-bg); border-color: #fde68a; }
.msg .meta { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; display: flex; justify-content: space-between; }
.msg .body { white-space: pre-wrap; }
