/* ---------- дизайн-токены ---------- */
:root,
[data-theme="light"] {
  --bg: #F6F7FA;
  --surface: #FFFFFF;
  --surface-2: #EEF1F6;
  --border: #E4E8EF;
  --text: #1B1F27;
  --muted: #6B7280;
  --accent: #5B6EF5;
  --accent-soft: #ECEEFE;
  --success: #16A34A;
  --success-soft: #E9F9EF;
  --danger: #DC2626;
  --danger-soft: #FDECEC;
  --shadow: 0 1px 2px rgba(20, 24, 33, 0.04), 0 8px 24px rgba(20, 24, 33, 0.06);
  --shadow-hover: 0 4px 10px rgba(20, 24, 33, 0.06), 0 16px 32px rgba(20, 24, 33, 0.10);
}

[data-theme="dark"] {
  --bg: #12141B;
  --surface: #1B1F29;
  --surface-2: #232836;
  --border: #2C3140;
  --text: #ECEEF3;
  --muted: #8B93A3;
  --accent: #8892FF;
  --accent-soft: rgba(136, 146, 255, 0.14);
  --success: #4ADE80;
  --success-soft: rgba(74, 222, 128, 0.12);
  --danger: #F87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-hover: 0 4px 10px rgba(0, 0, 0, 0.24), 0 16px 40px rgba(0, 0, 0, 0.36);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  padding: 48px 24px 72px;
  transition: background .25s ease, color .25s ease;
}

a { color: inherit; }

.frame { max-width: 1000px; margin: 0 auto; }
.frame-narrow { max-width: 440px; }

/* ---------- переключатель темы ---------- */
.theme-toggle {
  position: fixed;
  top: 20px; right: 20px;
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 50;
  transition: border-color .15s ease, transform .15s ease;
}
.theme-toggle:hover { border-color: var(--accent); transform: translateY(-1px); }
.theme-toggle svg { width: 19px; height: 19px; color: var(--muted); }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ---------- заголовок ---------- */
.hero { margin-bottom: 36px; }
.hero-simple { margin-bottom: 28px; }
.hero-with-actions {
  display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 16px;
}

.eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

h1 {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: clamp(28px, 4vw, 38px);
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.subline {
  font-size: 15px;
  color: var(--muted);
  margin-top: 10px;
  max-width: 520px;
  line-height: 1.6;
}

.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- сетка карточек (публичная панель) ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: var(--accent);
}
.card-offline { opacity: .6; }

.card-top { display: flex; align-items: flex-start; justify-content: space-between; }

.tile {
  width: 46px; height: 46px;
  border-radius: 13px;
  background: color-mix(in srgb, var(--tile-color) 16%, transparent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.tile svg { width: 22px; height: 22px; stroke: var(--tile-color); fill: none; }
.tile-sm { width: 38px; height: 38px; border-radius: 11px; }
.tile-sm svg { width: 18px; height: 18px; }

.card-name {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.card-host {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  color: var(--accent);
}
.card-ip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: -8px;
}

/* ---------- статус-пилюля ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 12px; font-weight: 600;
  color: var(--success);
  background: var(--success-soft);
  border: none;
  border-radius: 999px;
  padding: 5px 11px;
  white-space: nowrap;
}
.pill-off { color: var(--danger); background: var(--danger-soft); }
.pill-button { cursor: pointer; }
.dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}

.empty {
  grid-column: 1 / -1;
  padding: 32px;
  color: var(--muted);
  font-size: 14px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 16px;
  text-align: center;
}

footer {
  margin-top: 40px;
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  font-size: 13px; color: var(--muted);
}
footer a { text-decoration: none; color: var(--accent); font-weight: 600; }
footer a:hover { text-decoration: underline; }

/* ---------- флэш-сообщения ---------- */
.flash-stack { max-width: 1000px; margin: 0 auto 20px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  font-size: 13.5px; font-weight: 500;
  padding: 12px 16px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
}
.flash-success { color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, var(--border)); }
.flash-error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }

/* ---------- формы ---------- */
.panel-form {
  display: flex; flex-direction: column; gap: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 28px; box-shadow: var(--shadow);
}
.panel-form label {
  display: flex; flex-direction: column; gap: 7px;
  font-size: 13px; font-weight: 600; color: var(--muted);
}
.panel-form input, .panel-form select {
  font-family: 'Inter', sans-serif; font-size: 14.5px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px; outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.panel-form input:focus, .panel-form select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 12px; margin-top: 6px; }

.icon-picker { display: flex; flex-wrap: wrap; gap: 10px; }
.icon-option { cursor: pointer; }
.icon-option input { position: absolute; opacity: 0; pointer-events: none; }
.icon-swatch {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--surface-2); border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  transition: border-color .15s ease, background .15s ease;
}
.icon-swatch svg { width: 20px; height: 20px; stroke: var(--muted); fill: none; }
.icon-option input:checked + .icon-swatch {
  border-color: var(--tile-color);
  background: color-mix(in srgb, var(--tile-color) 16%, transparent);
}
.icon-option input:checked + .icon-swatch svg { stroke: var(--tile-color); }

.hint { font-size: 12.5px; color: var(--muted); margin-top: 18px; text-align: center; }
.hint code {
  font-family: 'JetBrains Mono', monospace; color: var(--accent);
  background: var(--accent-soft); padding: 1px 6px; border-radius: 4px;
}
.back-link { display: block; text-align: center; margin-top: 16px; font-size: 13.5px; color: var(--muted); text-decoration: none; }
.back-link:hover { color: var(--accent); }

/* ---------- кнопки ---------- */
.btn {
  font-family: 'Inter', sans-serif; font-size: 13.5px; font-weight: 600;
  padding: 10px 18px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none; cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.btn-block { width: 100%; text-align: center; }
.btn-sm { padding: 7px 13px; font-size: 12.5px; }
.inline-form { display: inline; }

/* ---------- список в админке ---------- */
.admin-toolbar { margin-bottom: 18px; display: flex; justify-content: flex-end; }
.admin-list { display: flex; flex-direction: column; gap: 10px; }
.admin-item {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 14px 18px; box-shadow: var(--shadow);
}
.admin-info { flex: 1; min-width: 0; }
.admin-name { font-family: 'Manrope', sans-serif; font-weight: 700; font-size: 15px; }
.admin-meta {
  font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--muted);
  margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.admin-actions { display: flex; gap: 8px; flex-shrink: 0; }

@media (max-width: 640px) {
  .card-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .admin-item { flex-wrap: wrap; }
  .admin-actions { width: 100%; justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  .card, .theme-toggle { transition: none; }
}
