/* Aurora — design system: light + dark, adaptive layout */
:root {
  --bg: #ffffff;
  --card: #f8fafc;
  --card-hover: #f1f5f9;
  --border: #e5e7eb;
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-rgb: 37, 99, 235;

  --green: #16a34a;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --yellow: #ca8a04;
  --yellow-soft: #fef9c3;

  --proto-socks5: #7c3aed;
  --proto-socks5-soft: #ede9fe;
  --proto-http: #2563eb;
  --proto-http-soft: #dbeafe;
  --proto-https: #16a34a;
  --proto-https-soft: #dcfce7;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.16);

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --ease: 220ms cubic-bezier(0.4, 0, 0.2, 1);
  --radius: 14px;
  --radius-sm: 9px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
  :root:not([data-theme="light"]) {
    --bg: #0a0d13;
    --card: #12161f;
    --card-hover: #1a1f2b;
    --border: #232a37;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --muted-2: #5b6675;

    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-soft: rgba(59, 130, 246, 0.16);
    --accent-rgb: 59, 130, 246;

    --green: #22c55e;
    --green-soft: rgba(34, 197, 94, 0.16);
    --red: #f87171;
    --red-soft: rgba(248, 113, 113, 0.16);
    --yellow: #facc15;
    --yellow-soft: rgba(250, 204, 21, 0.16);

    --proto-socks5: #a78bfa;
    --proto-socks5-soft: rgba(167, 139, 250, 0.16);
    --proto-http: #60a5fa;
    --proto-http-soft: rgba(96, 165, 250, 0.16);
    --proto-https: #4ade80;
    --proto-https-soft: rgba(74, 222, 128, 0.16);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0d13;
  --card: #12161f;
  --card-hover: #1a1f2b;
  --border: #232a37;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --muted-2: #5b6675;

  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: rgba(59, 130, 246, 0.16);
  --accent-rgb: 59, 130, 246;

  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.16);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.16);
  --yellow: #facc15;
  --yellow-soft: rgba(250, 204, 21, 0.16);

  --proto-socks5: #a78bfa;
  --proto-socks5-soft: rgba(167, 139, 250, 0.16);
  --proto-http: #60a5fa;
  --proto-http-soft: rgba(96, 165, 250, 0.16);
  --proto-https: #4ade80;
  --proto-https-soft: rgba(74, 222, 128, 0.16);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-sans);
  padding: 24px;
  -webkit-font-smoothing: antialiased;
  animation: pageFadeIn 320ms ease;
  transition: background var(--ease), color var(--ease);
  max-width: 1400px;
  margin-left: auto; margin-right: auto;
}
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: -0.015em; }
h2 { font-size: 12px; color: var(--muted); margin: 0 0 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }

a { color: var(--accent); }

