:root {
  --bg: #12141c;
  --surface: #1a1d29;
  --surface-2: #141722;
  --border: #2a2e3d;
  --border-soft: #1f2231;
  --text: #ffffff;
  --text-muted: #b0b4c8;
  --text-dim: #7a7f96;
  --text-faint: #5a5f76;
  --accent: #3b9eff;
  --accent-2: #2b8ae6;
  --accent-soft: rgba(59, 158, 255, 0.1);
  --green: #1fbf75;
  --amber: #e6a82b;
  --red: #e64545;
  --radius: 14px;
  --radius-sm: 10px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

.wrap { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 16px; max-width: 960px; margin: 0 auto;
  border-bottom: 1px solid var(--border-soft);
}
.logo { font-size: 20px; font-weight: 700; letter-spacing: 0.3px; }
.logo span { color: var(--accent); }
.logo small { display:block; font-size: 11px; font-weight: 500; color: var(--text-faint); letter-spacing: 0.4px; text-transform: uppercase; }
.topbar .who { font-size: 13px; color: var(--text-dim); }
.topbar .who a { color: var(--text-dim); margin-left: 12px; }

/* Accent rule */
.accent-rule { height: 3px; max-width: 960px; margin: 0 auto;
  background: linear-gradient(90deg, var(--accent-2), #5bc0ff, var(--accent-2)); }

/* Filters */
.filters { display:flex; gap:8px; flex-wrap: wrap; margin: 24px 0 16px; }
.chip {
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--surface); color: var(--text-muted); border: 1px solid var(--border);
}
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: rgba(59,158,255,0.35); }
.chip .count { opacity: 0.7; margin-left: 4px; }

/* Ticket list */
.ticket-list { display: flex; flex-direction: column; gap: 10px; }
.ticket-row {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; transition: border-color .15s, transform .05s;
}
.ticket-row:hover { border-color: rgba(59,158,255,0.4); text-decoration: none; }
.ticket-row:active { transform: scale(0.997); }
.ticket-top { display:flex; align-items:center; justify-content: space-between; gap: 12px; }
.ticket-subject { font-weight: 600; color: var(--text); font-size: 15px; }
.ticket-meta { margin-top: 6px; font-size: 13px; color: var(--text-dim); }
.ticket-meta .id { color: var(--accent); font-weight: 600; }
.ticket-snippet { margin-top: 8px; font-size: 13px; color: var(--text-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Status badges */
.badge { display:inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.new     { background: rgba(59,158,255,0.12); color: #6cb6ff; }
.badge.open    { background: rgba(31,191,117,0.12); color: #45e29a; }
.badge.pending { background: rgba(230,168,43,0.12); color: #ffce5b; }
.badge.closed  { background: rgba(120,125,150,0.14); color: #9a9fb5; }

/* Channel badges */
.badge.ch-email    { background: rgba(91,170,255,0.12); color: #8ec5ff; }
.badge.ch-telegram { background: rgba(41,171,226,0.14); color: #4fc3f7; }
.badge.ch-vk       { background: rgba(76,118,255,0.14); color: #8fa6ff; }

/* Unread state */
.ticket-row.unread { background: #1e2333; border-color: #34507a; }
.ticket-row.unread .ticket-subject { font-weight: 700; color: #ffffff; }
.unread-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #3b9eff; margin-right: 8px; vertical-align: middle;
  box-shadow: 0 0 0 3px rgba(59,158,255,0.18);
}

/* Card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.card + .card { margin-top: 16px; }

/* Thread */
.thread { display:flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.msg { border-radius: var(--radius-sm); padding: 14px 16px; font-size: 14px; line-height: 1.6; }
.msg.requester { background: var(--surface-2); border: 1px solid var(--border); }
.msg.operator  { background: var(--accent-soft); border: 1px solid rgba(59,158,255,0.25); }
.msg .msg-head { font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600;
  color: var(--text-faint); margin-bottom: 8px; display:flex; justify-content: space-between; }
.msg .msg-body { color: #e2e4ee; white-space: pre-wrap; word-wrap: break-word; }

/* Forms */
label { display:block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; }
textarea, input[type=text], input[type=email], input[type=password], select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 15px; padding: 12px 14px;
  font-family: inherit; resize: vertical;
}
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 140px; }

.row { display:flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 160px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 22px; border-radius: var(--radius-sm); font-size: 15px; font-weight: 600;
  border: none; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
}
.btn:hover { text-decoration: none; opacity: 0.95; }
.btn.full { width: 100%; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn.subtle { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted); }

.btn-group { display:flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* Page header */
.page-head { display:flex; align-items: center; justify-content: space-between; gap: 12px; margin: 24px 0 8px; }
.page-head h1 { font-size: 22px; margin: 0; }
.back { font-size: 13px; color: var(--text-dim); }

/* Login */
.login-wrap { max-width: 380px; margin: 80px auto 0; padding: 0 16px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; text-align: center; }
.login-card .sub { text-align:center; color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }
.login-card label { margin-top: 14px; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.alert.err { background: rgba(230,69,69,0.1); border-left: 3px solid var(--red); color: #ff9a9a; }
.alert.ok  { background: rgba(31,191,117,0.1); border-left: 3px solid var(--green); color: #5fe0a6; }

.empty { text-align:center; color: var(--text-faint); padding: 48px 16px; }

.dim { color: var(--text-dim); }
.muted { color: var(--text-muted); }

@media (max-width: 600px) {
  .topbar .logo small { display:none; }
  .page-head { flex-direction: column; align-items: flex-start; }
}
