/* ============================================================
   MoST Sindh Portal — Components
   All UI components: buttons, cards, tables, forms, badges,
   modals, nav, chat, sidebar, header, toasts, etc.
   Mobile-first, RTL-aware
   ============================================================ */

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  border-radius: var(--r-md);
  font-weight: 600; font-size: .9rem;
  line-height: 1.2; white-space: nowrap;
  transition: all var(--dur-fast) var(--ease);
  border: 1.5px solid transparent;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .icon { width: 18px; height: 18px; }

.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: var(--sh-sm);
}
.btn-primary:hover { background: var(--accent-strong); box-shadow: var(--sh-md); text-decoration: none; }

.btn-dark { background: var(--brand); color: #fff; }
.btn-dark:hover { background: var(--brand-2); text-decoration: none; }

.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); border-color: var(--ink-400); text-decoration: none; }

.btn-ghost { background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

.btn-danger { background: var(--red-500); color: #fff; }
.btn-danger:hover { background: #dc2626; text-decoration: none; }

.btn-sm { padding: 6px 12px; font-size: .82rem; border-radius: var(--r-sm); }
.btn-lg { padding: 14px 24px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: 9px; aspect-ratio: 1; }
.btn-icon.btn-sm { padding: 6px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--sh-xs);
}
.card-hover { transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }
.card-hover:hover { box-shadow: var(--sh-md); transform: translateY(-2px); }
.card-pad-sm { padding: 14px; }
.card-pad-lg { padding: 24px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.card-title { font-weight: 700; font-size: 1.02rem; display: flex; align-items: center; gap: 8px; }

.card-clickable { cursor: pointer; transition: all var(--dur) var(--ease); }
.card-clickable:hover { border-color: var(--accent); box-shadow: var(--sh-md); }

/* KPI stat card */
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px; position: relative; overflow: hidden;
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.stat-card:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }
.stat-card .stat-ico {
  width: 42px; height: 42px; border-radius: var(--r-md);
  display: grid; place-items: center; margin-bottom: 10px;
}
.stat-card .stat-val { font-size: 1.8rem; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.stat-card .stat-label { color: var(--text-muted); font-size: .82rem; margin-top: 4px; font-weight: 500; }
.stat-card .stat-trend { font-size: .75rem; margin-top: 6px; display: flex; align-items: center; gap: 4px; }
.trend-up { color: var(--green-600); }
.trend-down { color: var(--red-500); }

/* ============================================================
   BADGES & CHIPS
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--r-full);
  font-size: .74rem; font-weight: 600; line-height: 1.5;
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.badge-green  { background: var(--green-100); color: var(--green-600); }
.badge-blue   { background: var(--blue-100);  color: var(--blue-500); }
.badge-amber  { background: var(--amber-100); color: #b45309; }
.badge-red    { background: var(--red-100);   color: var(--red-500); }
.badge-purple { background: var(--purple-100);color: var(--purple-500); }
.badge-gray   { background: var(--ink-200);   color: var(--ink-600); }
.badge-cyan   { background: var(--cyan-100);  color: #0e7490; }
.badge-pink   { background: var(--pink-100);  color: #be185d; }
.badge-solid-green { background: var(--green-500); color: #fff; }

/* status badge colors via data attr */
.badge[data-status="open"]       { background: var(--blue-100);  color: var(--blue-500); }
.badge[data-status="in_progress"]{ background: var(--amber-100); color: #b45309; }
.badge[data-status="resolved"]   { background: var(--green-100); color: var(--green-600); }
.badge[data-status="closed"]     { background: var(--ink-200);   color: var(--ink-600); }
.badge[data-status="reopened"]   { background: var(--red-100);   color: var(--red-500); }

.badge[data-priority="urgent"] { background: var(--red-100);   color: var(--red-500); }
.badge[data-priority="normal"] { background: var(--blue-100);  color: var(--blue-500); }
.badge[data-priority="low"]    { background: var(--ink-200);   color: var(--ink-500); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--r-full);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: .84rem; font-weight: 500; color: var(--text-soft);
  cursor: pointer; transition: all var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.chip:hover { border-color: var(--ink-400); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip.active .icon { color: #fff; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 6px; color: var(--text); }
.form-label .req { color: var(--red-500); }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: 5px; }

.input, .select, .textarea {
  width: 100%; padding: 11px 13px;
  border: 1.5px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  font-size: .92rem; transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  -webkit-appearance: none; appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-400); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 100px; font-family: inherit; line-height: 1.6; }
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}
html[dir="rtl"] .select { background-position: left 12px center; padding-right: 13px; padding-left: 36px; }

.input-group { display: flex; align-items: center; gap: 0; }
.input-group .input { border-radius: 0; }
.input-group .input:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.input-group .input:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }
.input-group .btn { border-radius: 0; }

.input-with-icon { position: relative; }
.input-with-icon .input { padding-left: 40px; }
html[dir="rtl"] .input-with-icon .input { padding-left: 13px; padding-right: 40px; }
.input-with-icon .lead-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-400); pointer-events: none; }
html[dir="rtl"] .input-with-icon .lead-icon { left: auto; right: 12px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; cursor: pointer; inset: 0; background: var(--ink-300); border-radius: var(--r-full); transition: var(--dur) var(--ease); }
.switch .slider::before { content: ''; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: var(--dur) var(--ease); box-shadow: var(--sh-sm); }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(20px); }
html[dir="rtl"] .switch input:checked + .slider::before { transform: translateX(-20px); }

