:root {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --text: #1c1f2a;
  --muted: #6b7083;
  --line: #e4e6ee;
  --accent: #5b4cf0;
  --accent-soft: #eeecfe;
  --ok: #138a5b;
  --ok-soft: #e3f6ee;
  --warn: #b26b00;
  --warn-soft: #fff3df;
  --bad: #c43a3a;
  --bubble-user: #eef0f5;
  --radius: 12px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141b;
    --panel: #1b1e28;
    --text: #e8e9ef;
    --muted: #9a9fb2;
    --line: #2b2f3d;
    --accent: #8b80ff;
    --accent-soft: #272448;
    --ok: #4cc795;
    --ok-soft: #173329;
    --warn: #f0b04a;
    --warn-soft: #3a2c14;
    --bad: #ff7a7a;
    --bubble-user: #262a37;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; }
.hidden { display: none !important; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
p { line-height: 1.5; }
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1em; }
a { color: var(--accent); }

.brand { font-weight: 700; font-size: 18px; letter-spacing: -0.3px; }
.brand span { color: var(--accent); }
.brand.big { font-size: 28px; }

.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 9px 16px; border-radius: 9px; cursor: pointer; font: inherit; font-weight: 600;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn:disabled { opacity: 0.55; cursor: wait; }

input, textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; margin-top: 5px;
}
textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 14px; }
label small { display: block; font-weight: 400; color: var(--muted); margin-top: 2px; }
label.check { display: flex; gap: 8px; align-items: center; }
label.check input { width: auto; margin: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }

.social { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.btn.fb { background: #1877f2; border-color: #1877f2; color: #fff; text-align: center; text-decoration: none; }
.btn.ig {
  background: linear-gradient(45deg, #f58529, #dd2a7b 50%, #8134af); border: 0; color: #fff;
  text-align: center; text-decoration: none;
}
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.banner { border-color: var(--accent); background: var(--accent-soft); }

.topbar {
  display: flex; align-items: center; gap: 16px; padding: 12px 20px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.tenant-switch { flex: 1; display: flex; gap: 8px; align-items: center; }
.tenant-switch select { max-width: 260px; margin: 0; }
.layout { display: flex; min-height: calc(100vh - 57px); }
.nav { width: 220px; padding: 16px 10px; border-right: 1px solid var(--line); background: var(--panel); flex-shrink: 0; }
.nav a {
  display: flex; justify-content: space-between; padding: 9px 12px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-weight: 600; margin-bottom: 2px;
}
.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.badge { background: var(--bad); color: #fff; border-radius: 99px; font-size: 12px; padding: 1px 7px; }
.view { flex: 1; padding: 24px; max-width: 1100px; min-width: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.stat .num { font-size: 28px; font-weight: 700; margin-top: 4px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.off { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
.table-wrap { overflow-x: auto; }

/* Bisedat */
.inbox { display: grid; grid-template-columns: 320px 1fr; gap: 16px; height: calc(100vh - 160px); min-height: 420px; }
.conv-list { overflow-y: auto; padding: 0; }
.conv-item { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.conv-item:hover, .conv-item.active { background: var(--accent-soft); }
.conv-item .name { font-weight: 600; display: flex; gap: 6px; align-items: center; }
.conv-item .last { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.thread-head { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 75%; padding: 9px 13px; border-radius: 16px; white-space: pre-wrap; line-height: 1.4; word-wrap: break-word; }
.bubble.user { background: var(--bubble-user); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.assistant { background: var(--accent); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.human { background: var(--ok); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble .who { font-size: 11px; opacity: 0.75; display: block; margin-bottom: 2px; }
.bubble img { max-width: 220px; border-radius: 10px; display: block; margin-bottom: 4px; }
.system-note { align-self: center; font-size: 12px; color: var(--muted); background: var(--warn-soft); padding: 4px 10px; border-radius: 99px; }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.composer textarea { min-height: 44px; height: 44px; margin: 0; }
.typing { align-self: flex-start; color: var(--muted); font-size: 13px; }

.phone { max-width: 460px; height: 600px; display: flex; flex-direction: column; padding: 0; overflow: hidden; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--text); color: var(--panel); padding: 10px 18px; border-radius: 10px;
  transition: transform 0.25s; z-index: 50; max-width: calc(100vw - 32px);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.steps { padding-left: 20px; line-height: 1.7; }
code { background: var(--bg); padding: 1px 6px; border-radius: 5px; font-size: 13px; border: 1px solid var(--line); word-break: break-all; }

@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .nav { width: 100%; display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .nav a { white-space: nowrap; }
  .view { padding: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .inbox { grid-template-columns: 1fr; height: auto; }
  .conv-list { max-height: 260px; }
  .thread { height: 70vh; }
  .topbar { padding: 10px 16px; gap: 10px; }
}

/* Brenda panelit të Trend Workforce (iframe) */
body.embed .topbar { padding: 8px 16px; }
body.embed .topbar .brand, body.embed #logoutBtn { display: none; }
body.embed .layout { min-height: 100vh; }
body.embed .view { padding: 16px; }
