/* ─────────────────────────────────────────────────
   TOKENS
───────────────────────────────────────────────── */
:root {
  --bg:              #f0f4f9;
  --surface:         #ffffff;
  --surface-soft:    #f7fafd;
  --surface-offset:  #eef2f7;

  --text:            #1a2236;
  --muted:           #64748b;
  --faint:           #a0aec0;

  --border:          #e2e8f0;
  --border-soft:     #edf2f7;

  --primary:         #0f766e;
  --primary-hover:   #0b5f59;
  --primary-active:  #094f49;
  --primary-bg:      #e6f7f5;
  --primary-ring:    rgba(15, 118, 110, 0.18);

  --danger:          #c0392b;
  --danger-bg:       #fff0ee;
  --danger-hover:    #a93226;

  --success-bg:      #eaf7ee;
  --success-text:    #166534;
  --success-border:  #bbf7d0;

  --error-bg:        #fff1f2;
  --error-text:      #be123c;
  --error-border:    #fecdd3;

  --shadow-sm:       0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md:       0 4px 16px rgba(15,23,42,.08), 0 2px 6px rgba(15,23,42,.05);
  --shadow-lg:       0 12px 36px rgba(15,23,42,.11), 0 4px 12px rgba(15,23,42,.06);

  --radius-sm:       10px;
  --radius-md:       14px;
  --radius-lg:       18px;
  --radius-xl:       24px;
  --radius-full:     9999px;

  --font: 'Inter', system-ui, sans-serif;

  --topbar-h: 64px;
}

/* ─────────────────────────────────────────────────
   RESET & BASE
───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
    display: flex;
  flex-direction: column;
}
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
input, select, textarea, button { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

/* ─────────────────────────────────────────────────
   TOPBAR
───────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary) 0%, #38b2ac 100%);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.brand-sub {
  font-weight: 400;
  color: var(--muted);
}

.topbar-nav {
  display: flex;
  gap: 4px;
  margin-left: 16px;
  flex: 1;
}

.nav-link {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  transition: background .15s, color .15s;
}

.nav-link:hover {
  background: var(--surface-offset);
  color: var(--text);
}

.nav-link.active {
  background: var(--primary-bg);
  color: var(--primary);
  font-weight: 600;
}

/* ─────────────────────────────────────────────────
   LAYOUT
───────────────────────────────────────────────── */
.wrapper {
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  width: 100%;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-head h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.5px;
  line-height: 1.2;
}

.page-head .muted {
  margin-top: 4px;
  font-size: 14px;
  color: var(--muted);
}

/* ─────────────────────────────────────────────────
   CARDS
───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 28px;
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.card-sub {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 24px;
}

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  width: 100%;
}

/* ─────────────────────────────────────────────────
   FILTERS BAR
───────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-search {
  position: relative;
  flex: 1;
  min-width: 240px;
  display: flex;
  align-items: center;
}

.filter-search > svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  pointer-events: none;
  flex-shrink: 0;
}

.filter-search > input {
  width: 100%;
  padding: 11px 14px 11px 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}

.filter-search > input:focus {
  outline: none;
  border-color: #8bc6c1;
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.filters-bar select {
  padding: 11px 36px 11px 14px; /* ← справа 36px под стрелку */
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 14px;
  cursor: pointer;
  min-width: 180px;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  -webkit-appearance: none;
  /* своя стрелка вместо браузерной */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.filters-bar select:focus {
  outline: none;
  border-color: #8bc6c1;
  box-shadow: 0 0 0 3px var(--primary-ring);
}

/* ─────────────────────────────────────────────────
   TABLE
───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
  font-size: 14px;
}

thead th {
  padding: 13px 16px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  background: var(--surface-soft);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  transition: background .12s;
}

tbody tr:hover {
  background: var(--surface-soft);
}

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

.td-long {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}



.nowrap { white-space: nowrap; }

.muted { color: var(--muted); }

/* ─────────────────────────────────────────────────
   BADGES
───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-logo   { background: #e0f2fe; color: #0369a1; }
.badge-psych  { background: #f3e8ff; color: #7e22ce; }
.badge-defect { background: #fef9c3; color: #854d0e; }
.badge-social { background: #dcfce7; color: #166534; }
.badge-default{ background: var(--surface-offset); color: var(--muted); }

/* ─────────────────────────────────────────────────
   FILE LINK
───────────────────────────────────────────────── */
.file-link {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  color: var(--primary);
  font-weight: 500;
  font-size: 13px;
  transition: color .15s;
}

