:root {
    --indigo: #4f46e5;
    --indigo-600: #4338ca;
    --indigo-50: #eef2ff;
    --slate-950: #020617;
    --slate-900: #0f172a;
    --slate-800: #1e293b;
    --slate-700: #334155;
    --slate-600: #475569;
    --slate-500: #64748b;
    --slate-400: #94a3b8;
    --slate-300: #cbd5e1;
    --slate-200: #e2e8f0;
    --slate-100: #f1f5f9;
    --slate-50: #f8fafc;
    --emerald: #059669;
    --emerald-bg: #ecfdf5;
    --amber: #b45309;
    --amber-bg: #fffbeb;
    --red: #dc2626;
    --red-bg: #fef2f2;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .08);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, .06), 0 2px 4px rgba(15, 23, 42, .04);
}

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

body {
    font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--slate-50);
    color: var(--slate-900);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    font-size: 14px;
}

a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: none; }
.muted { color: var(--slate-500); }

/* ============ App shell ============ */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px; flex-shrink: 0;
    background: #fff;
    border-right: 1px solid var(--slate-200);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
    display: flex; align-items: center; gap: 11px;
    font-weight: 700; font-size: 18px; color: var(--slate-900);
    letter-spacing: -.02em;
    padding: 22px 22px 18px;
}
/* Фирменный знак целиком: логотип со словом, а не буква в квадрате */
.brand picture { display: block; line-height: 0; }
.brand-logo { display: block; height: 28px; width: auto; }
.nav { padding: 6px 12px; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-label {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .06em; color: var(--slate-400);
    padding: 14px 10px 6px;
}
.nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 10px; border-radius: 9px;
    color: var(--slate-600); font-weight: 500; font-size: 14px;
    transition: background .12s, color .12s;
}
.nav a:hover { background: var(--slate-100); color: var(--slate-900); }
.nav a.active { background: var(--indigo-50); color: var(--indigo-600); font-weight: 600; }
.nav a svg { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.8; }
.sidebar-foot { border-top: 1px solid var(--slate-200); padding: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--indigo-50); color: var(--indigo-600);
    display: grid; place-items: center; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-chip .u-meta { min-width: 0; flex: 1; }
.user-chip .u-name { font-weight: 600; font-size: 13px; color: var(--slate-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .u-mail { font-size: 12px; color: var(--slate-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
    width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--slate-200);
    background: #fff; color: var(--slate-500); display: grid; place-items: center; cursor: pointer;
    transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--slate-100); color: var(--slate-700); }
.icon-btn svg { width: 16px; height: 16px; stroke-width: 1.8; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 30px 36px 64px; max-width: 1120px; width: 100%; }

/* ============ Headings ============ */
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--slate-500); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 30px 0 14px; }
.section-head h2 { font-size: 16px; margin: 0; letter-spacing: -.01em; }
.back-link { font-size: 13px; color: var(--slate-500); display: inline-flex; align-items: center; gap: 6px; margin-bottom: 16px; }
.back-link:hover { color: var(--slate-700); }