.mono { font-family: var(--font-mono); }
.icon { width: 15px; height: 15px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.icon-sm { width: 13px; height: 13px; vertical-align: -2px; }

/* ---------------- Header ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: conic-gradient(from 200deg, #4f46e5, #06b6d4, #a855f7, #4f46e5);
  box-shadow: 0 2px 10px rgba(79, 70, 229, 0.4);
}
.brand-name { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }

.nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav-tabs { display: flex; gap: 2px; background: var(--card); border: 1px solid var(--border); border-radius: 11px; padding: 3px; max-width: 100%; overflow-x: auto; }
.nav-link {
  color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600;
  padding: 7px 14px; border-radius: 8px; transition: background var(--ease), color var(--ease);
  white-space: nowrap;
}
.nav-link:hover { color: var(--text); background: var(--card-hover); }
.nav-link.active { background: var(--accent); color: #fff; }
.nav-user { color: var(--muted); font-size: 13px; margin-left: 4px; }

.theme-toggle {
  background: var(--card); color: var(--muted); border: 1px solid var(--border);
  border-radius: 9px; width: 34px; height: 34px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background var(--ease), color var(--ease), border-color var(--ease), transform var(--ease);
}
.theme-toggle:hover { background: var(--card-hover); color: var(--text); }
.theme-toggle:active { transform: scale(0.92); }
.theme-toggle .icon { width: 17px; height: 17px; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: inline-block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: inline-block; }
}

/* ---------------- Cards & layout ---------------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--ease), border-color var(--ease), background var(--ease);
}
.card:hover { box-shadow: var(--shadow-md); }

textarea {
  width: 100%; min-height: 110px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px;
  font-family: var(--font-mono); font-size: 13px; resize: vertical;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease), color var(--ease);
}
textarea:focus, input:focus, select:focus, button:focus-visible {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 10px; }

button {
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm);
  padding: 9px 16px; font-weight: 600; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  transition: background var(--ease), transform 120ms ease, box-shadow var(--ease), opacity var(--ease);
  box-shadow: 0 1px 2px rgba(var(--accent-rgb), 0.25);
}
button:hover { background: var(--accent-hover); }
button:active { transform: scale(0.96); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
button.secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
button.secondary:hover { background: var(--card-hover); border-color: var(--muted-2); }
button.small { padding: 6px 11px; font-size: 12px; }
button.danger { background: var(--bg); color: var(--red); border: 1px solid var(--red-soft); box-shadow: none; }
button.danger:hover { background: var(--red-soft); }

input[type=file] { color: var(--muted); font-size: 13px; }
input[type=text], input[type=password], input[type=date], select {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease), color var(--ease);
}

.scroll-x { overflow-x: auto; }
.summary { color: var(--muted); font-size: 13px; margin-top: 8px; }
.muted { color: var(--muted); }

.tabs { display: flex; gap: 8px; margin-bottom: 10px; }
.tab {
  padding: 6px 14px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--border);
  cursor: pointer; font-size: 13px; font-weight: 500; color: var(--muted);
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.panel { display: none; }
.panel.active { display: block; }

/* ---------------- Login ---------------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-card { width: 340px; text-align: center; }
.login-logo { display: flex; justify-content: center; margin-bottom: 6px; }
.login-logo .logo { width: 44px; height: 44px; border-radius: 14px; }
.login-form { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; text-align: left; }
.login-form label { font-size: 12px; color: var(--muted); font-weight: 600; }
.login-form input { padding: 10px; }
.login-form button { margin-top: 10px; justify-content: center; }
.login-error { color: var(--red); font-size: 13px; margin-top: 10px; }

/* ---------------- Сводка (кликабельные карточки) ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: left; cursor: pointer; position: relative;
  transition: transform var(--ease), border-color var(--ease), box-shadow var(--ease), background var(--ease);
}
.stat-card:hover { border-color: var(--muted-2); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card.active { border-color: var(--accent); background: var(--accent-soft); }
.stat-card .num { font-size: 27px; font-weight: 700; line-height: 1.1; transition: color var(--ease); letter-spacing: -0.02em; }
.stat-card .label { color: var(--muted); font-size: 12px; margin-top: 6px; font-weight: 600; }
.stat-card.stat-alive .num { color: var(--green); }
.stat-card.stat-dead .num { color: var(--red); }
.stat-card.stat-expiring .num { color: var(--yellow); }
.filter-active-bar {
  display: none; align-items: center; gap: 10px; margin-bottom: 12px;
  font-size: 13px; color: var(--muted);
}
.filter-active-bar.visible { display: flex; }
.filter-active-bar .chip {
  background: var(--accent-soft); color: var(--accent); padding: 4px 10px;
  border-radius: 999px; font-weight: 600; font-size: 12px;
}

/* ---------------- Таблица ---------------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th {
  color: var(--muted); font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em;
  position: sticky; top: 0; background: var(--card); cursor: pointer; user-select: none;
}
th:hover { color: var(--text); }
tbody tr { transition: background var(--ease); }
tbody tr:nth-child(even) { background: var(--card); }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--card) 40%, transparent); }
tbody tr:hover { background: var(--card-hover); }

.status-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  transition: background-color 300ms ease, box-shadow 300ms ease;
}
.status-dot.alive { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.status-dot.dead { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.status-dot.unknown { background: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-soft); }

/* При смене статуса (жив ⇄ мёртв) — плавная вспышка вместо резкого скачка */
.status-dot.changed { animation: statusPulse 700ms ease; }
@keyframes statusPulse {
  0% { opacity: 0.15; transform: scale(0.6); }
  40% { opacity: 1; transform: scale(1.4); }
  100% { opacity: 1; transform: scale(1); }
}

.days-warn { color: var(--yellow); font-weight: 600; }
.days-crit { color: var(--red); font-weight: 600; }

.pw-cell { cursor: pointer; color: var(--muted); }
.del-btn {
  background: transparent; color: var(--muted); border: none; padding: 5px 7px;
  border-radius: 7px; cursor: pointer; transition: background var(--ease), color var(--ease), transform 120ms ease;
  display: inline-flex; align-items: center; justify-content: center;
}
.del-btn:hover { background: var(--card-hover); color: var(--text); }
.del-btn:active { transform: scale(0.9); }
.del-btn.del-btn-danger:hover { background: var(--red-soft); color: var(--red); }

.tag-pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px;
  margin-right: 4px; color: #fff; font-weight: 600;
}

