@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap');

:root {
  --red: #e93e3f;
  --red-dark: #c9302f;
  --charcoal: #333333;
  --blue: #066ab5;
  --grey: #ebecf0;
  --grey-2: #d5d7de;
  --muted: #6b6f7a;
  --bg: #ffffff;
  --surface: #ffffff;
  --text: var(--charcoal);
  --ok: #1f8a4c;
  --warn: #b7791f;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.06);
  font-family: 'Open Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--grey); color: var(--text); min-height: 100vh; }
a { color: var(--blue); }
h1, h2, h3 { color: var(--charcoal); margin: 0 0 0.5em; }
h1 { font-size: 1.6rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ---- Header ---- */
.brandbar {
  background: var(--surface);
  border-bottom: 4px solid var(--red);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brandbar .logo { height: 36px; }
.wordmark { font-weight: 700; font-size: 1.15rem; letter-spacing: 0.2px; }
.wordmark span { color: var(--red); }
.brandbar .spacer { flex: 1; }

/* ---- Layout ---- */
.wrap { max-width: 560px; margin: 40px auto; padding: 0 16px; }
.wide { max-width: 1100px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.card + .card { margin-top: 16px; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---- Controls ---- */
label { font-weight: 600; font-size: 0.9rem; display: block; margin-bottom: 4px; }
input[type='text'], input[type='email'], input[type='password'], input[type='search'], textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--grey-2);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
input:focus, textarea:focus, button:focus-visible { outline: 3px solid rgba(6, 106, 181, 0.35); outline-offset: 1px; }
button, .btn {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 8px;
  padding: 11px 18px;
  cursor: pointer;
  background: var(--red);
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
button:hover, .btn:hover { background: var(--red-dark); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--charcoal); border: 1px solid var(--grey-2); }
.btn-secondary:hover { background: var(--grey); }
.btn-blue { background: var(--blue); }
.btn-blue:hover { background: #05589a; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 22px; font-size: 1.05rem; }

.error { color: var(--red-dark); font-weight: 600; min-height: 1.2em; }

/* ---- Code entry ---- */
.code-input { display: flex; gap: 8px; justify-content: center; }
.code-input input {
  width: 52px;
  height: 64px;
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  padding: 0;
}
.code-display {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--charcoal);
  font-variant-numeric: tabular-nums;
}

/* ---- Status pills ---- */
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 0.78rem; font-weight: 700; background: var(--grey); }
.pill.waiting { background: #fff4e0; color: var(--warn); }
.pill.joined { background: #e6f0fa; color: var(--blue); }
.pill.active { background: #e3f5ea; color: var(--ok); }
.pill.ended, .pill.expired, .pill.denied { background: var(--grey); color: var(--muted); }

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

/* ---- Sharing banner (customer) ---- */
.share-banner {
  background: var(--red);
  color: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
}
.share-banner button { background: #fff; color: var(--red); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }

/* ---- Chat ---- */
.chat-log { height: 220px; overflow-y: auto; background: var(--grey); border-radius: 8px; padding: 10px; font-size: 0.92rem; }
.chat-log .me { text-align: right; }
.chat-log div { margin: 4px 0; }
.chat-log b { font-weight: 600; }

/* ---- Technician viewer ---- */
body.viewer { background: #1e1f23; color: #e7e8ec; overflow: hidden; }
.viewer-bar {
  height: 48px;
  background: #2a2b31;
  border-bottom: 3px solid var(--red);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}
.viewer-bar .title { font-weight: 700; margin-right: 8px; }
.viewer-bar button, .viewer-bar select {
  background: #3a3b42;
  color: #e7e8ec;
  padding: 7px 12px;
  font-size: 0.85rem;
  border-radius: 6px;
  border: 0;
  font-family: inherit;
}
.viewer-bar button:hover { background: #4a4b53; }
.viewer-bar button.danger { background: var(--red); color: #fff; }
.viewer-bar button.on { background: var(--blue); }
.viewer-bar .stats { font-size: 0.78rem; color: #a5a7b0; font-variant-numeric: tabular-nums; }
.viewer-main { display: flex; height: calc(100vh - 48px); }
.stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: auto; outline: none; }
.stage video { max-width: 100%; max-height: 100%; background: #000; cursor: default; }
.stage.actual video { max-width: none; max-height: none; }
.stage .overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; color: #c9cad1; text-align: center; padding: 20px; }
.side { width: 300px; background: #26272c; border-left: 1px solid #34353c; display: flex; flex-direction: column; padding: 12px; gap: 12px; overflow-y: auto; }
.side h3 { color: #e7e8ec; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; margin: 0; }
.side .chat-log { background: #1e1f23; flex: 1; min-height: 160px; height: auto; }
.side input { background: #1e1f23; border-color: #3a3b42; color: #e7e8ec; }
.kv { font-size: 0.85rem; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; }
.kv dt { color: #a5a7b0; }
.kv dd { margin: 0; word-break: break-word; }
.spinner { width: 32px; height: 32px; border: 3px solid #4a4b53; border-top-color: var(--red); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .wrap { margin: 20px auto; }
  .card { padding: 20px; }
  .code-input input { width: 42px; height: 56px; font-size: 1.5rem; }
  .side { display: none; }
}

.grow { flex: 1; }
.mt8 { margin-top: 8px; }
hr.sep { border: 0; border-top: 1px solid var(--grey); }
