:root {
  color-scheme: dark;
  --bg: #12141a;
  --panel: #1a1d26;
  --panel-border: #2a2e3a;
  --text: #e6e8ee;
  --muted: #9aa0ad;
  --accent: #5b8cff;
  --good: #3ecf8e;
  --bad: #ef5b5b;
  --warn: #e6b34d;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--panel-border);
}

header h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--bad);
}
.status-dot.connected { background: var(--good); }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  gap: 24px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 18px 20px;
}

.panel h2 {
  font-size: 15px;
  margin: 0 0 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--panel-border); }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #2a2e3a;
}
.badge.online { background: rgba(62,207,142,0.15); color: var(--good); }
.badge.offline { background: rgba(239,91,91,0.12); color: var(--bad); }

button, select, input {
  font-family: inherit;
  font-size: 13px;
  background: #20232c;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 6px 10px;
}

button {
  cursor: pointer;
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 500;
}
button.secondary { background: #20232c; color: var(--text); border-color: var(--panel-border); }
button.danger { background: var(--bad); border-color: var(--bad); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row + .row { margin-top: 8px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}
.form-grid label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.conversations { display: grid; gap: 10px; }
.conversation {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 10px 12px;
}
.conversation-header {
  display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 8px;
}
.messages { display: grid; gap: 6px; max-height: 220px; overflow-y: auto; margin-bottom: 10px; }
.message { font-size: 13px; padding: 6px 10px; border-radius: 8px; max-width: 80%; }
.message.incoming { background: #20232c; align-self: flex-start; }
.message.outgoing { background: rgba(91,140,255,0.18); align-self: flex-end; margin-left: auto; }
.message .meta { color: var(--muted); font-size: 11px; margin-top: 2px; }

.reply-row { display: flex; gap: 8px; }
.reply-row input { flex: 1; }

.audit-log { font-size: 12px; color: var(--muted); max-height: 180px; overflow-y: auto; }
.audit-log div { padding: 4px 0; border-bottom: 1px solid var(--panel-border); }

.muted { color: var(--muted); font-size: 12px; }
.toast-area { position: fixed; bottom: 16px; right: 16px; display: grid; gap: 8px; z-index: 10; }
.toast {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  min-width: 220px;
}
.toast.error { border-color: var(--bad); }
.toast.success { border-color: var(--good); }

/* login page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 32px;
  width: 320px;
}
.login-card h1 { font-size: 16px; margin: 0 0 16px; }
.login-card input { width: 100%; margin-bottom: 12px; }
.login-card button { width: 100%; }
.login-error { color: var(--bad); font-size: 13px; margin-bottom: 12px; min-height: 16px; }