.protocol-badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10.5px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
}
.protocol-badge.proto-socks5 { background: var(--proto-socks5-soft); color: var(--proto-socks5); }
.protocol-badge.proto-http { background: var(--proto-http-soft); color: var(--proto-http); }
.protocol-badge.proto-https { background: var(--proto-https-soft); color: var(--proto-https); }

/* ---------------- Фильтры/папки/теги ---------------- */
.folder-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.folder-tab {
  padding: 6px 13px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border);
  cursor: pointer; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.folder-tab:hover { border-color: var(--muted-2); color: var(--text); }
.folder-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.folder-tab .fdel { opacity: 0.55; }
.folder-tab .fdel:hover { opacity: 1; }

.filters-row { align-items: center; }
.search-input { min-width: 220px; flex: 1; }
.tag-filter { display: flex; gap: 6px; flex-wrap: wrap; }
.tag-chip {
  padding: 3px 10px; border-radius: 999px; font-size: 11px; cursor: pointer;
  border: 1px solid transparent; opacity: 0.65; transition: opacity var(--ease), border-color var(--ease);
}
.tag-chip.active { opacity: 1; border-color: currentColor; }
.checkbox-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }

/* ---------------- Массовые действия ---------------- */
.bulk-bar {
  background: var(--accent-soft); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  overflow: hidden; max-height: 0; opacity: 0; margin-top: 0; padding-top: 0; padding-bottom: 0; border-width: 0;
  transition: max-height var(--ease), opacity var(--ease), padding var(--ease), margin var(--ease), border-width var(--ease);
}
.bulk-bar.visible {
  max-height: 100px; opacity: 1; margin-top: 10px; padding-top: 10px; padding-bottom: 10px; border-width: 1px;
}
.export-group { display: flex; gap: 6px; align-items: center; margin-left: auto; flex-wrap: wrap; }
.export-all-row { align-items: center; }

/* ---------------- Инлайн-редактирование ---------------- */
.editable { cursor: pointer; border-bottom: 1px dashed var(--muted-2); transition: background var(--ease), box-shadow var(--ease); border-radius: 4px; position: relative; }
td.editable[data-field="name"], td.proxy-name { font-weight: 600; }
.editable:hover { color: var(--accent); background: var(--accent-soft); }
.editable:hover::after {
  content: "✎"; position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  font-size: 10px; opacity: 0.55;
}
.editable.editing { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); }
.editable input, .editable select { width: 100%; font-size: 13px; }

/* ---------------- Архив ---------------- */
.archive-banner { color: var(--muted); font-size: 13px; margin-bottom: 12px; }