.file-link:hover { color: var(--primary-hover); text-decoration: underline; }

.file-size {
  font-size: 11px;
  font-weight: 400;
  color: var(--faint);
}

/* ─────────────────────────────────────────────────
   ACTION BUTTONS
───────────────────────────────────────────────── */
.td-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.action-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  transition: background .15s, color .15s;
  color: var(--muted);
  flex-shrink: 0;
}

.action-btn.edit:hover  { background: var(--primary-bg);  color: var(--primary); }
.action-btn.delete:hover{ background: var(--danger-bg);   color: var(--danger);  }

/* ─────────────────────────────────────────────────
   BUTTONS
───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  transition: background .15s, box-shadow .15s, color .15s;
  white-space: nowrap;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 14px rgba(15,118,110,.28);
}
.btn-primary:active { background: var(--primary-active); }

.btn-light {
  background: var(--primary-bg);
  color: var(--primary);
  border-color: transparent;
}
.btn-light:hover { background: #cdeae7; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-offset); color: var(--text); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: transparent;
}
.btn-danger:hover { background: #fdd; }

.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-full { width: 100%; }

/* ─────────────────────────────────────────────────
   FORMS
───────────────────────────────────────────────── */
.form-grid { display: grid; gap: 20px; }

.form-row { display: grid; gap: 7px; }

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.field-hint {
  font-size: 12px;
  color: var(--faint);
  margin-top: 4px;
}

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 14px;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #8bc6c1;
  box-shadow: 0 0 0 3px var(--primary-ring);
}

input::placeholder, textarea::placeholder { color: var(--faint); }

.input-eye {
  position: relative;
}

.input-eye input { padding-right: 44px; }

.eye-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--faint);
  display: grid;
  place-items: center;
  padding: 4px;
  border-radius: 6px;
  transition: color .15s;
}
.eye-btn:hover { color: var(--muted); }

/* Загрузка файла */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
}

.file-drop:hover, .file-drop.dragover {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.file-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.file-drop-icon { color: var(--faint); margin: 0 auto 10px; }
.file-drop-label { font-size: 14px; font-weight: 600; color: var(--text); }
.file-drop-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.file-drop-chosen { font-size: 13px; color: var(--primary); font-weight: 600; margin-top: 8px; }

/* ─────────────────────────────────────────────────
   MESSAGES
───────────────────────────────────────────────── */
.message {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
  border: 1px solid transparent;
}

.message.success {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-border);
}

.message.error {
  background: var(--error-bg);
  color: var(--error-text);
  border-color: var(--error-border);
}

/* ─────────────────────────────────────────────────
   EMPTY STATE
───────────────────────────────────────────────── */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
}

.empty p { font-size: 15px; }

/* ─────────────────────────────────────────────────
   PAGINATION
───────────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 20px;
  border-top: 1px solid var(--border-soft);
}

.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: background .15s, color .15s, border-color .15s;
}

.page-btn:hover { background: var(--surface-offset); color: var(--text); }
.page-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 700;
}

/* ─────────────────────────────────────────────────
   AUTH PAGE
───────────────────────────────────────────────── */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #eaf5f4 0%, #f0f4f9 60%, #f7f0fb 100%);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 36px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.auth-brand-text h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.3px;
}

.auth-brand-text p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

