:root {
  --text: #414042;
  --paragraph: #4B5563;
  --cta: #CE8A14;
  --cta-hover: #b57610;
  --cta-soft: #f6ead3;
  --bg: #f4f0e8;
  --paper: #fbf7f0;
  --card: #ffffff;
  --dark: #141414;
  --dark-2: #1e1e1e;
  --line: #e6dfd3;
  --available: #2f7d4a;
  --unavailable: #8a8175;
  --danger: #b42318;
  --shadow: 0 18px 40px rgba(28, 24, 18, 0.08);
  --radius: 22px;
  --font: "Noto Kufi Arabic", "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.7;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 68px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 #CE8A14, 0 10px 24px rgba(65, 64, 66, 0.05);
}

.nav-bar {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 52px;
  height: 56px;
  flex: 0 0 52px;
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: visible;
}

.brand-mark img {
  width: 52px;
  height: 56px;
  object-fit: contain;
  object-position: center;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand-copy strong {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

.brand-copy span {
  font-size: 11px;
  color: var(--paragraph);
}

.nav-label,
.nav-link {
  font-size: 13px;
  font-weight: 700;
  color: var(--paragraph);
  white-space: nowrap;
}

.nav-link {
  padding: 8px 12px;
  border-radius: 10px;
}

.nav-link:hover {
  background: var(--cta-soft);
  color: var(--text);
}

.site-footer {
  margin-top: auto;
  background: #ffffff;
  color: var(--paragraph);
  text-align: center;
  padding: 16px;
  font-size: 12px;
  border-top: 1px solid var(--line);
}

.wrap {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
}

.hero {
  text-align: center;
  padding: 28px 0 8px;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.6rem, 4vw, 2.35rem);
  font-weight: 700;
}

.hero p {
  margin: 0 auto;
  max-width: 36rem;
  color: var(--paragraph);
  font-size: 1.02rem;
}

.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 18px;
  padding: 28px 0 48px;
}

.person-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 18px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.person-card.is-live {
  animation: cardPulse 0.7s ease;
}

.person-card.is-unavailable {
  background: #faf8f4;
}

@keyframes cardPulse {
  0% { transform: translateY(0); box-shadow: 0 0 0 0 rgba(206, 138, 20, 0.35); }
  40% { transform: translateY(-3px); }
  100% { transform: translateY(0); }
}

.avatar {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #e8d7b8;
  background: #f3ede3;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.person-card h2 {
  margin: 14px 0 8px;
  font-size: 1.15rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
}

.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-pill.is-available {
  background: #e8f6ec;
  color: var(--available);
}

.status-pill.is-available .dot {
  background: var(--available);
  box-shadow: 0 0 0 0 rgba(47, 125, 74, 0.7);
  animation: liveDot 1.6s infinite;
}

.status-pill.is-unavailable {
  background: #f1eee8;
  color: var(--unavailable);
}

.status-pill.is-unavailable .dot { background: var(--unavailable); }

@keyframes liveDot {
  0% { box-shadow: 0 0 0 0 rgba(47, 125, 74, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(47, 125, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 125, 74, 0); }
}

.actions {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: 0.18s ease;
}

.btn-cta {
  background: var(--cta);
  color: #fff;
}

.btn-cta:hover { background: var(--cta-hover); }

.btn-wa {
  background: #25D366;
  color: #fff;
}

.btn-wa:hover { background: #1ebe5d; }

.btn-ghost {
  background: #efe8db;
  color: var(--text);
}

.btn-danger {
  background: #f8e4e2;
  color: var(--danger);
}

.btn[disabled], .btn.is-disabled {
  pointer-events: none;
  opacity: 0.45;
  filter: grayscale(0.2);
}

.unavailable-note {
  width: 100%;
  margin-top: 16px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: #efeae2;
  color: var(--paragraph);
  font-weight: 600;
}

.empty-state, .loading-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 16px;
  color: var(--paragraph);
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(circle at 20% 10%, rgba(206, 138, 20, 0.16), transparent 28%),
    var(--dark);
}

.auth-card {
  width: min(420px, 100%);
  background: var(--paper);
  border-radius: 28px;
  padding: 28px 24px 24px;
  box-shadow: var(--shadow);
  text-align: center;
}

.auth-card .logo { height: 84px; margin: 0 auto 8px; }
.auth-card h1 { margin: 8px 0 6px; font-size: 1.35rem; }
.auth-card p { margin: 0 0 18px; color: var(--paragraph); }

.form {
  display: grid;
  gap: 12px;
  text-align: right;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
}

.field input, .field textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid #ddd4c6;
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

.field textarea {
  min-height: 110px;
  resize: vertical;
}

.copy-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  display: grid;
  gap: 12px;
  max-width: 680px;
}

.field input:focus, .field textarea:focus {
  outline: 2px solid rgba(206, 138, 20, 0.35);
  border-color: var(--cta);
}

.field small {
  display: block;
  margin-top: 6px;
  color: var(--paragraph);
  font-size: 12px;
}

