:root {
  --bg: #171615;
  --surface: #1e1c1b;
  --surface-2: #262320;
  --border: #322f2c;
  --text: #dedcda;
  --text-dim: #8a8886;
  --accent: #12777f;
  --accent-dim: #0a565c;
  --accent-bright: #1c95a0;
  --accent-glow: rgba(18, 119, 127, 0.28);
  --radius: 16px;
  --danger: #d9695c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

a { color: var(--accent-bright); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text);
}

.logo .mark {
  width: 26px;
  height: 26px;
  display: inline-block;
  object-fit: contain;
  filter: invert(1) brightness(1.15);
}

.nav-links {
  display: flex;
  gap: 18px;
  font-size: 14px;
}

.nav-links a {
  color: var(--text-dim);
  text-decoration: none;
}

.nav-links a:hover { color: var(--text); }

/* ---------- Client page ---------- */

.client-shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 8vh 20px 40px;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 66px);
}

.hero {
  text-align: center;
  margin-bottom: 26px;
}

.hero h1 {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}

.hero p {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0;
}

.model-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

select#modelSelect {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-family: inherit;
}

.new-thread-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.new-thread-btn:hover { color: var(--text); border-color: var(--accent-dim); }

.offline-banner {
  text-align: center;
  font-size: 13px;
  color: #e0b152;
  background: rgba(224, 177, 82, 0.1);
  border: 1px solid rgba(224, 177, 82, 0.3);
  border-radius: 10px;
  padding: 8px 14px;
  margin: 0 0 14px;
}

.chat-ended {
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  padding: 10px 0;
  border-top: 1px dashed var(--border);
  margin-top: 10px;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 8px 6px 20px;
  transition: border-color 0.15s;
}

.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.search-box textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  resize: none;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 10px 0;
  max-height: 160px;
}

.search-box textarea::placeholder { color: var(--text-dim); }

.send-btn {
  background: var(--accent);
  border: none;
  color: #f2f7f7;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.send-btn:hover { background: var(--accent-bright); }
.send-btn:disabled { opacity: 0.4; cursor: default; }

.thread {
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  flex: 1;
}

.msg-block { display: flex; flex-direction: column; gap: 8px; }

.msg-client {
  align-self: flex-end;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 12px 16px;
  max-width: 80%;
  font-size: 15px;
}

.msg-ai-wrap { display: flex; flex-direction: column; gap: 6px; }

.msg-ai-label {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.msg-ai-label .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}

.msg-ai {
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.typing {
  color: var(--text-dim);
  font-size: 14px;
  font-style: italic;
}

.footer-disclaimer {
  text-align: center;
  color: #57544f;
  font-size: 11px;
  padding: 18px 20px 24px;
}

/* ---------- Auth (employee/manager login) ---------- */

.auth-shell {
  max-width: 380px;
  margin: 12vh auto;
  padding: 0 20px;
  text-align: center;
}

.auth-shell h1 { font-size: 22px; margin-bottom: 4px; }
.auth-shell p.sub { color: var(--text-dim); font-size: 14px; margin-bottom: 24px; }

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: left;
}

label { font-size: 13px; color: var(--text-dim); display: block; margin-bottom: 6px; }

input[type="text"], input[type="password"] {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

.btn {
  background: var(--accent);
  color: #f2f7f7;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--accent-bright); }
.btn.secondary {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn.secondary:hover { color: var(--text); border-color: var(--accent-dim); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: #f06868; }

.error-text { color: var(--danger); font-size: 13px; margin: -6px 0 12px; }

/* ---------- Employee dashboard ---------- */

.dash-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 66px);
}

.dash-sidebar {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
}

.status-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border); border-radius: 999px; transition: 0.2s;
}
.slider:before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: 0.2s;
}
input:checked + .slider { background: var(--accent); }
input:checked + .slider:before { transform: translateX(18px); }

.convo-item {
  padding: 12px;
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 6px;
  border: 1px solid transparent;
}
.convo-item:hover { background: var(--surface); }
.convo-item.active { background: var(--surface-2); border-color: var(--accent-dim); }
.convo-item .badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  display: block;
  margin-bottom: 4px;
}
.convo-item .badge.waiting { color: #e0b152; }
.convo-item .badge.active-badge { color: var(--accent); }
.convo-item .preview {
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-main {
  display: flex;
  flex-direction: column;
  padding: 16px 24px;
  overflow: hidden;
}

.dash-main .thread { overflow-y: auto; flex: 1; padding-bottom: 12px; }

.empty-state {
  margin: auto;
  color: var(--text-dim);
  text-align: center;
  font-size: 14px;
}

.reply-box {
  display: flex;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.reply-box textarea {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  resize: none;
}

/* ---------- Manager dashboard ---------- */

.manager-shell { max-width: 920px; margin: 0 auto; padding: 30px 20px 60px; }

.tabs { display: flex; gap: 8px; margin-bottom: 22px; }
.tab-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
}
.tab-btn.active { color: var(--text); border-color: var(--accent); background: var(--surface-2); }

.panel { display: none; }
.panel.active { display: block; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--text-dim); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.pill.on { background: rgba(18,119,127,0.22); color: var(--accent); }
.pill.off { background: rgba(155,153,151,0.12); color: var(--text-dim); }

.row-actions { display: flex; gap: 8px; }
.row-actions button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.row-actions button:hover { color: var(--text); border-color: var(--accent-dim); }

.add-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 22px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.add-form .field { flex: 1; min-width: 160px; }
.add-form label { margin-bottom: 4px; }
.add-form input, .add-form select { margin-bottom: 0; }

.section-title { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.section-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 18px; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--accent-dim);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  display: none;
}