/* ─────────────────────────────────────────────────
   FOOTER
───────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  text-align: center;
  font-size: 13px;
  color: var(--faint);
  background: var(--surface);
  margin-top: 40px;
}

/* ─────────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .wrapper { padding: 20px 16px 48px; }
  .topbar-nav { display: none; }
  .page-head { flex-direction: column; }
  .form-row-2 { grid-template-columns: 1fr; }
  .filters-bar { flex-direction: column; }
  .filter-search { min-width: unset; width: 100%; }
  .filters-bar select { width: 100%; }
  table { min-width: 700px; }
}

/* ─── ADD PAGE ──────────────────────────────────── */
.add-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

.add-hint-card { position: sticky; top: calc(var(--topbar-h) + 20px); }

.hint-list {
  list-style: none;
  display: grid;
  gap: 14px;
}

.hint-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.hint-list li svg { color: var(--primary); flex-shrink: 0; margin-top: 2px; }

.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.input-error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(192, 57, 43, .12) !important;
}

.file-drop-error { border-color: var(--danger); }

.field-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 2px;
}

@media (max-width: 900px) {
  .add-layout { grid-template-columns: 1fr; }
  .add-hint-card { position: static; }
}

/* ─── STICKY FOOTER ─────────────────────────────── */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.wrapper {
  flex: 1; /* занимает всё свободное пространство */
}
a {
  text-decoration: none;
}

.filter-search > input[type="text"] {
  padding-left: 38px !important;
}

/* ─── HINT CARD ─────────────────────────────────── */
.hint-card {
  position: sticky;
  top: calc(var(--topbar-h) + 20px);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

.hint-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.hint-items {
  background: var(--surface);
  display: grid;
  gap: 0;
}

.hint-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
}

.hint-item:last-child {
  border-bottom: none;
}

.hint-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.hint-item strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 2px;
}

.hint-item p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  max-width: none;
}

@media (max-width: 900px) {
  .hint-card { position: static; }
}

/* ─── REGION SEARCH ─────────────────────────────── */
.region-wrap {
  position: relative;
}

.region-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 260px;
  overflow-y: auto;
  z-index: 100;
  list-style: none;
  margin: 0;
  padding: 4px 0;
}

.region-item {
  padding: 9px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background .12s;
  line-height: 1.4;
}

.region-item:hover {
  background: var(--primary-bg);
  color: var(--primary);
}

.region-empty {
  color: var(--faint);
  cursor: default;
  font-style: italic;
}

.region-dropdown::-webkit-scrollbar {
  width: 6px;
}
.region-dropdown::-webkit-scrollbar-track {
  background: var(--surface-soft);
}
.region-dropdown::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

.action-btn.view:hover {
  background: #e0f2fe;
  color: #0369a1;
}

/* ─── VIEW PAGE ─────────────────────────────────── */
.view-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}

.view-fields {
  display: grid;
  gap: 0;
}

.view-field {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-soft);
  align-items: start;
}

.view-field:last-child {
  border-bottom: none;
}

.view-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding-top: 1px;
}

.view-value {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}

.file-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.file-preview-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
}

.file-preview-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.file-preview-info strong {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-preview-info span {
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 768px) {
  .view-layout { grid-template-columns: 1fr; }
  .view-field { grid-template-columns: 1fr; gap: 4px; }
}

/* ─── EDIT PAGE ─────────────────────────────────── */
.current-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.current-file svg {
  color: var(--primary);
  flex-shrink: 0;
}

.hint-optional {
  font-weight: 400;
  color: var(--faint);
  font-size: 12px;
}
.table-sub {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.btn-cert {
  background: #fef9c3;
  color: #92400e;
  border: 1px solid #fde68a;
}

.btn-cert:hover {
  background: #fde68a;
  color: #78350f;
}

.badge-success {
    background: #e6f4ea;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
}

.page-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

@media (max-width: 520px) {
  .page-head-actions {
    width: 100%;
  }

  .page-head-actions .btn {
    flex: 1;
  }
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  margin-bottom: 24px;
}

.page-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 10px;
  margin-left: auto;
  white-space: nowrap;
}

.filters-bar {
  display: flex;
  clear: both;
  width: 100%;
  margin-bottom: 16px;
}

.filter-search {
  flex: 1 1 420px;
  min-width: 260px;
}