.alert {
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8e4e2;
  color: var(--danger);
  font-size: 14px;
  text-align: right;
}

.dash {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
  background: var(--bg);
}

.side {
  background: #fff;
  color: var(--text);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-left: 1px solid var(--line);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 14px;
  border-bottom: 1px solid var(--line);
}

.side-brand img {
  width: 42px;
  height: 48px;
  object-fit: contain;
}

.side-brand strong {
  display: block;
  font-size: 16px;
  line-height: 1.3;
}

.side-brand span {
  display: block;
  font-size: 11px;
  color: var(--paragraph);
}

.tabs {
  display: grid;
  gap: 6px;
}

.tab-btn {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--paragraph);
  font-weight: 700;
  cursor: pointer;
  text-align: right;
  padding: 10px 12px;
}

.tab-btn.is-active,
.tab-btn:hover {
  background: var(--cta-soft);
  color: var(--text);
}

.tab-btn.is-active {
  box-shadow: inset -3px 0 0 var(--cta);
}

.side-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.who-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  background: #f7f2ea;
}

.who-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--cta);
  color: #fff;
  font-weight: 800;
}

.who-chip b { display: block; font-size: 13px; }
.who-chip span { display: block; font-size: 11px; color: var(--paragraph); }

.logout-link {
  display: block;
  text-align: center;
  padding: 10px;
  border-radius: 12px;
  font-weight: 700;
  color: var(--paragraph);
}

.logout-link:hover {
  background: #f1ece3;
  color: var(--text);
}

.secret-field {
  display: flex;
  align-items: center;
  border: 1px solid #ddd4c6;
  border-radius: 12px;
  background: #fff;
}

.secret-field:focus-within {
  outline: 2px solid rgba(206, 138, 20, 0.35);
  border-color: var(--cta);
}

.secret-field input,
.secret-field input:focus {
  border: 0;
  outline: 0;
  min-height: 48px;
  flex: 1;
  width: auto;
  background: transparent;
}

.secret-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 6px 0 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--paragraph);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.icon-btn:hover,
.btn-generate:hover {
  background: var(--cta-soft);
  color: var(--text);
}

.btn-generate {
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--cta);
  font-weight: 800;
  font-size: 12px;
  padding: 0 8px;
  cursor: pointer;
}

.autofill-trap {
  position: absolute;
  opacity: 0;
  height: 0;
  width: 0;
  pointer-events: none;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translate(-50%, 12px);
  background: var(--text);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 40;
}

.toast.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.main { padding: 24px; }
.panel { display: none; }
.panel.is-active { display: block; }

.panel h1 { margin: 0 0 6px; }
.lede { color: var(--paragraph); margin: 0 0 22px; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}

.stat b { display: block; font-size: 1.6rem; color: var(--cta); }
.stat span { color: var(--paragraph); font-size: 13px; }

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.people-admin {
  display: grid;
  gap: 12px;
}

.admin-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 14px;
  align-items: center;
}

.admin-card .mini-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  background: #f3ede3;
}

.admin-card .mini-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.meta { min-width: 0; }
.meta h3 { margin: 0 0 4px; font-size: 1.02rem; }
.meta p { margin: 0; color: var(--paragraph); font-size: 13px; }

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.toggle {
  width: 48px;
  height: 28px;
  border-radius: 999px;
  border: 0;
  background: #d7d0c5;
  position: relative;
  cursor: pointer;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: 0.18s ease;
}

.toggle.is-on { background: var(--cta); }
.toggle.is-on::after { right: 24px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(16, 14, 12, 0.55);
  display: none;
  place-items: center;
  padding: 16px;
  z-index: 20;
}

.modal.is-open { display: grid; }

.modal-card {
  width: min(520px, 100%);
  background: var(--paper);
  border-radius: 24px;
  padding: 22px;
}

.modal-card h2 { margin: 0 0 14px; }

.agent-home {
  display: grid;
  place-items: center;
  padding: 40px 16px 56px;
}

.presence-card {
  width: min(520px, 100%);
  background: var(--card);
  border-radius: 28px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 28px 22px;
  text-align: center;
}

.presence-card .avatar { width: 110px; height: 110px; margin: 0 auto 12px; }
.presence-card h1 { margin: 8px 0 6px; }

.big-toggle {
  margin-top: 22px;
  width: 100%;
  min-height: 64px;
  border-radius: 18px;
  border: 0;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  color: #fff;
}

.big-toggle.is-on { background: var(--available); }
.big-toggle.is-off { background: #8a8175; }

.hint { color: var(--paragraph); font-size: 14px; margin-top: 12px; }

.paused-flag {
  display: inline-block;
  margin-top: 6px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 860px) {
  .dash { grid-template-columns: 1fr; }
  .side { padding-bottom: 12px; }
  .stats { grid-template-columns: 1fr; }
  .admin-card { grid-template-columns: 56px 1fr; }
  .row-actions { grid-column: 1 / -1; }
  .nav-bar { padding: 0 16px; }
  .brand-copy span { display: none; }
}

@media (max-width: 520px) {
  .actions { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
}