/* checkbox/radio cards */
.check-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--r-md);
  cursor: pointer; transition: all var(--dur-fast) var(--ease);
}
.check-card:hover { border-color: var(--ink-400); }
.check-card input { accent-color: var(--accent); width: 18px; height: 18px; }
.check-card:has(input:checked) { border-color: var(--accent); background: var(--green-50); }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; min-width: 600px; }
table.tbl th, table.tbl td { padding: 12px 14px; text-align: left; vertical-align: middle; }
html[dir="rtl"] table.tbl th, html[dir="rtl"] table.tbl td { text-align: right; }
table.tbl thead th {
  background: var(--surface-2); font-weight: 600; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-muted); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
table.tbl tbody tr { border-bottom: 1px solid var(--border); transition: background var(--dur-fast); }
table.tbl tbody tr:last-child { border-bottom: none; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl td.link { cursor: pointer; }
table.tbl td.link:hover { color: var(--accent-strong); }

@media (max-width: 700px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
  .table-cards tr { border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 10px; padding: 6px 4px; }
  .table-cards td { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; border: none; text-align: right; }
  html[dir="rtl"] .table-cards td { text-align: left; }
  .table-cards td::before { content: attr(data-label); font-weight: 600; font-size: .76rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
  .table-cards td.full-row { width: 100%; }
  .table-cards td.full-row::before { display: none; }
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--brand);
  color: #c5d3e8;
  display: flex; flex-direction: column;
  z-index: var(--z-sidebar);
  transition: width var(--dur) var(--ease), transform var(--dur-slow) var(--ease);
  overflow: hidden;
}
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .sidebar .nav-label,
body.sidebar-collapsed .sidebar .brand-text,
body.sidebar-collapsed .sidebar .nav-section-label { opacity: 0; pointer-events: none; }
body.sidebar-collapsed .sidebar .nav-item { justify-content: center; }

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  height: var(--header-h);
  flex-shrink: 0;
}
.brand-logo {
  width: 34px; height: 34px; border-radius: var(--r-sm); flex-shrink: 0;
  background: linear-gradient(135deg, var(--green-500), var(--green-600));
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1.1rem;
  box-shadow: 0 2px 8px rgba(16,185,129,.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; transition: opacity var(--dur); white-space: nowrap; }
.brand-text strong { color: #fff; font-size: .92rem; font-weight: 700; }
.brand-text small { color: var(--ink-400); font-size: .68rem; }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 10px 20px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border: none; }

.nav-section-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  color: rgba(197,211,232,.5); padding: 14px 12px 6px; font-weight: 600;
  transition: opacity var(--dur); white-space: nowrap;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-md);
  color: #b5c5dc; font-size: .9rem; font-weight: 500;
  margin-bottom: 2px; transition: all var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent; white-space: nowrap; position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(16,185,129,.16); color: var(--green-400); }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 20%; bottom: 20%; width: 3px; background: var(--green-500); border-radius: 0 2px 2px 0; }
