@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* Палитра подобрана через ui-ux-pro-max (стиль "Data-Dense Dashboard" +
   цвета "Financial/RPA Dashboard": slate-фон, статусные цвета зелёный/
   жёлтый/красный как в индустрии; акцент — фирменный фиолетовый, чтобы
   не терять узнаваемость десктопной версии). */
:root {
  --bg: #020617;
  --content-bg: #020617;
  --sidebar-bg-1: #140f22;
  --sidebar-bg-2: #05050c;
  --card: #0e1223;
  --card-hover: #131730;
  --accent: #7c6cf6;
  --accent-2: #a78bfa;
  --accent-soft: #1d1833;
  --text1: #f1f5f9;
  --text2: #94a3b8;
  --text3: #64748b;
  --border: #33415580;
  --border-strong: #334155;
  --green: #4ade80;
  --green-bg: #0f2e1e;
  --red: #f87171;
  --red-bg: #3a1616;
  --yellow: #f5b942;
  --yellow-bg: #3a2e0c;
  --blue: #60a5fa;
  --blue-bg: #10233e;
  --radius: 14px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--content-bg);
  color: var(--text1);
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

a { color: var(--accent); text-decoration: none; }

/* ── Layout: sidebar + content ─────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--sidebar-bg-1), var(--sidebar-bg-2));
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
}

.sidebar-brand-row { display: flex; align-items: center; justify-content: space-between; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 26px; }
.nav-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 36px; height: 36px; flex-shrink: 0;
  background: transparent; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--text2); cursor: pointer;
}
.nav-toggle svg { width: 18px; height: 18px; }
.nav-toggle:hover { color: var(--text1); border-color: var(--accent); }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(124,108,246,.35);
}
.brand-mark svg { width: 17px; height: 17px; color: #fff; }
.brand-title { font-weight: 700; font-size: 14.5px; color: var(--text1); letter-spacing: -0.01em; }
.brand-sub { font-size: 11.5px; color: var(--text3); margin-top: 1px; }

.nav-links { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text2); font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent;
  transition: background .15s, color .15s;
}
.nav-icon { display: flex; width: 18px; height: 18px; flex-shrink: 0; }
.nav-icon svg { width: 100%; height: 100%; }
.nav-link:hover { color: var(--text1); background: rgba(255,255,255,.03); }
.nav-link.active {
  color: #fff; background: var(--accent-soft);
  border-color: rgba(124,108,246,.35);
}

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 600; color: var(--text1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text3); }
.icon-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text2);
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  flex-shrink: 0;
}
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover { color: var(--red); border-color: var(--red); }

.page {
  flex: 1;
  min-width: 0;
  max-width: 1180px;
  padding: 34px 40px 60px;
}

.page-head { margin-bottom: 22px; }
h1 { font-size: 21px; margin: 0 0 4px; letter-spacing: -0.015em; font-weight: 700; }
.page-sub { color: var(--text2); font-size: 13.5px; margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
}

h2 { font-size: 15px; margin: 0 0 16px; color: var(--text1); font-weight: 600; }

label { display: block; margin-bottom: 6px; color: var(--text2); font-size: 12.5px; font-weight: 500; }

input[type=text], input[type=password], input[type=tel], select {
  width: 100%;
  padding: 10px 13px;
  background: #1a1a26;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text1);
  font-size: 13.5px;
  margin-bottom: 14px;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--text3); }
input:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,108,246,.18);
}

.search-box { position: relative; }
.search-box-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--text3); pointer-events: none;
}
.search-box-icon svg { width: 100%; height: 100%; }
.search-box input[type=text] {
  padding-left: 42px; margin-bottom: 0; font-size: 14.5px; padding-top: 12px; padding-bottom: 12px;
}

.btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  box-shadow: 0 2px 10px rgba(124,108,246,.25);
  transition: filter .15s, transform .1s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; box-shadow: none; filter: none; }
.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
}
.btn-ghost:hover { color: var(--text1); border-color: var(--accent); }
.btn-danger { background: linear-gradient(135deg, #d9706f, #c85a5a); box-shadow: none; }
.btn-small { padding: 5px 11px; font-size: 12px; border-radius: 7px; }

.tabs {
  display: flex; gap: 3px; margin-bottom: 20px;
  background: #1a1a26; border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 3px;
}
.tab {
  flex: 1; text-align: center;
  padding: 8px 10px; border-radius: 8px;
  cursor: pointer; color: var(--text2); font-size: 13px; font-weight: 500;
  transition: background .15s, color .15s;
}
.tab.active { background: var(--accent); color: #fff; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 9px 10px; color: var(--text3);
  font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border-strong);
  position: sticky; top: 0; background: var(--card);
}
td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text1); }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.03); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-exact { background: var(--green-bg); color: var(--green); }
.badge-substr, .badge-art_in_name { background: var(--blue-bg); color: var(--blue); }
.badge-block_draw, .badge-block_fact { background: var(--blue-bg); color: var(--blue); }
.badge-name { background: var(--yellow-bg); color: var(--yellow); }
.badge-none { background: var(--red-bg); color: var(--red); }
.badge-admin { background: var(--accent-soft); color: var(--accent-2); }

.error {
  background: var(--red-bg); color: var(--red);
  padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13px;
  border: 1px solid rgba(239,138,138,.25);
}
.success {
  background: var(--green-bg); color: var(--green);
  padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13px;
  border: 1px solid rgba(88,201,138,.25);
}
.hint { color: var(--text3); font-size: 12px; margin-top: -8px; margin-bottom: 14px; }

.stats { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; min-width: 130px; flex: 1;
  border-top: 2px solid var(--border-strong);
}
.stat.stat-total { border-top-color: var(--accent); }
.stat.stat-exact { border-top-color: var(--green); }
.stat.stat-found { border-top-color: var(--blue); }
.stat.stat-none { border-top-color: var(--red); }
.stat .num { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.stat .lbl { color: var(--text2); font-size: 12px; margin-top: 2px; }

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 36px 20px;
  text-align: center;
  color: var(--text2);
  cursor: pointer;
  margin-bottom: 16px;
  transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--accent); background: rgba(124,108,246,.04); color: var(--text1); }
.dropzone .dz-icon { width: 30px; height: 30px; margin: 0 auto 10px; color: var(--accent-2); }
.dropzone .dz-icon svg { width: 100%; height: 100%; }

.center-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 15%, rgba(124,108,246,.14), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(167,139,250,.10), transparent 40%),
    var(--bg);
}
.login-box { width: 380px; }
.login-box .card { padding: 30px; }
.login-title { text-align: center; margin-bottom: 24px; }
.login-logo {
  width: 46px; height: 46px; border-radius: 13px; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(124,108,246,.35);
}
.login-logo svg { width: 25px; height: 25px; color: #fff; }
.login-title .big { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.login-title .small { color: var(--text2); font-size: 12.5px; margin-top: 4px; }

.switch { position: relative; width: 36px; height: 20px; display: inline-block; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #26263a; border-radius: 20px; cursor: pointer; transition: .2s; }
.slider:before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: white; border-radius: 50%; transition: .2s; }
input:checked + .slider { background: var(--accent); }
input:checked + .slider:before { transform: translateX(16px); }

/* ── Responsive: на узких экранах сайдбар — компактная панель сверху
   с кнопкой-гамбургером, раскрывающей меню, а не сжатая в одну строку ──── */
