/* Kosmos Vault — палитра с kosmos.marketing */
:root {
  --space: #06070B;
  --navy: #0D0E16;
  --navy-2: #15161F;
  --navy-3: #1C1D29;
  --violet: #7C3AED;
  --violet-2: #A78BFA;
  --violet-soft: rgba(124, 58, 237, .16);
  --blue: #2E5BFF;
  --light: #F2F4F8;
  --text: rgba(242, 244, 248, .72);
  --muted: rgba(242, 244, 248, .5);
  --line: rgba(255, 255, 255, .1);
  --line-2: rgba(255, 255, 255, .18);
  --danger: #F87171;
  --ok: #4ADE80;
  --radius: 18px;
  --radius-sm: 12px;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(.22, .61, .36, 1);
  --header-h: 68px;
  --sidebar-w: 280px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--space);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--violet-2); text-decoration: none; }
a:hover { color: var(--light); }
[hidden] { display: none !important; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--violet-2); outline-offset: 2px; }

/* ---------- Шапка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  display: flex; align-items: center; gap: 20px;
  padding: 0 20px;
  background: rgba(6, 7, 11, .86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; flex: none; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-tag {
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--violet-2); border: 1px solid rgba(167, 139, 250, .4);
  padding: 3px 8px; border-radius: 999px;
}
.search { position: relative; flex: 1; max-width: 520px; margin-left: auto; }
.search input {
  width: 100%; height: 42px; padding: 0 40px 0 40px;
  background: var(--navy-2); border: 1px solid var(--line); border-radius: 999px;
  outline: none; transition: border-color .2s var(--ease);
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--violet); }
.search input::-webkit-search-cancel-button { display: none; }
.search-icon { position: absolute; left: 14px; top: 12px; color: var(--muted); display: flex; }
.search-kbd {
  position: absolute; right: 12px; top: 10px;
  font: 12px var(--mono); color: var(--muted);
  border: 1px solid var(--line-2); border-radius: 6px; padding: 0 6px;
}
.search-results {
  position: absolute; top: 50px; left: 0; right: 0;
  background: var(--navy-2); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 6px; max-height: 60vh; overflow: auto;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, .8);
}
.search-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; background: none; border-radius: 8px; text-align: left; cursor: pointer;
}
.search-item:hover, .search-item.active { background: var(--navy-3); }
.search-item .title { color: var(--light); }
.search-item .sub { color: var(--muted); font-size: 13px; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-empty { padding: 10px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 14px; flex: none; }
.user { font-size: 13px; color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.burger { display: none; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--line-2); background: transparent; color: var(--light);
  cursor: pointer; font-weight: 500; white-space: nowrap;
  transition: background .2s var(--ease), border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.btn:hover { border-color: var(--violet); background: var(--violet-soft); }
.btn-primary { background: var(--violet); border-color: var(--violet); color: #fff; }
.btn-primary:hover { background: var(--blue); border-color: var(--blue); box-shadow: 0 14px 34px -12px rgba(46, 91, 255, .65); }
.btn-ghost { border-color: transparent; color: var(--text); }
.btn-danger { color: var(--danger); border-color: rgba(248, 113, 113, .4); }
.btn-danger:hover { background: rgba(248, 113, 113, .12); border-color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.icon-btn:hover { color: var(--light); background: var(--navy-3); }
.icon-btn-accent { color: #fff; background: var(--violet); }
.icon-btn-accent:hover { background: var(--blue); }
.icon-btn.danger:hover { color: var(--danger); }

/* ---------- Раскладка ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: calc(100vh - var(--header-h)); }
.sidebar {
  position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h));
  border-right: 1px solid var(--line); background: var(--navy);
  display: flex; flex-direction: column;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 10px 20px; }
.eyebrow { font: 12px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.client-list { overflow-y: auto; padding: 4px 10px 20px; flex: 1; }
.client-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: 10px; border: 0; background: none;
  color: var(--text); text-align: left; cursor: pointer;
}
.client-item:hover { background: var(--navy-2); color: var(--light); }
.client-item.active { background: var(--violet-soft); color: var(--light); box-shadow: inset 2px 0 0 var(--violet); }
.client-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.client-item .count { font: 12px var(--mono); color: var(--muted); }
.avatar {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px; color: #fff;
  background: linear-gradient(135deg, var(--violet), var(--blue));
}
.avatar.lg { width: 40px; height: 40px; border-radius: 12px; font-size: 15px; }
.tile.sm { width: 28px; height: 28px; border-radius: 8px; font-size: 10px; }
.sidebar-empty { padding: 12px; color: var(--muted); font-size: 14px; }
.scrim { display: none; }

.main { padding: 28px 32px 60px; min-width: 0; }

/* ---------- Экран клиента ---------- */
.client-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 24px; }
.client-head h1 { margin: 0; font-size: 30px; line-height: 1.2; font-weight: 600; color: var(--light); letter-spacing: -.01em; overflow-wrap: anywhere; }
.client-head .actions { display: flex; gap: 4px; }
.client-head .spacer { flex: 1; }

