:root {
  --primary: #1a5c9e;
  --bg: #f4f6f9;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: #222;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--primary);
  color: #fff;
  padding: 10px 24px;
}
.topbar .brand { font-size: 20px; font-weight: 600; }
.topbar nav a { color: #dce9f7; margin-left: 16px; text-decoration: none; }
.topbar nav a:hover { color: #fff; }
.topbar .who { color: #a9c8e6; margin-left: 16px; }
.container { max-width: 960px; margin: 32px auto; padding: 0 16px; }

.login-card {
  max-width: 380px;
  margin: 64px auto;
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
}
.login-card label { display: block; margin: 14px 0; font-size: 14px; color: #555; }
.login-card input {
  width: 100%;
  padding: 10px;
  margin-top: 4px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 16px;
}
.login-card button {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: #fff;
  border: 0;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  margin-top: 12px;
}
.error {
  background: #fdecea;
  color: #b3261e;
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 8px;
}
.hint { color: #667; font-size: 14px; }
.empty { color: #889; }

.base-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.base-card {
  display: block;
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  text-decoration: none;
  color: #222;
  box-shadow: 0 2px 8px rgba(0,0,0,.07);
  transition: box-shadow .15s;
}
.base-card:hover { box-shadow: 0 4px 14px rgba(26,92,158,.25); }
.base-name { font-size: 18px; font-weight: 600; }
.base-meta { color: #778; font-size: 13px; margin-top: 4px; }
.base-action { display: block; color: var(--primary); margin-top: 12px; font-size: 14px; font-weight: 600; text-decoration: none; }
.base-alt { display: block; color: #778; margin-top: 6px; font-size: 13px; }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid #e6e9ee; font-size: 14px; }
th { background: #eef2f7; }
.btn {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 6px;
  border: 0;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  cursor: pointer;
}
.btn.secondary { background: #6c757d; }
.btn.danger { background: #b3261e; }
form.inline { display: inline; }
.steps li { margin: 8px 0; }
.download-btn {
  display: inline-block;
  background: #2e7d32;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
}

/* Окно входа 1С (тонкий клиент ~400×500): всё помещается без прокрутки.
   Во встроенном WebKit 1С поля ввода не принимают буквы, если страница прокручена. */
body.compact { background: #fff; }
.compact .container { margin: 0; padding: 0; max-width: none; }
.compact .login-card {
  max-width: none;
  margin: 0;
  padding: 16px 20px;
  border-radius: 0;
  box-shadow: none;
}
.compact .login-card h1 { font-size: 20px; margin: 0 0 8px; }
.compact .login-card label { margin: 8px 0; }
.compact .login-card input { padding: 8px 10px; }
.compact .login-card button { margin-top: 8px; padding: 10px; }
.compact .hint { font-size: 13px; margin: 8px 0; }

/* Вход в 1С по коду */
.login-code { font-size: 36px; font-weight: 600; letter-spacing: 4px; text-align: center; margin: 8px 0 12px; }
.code-steps { padding-left: 20px; margin: 8px 0; font-size: 15px; }
.code-steps li { margin: 6px 0; }
.success { background: #e7f5ea; color: #1e6b33; padding: 10px; border-radius: 6px; margin-bottom: 8px; }
.big-btn {
  display: block; text-align: center; padding: 14px; margin: 12px 0;
  background: var(--primary); color: #fff; border-radius: 6px; font-size: 17px; text-decoration: none;
}
.code-inline { letter-spacing: 2px; white-space: nowrap; }
.code-confirm { font-size: 32px; font-weight: 600; letter-spacing: 4px; text-align: center; margin: 12px 0; }

/* ---------- Админ-панель ---------- */
.container.wide { max-width: none; padding: 0 24px; }
.admin-shell { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; }
.admin-nav { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 2px; background: #fff; border-radius: 10px; padding: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.admin-nav a { padding: 10px 12px; border-radius: 6px; color: #334; text-decoration: none; font-size: 15px; }
.admin-nav a:hover { background: #eef2f7; }
.admin-nav a.active { background: var(--primary); color: #fff; font-weight: 600; }
.admin-content h1 { margin: 0 0 16px; font-size: 24px; }
.admin-content h2 { margin: 28px 0 10px; font-size: 18px; }
.flash { background: #e7f5ea; color: #1e6b33; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.admin-content .error { margin-bottom: 12px; }

.card { background: #fff; border-radius: 10px; padding: 16px 20px; box-shadow: 0 1px 4px rgba(0,0,0,.06); margin: 12px 0; }
form.card { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 16px; align-items: end; }
form.card > button, form.card > .full { grid-column: 1 / -1; justify-self: start; }
.admin-content label { display: block; font-size: 13px; color: #556; }
.admin-content input:not([type=checkbox]):not([type=radio]), .admin-content select {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font-size: 15px;
  border: 1px solid #c5ccd6; border-radius: 6px; background: #fff; font-family: inherit;
}
.admin-content label > input[type=checkbox] { margin-right: 6px; }
.admin-content td input:not([type=checkbox]), .admin-content td select { margin: 0; padding: 5px 8px; font-size: 14px; width: auto; display: inline-block; }
.admin-content :focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; margin: 0 0 12px; }
.toolbar label { flex: 1 1 240px; }
.toolbar .btn { margin-bottom: 1px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin: 12px 0 8px; }
.stat { background: #fff; border-radius: 10px; padding: 14px 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06); text-decoration: none; color: inherit; display: block; }
a.stat:hover { box-shadow: 0 3px 10px rgba(26,92,158,.2); }
.stat b { display: block; font-size: 26px; font-weight: 600; }
.stat span { color: #667; font-size: 13px; }
.stat.warn b { color: #b3261e; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: #e3e8ef; color: #334; white-space: nowrap; }
.badge.ok { background: #e7f5ea; color: #1e6b33; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.bad { background: #fdecea; color: #b3261e; }
.badge.info { background: #e4eefb; color: #1a5c9e; }
td a { color: var(--primary); }
tr.row-blocked td { color: #889; }
.table-wrap { overflow-x: auto; border-radius: 8px; }
.table-wrap table { min-width: 640px; }
td.num, th.num { text-align: right; }
.actions { white-space: nowrap; }
.actions .btn { margin-right: 4px; }
details.card > summary { cursor: pointer; font-weight: 600; color: var(--primary); }
details.card[open] > summary { margin-bottom: 12px; }
.breadcrumb { font-size: 14px; margin: 0 0 8px; }
.breadcrumb a { color: var(--primary); text-decoration: none; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid #dde3ec; margin: 16px 0; overflow-x: auto; }
.tabs a { padding: 9px 16px; text-decoration: none; color: #445; border-radius: 8px 8px 0 0; white-space: nowrap; }
.tabs a:hover { background: #eef2f7; }
.tabs a.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 -2px 0 var(--primary) inset; }

.matrix { width: auto; min-width: 0; }
.matrix th, .matrix td { text-align: center; padding: 6px 12px; }
.matrix th:first-child, .matrix td:first-child { text-align: left; position: sticky; left: 0; background: #fff; }
.matrix thead th { background: #eef2f7; vertical-align: bottom; max-width: 160px; overflow-wrap: anywhere; }
.matrix input[type=checkbox] { width: 20px; height: 20px; cursor: pointer; }
.matrix tbody tr:hover td { background: #f6f9fd; }
.matrix-actions { display: flex; gap: 12px; align-items: center; margin: 12px 0; }

@media (max-width: 800px) {
  .admin-shell { grid-template-columns: 1fr; gap: 12px; }
  .admin-nav { position: static; flex-direction: row; overflow-x: auto; }
  .admin-nav a { white-space: nowrap; }
}

/* ---------- Страница «Мои базы»: один заметный путь — открыть в браузере ---------- */
.lead { font-size: 18px; line-height: 1.5; max-width: 760px; }
.open-btn {
  display: block;
  margin-top: 16px;
  padding: 16px 20px;
  background: #2e7d32;
  color: #fff;
  border-radius: 10px;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
}
.open-btn:hover, .open-btn:focus-visible { background: #256628; }
.program-box {
  margin-top: 40px;
  padding: 20px 24px;
  background: #fff;
  border: 2px solid #c9d6e6;
  border-radius: 12px;
}
.program-box h2 { margin-top: 0; }
.big-steps { list-style: none; padding: 0; margin: 20px 0 0; }
.big-steps > li { margin: 0 0 24px; padding-left: 0; }
.step-title { font-size: 18px; font-weight: 600; margin-bottom: 10px; }
.step-num {
  display: inline-block; width: 32px; height: 32px; line-height: 32px; margin-right: 8px;
  text-align: center; border-radius: 50%; background: var(--primary); color: #fff;
}
.step-btn {
  display: inline-block; padding: 12px 22px; background: var(--primary); color: #fff;
  border-radius: 8px; font-size: 16px; font-weight: 600; text-decoration: none;
}
.step-btn:hover, .step-btn:focus-visible { background: #144a80; }
.step-done { display: none; color: #2e7d32; font-weight: 600; font-size: 14px; margin-left: 8px; }
.big-steps > li.is-done .step-done { display: inline; }
.big-steps > li.is-done .step-num { background: #2e7d32; }
.sub-steps { margin: 10px 0 0 4px; }
.sub-steps li { margin: 8px 0; line-height: 1.45; }
.support { margin-top: 32px; padding: 12px 16px; background: #fff8e1; border-radius: 8px; }
.invite textarea { width: 100%; min-height: 140px; font-family: inherit; font-size: 14px; }
