/* ДокПакет — мобильный-first, светлая тема, акцент #2563eb */
:root {
  --accent: #2563eb;
  --accent-dark: #1e40af;
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --danger: #dc2626;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}
a { color: var(--accent); }

/* ---------- Шапка и навигация ---------- */
.site-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.brand {
  font-weight: 700;
  font-size: 1.15em;
  color: var(--accent);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}
.user-box { color: var(--muted); font-size: .9em; display: flex; align-items: center; gap: 8px; }
.user-box a { color: var(--danger); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }

/* Бургер-меню */
#nav-toggle { display: none; }
.burger {
  display: none;
  width: 44px; height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  color: var(--text);
}
.main-nav { display: flex; flex-wrap: wrap; gap: 2px; }
.main-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  font-size: .95em;
  white-space: nowrap;
}
.main-nav a:hover { background: #eff6ff; color: var(--accent); }
#nav-toggle:checked ~ .main-nav { display: flex; }

@media (max-width: 800px) {
  .burger { display: inline-flex; align-items: center; justify-content: center; }
  .main-nav {
    display: none;
    flex-direction: column;
    width: 100%;
    padding: 8px 0 12px;
    gap: 0;
  }
  .main-nav a { min-height: 48px; padding: 0 8px; }
  .header-inner { padding-bottom: 8px; }
}

/* ---------- Контент ---------- */
main {
  max-width: 1100px;
  margin: 24px auto;
  padding: 0 16px 48px;
}
h1 { font-size: 1.5em; margin: 0 0 16px; }
h2 { font-size: 1.2em; }
h3 { font-size: 1.05em; margin-top: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.card form label { font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- Формы ---------- */
label { display: block; font-size: .92em; color: #475569; margin-top: 12px; }
input, select, textarea {
  font: inherit;
  padding: 10px 12px;
  margin: 4px 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  max-width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
input[type="checkbox"] {
  width: 20px; height: 20px;
  accent-color: var(--accent);
  margin: 0 8px 0 0;
  vertical-align: middle;
}
.check-label {
  display: flex; align-items: flex-start;
  font-weight: 400; color: var(--text);
  margin: 8px 0;
  cursor: pointer;
}
.full { width: 100%; }

/* Флекс/грид-дети не должны распирать сетку длинным контентом (фикс overflow на 390px) */
.grid2 > * { min-width: 0; }
.check-label { min-width: 0; }
.list-box label { overflow-wrap: anywhere; }

/* Поля внутри табличных форм (загрузка версий и т.п.) — не шире своей ячейки */
td input:not([type="checkbox"]), td select, td textarea { width: 100%; max-width: 100%; }

/* ---------- Кнопки (тач-таргеты ≥44px) ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  margin: 6px 4px 6px 0;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.btn:hover { background: var(--accent-dark); }
.btn.sm { min-height: 38px; padding: 0 14px; font-size: .9em; }
.btn.secondary { background: #eef2ff; color: var(--accent); }
.btn.secondary:hover { background: #e0e7ff; }
.btn.danger { background: var(--danger); }

/* ---------- Таблицы: скролл на мобильных ---------- */
.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
}
table { border-collapse: collapse; width: 100%; min-width: 560px; }
th, td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  font-size: .95em;
}
th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: .85em; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }

/* ---------- Прочее ---------- */
.badge {
  background: #eff6ff;
  color: var(--accent-dark);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: .82em;
  display: inline-block;
  margin: 1px 0;
}
.badge.warn { background: #fef3c7; color: #92400e; }
.error { color: var(--danger); font-weight: 600; }
.muted { color: var(--muted); font-size: .88em; }
.hint { color: var(--muted); font-size: .88em; margin-top: 6px; }
code {
  background: #f1f5f9;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: .9em;
  word-break: break-all;
}
.list-box {
  max-height: 260px; overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 6px;
  background: #f8fafc;
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.frame-pdf { width: 100%; height: 80vh; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.viewer-frame { width: 100%; height: 100%; border: 0; }
.center-page { max-width: 420px; margin: 60px auto; }