/* Ресурс — одна строка */
.res-list { display: flex; flex-direction: column; gap: 10px; }
.res {
  background: var(--navy); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px 10px 14px; min-width: 0;
  transition: border-color .2s var(--ease);
}
.res:hover { border-color: var(--line-2); }
.res.flash { animation: flash 1.6s var(--ease); }
@keyframes flash { 0%, 40% { border-color: var(--violet); box-shadow: 0 0 0 4px var(--violet-soft); } }
.res-row, .res-extra {
  display: grid; align-items: center; gap: 14px;
  grid-template-columns: 40px minmax(140px, 220px) minmax(0, 1fr) 46px 70px;
}
.res-title { min-width: 0; }
.res-title h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--light); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-title a { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; max-width: 100%; overflow: hidden; }
.res-title a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-title a svg.i { width: 13px; height: 13px; flex: none; }
.res-title .nolink { font-size: 13px; color: var(--muted); }
.res-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; min-width: 0; }
.res-nofields { color: var(--muted); font-size: 13px; }
.res-extra { margin-top: 8px; }
.res-extra-fields { grid-column: 3; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 14px; min-width: 0; }
.more-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  height: 30px; padding: 0 6px; border-radius: 8px; border: 1px solid var(--line);
  background: none; color: var(--muted); font: 12px var(--mono); cursor: pointer;
}
.more-btn:hover { color: var(--light); border-color: var(--violet); }
.more-btn svg.i { width: 14px; height: 14px; transition: transform .2s var(--ease); }
.more-btn.open svg.i { transform: rotate(180deg); }
.more-btn.placeholder { border: 0; }
.card-actions { display: flex; gap: 2px; justify-content: flex-end; opacity: .55; transition: opacity .15s; }
.res:hover .card-actions, .res:focus-within .card-actions { opacity: 1; }

