/* Сквозуха admin UI · общая палитра + темы. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #0d1117;
  --text-muted: #6b7280;
  --accent: #3ea884;
  --accent-soft: #e6f5ee;
  --accent-strong: #2c8e6c;
  --warn: #d97757;
  --danger: #d33b3b;
  --link: #2c7adb;
  --chip: #eef0f3;
  --chip-text: #485162;
  --code-bg: #f1f3f6;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui,
          "Helvetica Neue", Arial, "Apple Color Emoji", sans-serif;
  --mono: ui-monospace, "SF Mono", "Menlo", "Consolas", monospace;
}

[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #161a21;
  --surface-2: #1d222a;
  --border: #2a2f38;
  --border-strong: #3a4150;
  --text: #f1f3f6;
  --text-muted: #9aa3b2;
  --accent: #4fcf9e;
  --accent-soft: #1a3c2f;
  --accent-strong: #6cdcb0;
  --warn: #e89668;
  --danger: #ef6363;
  --link: #6aa8ff;
  --chip: #232932;
  --chip-text: #c4ccd9;
  --code-bg: #1a1f27;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ---------- layout ---------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(180%) blur(8px);
}

.brand {
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: var(--text);
}
.brand .dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; }

.nav {
  display: flex;
  gap: 4px;
}
.nav a {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
  transition: background .15s, color .15s;
  text-decoration: none;
}
.nav a:hover { background: var(--chip); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-strong); }

.header-tools { display: flex; align-items: center; gap: 8px; }

button.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--text-muted);
  font-family: var(--font);
  cursor: pointer;
  font-size: 13px;
  transition: background .15s;
}
button.icon-btn:hover { background: var(--chip); color: var(--text); }

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

h1 {
  font-size: 26px;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.subtitle { color: var(--text-muted); margin: 0 0 24px; font-size: 14px; }
h2 {
  font-size: 18px;
  letter-spacing: -0.01em;
  margin: 28px 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
h2 .count {
  font-size: 12px;
  background: var(--chip);
  color: var(--chip-text);
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 500;
}

/* ---------- cards ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, transform .1s, box-shadow .15s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.card:hover {
  border-color: var(--border-strong);
  text-decoration: none;
}
.card.clickable:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 6px;
}
.card .value {
  font-size: 26px;
  letter-spacing: -0.02em;
  font-weight: 600;
  color: var(--text);
}
.card .unit { font-size: 14px; color: var(--text-muted); font-weight: 500; }
.card.accent { background: linear-gradient(180deg, var(--accent-soft), var(--surface)); border-color: var(--accent-soft); }
.card.accent .value { color: var(--accent-strong); }

/* ---------- table ---------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; transition: background .12s; }
tbody tr.clickable:hover { background: var(--surface-2); }

/* Подсветка «своих» профилей. На светлой теме — мягкий зелёный фон;
   на тёмной — лёгкое изумрудное свечение через полупрозрачность,
   чтобы не контрастировать ярко с тёмным окружением. */
tbody tr.tr-owner { background: #e8f5e9; }
tbody tr.tr-owner:hover { background: #d6ebd9; }
[data-theme="dark"] tbody tr.tr-owner { background: rgba(46, 125, 50, 0.16); }
[data-theme="dark"] tbody tr.tr-owner:hover { background: rgba(46, 125, 50, 0.26); }

.chip.owner-chip { background: #2e7d32; color: #fff; font-weight: 600; }
[data-theme="dark"] .chip.owner-chip { background: #66bb6a; color: #003a0a; }

.chip.owner-badge { background: #c8e6c9; color: #1b5e20; font-weight: 600; padding: 3px 10px; }
[data-theme="dark"] .chip.owner-badge { background: rgba(102, 187, 106, 0.22); color: #a5d6a7; }

.empty {
  padding: 36px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- chips ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--chip);
  color: var(--chip-text);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 500;
}
.chip.accent { background: var(--accent-soft); color: var(--accent-strong); }
.chip.warn { background: rgba(217,119,87,0.15); color: var(--warn); }
.chip.danger { background: rgba(211,59,59,0.12); color: var(--danger); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost-danger { color: var(--danger); }
.btn.ghost-danger:hover { background: rgba(211,59,59,0.08); border-color: var(--danger); }

/* ---------- timeline ---------- */

.timeline {
  position: relative;
  margin-top: 16px;
  padding-left: 28px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 8px; top: 4px; bottom: 4px;
  width: 2px;
  background: var(--border);
}
.event {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.event::before {
  content: "";
  position: absolute;
  left: -24px;
  top: 18px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--bg);
}
.event-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.event-type { font-weight: 600; font-size: 14px; }
.event-time { color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.event-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.event details { margin-top: 10px; }
.event summary { cursor: pointer; color: var(--text-muted); font-size: 12px; }
.event pre {
  margin: 8px 0 0;
  padding: 10px 12px;
  background: var(--code-bg);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.45;
  overflow: auto;
  max-width: 100%;
  color: var(--text);
}

/* ---------- back link ---------- */

.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.back:hover { color: var(--text); }

/* ---------- identifiers section ---------- */

.id-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.id-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.id-cell .k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.id-cell .v {
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
}
.id-cell .v.muted { color: var(--text-muted); font-family: inherit; }
