:root {
  --bg: #0f1419;
  --panel: #1a222c;
  --line: #2a3542;
  --text: #e8eef4;
  --muted: #9aabbc;
  --accent: #3d9cf0;
  --ok: #2f9e6b;
  --warn: #c9942e;
  --bad: #d45454;
  --radius: 10px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background:
    radial-gradient(900px 400px at 10% -10%, #1b3348 0%, transparent 55%),
    radial-gradient(700px 360px at 100% 0%, #24301f 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 20, 25, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  text-decoration: none;
  font-size: 1.15rem;
}
.nav { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; }
.nav-link { color: var(--muted); position: relative; }
.nav-link:hover { color: var(--text); text-decoration: none; }
.who { color: var(--muted); font-size: 0.9rem; }

.wrap { max-width: 980px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

.login-panel {
  max-width: 420px;
  margin: 4rem auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.75rem;
}
.login-panel h1 { margin: 0 0 0.35rem; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.page-head h1 { margin: 0 0 0.4rem; font-size: 1.55rem; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.filters { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
}
.chip.active, .chip:hover { color: var(--text); border-color: var(--accent); }

.search, input, select, textarea {
  width: 100%;
  background: #121820;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  font: inherit;
}
.search { max-width: 280px; }
textarea { resize: vertical; }
label { display: grid; gap: 0.35rem; font-weight: 600; }

.stack { display: grid; gap: 0.9rem; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #222b36;
  color: var(--text);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #061018; font-weight: 650; }
.btn.danger { background: #3a1d1d; border-color: var(--bad); color: #ffd4d4; }

.ticket-list { display: grid; gap: 0.55rem; }
.ticket-card {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}
.ticket-card:hover { border-color: var(--accent); text-decoration: none; }
.ticket-card-side { display: flex; align-items: center; gap: 0.6rem; white-space: nowrap; }
.meta, .time, .muted { color: var(--muted); font-weight: 400; font-size: 0.92rem; }
.error { color: #ff9b9b; }
.ok-msg { color: #8dffc0; }

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  background: #243040;
  color: var(--muted);
}
.badge.ok { background: #163528; color: #8dffc0; }
.badge.warn { background: #3a2f12; color: #ffd789; }
.badge.bad { background: #3a1d1d; color: #ffb0b0; }
.badges { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }

.view-grid { display: grid; gap: 1rem; }
.view-grid.with-side { grid-template-columns: 1fr 240px; }
@media (max-width: 800px) {
  .view-grid.with-side { grid-template-columns: 1fr; }
}

.messages {
  max-height: 520px;
  overflow-y: auto;
  display: grid;
  gap: 0.55rem;
  margin-bottom: 1rem;
}
.msg {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
}
.msg.staff { border-color: #3a6ea5; }
.msg-head { display: flex; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.35rem; }
.msg-body { margin: 0; white-space: pre-wrap; }

.search-wrap { position: relative; }
.search-results {
  position: absolute;
  z-index: 30;
  left: 0; right: 0; top: 100%;
  background: #121820;
  border: 1px solid var(--line);
  border-radius: 0 0 8px 8px;
  max-height: 240px;
  overflow: auto;
}
.sr-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  padding: 0.55rem 0.7rem;
  cursor: pointer;
  font: inherit;
}
.sr-item:hover { background: #1c2733; }
.sr-sub, .sr-empty { color: var(--muted); font-size: 0.85rem; padding: 0.6rem; }
.selected { margin-top: 0.35rem; }
.linkish {
  background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit;
}
.row-line { display: flex; gap: 0.5rem; }
.row-line input { flex: 1; }

#ticket-unread-badge {
  display: none;
  position: absolute;
  top: -6px;
  right: -10px;
  background: var(--bad);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 50%;
  padding: 0 4px;
}