.field { display: flex; align-items: center; gap: 10px; min-width: 0; }
.field-label { flex: 0 1 auto; width: 92px; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-value { display: flex; align-items: center; gap: 2px; min-width: 0; flex: 1; }
.chip {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 10px 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--navy-2);
  font: 14px var(--mono); color: var(--light); text-align: left; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.chip:hover { border-color: var(--violet); background: var(--navy-3); }
.chip .v { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .copy-hint { color: var(--muted); display: flex; }
.chip:hover .copy-hint { color: var(--violet-2); }
.chip.masked .v { letter-spacing: .06em; color: var(--text); }
.chip.empty { cursor: default; color: var(--muted); font-family: var(--font); font-size: 13px; }
.chip.empty:hover { border-color: var(--line); background: var(--navy-2); }
.chip.copied { border-color: var(--ok); }
.chip .timer { font-size: 12px; color: var(--violet-2); }
.note-chip { font-family: var(--font); }
.field-value .icon-btn { width: 30px; height: 30px; }

/* Плитки и логотипы */
.tile {
  width: 40px; height: 40px; border-radius: 11px; flex: none; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font: 600 12px var(--mono); color: var(--violet-2);
  background: var(--violet-soft); border: 1px solid rgba(167, 139, 250, .25);
}
.tile.brand { border: 0; }
.tile.brand svg { width: 55%; height: 55%; fill: currentColor; }
.tile.brand.outlined { box-shadow: inset 0 0 0 1px var(--line-2); }
.tile.img { background: #fff; border: 0; padding: 5px; }
.tile.img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile.upload { color: var(--light); background: var(--navy-3); border: 1px dashed var(--line-2); }
.tile.upload svg.i { width: 20px; height: 20px; }
.tile.sm { width: 28px; height: 28px; border-radius: 8px; font-size: 10px; }
.tile.sm.img { padding: 3px; }
.tile.xl { width: 56px; height: 56px; border-radius: 14px; font-size: 14px; }

.add-row {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 58px; border: 1px dashed var(--line-2); background: transparent; border-radius: var(--radius-sm);
  color: var(--muted); cursor: pointer; transition: color .2s, border-color .2s, background .2s;
}
.add-row:hover { color: var(--light); border-color: var(--violet); background: var(--violet-soft); }
.add-row .plus { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: var(--violet); color: #fff; }

.empty-state { max-width: 460px; margin: 12vh auto 0; text-align: center; }
.empty-state h2 { color: var(--light); font-weight: 600; margin: 16px 0 8px; }
.empty-state p { margin: 0 0 20px; }
.empty-state .orb {
  width: 72px; height: 72px; margin: 0 auto; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--violet-2), var(--violet) 45%, var(--blue));
  box-shadow: 0 0 80px -10px var(--violet);
}
.loading { color: var(--muted); padding: 20px 0; }

/* ---------- Диалоги ---------- */
dialog {
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 1px solid var(--line-2); border-radius: 22px;
  background: var(--navy); color: var(--text);
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, .9);
}
dialog::backdrop { background: rgba(3, 4, 8, .72); backdrop-filter: blur(4px); }
dialog.wide { width: min(920px, calc(100vw - 32px)); }
.dlg { display: flex; flex-direction: column; max-height: calc(100vh - 50px); }
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px 12px; }
.dlg-head h2 { margin: 0; font-size: 20px; font-weight: 600; color: var(--light); flex: 1; }
.dlg-body { padding: 8px 22px 16px; overflow: auto; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; border-top: 1px solid var(--line); }
.dlg-foot .left { margin-right: auto; }
.form-error { color: var(--danger); font-size: 14px; margin-top: 10px; }

.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 12px;
  background: var(--navy-2); border: 1px solid var(--line); border-radius: 10px; outline: none;
  transition: border-color .15s;
}
.textarea { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--violet); }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input.mono { font-family: var(--mono); font-size: 14px; }
label.lbl { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tpl {
  display: flex; align-items: center; gap: 10px; padding: 12px; text-align: left;
  border: 1px solid var(--line); border-radius: 14px; background: var(--navy-2); cursor: pointer;
}
.tpl:hover { border-color: var(--violet); background: var(--navy-3); color: var(--light); }
.tpl .tile { width: 34px; height: 34px; font-size: 11px; }

.form-top { display: grid; grid-template-columns: auto 1fr 1fr; gap: 12px; align-items: end; }
.logo-btn { position: relative; padding: 0; border: 0; background: none; cursor: pointer; display: block; border-radius: 14px; }
.logo-btn .logo-btn-edit {
  position: absolute; right: -6px; bottom: -6px; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--violet); color: #fff; border: 2px solid var(--navy);
}
.logo-btn .logo-btn-edit svg.i { width: 12px; height: 12px; }
.logo-btn:hover .tile { box-shadow: 0 0 0 2px var(--violet); }
.logo-cell .lbl { white-space: nowrap; }
.logo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 14px; }
.logo-opt {
  display: flex; align-items: center; gap: 10px; padding: 8px; text-align: left; min-width: 0;
  border: 1px solid var(--line); border-radius: 12px; background: var(--navy-2); cursor: pointer; font-size: 13px;
}
.logo-opt span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo-opt .tile { width: 34px; height: 34px; border-radius: 9px; font-size: 11px; }
.logo-opt:hover { border-color: var(--violet); color: var(--light); }
.logo-opt.sel { border-color: var(--violet); background: var(--violet-soft); color: var(--light); }