html[dir="rtl"] .nav-item.active::before { left: auto; right: 0; border-radius: 2px 0 0 2px; }
.nav-item .icon { flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--red-500); color: #fff; font-size: .68rem; font-weight: 700; padding: 1px 7px; border-radius: var(--r-full); min-width: 20px; text-align: center; }
html[dir="rtl"] .nav-badge { margin-left: 0; margin-right: auto; }
.nav-label { transition: opacity var(--dur); }

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); flex-shrink: 0; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r-md); cursor: pointer; transition: background var(--dur-fast); }
.sidebar-user:hover { background: rgba(255,255,255,.07); }
.sidebar-user .avatar { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-weight: 700; font-size: .82rem; color: #fff; }

/* mobile drawer */
.sidebar-overlay { position: fixed; inset: 0; background: rgba(10,22,40,.55); backdrop-filter: blur(2px); z-index: calc(var(--z-sidebar) - 1); opacity: 0; pointer-events: none; transition: opacity var(--dur); }
.sidebar-overlay.show { opacity: 1; pointer-events: auto; }

/* ============================================================
   HEADER (top bar)
   ============================================================ */
.topbar {
  height: var(--header-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  padding: 0 clamp(12px, 3vw, 24px);
  position: sticky; top: 0; z-index: var(--z-header);
  backdrop-filter: blur(8px);
}
.topbar-title { font-weight: 700; font-size: 1.05rem; flex: 1; min-width: 0; }
.topbar-title .crumb { color: var(--text-muted); font-weight: 500; font-size: .85rem; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: var(--r-md);
  display: grid; place-items: center; color: var(--text-soft);
  transition: all var(--dur-fast) var(--ease); position: relative; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .ping-dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; background: var(--red-500); border-radius: 50%; border: 2px solid var(--surface); }
html[dir="rtl"] .icon-btn .ping-dot { right: auto; left: 8px; }

.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem; color: #fff; flex-shrink: 0; overflow: hidden; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.2rem; }

/* ============================================================
   MOBILE BOTTOM NAV
   ============================================================ */
.mobile-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: var(--z-mobile-nav);
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -2px 12px rgba(15,23,42,.06);
}
.mobile-nav-inner { display: flex; align-items: center; justify-content: space-around; height: 100%; }
.mobile-nav-item { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink-400); font-size: .65rem; font-weight: 600; padding: 6px 10px; border-radius: var(--r-md); transition: color var(--dur-fast); position: relative; -webkit-tap-highlight-color: transparent; }
.mobile-nav-item.active { color: var(--accent-strong); }
.mobile-nav-item .icon { width: 22px; height: 22px; }
.mobile-nav-item .mb-badge { position: absolute; top: 2px; right: 8px; background: var(--red-500); color: #fff; font-size: .58rem; border-radius: var(--r-full); padding: 0 4px; min-width: 14px; height: 14px; display: grid; place-items: center; }
html[dir="rtl"] .mobile-nav-item .mb-badge { right: auto; left: 8px; }

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--sh-xl); }
  html[dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .content-area { margin-left: 0 !important; }
  body.sidebar-collapsed .content-area { margin-left: 0; }
  .mobile-nav { display: block; }
  body.sidebar-collapsed .sidebar { width: var(--sidebar-w); }
  body.sidebar-collapsed .nav-label, body.sidebar-collapsed .brand-text, body.sidebar-collapsed .nav-section-label { opacity: 1; pointer-events: auto; }
}

/* ============================================================
   DROPDOWN / NOTIFICATION PANEL
   ============================================================ */
.dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 360px; max-width: calc(100vw - 24px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--sh-lg);
  z-index: var(--z-dropdown); overflow: hidden;
  animation: slideDown var(--dur) var(--ease);
}
html[dir="rtl"] .dropdown { right: auto; left: 0; }
.dropdown-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.dropdown-body { max-height: 420px; overflow-y: auto; }
.dropdown-foot { padding: 10px 16px; border-top: 1px solid var(--border); text-align: center; }

.notif-item { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); transition: background var(--dur-fast); cursor: pointer; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: var(--green-50); }
.notif-item:last-child { border-bottom: none; }
.notif-ico { width: 36px; height: 36px; border-radius: var(--r-md); display: grid; place-items: center; flex-shrink: 0; }
.notif-body { flex: 1; min-width: 0; }
.notif-body strong { font-size: .86rem; display: block; }
.notif-body p { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.notif-time { font-size: .72rem; color: var(--ink-400); margin-top: 4px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10,22,40,.6);
  backdrop-filter: blur(3px); z-index: var(--z-overlay);
  display: grid; place-items: center; padding: 16px;
  animation: fadeIn var(--dur) var(--ease);
}
.modal {
  background: var(--surface); border-radius: var(--r-xl);
  width: 100%; max-width: 520px; max-height: calc(100dvh - 32px);
  overflow: hidden; display: flex; flex-direction: column;
  box-shadow: var(--sh-xl); animation: scaleIn var(--dur) var(--ease-out);
}
.modal.lg { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 1.1rem; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ============================================================
   TOASTS
   ============================================================ */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
html[dir="rtl"] .toast-container { right: auto; left: 20px; }
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 12px 16px; min-width: 260px;
  box-shadow: var(--sh-lg); display: flex; align-items: flex-start; gap: 10px;
  animation: slideUp var(--dur) var(--ease-out); border-left: 4px solid var(--accent);
}
html[dir="rtl"] .toast { border-left: 1px solid var(--border); border-right: 4px solid var(--accent); }
.toast.success { border-left-color: var(--green-500); }
.toast.error { border-left-color: var(--red-500); }
.toast.warn { border-left-color: var(--amber-500); }
.toast.info { border-left-color: var(--blue-500); }
.toast .toast-ico { flex-shrink: 0; margin-top: 1px; }
.toast .toast-body { flex: 1; }
.toast .toast-title { font-weight: 600; font-size: .9rem; }
.toast .toast-msg { font-size: .82rem; color: var(--text-muted); margin-top: 2px; }
@media (max-width: 600px) {
  .toast-container { left: 12px; right: 12px; bottom: calc(var(--bottom-nav-h) + 12px); max-width: none; }
}

/* ============================================================
   CHAT / MESSAGE THREAD
   ============================================================ */
.chat-thread { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 10px; max-width: 85%; animation: slideUp var(--dur) var(--ease-out); }
.msg.msg-company { align-self: flex-start; }
.msg.msg-staff { align-self: flex-end; flex-direction: row-reverse; }
.msg.msg-ai { align-self: flex-start; max-width: 90%; }
html[dir="rtl"] .msg.msg-staff { flex-direction: row; }
html[dir="rtl"] .msg.msg-company { flex-direction: row-reverse; align-self: flex-end; }
html[dir="rtl"] .msg.msg-ai { align-self: flex-start; }