/* ---------------- Переключение вкладок / появление контента ---------------- */
.fade-in { animation: fadeIn 250ms ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- Модальное окно ---------------- */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(10, 13, 19, 0.5);
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
  animation: fadeIn 180ms ease; backdrop-filter: blur(2px);
}
.modal-overlay.visible { display: flex; }
.modal-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 18px; padding: 22px; width: 460px; max-width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalPop 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalPop {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-title { font-size: 17px; font-weight: 700; margin: 0; }
.modal-close {
  background: transparent; border: none; color: var(--muted); font-size: 15px;
  cursor: pointer; padding: 5px 9px; border-radius: 7px; transition: background var(--ease), color var(--ease);
}
.modal-close:hover { background: var(--card-hover); color: var(--text); }
.form-row { display: flex; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.form-field { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 140px; }
.form-field label { font-size: 12px; font-weight: 600; color: var(--muted); }
.form-field input, .form-field select { width: 100%; }
.modal-test-result { font-size: 13px; min-height: 18px; margin: 2px 0 4px; }
.modal-test-result.ok { color: var(--green); font-weight: 600; }
.modal-test-result.fail { color: var(--red); font-weight: 600; }
.modal-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; flex-wrap: wrap; gap: 10px; }
.modal-footer-right { display: flex; gap: 8px; }

/* ---------------- Фрод-чекер ---------------- */
.fraud-score-row { display: flex; align-items: baseline; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.fraud-score { font-size: 40px; font-weight: 700; line-height: 1; }
.fraud-score.low { color: var(--green); }
.fraud-score.mid { color: var(--yellow); }
.fraud-score.high { color: var(--red); }
.fraud-score-label { color: var(--muted); font-size: 13px; }
.fraud-meta { color: var(--muted-2); font-size: 12px; margin-bottom: 14px; }
.fraud-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.fraud-field {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.fraud-field .fraud-field-label { color: var(--muted); font-size: 12px; }
.fraud-field .fraud-field-value { font-weight: 600; font-size: 13px; text-align: right; }
.fraud-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.fraud-badge.yes { background: var(--red-soft); color: var(--red); }
.fraud-badge.no { background: var(--green-soft); color: var(--green); }
.fraud-error { color: var(--red); font-size: 13px; }

/* ---------------- Пустые состояния ---------------- */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .icon { width: 32px; height: 32px; opacity: 0.4; margin-bottom: 10px; }
.empty-state .empty-title { font-weight: 600; color: var(--text); margin-bottom: 4px; font-size: 14px; }
.empty-state .empty-hint { font-size: 12.5px; }

/* ---------------- Мобильная адаптация ---------------- */
@media (max-width: 760px) {
  body { padding: 12px; }
  .topbar { gap: 8px; }
  .brand-name { font-size: 16px; }
  .nav { width: 100%; justify-content: space-between; }
  .nav-tabs { flex: 1; }
  .nav-link { padding: 7px 10px; font-size: 12px; }
  .card { padding: 13px; border-radius: 12px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-card .num { font-size: 22px; }
  .row { gap: 8px; }
  .export-group { margin-left: 0; width: 100%; }
  .modal-card { padding: 16px; border-radius: 14px; }
  .form-row { gap: 8px; }

  table.responsive-table thead { display: none; }
  table.responsive-table, table.responsive-table tbody, table.responsive-table tr, table.responsive-table td {
    display: block; width: 100%;
  }
  table.responsive-table tr {
    border: 1px solid var(--border); border-radius: 12px; margin-bottom: 10px; padding: 6px 10px;
    background: var(--card);
  }
  table.responsive-table td {
    border: none; padding: 7px 2px; white-space: normal;
    display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: right;
  }
  table.responsive-table td[data-label]::before {
    content: attr(data-label); text-align: left; font-weight: 700; color: var(--muted);
    font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; flex-shrink: 0;
  }
  table.responsive-table td:not([data-label]) { justify-content: flex-end; }
  table.responsive-table td.row-actions-cell { justify-content: flex-end; }
}