.frow { display: grid; grid-template-columns: 150px 118px 1fr auto; gap: 8px; align-items: start; margin-bottom: 8px; }
.frow .val { display: flex; gap: 4px; }
.frow .val > .input, .frow .val > .textarea { flex: 1; min-width: 0; }
.fhead { display: grid; grid-template-columns: 150px 118px 1fr 34px; gap: 8px; font-size: 12px; color: var(--muted); margin: 18px 0 6px; }
.add-field { margin-top: 4px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.confirm-text { margin: 0 0 8px; }
.confirm-text b { color: var(--light); }

/* ---------- Журнал ---------- */
.audit { width: 100%; border-collapse: collapse; font-size: 13px; }
.audit th { text-align: left; font-weight: 500; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--navy); }
.audit td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.audit td.ts { font-family: var(--mono); white-space: nowrap; color: var(--muted); }
.audit td.who { color: var(--light); overflow-wrap: anywhere; }
.badge { display: inline-block; font: 12px var(--mono); padding: 2px 8px; border-radius: 999px; background: var(--navy-3); white-space: nowrap; }
.badge.warn { background: rgba(124, 58, 237, .22); color: var(--violet-2); }
.badge.del { background: rgba(248, 113, 113, .14); color: var(--danger); }

/* ---------- Тосты ---------- */
.toast-wrap { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-radius: 999px; background: var(--light); color: var(--space);
  font-weight: 500; font-size: 14px; box-shadow: 0 18px 40px -14px rgba(0, 0, 0, .8);
  animation: toast-in .25s var(--ease);
}
.toast.error { background: var(--danger); color: #1a0505; }
.toast svg.i { width: 16px; height: 16px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Адаптив ---------- */
@media (max-width: 1180px) and (min-width: 861px) {
  .res-row, .res-extra { grid-template-columns: 40px minmax(120px, 180px) minmax(0, 1fr) 46px 70px; }
  .res-fields, .res-extra-fields { grid-template-columns: 1fr; gap: 6px; }
}
@media (max-width: 1000px) {
  .user { display: none; }
}
@media (max-width: 860px) {
  :root { --header-h: 60px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .burger { display: inline-flex; }
  .brand-logo { height: 24px; }
  .brand-tag { display: none; }
  .search-kbd { display: none; }
  #auditBtn .label { display: none; }
  #auditBtn { padding: 0 10px; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: var(--header-h); left: 0; bottom: 0; height: auto; width: min(300px, 86vw); z-index: 25;
    transform: translateX(-100%); transition: transform .25s var(--ease);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: var(--header-h) 0 0 0; background: rgba(0, 0, 0, .5); z-index: 20; }
  .main { padding: 20px 16px 60px; }
  .client-head h1 { font-size: 24px; }
  .res-row { grid-template-columns: 40px minmax(0, 1fr) auto auto; row-gap: 10px; }
  .res-extra { display: block; }
  .res-fields { grid-column: 1 / -1; grid-template-columns: 1fr; gap: 8px; }
  .res-extra-fields { grid-template-columns: 1fr; }
  .res-row .more-btn { grid-row: 1; grid-column: 3; }
  .res-row .card-actions { grid-row: 1; grid-column: 4; opacity: 1; }
  .more-btn.placeholder { display: none; }
  .form-top { grid-template-columns: auto 1fr; }
  .form-top > div:last-child { grid-column: 1 / -1; }
  .frow { grid-template-columns: 1fr 1fr auto; }
  .frow .val { grid-column: 1 / -1; grid-row: 2; }
  .fhead { display: none; }
  .row2 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .brand-logo { height: 20px; }
  .field-label { width: 72px; }
}
