:root {
  --bg: #0f1714;
  --bg-elev: #17211d;
  --bg-soft: #1e2b26;
  --line: #2c3d36;
  --text: #e7f0ea;
  --muted: #9bb0a5;
  --accent: #3ecf8e;
  --accent-2: #f0b429;
  --danger: #ef6b6b;
  --ok: #3ecf8e;
  --warn: #f0b429;
  --bad: #ef6b6b;
  --radius: 14px;
  --font: "Segoe UI", "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1d3a30 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #243028 0%, transparent 45%),
    var(--bg);
}

a { color: var(--accent); }
button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 0.55rem 0.9rem;
}
button.primary {
  background: linear-gradient(180deg, #49d99a, #2fb87a);
  color: #062016;
  border-color: transparent;
  font-weight: 650;
}
button.danger { background: #3a1f22; border-color: #6a3036; color: #ffd7d7; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-color: var(--accent);
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(420px, 100%);
  background: color-mix(in srgb, var(--bg-elev) 92%, black);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.6rem;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.login-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}
.login-card p { margin: 0 0 1.2rem; color: var(--muted); }
.login-card label { display: block; margin: 0.75rem 0 0.35rem; color: var(--muted); font-size: 0.92rem; }
.login-card .actions { margin-top: 1.2rem; display: flex; gap: 0.6rem; }
.login-card .error {
  margin-top: 0.9rem;
  color: #ffb4b4;
  min-height: 1.2rem;
  font-size: 0.92rem;
}

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-elev) 90%, black);
  padding: 1.1rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.brand {
  padding: 0.5rem 0.6rem 1rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.6rem;
}
.brand strong { display: block; font-size: 1.05rem; }
.brand span { color: var(--muted); font-size: 0.85rem; }
.nav-btn {
  text-align: left;
  background: transparent;
  border-color: transparent;
}
.nav-btn.active {
  background: var(--bg-soft);
  border-color: var(--line);
}
.sidebar .spacer { flex: 1; }
.main { padding: 1.2rem 1.4rem 2rem; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}
.topbar h2 { margin: 0; font-size: 1.35rem; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem;
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}
.card h3 { margin: 0 0 0.35rem; font-size: 0.92rem; color: var(--muted); font-weight: 600; }
.card .value { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.03em; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.8rem 0;
  align-items: center;
}
.toolbar input, .toolbar select { width: auto; min-width: 180px; }
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
}
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td {
  text-align: left;
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th { color: var(--muted); font-weight: 600; background: color-mix(in srgb, var(--bg-soft) 70%, transparent); }
tr:hover td { background: color-mix(in srgb, var(--bg-soft) 35%, transparent); }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  border: 1px solid var(--line);
  background: var(--bg-soft);
}
.badge.ok { color: #b6f5d4; border-color: #2f6b4f; }
.badge.warn { color: #ffe3a1; border-color: #7a5d1d; }
.badge.bad { color: #ffc2c2; border-color: #7a3030; }
.panel {
  display: none;
}
.panel.active { display: block; }
.stack { display: grid; gap: 0.8rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 0.86rem; word-break: break-all; }
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  display: none;
  place-items: center;
  padding: 1rem;
  z-index: 40;
}
.modal-backdrop.open { display: grid; }
.modal {
  width: min(720px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
}
.modal h3 { margin: 0 0 0.8rem; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}
.form-grid .full { grid-column: 1 / -1; }
.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: #123429;
  border: 1px solid #2f6b4f;
  color: #dff8ea;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  display: none;
  z-index: 50;
}
.toast.show { display: block; }
.toast.error { background: #3a1f22; border-color: #6a3036; color: #ffd7d7; }

.nav-badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  margin-left: 0.35rem;
  border-radius: 999px;
  background: var(--accent-2);
  color: #1a1405;
  font-size: 0.72rem;
  font-weight: 700;
}
.support-layout {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 0.8rem;
  min-height: calc(100vh - 7rem);
}
.support-list, .support-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin: 0;
}
.support-threads {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}
.support-thread {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
}
.support-thread.active {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
}
.support-thread.unread { box-shadow: inset 3px 0 0 var(--accent-2); }
.support-thread .meta { color: var(--muted); font-size: 0.82rem; margin-top: 0.25rem; }
.support-thread .preview {
  margin-top: 0.35rem;
  color: var(--text);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.support-chat-head {
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.7rem;
}
.support-messages {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding-right: 0.2rem;
}
.bubble {
  max-width: min(720px, 92%);
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.user { align-self: flex-start; }
.bubble.admin {
  align-self: flex-end;
  background: color-mix(in srgb, var(--accent) 14%, var(--bg));
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}
.bubble .who {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.support-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: end;
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}
.support-compose textarea { resize: vertical; min-height: 74px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar .spacer { display: none; }
  .brand { width: 100%; border: 0; margin: 0; padding-bottom: 0.4rem; }
  .form-grid { grid-template-columns: 1fr; }
  .support-layout { grid-template-columns: 1fr; min-height: auto; }
  .support-threads { max-height: 240px; }
  .support-messages { min-height: 280px; max-height: 50vh; }
  .support-compose { grid-template-columns: 1fr; }
}
