:root {
  --accent-dark: #1c2b39;
  --blue: #2f8fd1;
  --blue-dark: #2378b5;
  --green: #4caf50;
  --green-dark: #3f9a43;
  --text: #2b333a;
  --muted: #6b7680;
  --border: #e2e6ea;
  --alert-bg: #fdf6e3;
  --alert-border: #f0e0b0;
  --alert-text: #8a6d3b;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  color: var(--text);
  background: #ffffff;
}

a {
  color: inherit;
  text-decoration: none;
}

.header {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  padding: 0 32px;
  min-height: 58px;
  border-bottom: 1px solid var(--border);
}

.header__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}

.header__logo img {
  display: block;
}

.header__nav {
  display: flex;
  align-items: stretch;
  gap: 0;
  font-size: 15px;
}

.header__nav > a {
  display: flex;
  align-items: center;
  padding: 0 22px;
  color: var(--text);
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}

.header__nav > a:hover {
  background: var(--blue);
  color: #fff;
}

.lang-select {
  position: relative;
  display: flex;
  align-items: stretch;
}

.lang-select__btn {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
  background: #eef4fa;
  color: var(--blue-dark);
  padding: 0 20px;
  border-radius: 0;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-size: 14px;
  transition: background 0.15s ease, color 0.15s ease;
}

.lang-select__btn:hover {
  background: var(--blue);
  color: #fff;
}

.lang-select__menu {
  display: none;
  position: absolute;
  top: 110%;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
  min-width: 90px;
  overflow: hidden;
  z-index: 10;
}

.lang-select__menu.open {
  display: block;
}

.lang-select__menu a {
  display: block;
  padding: 8px 12px;
  font-size: 14px;
}

.lang-select__menu a:hover {
  background: #f2f6fa;
}

.lang-select__menu a.is-active {
  color: var(--blue-dark);
  font-weight: 700;
}

.header__nav > a.btn-login {
  font-weight: 600;
  color: var(--blue-dark);
}

.header__nav > a.btn-login:hover {
  color: #fff;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 32px 80px;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: start;
}

.alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--alert-bg);
  border: 1px solid var(--alert-border);
  color: var(--alert-text);
  border-radius: 8px;
  padding: 16px 18px;
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 28px;
  position: relative;
}

.alert__icon {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.alert a {
  color: var(--alert-text);
  text-decoration: underline;
  font-weight: 600;
}

.alert__close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: #b7a678;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}

.alert__close:hover {
  color: var(--alert-text);
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 16px;
}

.pin-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  max-width: 340px;
  box-shadow: 0 2px 6px rgba(20, 30, 40, 0.04);
}

.pin-card label {
  display: block;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 8px;
}

.pin-card input[type="text"],
.pin-card input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
  margin-bottom: 16px;
  letter-spacing: 2px;
}

.pin-card input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 143, 209, 0.15);
}

.btn-open {
  width: 100%;
  background: var(--green);
  color: #fff;
  border: none;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-open:hover {
  background: var(--green-dark);
}

.pin-error {
  display: none;
  color: #c0392b;
  font-size: 13px;
  margin: -8px 0 14px;
}

.pin-hint {
  display: inline-block;
  margin-top: 18px;
  font-size: 14px;
  color: var(--blue-dark);
  text-decoration: underline;
}

.qr-block {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 22px;
  max-width: 340px;
}

.qr-block__img {
  width: 88px;
  height: 88px;
  flex: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  background: #fff;
}

.qr-block__caption {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.doc-preview {
  position: relative;
  display: flex;
  justify-content: center;
}

.doc-preview img {
  width: 100%;
  max-width: 420px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(20, 30, 40, 0.12);
}

.watermark {
  position: absolute;
  right: -10px;
  bottom: -30px;
  opacity: 0.9;
  pointer-events: none;
}

/* --- Состояния страницы просмотра документа (view.html) --- */

.pin-card.is-hidden {
  display: none;
}

.doc-status {
  display: none;
  align-items: center;
  gap: 10px;
  background: #eaf7ec;
  border: 1px solid #bfe6c6;
  color: #2f7a37;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
}

.doc-status.show {
  display: flex;
}

.doc-preview img.is-locked {
  filter: blur(14px);
}

.doc-preview img.is-hidden {
  display: none;
}

.pdf-result {
  display: none;
  width: 100%;
  max-width: 420px;
}

.pdf-result.show {
  display: block;
}

.pdf-frame {
  width: 100%;
  height: 520px;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(20, 30, 40, 0.12);
  background: #f4f6f8;
}

.pdf-download {
  display: block;
  text-align: center;
  text-decoration: none;
  margin-top: 12px;
}

.state-message {
  max-width: 340px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
}

/* --- Админка --- */

.admin-shell {
  max-width: 480px;
  margin: 60px auto;
  padding: 0 20px;
}

.admin-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
  box-shadow: 0 2px 6px rgba(20, 30, 40, 0.04);
}

.admin-card h1 {
  font-size: 20px;
  margin: 0 0 6px;
}

.admin-card p.admin-sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 20px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
}

.field .field-row {
  display: flex;
  gap: 8px;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
}

.field input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 143, 209, 0.15);
}

.btn-secondary {
  flex: none;
  background: #eef4fa;
  color: var(--blue-dark);
  border: none;
  border-radius: 6px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-secondary:hover {
  background: #e0ecf6;
}

.qr-download {
  display: inline-flex;
  align-items: center;
  height: 32px;
  text-decoration: none;
}

.btn-primary {
  width: 100%;
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--blue-dark);
}

.form-error {
  display: none;
  color: #c0392b;
  font-size: 13px;
  margin: -8px 0 14px;
}

.form-note {
  display: none;
  color: #2f7a37;
  background: #eaf7ec;
  border: 1px solid #bfe6c6;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  border-bottom: 1px solid var(--border);
}

.admin-topbar .header__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.btn-logout:hover {
  color: var(--text);
  border-color: var(--muted);
}

.admin-main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 32px 32px 80px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 32px;
  align-items: start;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 18px;
  text-align: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  position: relative;
}

.dropzone.has-file {
  border-color: var(--blue);
  color: var(--blue-dark);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone img.preview {
  max-width: 100%;
  max-height: 160px;
  border-radius: 6px;
  margin-bottom: 8px;
  display: none;
}

.link-result {
  display: none;
  background: #eef4fa;
  border: 1px solid #cfe2f2;
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 16px;
  font-size: 13px;
}

.link-result.show {
  display: block;
}

.link-result .link-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.link-result input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  font-size: 13px;
}

.records-table th,
.records-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.records-table th {
  background: #f7f9fb;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.records-table tr:last-child td {
  border-bottom: none;
}

.records-table td.mono {
  font-family: "Consolas", monospace;
}

.records-table .row-actions {
  display: flex;
  gap: 8px;
}

.records-table .row-actions a,
.records-table .row-actions button {
  font-size: 12px;
  font-weight: 600;
  color: var(--blue-dark);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.records-table .row-actions .danger {
  color: #c0392b;
}

.empty-state {
  color: var(--muted);
  font-size: 13px;
  padding: 20px;
  text-align: center;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .doc-preview {
    order: -1;
  }

  .header {
    padding: 0 18px;
  }

  .header__nav > a,
  .lang-select__btn {
    padding: 0 14px;
  }

  .container {
    padding: 28px 18px 60px;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .admin-topbar,
  .admin-main {
    padding-left: 18px;
    padding-right: 18px;
  }
}
