:root {
  --usm-blue: #003865;
  --usm-blue-2: #0b4f80;
  --usm-yellow: #f2a900;
  --usm-red: #c42b32;
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(15, 23, 42, 0.08);
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

body.bg-hero {
  background:
    radial-gradient(circle at 20% 20%, rgba(0, 56, 101, 0.12), transparent 25%),
    radial-gradient(circle at 80% 0%, rgba(242, 169, 0, 0.12), transparent 22%),
    #f6f8fb;
}

main { padding: 18px 18px 50px; }
@media (max-width: 720px) { main { padding: 12px 12px 40px; } }

/* -------- Topbar -------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #0b3c6b;
  color: #eef2ff;
  box-shadow: 0 14px 28px rgba(0, 56, 101, 0.28);
}
.topbar__inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar__brand-wrap { display: flex; align-items: center; gap: 14px; }
.topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: #fff;
  text-decoration: none;
  letter-spacing: 0.2px;
}
.topbar__logo {
  height: 42px;
  width: auto;
  display: block;
  object-fit: contain;
}
.topbar__nav {
  display: flex;
  align-items: center;
  gap: 14px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.topbar__link {
  color: #e2e8f0;
  text-decoration: none;
  font-weight: 600;
  padding: 9px 12px;
  border-radius: 10px;
  transition: 0.16s ease;
}
.topbar__link:hover { background: rgba(255, 255, 255, 0.12); }
.topbar__user {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.topbar__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
  border: 1px solid var(--border);
  padding: 6px;
  display: none;
}
.topbar__dropdown a,
.topbar__dropdown button {
  display: block;
  width: 100%;
  padding: 10px 12px;
  text-decoration: none;
  color: inherit;
  border-radius: 10px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.topbar__dropdown a:hover,
.topbar__dropdown button:hover { background: rgba(0, 56, 101, 0.06); }
.topbar__user.is-open .topbar__dropdown { display: block; }

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50px;
  padding: 4px 10px 4px 4px;
  min-width: 180px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
}
.user-pill__avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--usm-blue);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  border: 1px solid rgba(255,255,255,0.25);
}
.user-pill__name { color: #fff; font-weight: 700; }
.user-pill__chevron { color: #dce7f5; font-size: 0.85rem; }

.topbar__toggle {
  display: none;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
}
@media (max-width: 820px) {
  .topbar__inner { flex-wrap: wrap; }
  .topbar__toggle { display: inline-flex; gap: 6px; }
  .topbar__nav {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    display: none;
  }
  .topbar__nav.is-open { display: flex; }
  .topbar__link { width: 100%; }
  .topbar__user { width: 100%; justify-content: space-between; }
}

/* -------- Layout / cards -------- */
.section { max-width: 960px; margin: 28px auto; padding: 0 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-lg { display: flex; flex-direction: column; gap: 22px; }
.stack-center { align-items: center; }
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card--list {
  padding: 20px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}
.headline { margin: 0; font-size: 1.8rem; }
.subtitle { margin: 0; color: var(--muted); }
.section-title { margin: 0 0 10px; font-size: 1.2rem; }

/* -------- Buttons -------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 0;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  transition: 0.16s ease;
}
.btn-primary {
  background: linear-gradient(90deg, var(--usm-blue), var(--usm-blue-2));
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 56, 101, 0.25);
}
.btn-primary:hover { filter: brightness(0.95); }
.btn-accent {
  background: var(--usm-yellow);
  color: #1f2937;
}
.btn-ghost {
  background: none;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-danger {
  background: var(--usm-red);
  color: #fff;
}
.btn-small { padding: 8px 12px; font-size: 0.95rem; }

/* -------- Forms -------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.9rem; color: #1f2937; }
.field input,
.field select {
  padding: 11px 12px;
  border: 1px solid #d9dfe7;
  border-radius: 10px;
  font-size: 1rem;
}
.error {
  background: #fff1f2;
  color: #9f1239;
  border: 1px solid #fecdd3;
  padding: 10px 12px;
  border-radius: 10px;
}
.text-muted { color: var(--muted); }
.text-center { text-align: center; }
.empty { color: var(--muted); text-align: center; }

/* -------- Chat lists -------- */
.list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.list-btn {
  width: 100%;
  text-align: left;
  padding: 18px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  cursor: pointer;
  font-size: 1rem;
  transition: 0.15s ease;
}
.list-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(15, 23, 42, 0.1); }
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

/* -------- Messages -------- */
.messages-shell {
  max-width: 800px;
  margin: 20px auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.messages-box {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 18px;
  min-height: 400px;
  max-height: 70vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg {
  max-width: 80%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #e2e8f0;
}
.msg--mine { margin-left: auto; background: var(--usm-blue); color: #fff; }
.msg__body { white-space: pre-wrap; }
.msg__meta { font-size: 0.8rem; color: var(--muted); }
.msg--mine .msg__meta { color: #dbeafe; }
.msg__files { display: grid; grid-template-columns: repeat(auto-fit,minmax(140px,1fr)); gap: 8px; }
.msg__file {
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.msg__file:hover { border-color: var(--usm-blue); }

.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
  animation: pulseDots 1s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulseDots {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
  30% { transform: translateY(-3px); opacity: 1; }
}

.composer {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  box-shadow: var(--shadow);
}
.composer input[type="text"] {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
}
.file-chip {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px dashed #cbd5e1;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.file-chip input { display: none; }
.file-chip .badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--usm-red);
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  display: none;
}
.file-chip.has-files .badge { display: grid; }

/* -------- Auth cards -------- */
.auth-shell {
  display: grid;
  place-items: center;
  min-height: 78vh;
  padding: 30px 14px;
}
.online-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  padding: 8px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  color: var(--usm-blue);
}
.online-dot {
  width: 10px; height: 10px; border-radius: 50%; background: #22c55e;
}

/* -------- Grids for bots / cards -------- */
.card-grid {
  max-width: 1160px;
  margin: 20px auto;
  padding: 0 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
  align-items: stretch;
  grid-auto-rows: 1fr;
}
.tile {
  background: #fff;
  border-radius: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: 0 14px 30px rgba(15,23,42,0.12);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  height: 100%;
}
.tile:hover { transform: translateY(-3px); box-shadow: 0 18px 36px rgba(15,23,42,0.16); }
.tile__title { margin: 0; font-size: 1.05rem; }
.tile__desc { margin: 0; color: var(--muted); }
.tile__actions { display: flex; gap: 8px; justify-content: flex-start; }

/* -------- Page loader -------- */
.page-loader {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg, var(--usm-yellow), var(--usm-blue));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
  z-index: 9999;
}
.page-loader.is-on {
  transform: scaleX(1);
  animation: loaderFlow 1.2s infinite ease-in-out;
}
@keyframes loaderFlow {
  0% { opacity: 1; }
  50% { opacity: 0.4; }
  100% { opacity: 1; }
}

/* -------- Code / markdown -------- */
code {
  font-family: "SFMono-Regular","Consolas","Liberation Mono","Menlo",monospace;
  background: #f5f7fb;
  padding: 2px 4px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}
pre {
  background: #0b1221;
  color: #e2e8f0;
  padding: 12px;
  border-radius: 10px;
  overflow: auto;
  border: 1px solid rgba(255,255,255,0.08);
}
pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  display: block;
  white-space: pre-wrap;
}

/* -------- Floating online badge -------- */
.floating-online {
  position: fixed;
  left: 16px;
  bottom: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(15,23,42,0.15);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.floating-online.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.floating-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34,197,94,0.7);
  animation: breathing 2.2s infinite ease-in-out;
}
@keyframes breathing {
  0% { box-shadow: 0 0 0 0 rgba(34,197,94,0.6); }
  50% { box-shadow: 0 0 0 10px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* -------- Modal -------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}
.modal-overlay.is-open { display: flex; }
.modal {
  background: #fff;
  max-width: 520px;
  width: 100%;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(15,23,42,0.18);
  border: 1px solid var(--border);
  padding: 18px;
}
.modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