.msg-avatar { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; font-size: .78rem; font-weight: 700; color: #fff; }
.msg-bubble { padding: 10px 14px; border-radius: var(--r-lg); font-size: .9rem; line-height: 1.55; }
.msg-meta { font-size: .7rem; color: var(--ink-400); margin-top: 4px; }

.msg-company .msg-bubble { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: var(--r-xs); }
.msg-staff .msg-bubble { background: var(--brand); color: #fff; border-bottom-right-radius: var(--r-xs); }
.msg-staff .msg-meta { color: var(--ink-400); text-align: right; }
.msg-ai .msg-bubble { background: linear-gradient(135deg, rgba(16,185,129,.08), rgba(59,130,246,.06)); border: 1px solid var(--green-100); border-bottom-left-radius: var(--r-xs); }
.msg-ai .ai-tag { display: inline-flex; align-items: center; gap: 4px; font-size: .68rem; font-weight: 700; color: var(--accent-strong); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; }

.chat-input { display: flex; gap: 8px; align-items: flex-end; padding: 12px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-input .textarea { min-height: 44px; max-height: 120px; }

/* ============================================================
   STAR RATING
   ============================================================ */
.stars { display: inline-flex; gap: 2px; }
.star { color: var(--ink-300); cursor: pointer; transition: color var(--dur-fast); }
.star.filled, .star:hover, .star:hover ~ .star { }
.star.active, .stars:hover .star { color: var(--amber-500); }
.stars .star:hover { transform: scale(1.15); }

/* ============================================================
   TIMELINE
   ============================================================ */
.timeline { position: relative; padding-left: 24px; }
html[dir="rtl"] .timeline { padding-left: 0; padding-right: 24px; }
.timeline::before { content: ''; position: absolute; left: 9px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
html[dir="rtl"] .timeline::before { left: auto; right: 9px; }
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { position: absolute; left: -19px; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); display: grid; place-items: center; }
html[dir="rtl"] .timeline-dot { left: auto; right: -19px; }
.timeline-dot.warn { border-color: var(--amber-500); }
.timeline-dot.danger { border-color: var(--red-500); }
.timeline-content { font-size: .88rem; }
.timeline-content .time { font-size: .74rem; color: var(--ink-400); }

/* ============================================================
   PROGRESS / SLA
   ============================================================ */
.progress { height: 8px; background: var(--ink-100); border-radius: var(--r-full); overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: var(--r-full); transition: width var(--dur-slow) var(--ease); }
.progress-bar.warn { background: var(--amber-500); }
.progress-bar.danger { background: var(--red-500); }

.sla-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: var(--r-sm); font-size: .74rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.sla-safe { background: var(--green-100); color: var(--green-600); }
.sla-warn { background: var(--amber-100); color: #b45309; }
.sla-danger { background: var(--red-100); color: var(--red-500); }
.sla-breach { background: var(--red-500); color: #fff; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty .empty-ico { width: 64px; height: 64px; margin: 0 auto 14px; color: var(--ink-300); }
.empty h3 { color: var(--text-soft); margin-bottom: 6px; font-size: 1.05rem; }
.empty p { max-width: 360px; margin: 0 auto; font-size: .88rem; }

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--ink-200); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
.spinner-lg { width: 40px; height: 40px; border-width: 3.5px; }
.spinner-on-green { border-color: rgba(255,255,255,.3); border-top-color: #fff; }
.loading-center { display: grid; place-items: center; padding: 60px 20px; gap: 12px; color: var(--text-muted); font-size: .88rem; }

.btn .spinner { width: 16px; height: 16px; border-width: 2px; }

/* ============================================================
   TABS
   ============================================================ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 10px 16px; font-weight: 600; font-size: .9rem; color: var(--text-muted); border-bottom: 2px solid transparent; transition: all var(--dur-fast); white-space: nowrap; -webkit-tap-highlight-color: transparent; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-strong); border-bottom-color: var(--accent); }

/* ============================================================
   LANDING PAGE
   ============================================================ */
.landing-hero { background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 50%, #0d2438 100%); color: #fff; position: relative; overflow: hidden; }
.landing-hero::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 80% 20%, rgba(16,185,129,.18), transparent 50%), radial-gradient(circle at 20% 80%, rgba(59,130,246,.12), transparent 50%); pointer-events: none; }
.hero-inner { max-width: var(--content-max); margin: 0 auto; padding: clamp(40px, 8vw, 80px) clamp(20px, 5vw, 40px); position: relative; }
.hero-badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; background: rgba(16,185,129,.15); border: 1px solid rgba(16,185,129,.3); border-radius: var(--r-full); font-size: .82rem; font-weight: 600; color: var(--green-400); margin-bottom: 18px; }
.hero-title { font-size: clamp(1.9rem, 6vw, 3.4rem); font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; max-width: 760px; }
.hero-title .accent { color: var(--green-400); }
.hero-sub { font-size: clamp(1rem, 2.5vw, 1.2rem); color: #b5c5dc; max-width: 600px; margin-top: 16px; line-height: 1.6; }
.hero-cta { display: flex; gap: 12px; margin-top: 28px; flex-wrap: wrap; }
.hero-stats { display: flex; gap: clamp(20px, 5vw, 48px); margin-top: 40px; flex-wrap: wrap; }
.hero-stat .num { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 800; color: var(--green-400); line-height: 1; }
.hero-stat .lbl { font-size: .82rem; color: #8da2bd; margin-top: 4px; }

.feature-card { padding: 24px; height: 100%; }
.feature-ico { width: 48px; height: 48px; border-radius: var(--r-md); display: grid; place-items: center; margin-bottom: 14px; }
.step-num { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 1rem; flex-shrink: 0; }

.faq-item { border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 10px; overflow: hidden; background: var(--surface); }
.faq-q { display: flex; align-items: center; justify-content: space-between; padding: 16px; cursor: pointer; font-weight: 600; font-size: .95rem; gap: 12px; }
.faq-q .chev { transition: transform var(--dur); color: var(--text-muted); flex-shrink: 0; }
.faq-item.open .faq-q .chev { transform: rotate(180deg); }
.faq-a { max-height: 0; overflow: hidden; transition: max-height var(--dur-slow) var(--ease); color: var(--text-muted); }
.faq-item.open .faq-a { max-height: 400px; padding: 0 16px 16px; }

/* Auth pages */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, var(--navy-900), var(--navy-700)); }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border-radius: var(--r-xl); padding: clamp(24px, 5vw, 40px); box-shadow: var(--sh-xl); }
.auth-card.lg { max-width: 600px; }
.auth-logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 6px; }
.auth-logo .brand-logo { width: 44px; height: 44px; font-size: 1.4rem; }
.auth-logo h2 { color: var(--text); font-size: 1.2rem; }
.auth-sub { text-align: center; color: var(--text-muted); font-size: .9rem; margin-bottom: 24px; }

.demo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; }
@media (max-width: 420px) { .demo-grid { grid-template-columns: 1fr; } }
.demo-btn { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md); font-size: .82rem; font-weight: 600; transition: all var(--dur-fast); text-align: left; }
.demo-btn:hover { border-color: var(--accent); background: var(--green-50); text-decoration: none; }
.demo-btn .davatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; color: #fff; flex-shrink: 0; }