@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%; min-height: auto; position: sticky; top: 0; z-index: 40;
    flex-direction: column; align-items: stretch; padding: 10px 16px;
  }
  .sidebar-brand-row { width: 100%; }
  .sidebar-brand { padding: 4px 0; }
  .nav-toggle { display: flex; }

  .nav-links {
    display: none; flex-direction: column; width: 100%;
    margin-top: 10px; gap: 2px;
  }
  .sidebar-user {
    display: none; width: 100%;
    margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--border);
  }
  .sidebar.nav-open .nav-links { display: flex; }
  .sidebar.nav-open .sidebar-user { display: flex; }
  .sidebar.nav-open .user-info { display: block; }

  .nav-link { padding: 11px 12px; font-size: 14.5px; }

  .page { padding: 20px 16px 40px; }

  /* iOS Safari зумит страницу при фокусе на input с font-size < 16px — держим 16px */
  input[type=text], input[type=password], input[type=tel], select {
    font-size: 16px;
  }
  .search-box input[type=text] { font-size: 16px; }

  .login-box { width: 100%; max-width: 380px; }
  .center-login { padding: 20px; }

  .stat { min-width: 140px; }
}

@media (max-width: 420px) {
  .page { padding: 16px 12px 32px; }
  .card { padding: 16px; }
  .stats { gap: 10px; }
  .stat { min-width: calc(50% - 5px); padding: 14px 16px; }
}
