/* ---------- карточка ссылки ---------- */

.card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem 1.25rem;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 0.75rem; }

.pill {
  font-size: 0.78rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.pill.ok { color: var(--ok); border-color: #244a2c; }
.pill.off { color: var(--danger); border-color: #4a2727; }

.url-box { display: flex; gap: 0.5rem; margin: 0.75rem 0; }
.url-box input { font-family: var(--mono); font-size: 0.85rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
}
.stat span { display: block; font-size: 0.75rem; color: var(--muted); }
.stat b { font-size: 0.95rem; font-weight: 600; overflow-wrap: anywhere; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 0.75rem;
}

.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.75rem; }
.row input[type="url"] { flex: 1 1 320px; }

.origin { margin-top: 1.25rem; border-top: 1px solid var(--border); padding-top: 0.75rem; }
.origin summary { cursor: pointer; color: var(--muted); }

/* ---------- модалка, тост ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}
.modal-card {
  width: min(520px, 100%);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.modal-card.wide { width: min(880px, 100%); }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }

.profiles-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1rem; }
.profiles-layout .link-list { max-height: 24rem; overflow: auto; }

.error { color: var(--danger); font-size: 0.9rem; }

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  max-width: min(560px, 90vw);
  z-index: 60;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.toast.err { border-color: #4a2727; color: #ffb4ad; }

/* ---------- вход ---------- */

body.auth { display: flex; align-items: center; justify-content: center; padding: 1rem; }
.auth-card {
  width: min(380px, 100%);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.auth-card h1 { margin-bottom: 0.25rem; }
.auth-card form { margin-top: 1rem; }

@media (max-width: 820px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 0.75rem; }
  .sidebar { position: static; }
  .profiles-layout { grid-template-columns: minmax(0, 1fr); }
}

:root {
  --bg: #0f1419;
  --bg-soft: #161d25;
  --bg-card: #1b232d;
  --border: #2a3441;
  --text: #e6edf3;
  --muted: #8b98a6;
  --accent: #4c8dff;
  --accent-dark: #3a72d0;
  --ok: #3fb950;
  --danger: #f85149;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1.05rem; }
p { margin: 0.5rem 0; }
a { color: var(--accent); }
code, .mono { font-family: var(--mono); font-size: 0.9em; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.logo { color: var(--accent); }

/* Универсальное скрытие: атрибут [hidden] перебивается display:flex у .modal/.toast. */
.hidden { display: none !important; }

button {
  font: inherit;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
button:hover { border-color: #3b4a5c; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.6; cursor: default; }

.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.ghost { background: transparent; }
.danger { color: var(--danger); border-color: #4a2727; background: transparent; }
.danger:hover { border-color: var(--danger); }
.small { padding: 0.3rem 0.6rem; font-size: 0.85rem; }
.wide { width: 100%; }

input, select, textarea {
  font: inherit;
  width: 100%;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[readonly] { color: var(--muted); }
textarea { min-height: 8rem; resize: vertical; font-family: var(--mono); }

.field { display: block; margin-bottom: 0.75rem; }
.field > span { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.25rem; }

.check { display: flex; gap: 0.5rem; align-items: center; margin: 0.5rem 0; font-size: 0.9rem; }
.check input { width: auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: 0.02em; }
.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }

.badge {
  font-size: 0.8rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem 1.25rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
  align-items: start;
}

.sidebar {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  position: sticky;
  top: 4.1rem;
}
.sidebar-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.sidebar-foot { margin-top: 0.75rem; font-size: 0.8rem; }
.link-list { list-style: none; margin: 0.75rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }

.link-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
}
.link-item:hover { background: var(--bg-card); }
.link-item.active { background: var(--bg-card); border-color: var(--accent); }
.link-item .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.link-item.off .dot { background: var(--danger); }

.detail { min-height: 300px; }
.empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  color: var(--muted);
  text-align: center;
}
