:root {
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --text: #1a1d24;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #059669;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.04);
}

.card.wide { max-width: 720px; }

h1 { font-size: 1.4rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 16px; }
.subtitle { color: var(--muted); font-size: 0.92rem; margin: 0 0 24px; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: 18px;
  background: #fff;
  color: var(--text);
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}

textarea { min-height: 140px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }

button, .btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
button:hover, .btn:hover { background: var(--accent-hover); }

.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #f9fafb; }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }

.btn-small { padding: 6px 10px; font-size: 0.8rem; border-radius: 6px; }

.error-box {
  background: var(--danger-bg);
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 18px;
}

.code-display {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.6rem;
  letter-spacing: 2px;
  font-weight: 700;
  background: #f9fafb;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  margin: 16px 0;
}

.link-row {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.link-row input { margin-bottom: 0; flex: 1; background: #f9fafb; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-active { background: #ecfdf5; color: var(--success); }
.badge-inactive { background: #f3f4f6; color: var(--muted); }

.actions-row { display: flex; gap: 6px; flex-wrap: wrap; }
.actions-row form { display: inline; }

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.top-bar .btn { white-space: nowrap; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); }
.footer-link { text-align: center; margin-top: 18px; font-size: 0.85rem; }
.footer-link a { color: var(--muted); }

.chat-embed-page {
  margin: 0;
  min-height: 100vh;
  background: #f5f7fb;
  overflow: hidden;
  padding-top: 12px;
}

.chat-banner {
  position: relative;
  z-index: 10;
  margin: 0 auto 12px;
  max-width: 760px;
  background: rgba(79, 70, 229, 0.08);
  border: 1px solid rgba(79, 70, 229, 0.18);
  color: #1f2937;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.92rem;
  text-align: center;
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.08);
}

.chat-banner-note {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  color: #4b5563;
}

.chat-embed-page > *:first-child {
  position: static;
}

/* ---------- Logo and company name (views/partials/brand.ejs) ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
/* multiply blends a logo's white background (e.g. a JPG) into the page behind it. */
.brand-logo { display: block; object-fit: contain; mix-blend-mode: multiply; border-radius: 8px; }
.brand-name { font-weight: 700; color: var(--text); }

/* Centred at the top of a small card: entry, login and error pages. */
.brand-stacked { flex-direction: column; text-align: center; margin-bottom: 24px; }
.brand-stacked .brand-logo { max-height: 120px; max-width: 100%; }
.brand-stacked .brand-name { font-size: 1.05rem; }

/* One row at the top left: admin pages and the chat page. */
.brand-inline { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.brand-inline .brand-logo { max-height: 56px; max-width: 280px; }
.brand-inline .brand-name { font-size: 0.95rem; }

.chat-embed-page .brand-inline {
  justify-content: center;
  margin: 0 auto 12px;
  padding-bottom: 0;
  border-bottom: none;
}
