/* Хранилище ключей Price Hub — в стиле решений Price Hub (Ozon.Автоакции.Off) */
:root {
  color-scheme: light;
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-soft: #f6f7f9;
  --border: #e1e5eb;
  --border-soft: #edf0f4;
  --control-border: #c9d0db;
  --text: #161b26;
  --text-2: #2c3442;
  --muted: #5a6372;
  --primary: #1e5eff;
  --primary-dark: #1647cc;
  --primary-soft: #e8eeff;
  --primary-text: #1a47c2;
  --ok-bg: #e4f4ea;
  --ok: #12693f;
  --warn-bg: #fff1d6;
  --warn: #8a4b00;
  --bad-bg: #fce8e6;
  --bad: #a3211a;
  --danger: #b42318;
  --radius-card: 16px;
  --radius-control: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.22, .8, .36, 1);
  font-family: system-ui, -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--primary-text); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(30, 94, 255, .28);
  outline-offset: 2px;
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 13px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* Каркас */
.layout {
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 16px 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}
.content { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.loading-card { text-align: center; color: var(--muted); padding: 36px; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; }
.card-head .tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.back { display: inline-flex; gap: 6px; align-items: center; text-decoration: none; font-weight: 500; }

/* Боковая панель */
.sidebar {
  flex: 1 1 220px;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 16px;
}
.side-title { padding: 6px 10px 8px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.side-item {
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  color: inherit;
  transition: background .15s var(--ease);
}
.side-item:hover { background: var(--surface-soft); }
.side-item.active { background: #eef3ff; border-color: #c9d7ff; }
.side-item.active .side-name { color: #1a3a8f; }
.side-name { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; }
.side-count { font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.side-sub { font-size: 12px; color: var(--muted); }
.side-meta { margin-top: 10px; padding: 12px 10px 4px; border-top: 1px solid var(--border-soft); display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.side-meta b { color: var(--text); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: #9aa3b2; display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.info { background: var(--primary); }
.dot.warn { background: #d88a00; }
.dot.bad { background: var(--danger); }

/* Баннеры */
.banners { display: flex; flex-direction: column; gap: 10px; }
.banners:empty { display: none; }
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 16px; border-radius: 12px; border: 1px solid; }
.banner-text { flex: 1 1 360px; min-width: 0; }
.banner.bad { background: var(--bad-bg); border-color: #f3b8b2; color: #7a1a14; }
.banner.warn { background: var(--warn-bg); border-color: #f0ce8c; color: #6b3a00; }
.banner.muted { background: #eef0f3; border-color: #d5dbe4; color: var(--text-2); }
.banner a { color: inherit; font-weight: 600; }

/* Кнопки */
.btn {
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--control-border);
  background: var(--surface);
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  text-decoration: none;
  color: var(--text);
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.btn:hover { background: var(--surface-soft); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn-danger:hover { background: #8f1c13; }
.btn-danger-text { border-color: transparent; background: transparent; color: var(--danger); font-weight: 600; }
.btn-danger-text:hover { background: var(--bad-bg); }
.btn-link { border-color: transparent; background: transparent; color: var(--primary-text); padding: 0 6px; }
.btn-link:hover { background: var(--primary-soft); }
.btn:disabled { cursor: not-allowed; opacity: .55; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Пилюли */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #eef0f3; color: #3b4556; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad, .pill.error { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--primary-soft); color: var(--primary-text); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* Формы */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label, .field .label { font-size: 13px; font-weight: 600; }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  min-height: 40px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--control-border);
  background: #fff;
  width: 100%;
}
.textarea { resize: vertical; min-height: 72px; }
.input.secret { font-family: var(--mono); letter-spacing: .02em; }
.input.masked { -webkit-text-security: disc; text-security: disc; }  /* вместо type=password: без окна Chrome «Обновить пароль?» */
.check-row { display: flex; gap: 8px; align-items: center; }
.check-row input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); }
.search { max-width: 260px; height: 36px; min-height: 36px; padding: 0 10px; }
.select.compact { width: auto; height: 36px; min-height: 36px; padding: 0 8px; }

/* Сводка ключа */
.hero-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.hero-title h1 { font-family: var(--mono); font-size: 22px; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.fact { padding: 12px 14px; border-radius: 12px; background: var(--surface-soft); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fact-label { font-size: 12px; color: var(--muted); }
.fact-value { font-weight: 600; overflow-wrap: anywhere; }
.fact-value.mask { font-family: var(--mono); font-size: 18px; letter-spacing: .04em; }
.fact .actions { margin-top: 4px; }
.note { padding: 12px 14px; border-radius: 12px; font-size: 13px; }
.note.info { background: #eef3ff; color: #1a3a8f; }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.bad { background: var(--bad-bg); color: var(--bad); }
.note.ok { background: var(--ok-bg); color: var(--ok); }
.check-result { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Таблицы */
.table-wrap { overflow-x: auto; margin: 0 -8px; }
.table { width: 100%; border-collapse: collapse; min-width: 720px; }
.table th { padding: 8px 10px; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #f8faff; }
.table tr.archived td { opacity: .55; }
.table .key-name { font-family: var(--mono); font-weight: 600; overflow-wrap: anywhere; }
.table .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.table .right { text-align: right; }
.table input.input { min-height: 32px; height: 32px; padding: 4px 8px; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* Карточки проектов */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.project-card { text-align: left; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); padding: 16px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; text-decoration: none; color: inherit; transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
.project-card:hover { border-color: #c9d7ff; box-shadow: 0 4px 16px rgba(16, 24, 40, .06); }
.project-card.archived { opacity: .6; }
.project-card .status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.project-card .meta { font-size: 12px; color: var(--muted); }

/* Окно */
.modal { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); display: grid; place-items: center; padding: 16px; z-index: 30; }
.modal-card { width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: var(--radius-card); padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 24px 48px rgba(16, 24, 40, .25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.secret-box { display: block; padding: 12px 14px; border-radius: 10px; background: #141a24; color: #d7e0ee; font-family: var(--mono); font-size: 13px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }
.env-box { display: block; padding: 12px 14px; border-radius: 10px; background: var(--surface-soft); border: 1px solid var(--border); font-family: var(--mono); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Уведомление */
.toast { position: fixed; right: 18px; bottom: 18px; max-width: min(420px, calc(100% - 36px)); background: #202a3a; color: #fff; border-radius: 12px; box-shadow: 0 12px 32px rgba(16, 24, 40, .28); padding: 11px 14px; z-index: 40; }
.toast.bad { background: #7a1a14; }
.toast:not(.hidden) { animation: toast-in .28s var(--ease); }

/* Страница сообщения */
.centered-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.error-card { width: min(560px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.error-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--bad-bg); color: var(--danger); font-size: 28px; font-weight: 900; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media (max-width: 760px) {
  .layout { padding: 8px 8px 24px; }
  .sidebar { position: static; }
  .card { padding: 16px; }
  .search { max-width: none; }
}

/* Дополнения */
.hero-title h1.plain { font-family: inherit; }
.bad-text { color: var(--bad); font-weight: 600; }
.steps-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; color: var(--text-2); }
#view { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

@media (max-width: 760px) {
  .sidebar { flex-direction: row; flex-wrap: wrap; padding: 8px; gap: 6px; }
  .side-title, .side-sub, .side-meta { display: none; }
  .side-item { flex: 1 1 auto; padding: 8px 10px; }
  .card-head .tools { width: 100%; }
}

/* --- карточки доступа (главная) --- */
.group { display: flex; flex-direction: column; gap: 8px; }
.group-title { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 8px 0 0; }
.acc { border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); }
.acc.archived { opacity: .6; }
.acc.drop { outline: 2px dashed var(--primary); }
.acc-head { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: none; border: 0; cursor: pointer; text-align: left; font: inherit; color: var(--text); }
.acc-head:hover { background: var(--surface-soft); border-radius: var(--radius-card); }
.acc-title, .acc-sub { user-select: text; cursor: text; }
.acc-title { font-weight: 700; font-size: 15px; }
.acc-sub { color: var(--muted); font-size: 13px; }
.acc-meta { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.acc-body { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 14px; border-top: 1px solid var(--border-soft); }
.where h3, .fields-block h3 { margin: 8px 0 6px; font-size: 16px; }
/* «Где используется» — заливка, чтобы сразу отличать от полей со значениями */
.where { margin: 14px 0; padding: 4px 14px 12px; background: #eaf2ff; border: 1px solid #bcd0ff; border-left: 6px solid var(--primary); border-radius: 12px; }
.where h3 { color: var(--primary-text); }
.where .table th { background: transparent; }
.where .btn { background: #fff; }
/* компактная таблица: одна высота строк (2 строки текста), без горизонтальной прокрутки */
.usage-table { table-layout: fixed; width: 100%; }
.usage-table th, .usage-table td { padding: 8px 10px; vertical-align: middle; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.usage-table th:nth-child(1) { width: 17%; } .usage-table th:nth-child(2) { width: 13%; } .usage-table th:nth-child(3) { width: 29%; }
.usage-table th:nth-child(4) { width: 17%; } .usage-table th:nth-child(5) { width: 12%; } .usage-table th:nth-child(6) { width: 12%; }
.usage-table .c1 { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.usage-table .c1.mono-sub { font-weight: 400; }
.usage-table .sub { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.where .var { font-size: 13px; }
.where .table-wrap { overflow: visible; }
@media (max-width: 1000px) { .where .table-wrap { overflow-x: auto; } .usage-table { table-layout: auto; min-width: 760px; } }
.where .table td { font-size: 15px; }
.where .var { font-family: var(--mono); font-weight: 700; }
.plain-value { font-family: var(--mono); font-weight: 600; word-break: break-all; }
.inline-form { border: 1px solid var(--border-soft); border-radius: var(--radius-control); padding: 12px; background: var(--surface-soft); display: flex; flex-direction: column; gap: 10px; }
.drag-key { cursor: grab; }