/* ============ Stat tiles ============ */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat {
    background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 18px 20px;
    display: flex; flex-direction: column; gap: 10px;
}
.stat .s-top { display: flex; align-items: center; gap: 10px; }
.stat .s-ico {
    width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0;
}
.stat .s-ico svg { width: 18px; height: 18px; stroke-width: 1.9; }
.s-ico.indigo { background: var(--indigo-50); color: var(--indigo-600); }
.s-ico.emerald { background: var(--emerald-bg); color: var(--emerald); }
.s-ico.amber { background: var(--amber-bg); color: var(--amber); }
.stat .s-label { font-size: 13px; color: var(--slate-500); font-weight: 500; }
.stat .s-num { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.stat .s-sub { font-size: 12px; color: var(--slate-400); }

/* ============ Cards ============ */
.card {
    background: #fff; border: 1px solid var(--slate-200);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px;
}
.card-pad-lg { padding: 24px 26px; }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* license row (dashboard) */
.lic-row { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.lic-row .lr-main { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 240px; }
.prod-ico {
    width: 46px; height: 46px; border-radius: 11px;
    background: linear-gradient(135deg, var(--indigo), #8b7cf5); color: #fff;
    display: grid; place-items: center; font-weight: 800; font-size: 19px; flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(79, 70, 229, .3);
}
.lic-row h3 { margin: 0 0 3px; font-size: 16px; letter-spacing: -.01em; }
.lic-row .lr-sub { font-size: 13px; color: var(--slate-500); }
.lr-metrics { display: flex; gap: 30px; flex-wrap: wrap; }
.metric .label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--slate-400); }
.metric .value { font-weight: 600; font-size: 14px; margin-top: 3px; }

.key {
    font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace;
    background: var(--slate-100); border: 1px solid var(--slate-200); border-radius: 8px;
    padding: 8px 12px; font-size: 14px; letter-spacing: .04em; color: var(--slate-700);
    display: inline-flex; align-items: center; gap: 8px;
}

/* ============ Badges ============ */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; border: 1px solid transparent;
}
.badge.ok { background: var(--emerald-bg); color: var(--emerald); border-color: #a7f3d0; }
.badge.warn { background: var(--amber-bg); color: var(--amber); border-color: #fde68a; }
.badge.mut { background: var(--slate-100); color: var(--slate-500); border-color: var(--slate-200); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ============ Buttons ============ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-size: 14px; font-weight: 600; padding: 9px 16px; border-radius: 9px;
    border: 1px solid transparent; cursor: pointer; transition: background .15s, border-color .15s;
    white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; stroke-width: 2; }
.btn-primary { background: var(--indigo); color: #fff; }
.btn-primary:hover { background: var(--indigo-600); }
.btn-ghost { background: #fff; color: var(--slate-700); border-color: var(--slate-300); }
.btn-ghost:hover { background: var(--slate-50); }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }

/* ============ Tables ============ */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
    text-align: left; font-weight: 600; color: var(--slate-500);
    font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
    padding: 0 14px 10px; border-bottom: 1px solid var(--slate-200);
}
table.data td { padding: 13px 14px; border-bottom: 1px solid var(--slate-100); }
table.data tr:last-child td { border-bottom: none; }
table.data td.mono { font-family: ui-monospace, Menlo, monospace; font-size: 13px; color: var(--slate-700); }

/* ============ License detail grid ============ */
.detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.aside { display: flex; flex-direction: column; gap: 20px; }
.summary-list { display: flex; flex-direction: column; gap: 0; }
.summary-list .sl-row { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--slate-100); font-size: 14px; }
.summary-list .sl-row:last-child { border-bottom: none; }
.summary-list .sl-k { color: var(--slate-500); }
.summary-list .sl-v { font-weight: 600; }

.card-title { font-size: 15px; font-weight: 700; margin: 0 0 14px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.card-title svg { width: 17px; height: 17px; stroke-width: 1.9; color: var(--indigo); }

/* onboarding steps */
.steps { display: flex; flex-direction: column; gap: 14px; }
.step { display: flex; gap: 13px; }
.step .s-idx {
    width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
    background: var(--indigo-50); color: var(--indigo-600); font-weight: 700; font-size: 13px;
    display: grid; place-items: center;
}
.step .s-body { font-size: 13.5px; }
.step .s-body b { color: var(--slate-900); }
.step .s-body div { color: var(--slate-500); margin-top: 2px; }

.snippet {
    background: var(--slate-900); color: #e2e8f0; border-radius: 10px;
    padding: 12px 14px; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px;
    overflow-x: auto; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.snippet .s-key { color: #a5b4fc; letter-spacing: .04em; }

/* ============ Alerts / empty ============ */
.alert { padding: 12px 16px; border-radius: 10px; font-size: 13.5px; margin-bottom: 18px; }
.alert-error { background: var(--red-bg); color: var(--red); border: 1px solid #fecaca; }
.alert-warn { background: var(--amber-bg); color: var(--amber); border: 1px solid #fde68a; }
.empty { text-align: center; padding: 52px 24px; color: var(--slate-500); }
.empty-mark { font-size: 32px; margin-bottom: 10px; }

/* ============ Login ============ */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--slate-100); }
.auth-card { width: 100%; max-width: 400px; box-shadow: var(--shadow-md); }
.auth-card .brand { justify-content: center; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }
.auth-card .brand-logo { height: 32px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--slate-700); margin-bottom: 6px; }
.field input[type=email], .field input[type=password] {
    width: 100%; padding: 10px 12px; font-size: 14px;
    border: 1px solid var(--slate-300); border-radius: 9px; background: #fff; color: var(--slate-900);
    outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px var(--indigo-50); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--slate-500); }
.hint { text-align: center; font-size: 12.5px; color: var(--slate-400); margin-top: 18px; }

/* ============ Forms ============ */
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 13px; font-weight: 600; color: var(--slate-700); }
.input {
    width: 100%; padding: 10px 12px; font-size: 14px;
    border: 1px solid var(--slate-300); border-radius: 9px; background: #fff; color: var(--slate-900);
    outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px var(--indigo-50); }
.field-error { color: var(--red); font-size: 12.5px; }

/* ============ Выпадающий список ============ */
.sel { position: relative; }
.sel-btn {
    width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 10px 12px; font: inherit; font-size: 14px; text-align: left; cursor: pointer;
    border: 1px solid var(--slate-300); border-radius: 9px; background: #fff; color: var(--slate-900);
    outline: none; transition: border-color .15s, box-shadow .15s;
}
.sel-btn:hover { border-color: var(--slate-400); }
.sel.is-open .sel-btn, .sel-btn:focus-visible { border-color: var(--indigo); box-shadow: 0 0 0 3px var(--indigo-50); }
.sel-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-val.is-ph { color: var(--slate-400); }
.sel-arrow { width: 16px; height: 16px; flex-shrink: 0; stroke-width: 2; color: var(--slate-400); transition: transform .15s; }
.sel.is-open .sel-arrow { transform: rotate(180deg); }

.sel-menu {
    position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; right: 0;
    background: #fff; border: 1px solid var(--slate-200); border-radius: 11px;
    box-shadow: var(--shadow-md); padding: 5px; max-height: 280px; overflow: auto;
}
.sel-search { padding: 3px 3px 7px; }
.sel-search .input { padding: 7px 10px; font-size: 13px; }
.sel-opt {
    display: block; width: 100%; text-align: left; padding: 8px 10px;
    font: inherit; font-size: 13.5px; border: 0; border-radius: 7px;
    background: none; color: var(--slate-700); cursor: pointer;
}
.sel-opt:hover, .sel-opt:focus-visible { background: var(--slate-50); color: var(--slate-900); outline: none; }
.sel-opt.is-on { background: var(--indigo-50); color: var(--indigo-600); font-weight: 600; }
.sel-empty { padding: 10px; font-size: 13px; color: var(--slate-400); text-align: center; }

/* ============ Загрузки ============ */
.dl { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.dl-what { display: flex; align-items: center; gap: 9px; }
.dl-ver { font-size: 16px; font-weight: 600; }
.dl-meta { font-size: 12.5px; margin-top: 3px; }
.dl-note { color: var(--slate-500); font-size: 13px; margin: 14px 0 0; line-height: 1.55; }
.dl-older { margin-top: 14px; border-top: 1px solid var(--slate-100); padding-top: 12px; }
.dl-older summary {
    cursor: pointer; font-size: 13px; color: var(--slate-500);
    list-style: none; display: inline-flex; align-items: center; gap: 6px;
}
.dl-older summary::-webkit-details-marker { display: none; }
.dl-older summary::before { content: "▸"; font-size: 11px; transition: transform .15s; }
.dl-older[open] summary::before { transform: rotate(90deg); }
.dl-older summary:hover { color: var(--slate-900); }
.dl-pick { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.dl-pick .sel { flex: 1; }
@media (max-width: 560px) {
    .dl { flex-direction: column; align-items: stretch; }
    .dl-pick { flex-direction: column; align-items: stretch; }
}
.card-actions { margin-top: 18px; display: flex; justify-content: flex-end; gap: 10px; }
.alert-success { background: var(--emerald-bg); color: var(--emerald); border: 1px solid #a7f3d0; }
.card-desc { color: var(--slate-500); font-size: 13px; margin: -8px 0 16px; }

/* ============ Toggle ============ */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 0; border-bottom: 1px solid var(--slate-100); }
.toggle-row:last-child { border-bottom: none; }
.toggle-row .t-label { font-weight: 500; font-size: 14px; }
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--slate-300); border-radius: 999px; transition: .2s; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .slider { background: var(--indigo); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ============ Social ============ */
.social-list { display: flex; flex-direction: column; gap: 10px; }
.social-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--slate-200); border-radius: 11px; }
.social-item .si-left { display: flex; align-items: center; gap: 12px; }
.provider-ico { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; background: var(--slate-100); }
.provider-ico svg { width: 20px; height: 20px; }
.si-name { font-weight: 600; font-size: 14px; }
.si-sub { font-size: 12.5px; color: var(--slate-500); }

.social-auth { display: flex; flex-direction: column; gap: 10px; }
.btn-social { width: 100%; background: #fff; border: 1px solid var(--slate-300); color: var(--slate-700); }
.btn-social:hover { background: var(--slate-50); }
.btn-social svg { width: 18px; height: 18px; }
.divider-or { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--slate-400); font-size: 12.5px; }
.divider-or::before, .divider-or::after { content: ""; flex: 1; height: 1px; background: var(--slate-200); }

@media (prefers-color-scheme: dark) {
    .input { background: var(--slate-900); border-color: #334155; color: var(--slate-100); }
    .form-field label { color: var(--slate-300); }
    .social-item { border-color: #1e293b; }
    .provider-ico { background: #1e293b; }
    .toggle-row { border-color: #1e293b; }
    .btn-social { background: var(--slate-900); border-color: #334155; color: var(--slate-200); }
    .btn-social:hover { background: #1e293b; }
    .divider-or::before, .divider-or::after { background: #1e293b; }
    .si-name { color: #f1f5f9; }
}

/* ============ Responsive ============ */
@media (max-width: 860px) {
    .sidebar { display: none; }
    .detail-grid { grid-template-columns: 1fr; }
    .content { padding: 22px 18px 48px; }
}

/* ============ Dark ============ */
@media (prefers-color-scheme: dark) {
    body { background: var(--slate-950); color: var(--slate-100); }
    .sidebar, .card, .stat, .field input[type=email], .field input[type=password], .btn-ghost, .icon-btn { background: var(--slate-900); border-color: #1e293b; }
    .sidebar { border-color: #1e293b; }
    .sidebar .brand, .page-head h1, .lic-row h3, .metric .value, .section-head h2, .summary-list .sl-v, .stat .s-num, .u-name { color: #f1f5f9; }
    .nav a { color: var(--slate-400); }
    .nav a:hover { background: #1e293b; color: #f1f5f9; }
    .key { background: #1e293b; border-color: #334155; color: var(--slate-200); }
    table.data th, table.data td, .summary-list .sl-row, .sidebar-foot { border-color: #1e293b; }
    .btn-ghost { color: var(--slate-200); }
    .btn-ghost:hover { background: #1e293b; }
    .badge.mut { background: #1e293b; border-color: #334155; }
    .auth-wrap { background: var(--slate-950); }
    .icon-btn:hover { background: #1e293b; }
}
