/* YMCA Front Desk - shared design system */
:root {
  --brand: #5c2e91;          /* YMCA purple */
  --brand-600: #4e2680;
  --brand-50: #f4effa;
  --brand-100: #e9def5;
  --blue: #0089d0;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e5e7eb;
  --line-2: #f0f1f3;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ok: #047857;  --ok-bg: #ecfdf5;
  --warn: #b45309; --warn-bg: #fffbeb;
  --bad: #b91c1c;  --bad-bg: #fef2f2;
  --info: #1d4ed8; --info-bg: #eff6ff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .05);
  --shadow: 0 1px 3px rgba(17, 24, 39, .06), 0 1px 2px rgba(17, 24, 39, .04);
  --shadow-lg: 0 12px 32px rgba(17, 24, 39, .10);
  --sidebar: 248px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; text-decoration: none; color: inherit; }
.brand img { width: 44px; height: auto; display: block; }
.brand .t1 { font-weight: 700; font-size: 15px; color: var(--ink); line-height: 1.2; }
.brand .t2 { font-size: 11.5px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav .label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); padding: 14px 10px 6px; }
.nav a, .nav button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink-2); font: 500 13.5px var(--font); text-decoration: none; cursor: pointer; text-align: left; }
.nav a:hover, .nav button:hover { background: var(--line-2); color: var(--ink); }
.nav .on { background: var(--brand-50); color: var(--brand); }
.nav .on svg { color: var(--brand); }
.nav svg { width: 18px; height: 18px; flex: none; color: var(--faint); }
.nav .count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 600; text-align: center; line-height: 18px; }
.nav .count:empty { display: none; }
.sidebar .spacer { flex: 1; }
.status-card { margin: 8px 4px 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 12px; color: var(--muted); }
.status-card b { display: flex; align-items: center; gap: 6px; color: var(--ink); font-weight: 600; margin-bottom: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.live { background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, .18); }
.dot.demo { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .18); }

.main { min-width: 0; display: flex; flex-direction: column; }
.main * { min-width: 0; }
.content, .card { max-width: 100%; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 22px 32px 6px; }
.topbar h1 { font-size: 22px; font-weight: 700; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.topbar .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.content { padding: 18px 32px 24px; flex: 1; }

/* ---------- primitives ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-h h2 { font-size: 14px; font-weight: 600; }
.card-h .sub { color: var(--muted); font-size: 12.5px; }
.card-h .right { margin-left: auto; }
.card-b { padding: 16px 18px; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.empty svg { width: 28px; height: 28px; color: var(--faint); display: block; margin: 0 auto 8px; }

.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { padding: 14px 16px; }
.stat .l { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.stat .hint { font-size: 11.5px; color: var(--faint); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-2); font: 500 13px var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow-sm); }
.btn:hover { border-color: #d1d5db; background: #fafafa; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-600); }
.btn.ghost { border-color: transparent; box-shadow: none; background: none; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.field label { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-2); margin-bottom: 5px; }
.input, textarea.input, select.input { width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); font: 13.5px var(--font); color: var(--ink); outline: none; box-shadow: var(--shadow-sm); }
textarea.input { height: auto; min-height: 64px; padding: 8px 11px; resize: vertical; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(92, 46, 145, .14); }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }

.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.badge.brand { background: var(--brand-50); color: var(--brand); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfc; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .sub { color: var(--muted); font-size: 12.5px; }

.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; color: var(--brand); background: var(--brand-100); }
.avatar.lg { width: 44px; height: 44px; font-size: 16px; }
.score { display: flex; align-items: center; gap: 8px; }
.score .bar { flex: 1; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; min-width: 60px; }
.score .bar i { display: block; height: 100%; border-radius: 3px; background: var(--brand); }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); }
.muted { color: var(--muted); }

/* ---------- messages ---------- */
.thread { display: flex; flex-direction: column; gap: 3px; padding: 16px; overflow-y: auto; background: #fbfbfc; }
.msg { max-width: 74%; padding: 8px 12px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; font-size: 13.5px; line-height: 1.4; }
.msg.in { align-self: flex-start; background: #ececef; color: var(--ink); border-bottom-left-radius: 6px; }
.msg.out { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 6px; }
.msg.out.staff { background: var(--ok); }
.msg.system { align-self: center; background: none; color: var(--muted); font-size: 12px; }
.msg-meta { font-size: 11px; color: var(--faint); margin: 1px 4px 8px; }
.msg-meta.r { align-self: flex-end; }
.msg-meta.l { align-self: flex-start; }

/* ---------- footer ---------- */
.mx2-foot { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 18px 32px 22px; font-size: 12px; color: var(--faint); border-top: 1px solid var(--line); background: var(--surface); }
.mx2-foot img { width: 22px; height: 22px; border-radius: 50%; display: block; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 5; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; gap: 8px; }
  .brand { padding: 0 8px 0 0; }
  .brand .t1, .brand .t2, .nav .label, .sidebar .spacer, .status-card { display: none; }
  .brand img { width: 36px; }
  .nav { flex-direction: row; gap: 2px; }
  .nav a, .nav button { white-space: nowrap; padding: 7px 10px; }
  .topbar { padding: 18px 16px 4px; flex-wrap: wrap; }
  .topbar .actions { margin-left: 0; }
  .content { padding: 14px 16px 20px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mx2-foot { padding: 16px; flex-wrap: wrap; text-align: center; }
}