/* ============================================================
   MISC HELPERS
   ============================================================ */
.divider { height: 1px; background: var(--border); margin: 16px 0; border: none; }
.divider-v { width: 1px; align-self: stretch; background: var(--border); }
.tag { display: inline-flex; padding: 2px 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-xs); font-size: .74rem; color: var(--text-soft); }
.code { font-family: ui-monospace, monospace; background: var(--surface-2); padding: 2px 6px; border-radius: var(--r-xs); font-size: .84em; color: var(--accent-strong); }

.kbd { display: inline-block; padding: 1px 6px; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: var(--r-xs); font-family: ui-monospace, monospace; font-size: .76rem; }

.insight-card { display: flex; gap: 12px; padding: 14px; border-radius: var(--r-md); border: 1px solid var(--border); }
.insight-card.warning { border-left: 4px solid var(--amber-500); background: var(--amber-50); }
.insight-card.success { border-left: 4px solid var(--green-500); background: var(--green-50); }
.insight-card.info    { border-left: 4px solid var(--blue-500); background: var(--blue-100); }
.insight-card.danger  { border-left: 4px solid var(--red-500); background: var(--red-50); }
html[dir="rtl"] .insight-card { border-left: 1px solid var(--border); border-right: 4px solid currentColor; }
.insight-card .ins-ico { flex-shrink: 0; }
.insight-card .ins-title { font-weight: 700; font-size: .88rem; }
.insight-card .ins-desc { font-size: .82rem; color: var(--text-soft); margin-top: 2px; }

.dept-color-bar { width: 4px; align-self: stretch; border-radius: var(--r-full); flex-shrink: 0; }

/* hide number input arrows */
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
