/* ==========================================================================
   University Ticketing & Tasks — stylesheet
   RTL-aware (logical properties), responsive, no external dependencies.
   Palette: teal/emerald primary, amber accent, stone neutrals.
   ========================================================================== */

@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Regular.ttf') format('truetype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Medium.ttf') format('truetype');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-SemiBold.ttf') format('truetype');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Bold.ttf') format('truetype');
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  /* palette — sky blue theme */
  --blue-50:#f0f9ff; --blue-100:#e0f2fe; --blue-200:#bae6fd; --blue-300:#7dd3fc;
  --blue-400:#38bdf8; --blue-500:#0ea5e9; --blue-600:#0284c7; --blue-700:#0369a1;
  --blue-800:#075985; --blue-900:#0c4a6e;

  --teal-50:#f0fdfa; --teal-100:#ccfbf1; --teal-200:#99f6e4; --teal-300:#5eead4;
  --teal-400:#2dd4bf; --teal-500:#14b8a6; --teal-600:#0d9488; --teal-700:#0f766e;
  --teal-800:#115e59; --teal-900:#134e4a;

  --amber-50:#fffbeb; --amber-100:#fef3c7; --amber-400:#fbbf24; --amber-500:#f59e0b; --amber-600:#d97706;
  --rose-50:#fff1f2; --rose-100:#ffe4e6; --rose-400:#fb7185; --rose-500:#f43f5e; --rose-600:#e11d48;
  --emerald-50:#ecfdf5; --emerald-100:#d1fae5; --emerald-500:#10b981; --emerald-600:#059669; --emerald-700:#047857;
  --violet-50:#f5f3ff; --violet-500:#8b5cf6;

  --stone-0:#fcfcfa; --stone-50:#f8fafc; --stone-100:#f1f5f9; --stone-200:#e2e8f0;
  --stone-300:#cbd5e1; --stone-400:#94a3b8; --stone-500:#64748b; --stone-600:#475569;
  --stone-700:#334155; --stone-800:#1e293b; --stone-900:#0f172a; --stone-950:#020617;

  /* semantic — smooth light blue */
  --bg: #f0f9ff;
  --bg-elev: #ffffff;
  --bg-soft: #e0f2fe;
  --surface: #ffffff;
  --surface-2: #f0f9ff;
  --border: #e0f2fe;
  --border-strong: #bae6fd;
  --text: #0c4a6e;
  --text-soft: #0369a1;
  --text-mute: #7dd3fc;
  --primary: #0ea5e9;
  --primary-hover: #0284c7;
  --primary-soft: #e0f2fe;
  --primary-ink: #075985;
  --accent: #0d9488;
  --ring: #38bdf8;

  --radius-sm: 10px; --radius: 14px; --radius-lg: 18px; --radius-xl: 24px; --radius-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(14,165,233,.06);
  --shadow-sm: 0 1px 3px rgba(14,165,233,.08), 0 1px 2px rgba(14,165,233,.04);
  --shadow: 0 4px 12px rgba(14,165,233,.08), 0 2px 4px rgba(14,165,233,.04);
  --shadow-md: 0 8px 24px rgba(14,165,233,.12), 0 3px 8px rgba(14,165,233,.06);
  --shadow-lg: 0 20px 48px rgba(14,165,233,.16), 0 8px 16px rgba(14,165,233,.08);

  --topbar-h: 60px;
  --sidebar-w: 240px;
  --container: 1180px;

  --font: 'Vazirmatn', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
}
/* Ensure font applies to ALL elements */
*, *::before, *::after { font-family: var(--font); }
input, select, textarea, button { font-family: var(--font); }
table, th, td { font-family: var(--font); }
canvas { font-family: var(--font); }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
img, svg { max-width: 100%; }
h1,h2,h3,h4 { margin: 0 0 .4em; font-weight: 700; line-height: 1.3; color: var(--text); }
p { margin: 0 0 1em; }
small { color: var(--text-soft); }

/* ---------- icons ---------- */
.ico { width: 20px; height: 20px; flex: 0 0 auto; display: inline-block; vertical-align: middle; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  color: var(--text-soft); background: transparent; border: 1px solid transparent;
  cursor: pointer; transition: all .15s ease; position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .ico { width: 20px; height: 20px; }

/* ---------- app shell ---------- */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.app-body { background: var(--bg); }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding-inline: 16px;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-block-end: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; }
.brand:hover { color: var(--primary); }
.brand-logo { width: 32px; height: 32px; border-radius: 8px; object-fit: contain; flex: 0 0 auto; }
.auth-logo { max-height: 120px; width: auto; height: auto; object-fit: contain; margin-bottom: 8px; border-radius: 12px; }
.brand-text { font-size: 16px; letter-spacing: -.01em; }
.topbar-spacer { flex: 1; }

.locale-switch { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; }
.locale-link { padding: 4px 8px; border-radius: var(--radius-sm); color: var(--text-soft); }
.locale-link.active { background: var(--primary-soft); color: var(--primary-ink); }
.locale-sep { color: var(--text-mute); }

.notif-btn .notif-badge {
  position: absolute; top: 4px; inset-inline-end: 4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--rose-500); color: #fff; border-radius: var(--radius-pill);
  font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}

.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: var(--radius-pill); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 11px; color: var(--text-soft); }

/* ---------- layout ---------- */
.layout { display: flex; flex: 1; align-items: stretch; }
.sidebar {
  flex: 0 0 var(--sidebar-w); width: var(--sidebar-w);
  background: linear-gradient(180deg, #ffffff 0%, #f0f9ff 100%);
  border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h));
  overflow: hidden;
}
.nav { padding: 10px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; overflow-x: hidden; }
.nav::-webkit-scrollbar { width: 4px; }
.nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-pill);
  color: var(--text-soft); font-weight: 500; font-size: 13px;
  transition: all .2s cubic-bezier(.4,0,.2,1); position: relative;
  opacity: 0; transform: translateX(8px);
  animation: navItemIn .3s ease forwards;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
[dir="rtl"] .nav-item { transform: translateX(-8px); }
@keyframes navItemIn { to { opacity: 1; transform: none; } }
.nav-item:nth-child(1) { animation-delay: .02s; }
.nav-item:nth-child(2) { animation-delay: .05s; }
.nav-item:nth-child(3) { animation-delay: .08s; }
.nav-item:nth-child(4) { animation-delay: .11s; }
.nav-item:nth-child(5) { animation-delay: .14s; }
.nav-item:nth-child(6) { animation-delay: .17s; }
.nav-item:nth-child(7) { animation-delay: .2s; }
.nav-item:nth-child(8) { animation-delay: .23s; }
.nav-item:nth-child(9) { animation-delay: .26s; }
.nav-item:nth-child(10) { animation-delay: .29s; }
.nav-item:nth-child(11) { animation-delay: .32s; }
.nav-item:nth-child(12) { animation-delay: .35s; }
.nav-item:nth-child(13) { animation-delay: .38s; }
.nav-item:nth-child(14) { animation-delay: .41s; }
.nav-item:hover { background: var(--primary-soft); color: var(--primary-ink); }
.nav-item.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff; font-weight: 600;
  box-shadow: 0 2px 8px rgba(14,165,233,.3);
}
.nav-item.active::before { display: none; }
.nav-item .ico { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item span { overflow: hidden; text-overflow: ellipsis; }

.sidebar-foot { padding: 12px; border-block-start: 1px solid var(--border); }
.hint-card { background: var(--surface-2); border-radius: var(--radius); padding: 12px; }
.hint-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-mute); margin-bottom: 8px; }

.drawer-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 45; border: 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 24px; max-width: var(--container); width: 100%; margin-inline: auto; flex: 1; }

/* ---------- page head ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 700; margin: 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius);
  font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1;
  border: 1px solid transparent; cursor: pointer; transition: all .15s ease;
  text-decoration: none; white-space: nowrap; user-select: none;
}
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .ico { width: 17px; height: 17px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-soft { background: var(--primary-soft); color: var(--primary-ink); }
.btn-soft:hover { background: var(--teal-100); color: var(--primary-ink); }
.btn-danger { background: var(--rose-500); color: #fff; }
.btn-danger:hover { background: var(--rose-600); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-sm .ico { width: 15px; height: 15px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.card-pad { padding: 18px; }
.card-head { padding: 16px 18px; border-block-end: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; font-size: 16px; }
.card-body { padding: 18px; }
.card-foot { padding: 12px 18px; border-block-start: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---------- stat grid ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px; position: relative; overflow: hidden; transition: transform .2s ease, box-shadow .2s ease;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-label { font-size: 12px; color: var(--text-soft); font-weight: 600; margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-trend { font-size: 12px; color: var(--emerald-600); margin-top: 6px; font-weight: 600; }
.stat .stat-ico { position: absolute; inset-inline-end: -8px; bottom: -10px; opacity: .08; }
.stat .stat-ico .ico { width: 80px; height: 80px; }
.stat.teal { border-block-start: 3px solid var(--teal-500); }
.stat.amber { border-block-start: 3px solid var(--amber-500); }
.stat.emerald { border-block-start: 3px solid var(--emerald-500); }
.stat.rose { border-block-start: 3px solid var(--rose-500); }
.stat.violet { border-block-start: 3px solid var(--violet-500); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { padding: 11px 14px; text-align: start; border-block-end: 1px solid var(--border); }
table.tbl thead th { background: var(--surface-2); font-weight: 700; color: var(--text-soft); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; }
table.tbl tbody tr { transition: background .12s ease; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-block-end: 0; }
.cell-strong { font-weight: 600; color: var(--text); }
.cell-mute { color: var(--text-soft); }
.cell-mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 13px; }
.row-link { cursor: pointer; }
.row-link:hover { background: var(--primary-soft) !important; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-no-dot::before { display: none; }
.badge-open { background: var(--amber-50); color: var(--amber-600); }
.badge-in_progress { background: var(--teal-50); color: var(--teal-800); }
.badge-resolved { background: var(--emerald-50); color: var(--emerald-700); }
.badge-closed { background: var(--stone-100); color: var(--stone-600); }
.badge-reopened { background: var(--rose-50); color: var(--rose-600); }
.badge-pending { background: var(--amber-50); color: var(--amber-600); }
.badge-done { background: var(--emerald-50); color: var(--emerald-700); }
.badge-cancelled { background: var(--stone-100); color: var(--stone-600); }
.badge-low { background: var(--stone-100); color: var(--stone-600); }
.badge-normal { background: var(--teal-50); color: var(--teal-700); }
.badge-high { background: var(--amber-50); color: var(--amber-600); }
.badge-urgent { background: var(--rose-50); color: var(--rose-600); }
.badge-soft { background: var(--surface-2); color: var(--text-soft); }
.badge-primary { background: var(--primary-soft); color: var(--primary-ink); }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.label { font-size: 13px; font-weight: 600; color: var(--text); }
.label .req { color: var(--rose-500); }
.hint { font-size: 12px; color: var(--text-soft); }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.select { appearance: none; 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='%2378716c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 12px center; padding-inline-start: 12px; padding-inline-end: 34px; }
[dir="rtl"] .select { background-position: right 12px center; padding-inline-start: 34px; padding-inline-end: 12px; }
.input-group { display: flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.input-group .input { border: 0; border-radius: 0; }
.input-group .input-adorn { display: flex; align-items: center; padding: 0 12px; background: var(--surface-2); color: var(--text-soft); }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 16px; height: 16px; }

/* search/filter bar */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filter-bar .search { position: relative; flex: 1; min-width: 200px; }
.filter-bar .search .ico { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-mute); pointer-events: none; }
.filter-bar .search .input { padding-inline-start: 38px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 3px; gap: 2px; }
.seg a { padding: 6px 12px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; color: var(--text-soft); }
.seg a.active { background: var(--primary); color: #fff; }

/* ---------- ticket thread ---------- */
.thread { display: flex; flex-direction: column; gap: 14px; }
.msg { display: flex; gap: 12px; }
.msg .msg-avatar { width: 36px; height: 36px; border-radius: 50%; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; font-size: 14px; }
.msg.from-creator .msg-avatar { background: linear-gradient(135deg, var(--teal-500), var(--teal-700)); }
.msg.from-staff .msg-avatar { background: linear-gradient(135deg, var(--amber-500), var(--amber-600)); }
.msg.from-admin .msg-avatar { background: linear-gradient(135deg, var(--violet-500), var(--teal-700)); }
.msg.from-student .msg-avatar { background: linear-gradient(135deg, var(--teal-400), var(--teal-600)); }
.msg-body { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.msg-name { font-weight: 700; font-size: 14px; }
.msg-role { font-size: 11px; color: var(--text-soft); background: var(--surface-2); padding: 1px 7px; border-radius: var(--radius-pill); }
.msg-time { font-size: 12px; color: var(--text-mute); }
.msg-bubble { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.internal .msg-bubble { background: var(--amber-50); border-color: var(--amber-100); border-inline-start: 3px solid var(--amber-500); }
.msg.internal .msg-bubble::before { content: '🔒 '; }

/* ticket meta panel */
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.kv { display: flex; flex-direction: column; gap: 2px; }
.kv .k { font-size: 11px; color: var(--text-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kv .v { font-size: 14px; color: var(--text); font-weight: 500; }

/* timeline / history */
.timeline { display: flex; flex-direction: column; gap: 0; position: relative; }
.timeline::before { content: ''; position: absolute; inset-inline-start: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-inline-start: 28px; padding-block: 6px; font-size: 13px; }
.tl-item::before { content: ''; position: absolute; inset-inline-start: 3px; top: 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); }
.tl-time { color: var(--text-mute); font-size: 11px; }
.tl-actor { font-weight: 600; }

/* ticket list rows */
.ticket-row { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-block-end: 1px solid var(--border); transition: background .12s; }
.ticket-row:hover { background: var(--surface-2); }
.ticket-row:last-child { border-block-end: 0; }
.ticket-row-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ticket-row-ref { font-family: ui-monospace, monospace; font-size: 12px; font-weight: 700; color: var(--primary); }
.ticket-row-subject { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-row-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-soft); }
.ticket-row-meta span { display: inline-flex; align-items: center; gap: 4px; }

.empty-state { text-align: center; padding: 56px 20px; color: var(--text-soft); }
.empty-state .ico { width: 56px; height: 56px; color: var(--text-mute); opacity: .5; margin-bottom: 12px; }
.empty-state h3 { color: var(--text); }

/* ---------- flash ---------- */
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.flash { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius); font-size: 14px; font-weight: 500; border: 1px solid transparent; animation: flashIn .25s ease; }
@keyframes flashIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.flash-success { background: var(--emerald-50); color: var(--emerald-700); border-color: var(--emerald-100); }
.flash-error { background: var(--rose-50); color: var(--rose-600); border-color: var(--rose-100); }
.flash-warning { background: var(--amber-50); color: var(--amber-600); border-color: var(--amber-100); }
.flash-info { background: var(--teal-50); color: var(--teal-800); border-color: var(--teal-100); }
.flash-msg { flex: 1; }
.flash-close { background: none; border: 0; color: inherit; font-size: 18px; cursor: pointer; opacity: .6; line-height: 1; padding: 0; }
.flash-close:hover { opacity: 1; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-block-end: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 10px 14px; font-size: 14px; font-weight: 600; color: var(--text-soft); border-block-end: 2px solid transparent; white-space: nowrap; cursor: pointer; }
.tab.active { color: var(--primary); border-block-end-color: var(--primary); }

/* ---------- footer ---------- */
.footer {
  margin-top: auto;
  padding: 18px 24px;
  border-block-start: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: 13px; color: var(--text-soft);
}
.footer-meta { color: var(--text-mute); }
.version-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 4px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  font-family: monospace;
  margin-inline-start: 4px;
  vertical-align: middle;
}

/* ---------- auth pages — cute light blue ---------- */
.auth-body {
  background: linear-gradient(135deg, #e0f2fe 0%, #f0f9ff 30%, #ddd6fe 60%, #fce7f3 100%);
  position: relative;
}
.auth-body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(circle at 15% 25%, rgba(56,189,248,.2), transparent 35%),
    radial-gradient(circle at 85% 75%, rgba(167,139,250,.15), transparent 35%),
    radial-gradient(circle at 50% 50%, rgba(244,114,182,.08), transparent 40%);
  animation: authPulse 6s ease-in-out infinite alternate;
}
@keyframes authPulse { 0% { opacity: .7; } 100% { opacity: 1; } }
.auth-wrap { position: relative; min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; overflow: hidden; z-index: 1; }
.auth-aurora {
  position: absolute; inset: -20% -20% auto -20%; height: 60%;
  background:
    radial-gradient(ellipse 50% 40% at 20% 20%, rgba(56,189,248,.25), transparent 60%),
    radial-gradient(ellipse 40% 30% at 80% 10%, rgba(244,114,182,.15), transparent 60%),
    radial-gradient(ellipse 50% 30% at 60% 0%, rgba(167,139,250,.12), transparent 60%);
  filter: blur(40px); pointer-events: none;
  animation: auroraShift 10s ease-in-out infinite alternate;
}
@keyframes auroraShift { 0% { transform: translateX(-15px) scale(1); } 100% { transform: translateX(15px) scale(1.03); } }
.auth-card-wrap { position: relative; z-index: 1; width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 16px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.auth-brand-text { font-size: 18px; font-weight: 700; }
.auth-card {
  background: rgba(255,255,255,.85); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,.4); border-radius: var(--radius-xl); padding: 32px;
  box-shadow: 0 16px 48px rgba(14,165,233,.12), 0 0 0 1px rgba(255,255,255,.2);
}
.auth-card h1 { font-size: 22px; text-align: center; margin-bottom: 4px; color: #0c4a6e; }
.auth-card .subtitle { text-align: center; color: var(--text-soft); margin-bottom: 22px; font-size: 14px; }
.auth-foot { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.auth-powered { font-size: 12px; color: #64748b; margin: 0; }

.demo-box { background: var(--primary-soft); border: 1px dashed var(--teal-300); border-radius: var(--radius); padding: 10px 12px; font-size: 12px; color: var(--primary-ink); margin-top: 16px; line-height: 1.7; }
.demo-box code { background: #fff; padding: 1px 6px; border-radius: 4px; font-family: ui-monospace, monospace; font-size: 11px; }

/* ==========================================================================
   TWO-PANEL LOGIN (marketing + form)
   ========================================================================== */
.auth-body-split { overflow: hidden; }
.auth-wrap-split { padding: 0; align-items: stretch; }
.auth-split-container { position: relative; width: 100%; height: 100vh; height: 100dvh; display: flex; }

.login-split { display: flex; width: 100%; height: 100%; min-height: 100vh; min-height: 100dvh; }

/* ----- Marketing Panel ----- */
.login-marketing {
  flex: 1 1 55%; position: relative; overflow: hidden;
  background: linear-gradient(135deg, #0c4a6e 0%, #075985 30%, #0369a1 60%, #0ea5e9 100%);
  background-size: 200% 200%;
  color: #fff; display: flex; align-items: center; justify-content: center;
  padding: 48px 40px;
  animation: marketingGradient 12s ease-in-out infinite;
}
@keyframes marketingGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.login-marketing-inner {
  position: relative; z-index: 2; max-width: 560px; width: 100%;
  display: flex; flex-direction: column; gap: 20px;
}
.login-marketing-head { margin-bottom: 4px; animation: fadeSlideDown .6s ease-out; }
.login-marketing-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px;
  background: rgba(255,255,255,.15); backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.2);
  font-size: 13px; font-weight: 600; color: #fff;
  animation: badgePulse 3s ease-in-out infinite;
}
.login-marketing-badge .ico { width: 18px; height: 18px; }
@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,.3); }
  50% { box-shadow: 0 0 0 8px rgba(255,255,255,0); }
}

.login-hero-title {
  font-size: 32px; font-weight: 800; line-height: 1.25; margin: 0;
  color: #fff; text-shadow: 0 2px 12px rgba(0,0,0,.2);
  animation: fadeSlideUp .8s ease-out .1s both;
}
.login-hero-subtitle {
  font-size: 15px; line-height: 1.7; margin: 0;
  color: rgba(255,255,255,.85);
  animation: fadeSlideUp .8s ease-out .2s both;
}
@keyframes fadeSlideDown { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@keyframes fadeSlideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* Feature grid */
.login-feat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 8px;
}
.login-feat {
  display: flex; gap: 12px; padding: 14px;
  background: rgba(255,255,255,.08); backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px; transition: background .2s, transform .2s, border-color .2s;
  opacity: 0;
  animation: featFadeIn .5s ease-out forwards;
}
.login-feat:nth-child(1) { animation-delay: .3s; }
.login-feat:nth-child(2) { animation-delay: .4s; }
.login-feat:nth-child(3) { animation-delay: .5s; }
.login-feat:nth-child(4) { animation-delay: .6s; }
.login-feat:nth-child(5) { animation-delay: .7s; }
.login-feat:nth-child(6) { animation-delay: .8s; }
@keyframes featFadeIn { from { opacity: 0; transform: translateY(16px) scale(.95); } to { opacity: 1; transform: none; } }
.login-feat:hover { background: rgba(255,255,255,.18); transform: translateY(-3px) scale(1.02); border-color: rgba(255,255,255,.3); }
.login-feat-ico {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.15);
  animation: iconFloat 4s ease-in-out infinite;
}
.login-feat:nth-child(odd) .login-feat-ico { animation-direction: alternate; }
.login-feat:nth-child(even) .login-feat-ico { animation-delay: -2s; }
@keyframes iconFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-4px) rotate(2deg); }
}
.login-feat-ico svg { width: 20px; height: 20px; color: #fff; }
.feat-ico-tickets { background: linear-gradient(135deg, #f59e0b, #ea580c); }
.feat-ico-calendar { background: linear-gradient(135deg, #8b5cf6, #6366f1); }
.feat-ico-orgchart { background: linear-gradient(135deg, #10b981, #059669); }
.feat-ico-kb { background: linear-gradient(135deg, #ec4899, #db2777); }
.feat-ico-multirole { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.feat-ico-security { background: linear-gradient(135deg, #f43f5e, #e11d48); }
.login-feat-body strong { display: block; font-size: 13px; font-weight: 700; color: #fff; margin-bottom: 3px; }
.login-feat-body p { margin: 0; font-size: 12px; line-height: 1.5; color: rgba(255,255,255,.75); }

/* Stats bar */
.login-stats-bar {
  display: flex; align-items: center; gap: 0; margin-top: 12px;
  padding: 16px 20px; border-radius: 14px;
  background: rgba(255,255,255,.08); backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.12);
  animation: fadeSlideUp .8s ease-out .9s both;
  position: relative; overflow: hidden;
}
.login-stats-bar::before {
  content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.1), transparent);
  animation: statsShimmer 4s ease-in-out infinite;
}
@keyframes statsShimmer { 0% { left: -100%; } 50%, 100% { left: 100%; } }
.login-stat { flex: 1; text-align: center; position: relative; z-index: 1; }
.login-stat-num { display: block; font-size: 22px; font-weight: 800; color: #fff; line-height: 1; }
.login-stat-label { display: block; font-size: 11px; color: rgba(255,255,255,.7); margin-top: 4px; }
.login-stat-sep { width: 1px; height: 32px; background: rgba(255,255,255,.15); }

/* Decorative shapes — more dynamic */
.login-deco { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .4; pointer-events: none; }
.login-deco-1 { width: 300px; height: 300px; background: #f59e0b; top: -100px; right: -80px; animation: floatDeco1 12s ease-in-out infinite alternate; }
.login-deco-2 { width: 250px; height: 250px; background: #8b5cf6; bottom: -80px; left: -60px; animation: floatDeco2 15s ease-in-out infinite alternate-reverse; }
.login-deco-3 { width: 200px; height: 200px; background: #ec4899; top: 40%; left: 50%; animation: floatDeco3 18s ease-in-out infinite alternate; opacity: .2; }
@keyframes floatDeco1 { 0% { transform: translate(0,0) scale(1); } 50% { transform: translate(40px,20px) scale(1.2); } 100% { transform: translate(30px,-30px) scale(1.15); } }
@keyframes floatDeco2 { 0% { transform: translate(0,0) scale(1); } 50% { transform: translate(-30px,-40px) scale(1.1); } 100% { transform: translate(30px,-30px) scale(1.15); } }
@keyframes floatDeco3 { 0% { transform: translate(-50%,0) scale(1); } 50% { transform: translate(-30%,-30px) scale(1.3); } 100% { transform: translate(-50%,-20px) scale(1.2); } }

/* ----- Form Panel ----- */
.login-form-panel {
  flex: 1 1 45%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 40px; background: var(--surface); position: relative;
}
.login-form-inner { width: 100%; max-width: 380px; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.login-form-title { font-size: 26px; font-weight: 800; color: var(--text); margin: 0 0 6px; }
.login-form-subtitle { font-size: 14px; color: var(--text-soft); margin: 0 0 28px; }
.login-form .field { margin-bottom: 16px; }
.login-form .btn { margin-top: 4px; font-size: 15px; padding: 10px; }
.login-form-links { text-align: center; }
.login-form-links .dot { margin: 0 6px; color: var(--text-mute); }

/* Flash stack for split layout */
.auth-flash-stack {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 100; width: auto; max-width: 90vw;
}

/* Footer under form panel (not absolute) */
.auth-foot-split {
  flex-direction: row; justify-content: space-between; align-items: center;
  width: 100%; max-width: 380px; margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.auth-foot-split .locale-switch { }
.auth-foot-split .auth-powered { margin: 0; }

/* ----- Responsive: stack vertically on mobile ----- */
@media (max-width: 900px) {
  .login-marketing { display: none; }
  .login-form-panel { flex: 1 1 100%; }
  .auth-split-container { height: auto; min-height: 100vh; min-height: 100dvh; }
  .login-split { flex-direction: column; }
}
@media (max-width: 560px) {
  .login-form-panel { padding: 32px 20px; }
  .login-form-title { font-size: 22px; }
}

/* ----- Dark mode for split login ----- */
.theme-dark .login-form-panel { background: var(--bg); }
.theme-dark .login-form-title { color: var(--text); }
.theme-dark .login-form-subtitle { color: var(--text-soft); }
.theme-dark.auth-body { background: var(--bg); }
.theme-dark.auth-body::before { opacity: .3; }

/* Theme toggle on login page */
.login-theme-toggle {
  position: absolute; top: 20px; inset-inline-end: 20px;
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-soft); transition: all .15s; z-index: 10;
}
.login-theme-toggle:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.login-theme-toggle .ico { width: 20px; height: 20px; }

/* role selector on login */
.role-pills { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; margin-bottom: 18px; }
.role-pill { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px; border: 1px solid var(--border-strong); border-radius: var(--radius); cursor: pointer; transition: all .15s ease; background: var(--surface); text-align: center; }
.role-pill:hover { border-color: var(--primary); background: var(--primary-soft); }
.role-pill .rp-ico { width: 28px; height: 28px; color: var(--text-soft); }
.role-pill .rp-label { font-size: 12px; font-weight: 600; color: var(--text); }

/* ---------- hierarchy tree (admin groups) ---------- */
.tree { list-style: none; padding: 0; margin: 0; }
.tree-node { border-inline-start: 2px solid var(--border); margin-inline-start: 6px; padding-inline-start: 12px; }
.tree-row { display: flex; align-items: center; gap: 8px; padding: 7px 6px; border-radius: var(--radius-sm); flex-wrap: wrap; }
.tree-row:hover { background: var(--surface-2); }
.tree-code { font-family: ui-monospace, monospace; font-size: 11px; color: var(--text-mute); background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }
.tree-title { font-weight: 500; }
.tree-indent { display: inline-block; }

/* switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; cursor: pointer; inset: 0; background: var(--stone-300); border-radius: var(--radius-pill); transition: .2s; }
.switch .slider::before { content: ''; position: absolute; height: 16px; width: 16px; inset-inline-start: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: var(--shadow-xs); }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(18px); }
[dir="rtl"] .switch input:checked + .slider::before { transform: translateX(-18px); }

/* agent chip list */
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; background: var(--primary-soft); color: var(--primary-ink); border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; }
.chip .chip-close { background: none; border: 0; color: inherit; cursor: pointer; opacity: .6; font-size: 14px; line-height: 1; padding: 0; }
.chip .chip-close:hover { opacity: 1; }

/* dropdown (redirect menu) */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { position: absolute; inset-inline-start: 0; top: calc(100% + 4px); min-width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 6px; z-index: 30; display: none; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); font-size: 14px; cursor: pointer; }
.dropdown-item:hover { background: var(--surface-2); }

/* utility */
.flex { display: flex; } .col { flex-direction: column; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.items-center { align-items: center; } .justify-between { justify-content: space-between; }
.wrap { flex-wrap: wrap; } .grow { flex: 1; }
.text-mute { color: var(--text-soft); } .text-sm { font-size: 13px; } .text-xs { font-size: 12px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.scroll-y { overflow-y: auto; }
.max-h-96 { max-height: 24rem; }

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
}
@media (max-width: 860px) {
  .drawer-toggle { display: inline-flex !important; }
  .sidebar {
    position: fixed; top: var(--topbar-h); bottom: 0; inset-inline-start: 0;
    width: 280px; z-index: 46; transform: translateX(-100%);
    transition: transform .25s ease; box-shadow: var(--shadow-lg);
  }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0) !important; }
  .sidebar.open ~ .drawer-backdrop { display: block; }
  .content { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: 1; }
  .user-meta { display: none; }
  .brand-text { display: none; }
  .footer { flex-direction: column; text-align: center; padding: 14px 16px; }
  .page-title { font-size: 19px; }
}
@media (max-width: 560px) {
  .topbar { padding-inline: 10px; gap: 6px; }
  .locale-switch .locale-link { padding: 3px 6px; font-size: 12px; }
  .auth-card { padding: 20px; }
  .role-pills { grid-template-columns: 1fr 1fr; }
  .kv-grid { grid-template-columns: 1fr; }
  .msg .msg-avatar { width: 30px; height: 30px; font-size: 12px; }
  .stat-value { font-size: 22px; }
  .content { padding: 12px; }
  .card-pad, .card-body { padding: 14px; }
}
@media (max-width: 380px) {
  .role-pills { grid-template-columns: 1fr; }
}

/* drawer toggle hidden on desktop */
.drawer-toggle { display: none; }

/* scrollbar styling */
.scroll-y::-webkit-scrollbar, .sidebar::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-y::-webkit-scrollbar-thumb, .sidebar::-webkit-scrollbar-thumb { background: var(--stone-300); border-radius: 4px; }
.scroll-y::-webkit-scrollbar-thumb:hover, .sidebar::-webkit-scrollbar-thumb:hover { background: var(--stone-400); }

/* print-friendly */
@media print {
  .topbar, .sidebar, .footer, .drawer-toggle, .page-actions, .reply-tabs, .reply-pane,
  .quick-reply-bar, .star-btn-form, .redirect-form, .card-foot, .bulk-bar,
  .activity-timeline, .workload-list, .filter-bar, .seg, .page-head-actions,
  .dropdown, .icon-btn, .btn { display: none !important; }
  .main { flex: 1; }
  .content { padding: 0; }
  .app-shell { display: block; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; page-break-inside: avoid; }
  .ticket-detail-grid { grid-template-columns: 1fr !important; }
  .ticket-side { position: static !important; }
  .msg-bubble { background: #f9f9f9 !important; border: 1px solid #ddd !important; }
  .msg.internal .msg-bubble { border-style: dashed !important; }
  body { background: #fff !important; color: #000 !important; font-size: 12pt; }
  .ticket-row-ref, .badge { border: 1px solid #999 !important; }
  h1, h2, h3 { color: #000 !important; }
  .stat-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 8px; }
  .stat-card { border: 1px solid #999 !important; background: #f9f9f9 !important; }
  table { width: 100% !important; border-collapse: collapse; }
  th, td { border: 1px solid #ccc !important; padding: 4px 8px !important; }
  .print-only { display: block !important; }
  .no-print { display: none !important; }
  .page-head { border-bottom: 2px solid #000 !important; padding-bottom: 8px !important; margin-bottom: 16px !important; }
  .page-title { font-size: 18pt !important; }
  a { text-decoration: none !important; color: #000 !important; }
  .flash { display: none !important; }
}
.print-only { display: none; }

/* ==========================================================================
   DARK MODE
   ========================================================================== */
.theme-dark {
  --bg: #0f172a;
  --bg-elev: #1e293b;
  --bg-soft: #1e293b;
  --surface: #1e293b;
  --surface-2: #334155;
  --border: #334155;
  --border-strong: #475569;
  --text: #f1f5f9;
  --text-soft: #cbd5e1;
  --text-mute: #94a3b8;
  --primary-soft: rgba(14,165,233,.15);
  --primary-ink: #7dd3fc;
  --ring: #38bdf8;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.3);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --shadow: 0 4px 12px rgba(0,0,0,.4);
  --shadow-md: 0 8px 24px rgba(0,0,0,.5);
  --shadow-lg: 0 20px 48px rgba(0,0,0,.6);
}
.theme-dark .topbar { background: rgba(15,23,42,.85); border-block-end-color: var(--border); }
.theme-dark .stat { background: var(--surface); }
.theme-dark .auth-aurora { opacity: .5; }
.theme-dark .msg-bubble { background: var(--bg-soft); }
/* badges */
.theme-dark .badge-open { background: rgba(245,158,11,.18); color: #fbbf24; }
.theme-dark .badge-in_progress { background: rgba(14,165,233,.18); color: #7dd3fc; }
.theme-dark .badge-resolved { background: rgba(16,185,129,.18); color: #6ee7b7; }
.theme-dark .badge-closed { background: rgba(100,116,139,.2); color: #cbd5e1; }
.theme-dark .badge-reopened { background: rgba(244,63,94,.18); color: #fda4af; }
.theme-dark .badge-pending { background: rgba(245,158,11,.18); color: #fbbf24; }
.theme-dark .badge-done { background: rgba(16,185,129,.18); color: #6ee7b7; }
.theme-dark .badge-cancelled { background: rgba(100,116,139,.2); color: #cbd5e1; }
.theme-dark .badge-low { background: rgba(100,116,139,.2); color: #cbd5e1; }
.theme-dark .badge-normal { background: rgba(14,165,233,.18); color: #7dd3fc; }
.theme-dark .badge-high { background: rgba(245,158,11,.18); color: #fbbf24; }
.theme-dark .badge-urgent { background: rgba(244,63,94,.18); color: #fda4af; }
.theme-dark .badge-soft { background: rgba(100,116,139,.2); color: #cbd5e1; }
.theme-dark .badge-primary { background: rgba(14,165,233,.18); color: #7dd3fc; }
.theme-dark .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='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); }
/* dark mode element overrides */
.theme-dark .sidebar { background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%); }
.theme-dark .hint-card { background: var(--bg-soft); }
.theme-dark .tree-code { background: var(--bg-soft); color: var(--text-mute); }
.theme-dark .tree-row-inner:hover { background: var(--bg-soft); }
.theme-dark .reply-pane[style*="amber"] { background: rgba(245,158,11,.1) !important; }
.theme-dark .msg.internal .msg-bubble { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.2); }
.theme-dark .card-foot { background: var(--bg-soft); }
.theme-dark .seg a { color: var(--text-soft); }
.theme-dark .seg a.active { background: var(--primary); color: #fff; }
.theme-dark .pg-btn { background: var(--surface); color: var(--text-soft); border-color: var(--border-strong); }
.theme-dark .pg-btn:hover:not(.disabled):not(.active) { background: var(--bg-soft); color: var(--text); }
.theme-dark .bar-track { background: var(--bg-soft); }
.theme-dark .auth-body { background: linear-gradient(135deg, #0c4a6e 0%, #075985 40%, #0f172a 100%); }
.theme-dark .input, .theme-dark .select, .theme-dark .textarea { background: var(--bg-soft); color: var(--text); border-color: var(--border-strong); }
.theme-dark .input:focus, .theme-dark .select:focus, .theme-dark .textarea:focus { border-color: var(--primary-ink); box-shadow: 0 0 0 3px var(--primary-soft); }
.theme-dark .input::placeholder { color: var(--text-mute); }
.theme-dark .dropdown-menu { background: var(--surface); border-color: var(--border); }
.theme-dark .dropdown-item:hover { background: var(--bg-soft); }
.theme-dark .notif-item-sm.unread { background: var(--primary-soft); }
.theme-dark .role-pill { background: var(--bg-soft); border-color: var(--border-strong); }
.theme-dark .role-pill:hover { border-color: var(--primary-ink); background: var(--primary-soft); }
.theme-dark .cat-badge { opacity: .85; }
.theme-dark .chip { background: var(--primary-soft); color: var(--primary-ink); }
.theme-dark .switch .slider { background: var(--border-strong); }
.theme-dark .flash-info { background: rgba(14,165,233,.15); color: #7dd3fc; border-color: rgba(14,165,233,.3); }
.theme-dark .flash-success { background: rgba(16,185,129,.15); color: #6ee7b7; border-color: rgba(16,185,129,.3); }
.theme-dark .flash-error { background: rgba(244,63,94,.15); color: #fda4af; border-color: rgba(244,63,94,.3); }
.theme-dark .flash-warning { background: rgba(245,158,11,.15); color: #fbbf24; border-color: rgba(245,158,11,.3); }
.theme-dark .demo-box { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-ink); }
.theme-dark .demo-box code { background: var(--bg-soft); }
.theme-dark .kv .k { color: var(--text-mute); }
.theme-dark .tl-item::before { background: var(--surface); border-color: var(--primary-ink); }
.theme-dark .lc-bar { background: linear-gradient(180deg, #38bdf8, #0ea5e9); opacity: .85; }
.theme-dark .stat-trend { color: #6ee7b7; }
.theme-dark .auth-aurora {
  background:
    radial-gradient(ellipse 60% 50% at 20% 20%, rgba(56,189,248,.15), transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 10%, rgba(167,139,250,.1), transparent 60%),
    radial-gradient(ellipse 60% 40% at 60% 0%, rgba(16,185,129,.08), transparent 60%);
}
.theme-dark .group-tree-select { background: var(--surface); border-color: var(--border-strong); }
.theme-dark .gt-search-box { background: var(--bg-soft); }
.theme-dark .gt-search-input { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.theme-dark .gt-node { color: var(--text); }
.theme-dark .gt-node:hover { background: var(--bg-soft); }
.theme-dark .gt-node.selected { background: var(--primary-soft); color: var(--primary-ink); }
.theme-dark .search-select-dropdown { background: var(--surface); border-color: var(--border-strong); }
.theme-dark .search-select-item:hover { background: var(--primary-soft); }
.theme-dark .att-chip { background: var(--bg-soft); border-color: var(--border); }
.theme-dark .att-chip:hover { background: var(--primary-soft); }
.theme-dark .cas-chip { background: var(--primary-soft); color: var(--primary-ink); }
.theme-dark .jdp-popup { background: var(--surface); border-color: var(--border-strong); }
.theme-dark .jdp-day { color: var(--text); }
.theme-dark .jdp-day:hover { background: var(--primary-soft); }
.theme-dark .jdp-prev:hover, .theme-dark .jdp-next:hover { background: var(--bg-soft); }
.theme-dark .heatmap-cell { color: #fff; }
.theme-dark .ticket-row:hover { background: var(--bg-soft); }
.theme-dark .wordcloud-container { background: var(--bg-soft); }
.theme-dark table.tbl thead th { background: var(--bg-soft); color: var(--text-soft); }
.theme-dark table.tbl tbody tr:hover { background: var(--bg-soft); }
.theme-dark .content { background: transparent; }
.theme-dark .footer { background: var(--surface); border-block-start-color: var(--border); }

/* ==========================================================================
   TABULAR NUMS + STAT POLISH + GRAPHICAL ENHANCEMENTS
   ========================================================================== */
.stat-value { font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.cell-mono { font-variant-numeric: tabular-nums; }

/* Colorful topbar gradient accent */
.topbar { background: linear-gradient(90deg, rgba(14,165,233,.03) 0%, rgba(255,255,255,.85) 50%, rgba(167,139,250,.03) 100%); }
.theme-dark .topbar { background: linear-gradient(90deg, rgba(14,165,233,.05) 0%, rgba(15,23,42,.85) 50%, rgba(167,139,250,.05) 100%); }

/* Gradient accent bar at top of page */
.app-shell::before {
  content: ''; position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100;
  background: linear-gradient(90deg, #0ea5e9, #8b5cf6, #ec4899);
  background-size: 200% 100%;
  animation: gradientShift 6s ease infinite;
}
@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Stat card colorful top borders */
.stat.teal { border-block-start: 3px solid #0ea5e9; }
.stat.amber { border-block-start: 3px solid #f59e0b; }
.stat.emerald { border-block-start: 3px solid #10b981; }
.stat.rose { border-block-start: 3px solid #f43f5e; }
.stat.violet { border-block-start: 3px solid #8b5cf6; }

/* Stat card glow on hover */
.stat.teal:hover { box-shadow: 0 8px 24px rgba(14,165,233,.15); }
.stat.amber:hover { box-shadow: 0 8px 24px rgba(245,158,11,.15); }
.stat.emerald:hover { box-shadow: 0 8px 24px rgba(16,185,129,.15); }
.stat.rose:hover { box-shadow: 0 8px 24px rgba(244,63,94,.15); }
.stat.violet:hover { box-shadow: 0 8px 24px rgba(139,92,246,.15); }

/* Card hover lift */
.card { transition: box-shadow .2s ease, transform .2s ease; }
.card:hover { box-shadow: var(--shadow-md); }

/* Animated gradient text for page titles */
.page-title {
  background: linear-gradient(135deg, #0c4a6e, #0ea5e9, #0c4a6e);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: textGradient 4s ease infinite;
}
@keyframes textGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.theme-dark .page-title {
  background: linear-gradient(135deg, #7dd3fc, #e2e8f0, #7dd3fc);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Brand logo subtle float */
@keyframes logoFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
.brand-logo { animation: logoFloat 3s ease-in-out infinite; }

/* Topbar glass effect */
.topbar {
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}

/* Content area subtle pattern */
.content { position: relative; }
.content::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 200px;
  background: radial-gradient(ellipse at top, rgba(14,165,233,.04), transparent 70%);
  pointer-events: none; z-index: -1;
}

/* Footer gradient */
.footer {
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
}

/* Button gradient */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  background-size: 150% 100%;
  transition: all .2s ease;
}
.btn-primary:hover { background-position: 100% 0; box-shadow: 0 4px 12px rgba(14,165,233,.3); }

/* Badge glow */
.badge { transition: all .15s ease; }
.badge:hover { transform: scale(1.05); }

/* ==========================================================================
   NOTIFICATION DROPDOWN
   ========================================================================== */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0;
  min-width: 320px; max-width: min(380px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  z-index: 60; display: none; overflow: hidden;
}
.dropdown.open .dropdown-menu { display: block; animation: dropIn .18s ease; }
@keyframes dropIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* Responsive: dropdown stays within viewport on mobile */
@media (max-width: 560px) {
  .dropdown-menu {
    position: fixed; top: var(--topbar-h); inset-inline-end: 8px; inset-inline-start: 8px;
    min-width: 0; max-width: none; width: calc(100vw - 16px);
  }
  .dropdown.open .dropdown-menu { animation: dropInMobile .2s ease; }
  @keyframes dropInMobile { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
}
.notif-menu-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-block-end: 1px solid var(--border);
}
.notif-menu-body { max-height: 360px; overflow-y: auto; }
.notif-menu-empty { padding: 28px 14px; text-align: center; }
.notif-item-sm {
  display: flex; gap: 10px; padding: 10px 14px;
  border-block-end: 1px solid var(--border);
  transition: background .12s;
}
.notif-item-sm:hover { background: var(--surface-2); }
.notif-item-sm.unread { background: var(--primary-soft); }
.notif-item-sm.unread::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary); flex: 0 0 auto; margin-top: 6px;
}
.notif-view-all {
  display: block; text-align: center; padding: 10px;
  font-weight: 600; font-size: 13px; color: var(--primary);
  border-block-start: 1px solid var(--border);
}
.notif-view-all:hover { background: var(--surface-2); }

/* ==========================================================================
   NOTIFICATION LIST (full page)
   ========================================================================== */
.notif-list { }
.notif-item {
  display: flex; gap: 14px; padding: 14px 16px;
  border-block-end: 1px solid var(--border);
  transition: background .12s; text-decoration: none; color: inherit;
}
.notif-item:last-child { border-block-end: 0; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: var(--primary-soft); }
.notif-ico {
  width: 40px; height: 40px; border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto; background: var(--surface-2); color: var(--text-soft);
}
.notif-ico .ico { width: 20px; height: 20px; }
.notif-ico.type-ticket_new { background: var(--teal-50); color: var(--teal-700); }
.notif-ico.type-ticket_reply { background: var(--amber-50); color: var(--amber-600); }
.notif-ico.type-ticket_redirected { background: var(--violet-50); color: var(--violet-500); }
.notif-ico.type-ticket_resolved { background: var(--emerald-50); color: var(--emerald-700); }
.notif-ico.type-ticket_closed { background: var(--stone-100); color: var(--stone-600); }
.notif-ico.type-task_assigned { background: var(--emerald-50); color: var(--emerald-700); }
.theme-dark .notif-ico { background: var(--bg-soft); }
.theme-dark .notif-ico.type-ticket_new { background: rgba(37,99,235,.2); color: #93c5fd; }
.theme-dark .notif-ico.type-ticket_reply { background: rgba(245,158,11,.2); color: #fbbf24; }
.theme-dark .notif-ico.type-ticket_redirected { background: rgba(139,92,246,.2); color: #c4b5fd; }
.theme-dark .notif-ico.type-ticket_resolved { background: rgba(16,185,129,.2); color: #6ee7b7; }
.theme-dark .notif-ico.type-ticket_closed { background: rgba(120,113,108,.2); color: #d6d3d1; }
.theme-dark .notif-ico.type-task_assigned { background: rgba(16,185,129,.2); color: #6ee7b7; }
.notif-body { flex: 1; min-width: 0; }
.notif-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.notif-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex: 0 0 auto; }
.notif-text { font-size: 13px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-time { font-size: 11px; color: var(--text-mute); margin-top: 4px; }

/* ==========================================================================
   PAGINATION
   ========================================================================== */
.pager-wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.pagination { display: flex; gap: 4px; flex-wrap: wrap; }
.pagination-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap;
}
.pagination-bar .pg-info {
  font-size: 12px; color: var(--text-mute); font-variant-numeric: tabular-nums;
}
.pg-ellipsis {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 36px; padding: 0 4px;
  color: var(--text-mute); font-size: 14px; user-select: none;
}
.pg-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 36px; padding: 0 10px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-soft);
  font-size: 13px; font-weight: 600; text-decoration: none;
  transition: all .12s; cursor: pointer;
}
.pg-btn:hover:not(.disabled):not(.active) { background: var(--surface-2); color: var(--text); border-color: var(--primary); }
.pg-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pg-btn.disabled { opacity: .4; cursor: not-allowed; }
.pager-info { font-variant-numeric: tabular-nums; }

/* ==========================================================================
   BAR CHARTS (analytics)
   ========================================================================== */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-label { width: 120px; flex: 0 0 auto; font-size: 13px; font-weight: 500; text-align: end; }
.bar-track { flex: 1; height: 22px; background: var(--surface-2); border-radius: var(--radius-sm); overflow: hidden; min-width: 60px; }
.bar-fill { height: 100%; border-radius: var(--radius-sm); transition: width .5s cubic-bezier(.4,0,.2,1); min-width: 2px; }
.bar-val { width: 36px; flex: 0 0 auto; font-size: 13px; font-weight: 700; text-align: start; font-variant-numeric: tabular-nums; }

.line-chart {
  display: flex; align-items: flex-end; gap: 6px; height: 180px;
  padding-block-end: 28px; position: relative; overflow-x: auto;
}
.lc-col {
  flex: 1; min-width: 32px; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; height: 100%;
  position: relative;
}
.lc-bar {
  width: 100%; max-width: 28px; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: linear-gradient(180deg, var(--teal-400), var(--teal-700));
  transition: height .5s cubic-bezier(.4,0,.2,1); min-height: 2px;
}
.lc-bar:hover { filter: brightness(1.15); }
.lc-label { font-size: 10px; font-weight: 700; color: var(--text); margin-top: 2px; font-variant-numeric: tabular-nums; }
.lc-date { position: absolute; bottom: -22px; font-size: 9px; white-space: nowrap; }

/* ==========================================================================
   PROFILE PAGE
   ========================================================================== */
.kv-row { padding: 6px 0; }

/* ==========================================================================
   CATEGORY BADGE
   ========================================================================== */
.cat-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.cat-badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ==========================================================================
   THEME TOGGLE ANIMATION
   ========================================================================== */
.theme-toggle .ico { transition: transform .3s ease; }
.theme-toggle:hover .ico { transform: rotate(15deg); }

/* ==========================================================================
   IMPROVED EMPTY STATES
   ========================================================================== */
.empty-state .ico { animation: emptyFloat 3s ease-in-out infinite; }
@keyframes emptyFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* ==========================================================================
   IMPROVED NAV ACTIVE (pill shape)
   ========================================================================== */
.nav-item.active {
  background: var(--primary-soft); color: var(--primary-ink); font-weight: 600;
  border-radius: var(--radius-pill);
}
.nav-item.active::before { display: none; }
.nav-item { border-radius: var(--radius-pill); }

/* ==========================================================================
   STAT CARD IMPROVEMENTS
   ========================================================================== */
.stat { position: relative; overflow: hidden; }
.stat::after {
  content: ''; position: absolute; inset-block-start: 0; inset-inline-end: 0;
  width: 60px; height: 60px; border-radius: 50%;
  background: radial-gradient(circle, currentColor, transparent 70%);
  opacity: .04; transform: translate(20px, -20px);
}

/* ==========================================================================
   MOBILE NOTIF DROPDOWN
   ========================================================================== */
@media (max-width: 560px) {
  .dropdown-menu { min-width: calc(100vw - 32px); max-width: calc(100vw - 32px); inset-inline-end: -8px; }
  .bar-label { width: 80px; font-size: 12px; }
}

/* ==========================================================================
   REPLY TABS (reply / internal note switcher)
   ========================================================================== */
.reply-tabs { border-block-end: 2px solid var(--border); }
.reply-tab {
  padding: 8px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  border: 0; background: none; color: var(--text-soft);
  border-block-end: 2px solid transparent; margin-block-end: -2px;
  transition: all .15s;
}
.reply-tab:hover { color: var(--text); }
.reply-tab.active { color: var(--primary); border-block-end-color: var(--primary); }
.reply-pane { display: none; }
.reply-pane.active { display: block; }

/* ==========================================================================
   GROUP HIERARCHY TREE
   ========================================================================== */
.tree-container { padding: 8px 4px; }
.tree-node-row { position: relative; }
.tree-row-inner {
  display: flex; align-items: center; gap: 8px; padding-block: 8px;
  padding-inline-end: 12px; border-radius: var(--radius-sm);
  transition: background .12s; flex-wrap: wrap;
}
.tree-row-inner:hover { background: var(--surface-2); }
.tree-toggle {
  flex: 0 0 auto; width: 24px; height: 24px; border: 0; background: none;
  cursor: pointer; color: var(--text-soft); border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .2s ease;
}
.tree-toggle:hover { background: var(--border); color: var(--text); }
.tree-toggle .ico { width: 16px; height: 16px; transition: transform .2s ease; }
.tree-node-row.collapsed > .tree-row-inner .tree-toggle .ico { transform: rotate(-90deg); }
[dir="rtl"] .tree-node-row.collapsed > .tree-row-inner .tree-toggle .ico { transform: rotate(90deg); }
.tree-toggle-placeholder { flex: 0 0 auto; width: 24px; height: 24px; }
.tree-code {
  font-family: ui-monospace, monospace; font-size: 11px; color: var(--text-mute);
  background: var(--surface-2); padding: 2px 7px; border-radius: 4px; flex: 0 0 auto;
}
.tree-title { font-weight: 500; flex: 1; min-width: 0; }
.tree-title.visible-mark { color: var(--primary); font-weight: 600; }
.tree-meta { display: flex; gap: 4px; flex-wrap: wrap; }
.tree-actions { flex: 0 0 auto; opacity: 0; transition: opacity .15s; }
.tree-row-inner:hover .tree-actions { opacity: 1; }
.tree-children { position: relative; }
.tree-children::before {
  content: ''; position: absolute; inset-inline-start: calc(12px + var(--tree-indent, 0px) + 11px);
  top: 0; bottom: 0; width: 1px; background: var(--border);
}
.tree-node-row.collapsed > .tree-children { display: none; }
.tree-node-users { border-block-start: 1px dashed var(--border); margin-block-start: 2px; }
.tree-user-name { font-weight: 500; font-size: 13px; }
.tree-user-list .badge { font-size: 10px; }
@media (max-width: 768px) {
  .tree-actions { opacity: 1; }
  .tree-meta { display: none; }
}

/* ==========================================================================
   AESTHETIC POLISH
   ========================================================================== */
/* smoother card transitions */
.card { transition: box-shadow .2s ease, border-color .2s ease; }
.card:hover { box-shadow: var(--shadow); }

/* refined stat cards */
.stat { transition: transform .2s ease, box-shadow .2s ease; }
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-value { transition: color .2s ease; }

/* button micro-interactions */
.btn { transition: all .18s cubic-bezier(.4,0,.2,1); }
.btn-primary:not(:disabled):active { transform: scale(.97); }
.btn-ghost:not(:disabled):active { transform: scale(.97); }

/* nav item smooth slide */
.nav-item { transition: all .2s cubic-bezier(.4,0,.2,1); }
.nav-item:hover { padding-inline-start: 16px; }

/* ticket row hover lift */
.ticket-row { transition: background .15s ease, padding-inline-start .2s ease; }
.ticket-row:hover { padding-inline-start: 22px; }

/* select focus ring refinement */
.select:focus, .input:focus, .textarea:focus { transition: border-color .15s ease, box-shadow .15s ease; }

/* avatar gradient refinement */
.avatar { transition: transform .2s ease; }
.avatar:hover { transform: scale(1.08); }

/* logo styling */
.brand-logo { transition: transform .2s ease; }
.brand:hover .brand-logo { transform: scale(1.08); }

/* card head spacing refinement */
.card-head { padding: 14px 18px; }
.card-body { padding: 18px; }

/* page head refinement */
.page-head { margin-bottom: 22px; }
.page-title { font-size: 24px; }

/* stat grid gap refinement */
.stat-grid { gap: 16px; }

/* table row hover refinement */
table.tbl tbody tr:hover { background: var(--primary-soft); }

/* badge hover */
.badge { transition: transform .15s ease; }
.badge:hover { transform: scale(1.05); }

/* button shadow on hover */
.btn-primary:not(:disabled):hover { box-shadow: 0 4px 12px rgba(22,74,116,.3); }

/* flash slide-in refinement */
.flash { animation: flashSlideIn .3s cubic-bezier(.4,0,.2,1); }
@keyframes flashSlideIn { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }
[dir="rtl"] .flash { animation: flashSlideInRTL .3s cubic-bezier(.4,0,.2,1); }
@keyframes flashSlideInRTL { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

/* refined page title */
.page-title { letter-spacing: -.02em; }

/* card head refinement */
.card-head { border-block-end-color: var(--border); }

/* table row hover refinement */
table.tbl tbody tr { transition: background .12s ease; }

/* link underline on hover */
a:not(.btn):not(.nav-item):not(.ticket-row):not(.stat):not(.pg-btn):not(.tab):not(.locale-link):not(.seg a):not(.dropdown-item) { transition: color .12s ease; }

/* focus visible refinement */
*:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 4px; }

/* refined scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

/* selection color */
::selection { background: var(--primary-soft); color: var(--primary-ink); }

/* refined shadows for depth */
.card { box-shadow: var(--shadow-xs); }
.card-pad { box-shadow: var(--shadow-xs); }

/* badge dot pulse for unread */
.badge::before { transition: opacity .2s ease; }
.notif-dot { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .6; transform: scale(1.2); } }

/* refined empty state */
.empty-state { animation: fadeInUp .4s ease; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* tree toggle smooth rotation */
.tree-toggle .ico { transition: transform .25s cubic-bezier(.4,0,.2,1); }

/* dropdown smooth appear */
.dropdown-menu { animation: dropIn .2s cubic-bezier(.4,0,.2,1); }

/* refined topbar */
.topbar { transition: box-shadow .2s ease; }

/* sidebar refinement */
.sidebar { transition: transform .25s cubic-bezier(.4,0,.2,1); }

/* message bubble refinement */
.msg-bubble { transition: background .15s ease; }
.msg { animation: msgIn .3s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* refined auth card */
.auth-card { animation: cardIn .4s cubic-bezier(.4,0,.2,1); }
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }

/* loading skeleton */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius); }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ==========================================================================
   GROUP TREE SELECTOR — inline multilevel tree with search + expand/collapse
   ========================================================================== */
.group-tree-select {
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
}
.gt-search-box { padding: 10px; border-block-end: 1px solid var(--border); background: var(--surface-2); }
.gt-search-input {
  width: 100%; padding: 8px 12px; font-family: inherit; font-size: 13px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.gt-search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.gt-tree { max-height: 280px; overflow-y: auto; padding: 4px; text-align: start; }
.gt-node {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; color: var(--text);
  transition: background .1s; user-select: none;
  direction: rtl; text-align: right;
}
[dir="ltr"] .gt-node { direction: ltr; text-align: left; }
.gt-node:hover { background: var(--surface-2); }
.gt-node.selected { background: var(--primary-soft); color: var(--primary-ink); font-weight: 600; }

.gt-chevron {
  flex: 0 0 auto; width: 20px; height: 20px; border: 0; background: none;
  cursor: pointer; color: var(--text-mute); border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.gt-chevron:hover { background: var(--border); color: var(--text); }
.gt-chevron svg { transition: transform .2s ease; }
.gt-chevron.open svg { transform: rotate(90deg); }
[dir="rtl"] .gt-chevron svg { transform: scaleX(-1); }
[dir="rtl"] .gt-chevron.open svg { transform: scaleX(-1) rotate(90deg); }
.gt-chevron-spacer { flex: 0 0 auto; width: 20px; }
.gt-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Keep old search-select classes for staff flat lists */
.search-select { position: relative; }
.search-select-input-wrap { position: relative; }
.search-select-input { width: 100%; }
.search-select-dropdown {
  position: absolute; inset-block-start: calc(100% + 4px); inset-inline: 0;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  max-height: 320px; z-index: 50; display: none; overflow-y: auto; padding: 4px;
}
.search-select-dropdown.open { display: block; animation: dropIn .18s ease; }
.search-select-item {
  padding: 8px 12px; border-radius: var(--radius-sm); cursor: pointer;
  transition: background .12s; display: flex; flex-direction: column; gap: 2px;
}
.search-select-item:hover { background: var(--primary-soft); }
.search-select-item .cell-strong { font-size: 14px; }
.search-select-item .text-xs { font-size: 11px; }
/* Multi-select: items that are already picked get a checkmark + muted look */
.search-select-item.search-select-item-selected { position: relative; }
.search-select-item.search-select-item-selected::after {
  content: '✓'; position: absolute; inset-inline-end: 10px; top: 50%;
  transform: translateY(-50%); color: var(--primary, #0f766e); font-weight: 700; font-size: 14px;
}
.search-select-item.search-select-item-selected .cell-strong { opacity: .55; }
.search-select-selected { margin-top: 6px; }
.search-select-selected.chip-list:empty { display: none; }
.cas-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; background: var(--primary-soft); color: var(--primary-ink);
  border-radius: var(--radius-pill); font-size: 13px; font-weight: 600;
}
.cas-chip-x { background: none; border: 0; color: inherit; cursor: pointer; opacity: .6; font-size: 16px; padding: 0; }
.cas-chip-x:hover { opacity: 1; }

/* Dark mode */
.theme-dark .group-tree-select { background: var(--surface); border-color: var(--border-strong); }
.theme-dark .gt-search-box { background: var(--bg-soft); }
.theme-dark .gt-search-input { background: var(--surface); border-color: var(--border-strong); }
.theme-dark .gt-node:hover { background: var(--bg-soft); }
.theme-dark .search-select-dropdown { background: var(--surface); border-color: var(--border-strong); }
.theme-dark .search-select-item:hover { background: var(--primary-soft); }

/* ==========================================================================
   JALALI DATE PICKER
   ========================================================================== */
.jdp-wrapper { position: relative; }
.jdp-input { width: 100%; }
.jdp-popup {
  position: absolute; inset-block-start: calc(100% + 4px); inset-inline: 0;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 60; padding: 12px; direction: rtl;
}
.jdp-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.jdp-title { font-weight: 700; font-size: 14px; color: var(--text); }
.jdp-prev, .jdp-next {
  width: 28px; height: 28px; border: 0; background: none; cursor: pointer;
  color: var(--text-soft); border-radius: var(--radius-sm); font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
}
.jdp-prev:hover, .jdp-next:hover { background: var(--surface-2); color: var(--text); }
.jdp-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; }
.jdp-wd { text-align: center; font-size: 11px; font-weight: 600; color: var(--text-mute); padding: 4px 0; }
.jdp-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.jdp-day {
  padding: 6px 0; text-align: center; font-size: 13px; border: 0; background: none;
  cursor: pointer; border-radius: var(--radius-sm); color: var(--text);
  transition: background .12s;
}
.jdp-day:hover { background: var(--primary-soft); }
.jdp-day.today { font-weight: 700; color: var(--primary); }
.jdp-day.selected { background: var(--primary); color: #fff; font-weight: 600; }
.jdp-day-empty { }
.jdp-footer { text-align: center; margin-top: 8px; }
.jdp-today-btn {
  padding: 6px 16px; font-size: 12px; font-weight: 600; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-soft); border-radius: var(--radius); cursor: pointer;
}
.jdp-today-btn:hover { background: var(--primary-soft); color: var(--primary-ink); }
.theme-dark .jdp-popup { background: var(--surface); border-color: var(--border-strong); }
.theme-dark .jdp-day:hover { background: var(--primary-soft); }
.theme-dark .jdp-prev:hover, .theme-dark .jdp-next:hover { background: var(--bg-soft); }

/* ==========================================================================
   ATTACHMENTS
   ========================================================================== */
.msg-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.att-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 12px; color: var(--text-soft);
  text-decoration: none; transition: all .15s;
}
.att-chip:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-ink); }
.att-icon { font-size: 14px; }
.att-name { font-weight: 500; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-size { color: var(--text-mute); font-size: 11px; }
.theme-dark .att-chip { background: var(--bg-soft); border-color: var(--border); }
.theme-dark .att-chip:hover { background: var(--primary-soft); }

/* ==========================================================================
   DIRECTORY PAGE
   ========================================================================== */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { margin: 0 0 4px; font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; }
.page-head-actions { display: flex; gap: 8px; align-items: center; }

.dir-filters { padding: 14px 16px; }
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-search { flex: 1; min-width: 220px; }
.input-with-icon { position: relative; display: flex; align-items: center; }
.input-with-icon .ico { position: absolute; inset-inline-start: 12px; width: 18px; height: 18px; color: var(--text-mute); pointer-events: none; }
.input-with-icon .input { padding-inline-start: 38px; }
.filter-row .select { max-width: 170px; }

.dir-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.dir-card {
  padding: 18px;
  transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
  display: flex; flex-direction: column; gap: 14px;
  position: relative; overflow: hidden;
}
.dir-card::before {
  content: '';
  position: absolute; inset-block-start: 0; inset-inline-start: 0;
  width: 4px; height: 100%;
  background: var(--primary);
  opacity: 0; transition: opacity .2s;
}
.dir-card[data-role="prof"]::before { background: var(--emerald, #059669); }
.dir-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.dir-card:hover::before { opacity: 1; }

.dir-card-head { display: flex; align-items: center; gap: 12px; }
.dir-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 16px;
  flex-shrink: 0; box-shadow: 0 2px 8px rgba(0,0,0,.15);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.dir-card-info { flex: 1; min-width: 0; }
.dir-card-name { margin: 0 0 4px; font-size: 15px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dir-card-meta { display: flex; gap: 5px; flex-wrap: wrap; }

.dir-card-body { display: flex; flex-direction: column; gap: 8px; }
.dir-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dir-row-label { flex-shrink: 0; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; color: var(--text-mute); }
.dir-row-label .ico { width: 16px; height: 16px; }
.dir-row-value { color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dir-card-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }

/* Responsive */
@media (max-width: 640px) {
  .dir-grid { grid-template-columns: 1fr; }
  .filter-row .select { max-width: 100%; flex: 1; }
  .filter-search { min-width: 100%; }
}

/* Dark mode */
.theme-dark .dir-card { background: var(--surface); }
.theme-dark .dir-avatar { box-shadow: 0 2px 12px rgba(0,0,0,.4); }
.theme-dark .dir-card:hover { border-color: var(--primary); }

/* ==========================================================================
   DASHBOARD STAT CARD ENHANCEMENTS
   ========================================================================== */
.stat-card {
  position: relative; overflow: hidden;
  transition: transform .25s cubic-bezier(.4,0,.2,1), box-shadow .25s;
}
.stat-card::after {
  content: '';
  position: absolute; inset-block-end: -30px; inset-inline-end: -30px;
  width: 90px; height: 90px; border-radius: 50%;
  background: currentColor; opacity: 0.06;
  transition: transform .3s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-card:hover::after { transform: scale(1.3); }
.stat-card .stat-icon { width: 22px; height: 22px; opacity: 0.85; }
.stat-card .stat-value { font-variant-numeric: tabular-nums; }

/* Color variants */
.stat-card.stat-teal { color: #0d9488; }
.stat-card.stat-violet { color: #7c3aed; }
.stat-card.stat-emerald { color: #059669; }
.stat-card.stat-amber { color: #d97706; }
.stat-card.stat-rose { color: #e11d48; }
.stat-card.stat-blue { color: #164a74; }

/* ==========================================================================
   PAGINATION
   ========================================================================== */
.pagination-wrap { display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; }
.page-btn {
  min-width: 38px; height: 38px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-soft);
  text-decoration: none; font-weight: 500; font-size: 14px;
  transition: all .15s;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary-ink); background: var(--primary-soft); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-ellipsis { padding: 0 4px; color: var(--text-mute); }

/* ==========================================================================
   TICKET ROW ENHANCEMENTS
   ========================================================================== */
.ticket-row { transition: background .15s, border-color .15s; }
.ticket-row:hover { background: var(--surface-2); }

/* SLA badge */
.sla-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.sla-badge .ico { width: 12px; height: 12px; }
.sla-ok { background: rgba(5,150,105,.12); color: #059669; }
.sla-warn { background: rgba(217,119,6,.14); color: #d97706; }
.sla-breach { background: rgba(225,29,72,.14); color: #e11d48; }
.theme-dark .sla-ok { background: rgba(5,150,105,.22); color: #34d399; }
.theme-dark .sla-warn { background: rgba(217,119,6,.22); color: #fbbf24; }
.theme-dark .sla-breach { background: rgba(225,29,72,.22); color: #fb7185; }

/* ==========================================================================
   QUICK ACTIONS CARD POLISH
   ========================================================================== */
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 0 1 auto; }

/* Gradient header strip for dashboard welcome */
.flash-info {
  background: linear-gradient(135deg, var(--primary-soft) 0%, var(--surface) 100%);
  border-inline-start: 4px solid var(--primary);
  font-weight: 500;
}
.theme-dark .flash-info { background: linear-gradient(135deg, rgba(22,74,116,.25) 0%, var(--surface) 100%); }

/* ==========================================================================
   STAT CARD WITH ICON
   ========================================================================== */
.stat .stat-icon {
  position: absolute; inset-block-start: 14px; inset-inline-end: 14px;
  width: 22px; height: 22px; opacity: 0.6;
}
.stat .stat-icon .ico { width: 22px; height: 22px; }
.stat-card { position: relative; }

/* ==========================================================================
   STAR BUTTON (ticket favorites)
   ========================================================================== */
.star-btn-form { display: inline; margin: 0; }
.star-btn {
  position: absolute; inset-block-start: 50%; inset-inline-end: 8px;
  transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-mute); transition: all .2s;
  z-index: 2;
}
.star-btn .ico { width: 18px; height: 18px; transition: transform .2s; }
.star-btn:hover { background: var(--surface-2); color: #f59e0b; transform: translateY(-50%) scale(1.15); }
.star-btn:hover .ico { transform: scale(1.1); }
.star-btn.starred { color: #f59e0b; }
.star-btn.starred .ico { fill: #f59e0b; }

/* Large star button (ticket detail) */
.star-btn-lg {
  position: static; transform: none;
  width: auto; padding: 6px 14px; border-radius: var(--radius-pill);
  background: var(--surface-2); border: 1px solid var(--border);
  gap: 6px; font-size: 13px; font-weight: 600;
}
.star-btn-lg:hover { transform: scale(1.05); background: rgba(245,158,11,.1); border-color: #f59e0b; color: #f59e0b; }
.star-btn-lg.starred { background: rgba(245,158,11,.12); border-color: #f59e0b; color: #f59e0b; }
.star-btn-lg .ico { width: 16px; height: 16px; }
.star-label { font-size: 12px; }

.ticket-row-wrap { position: relative; border-bottom: 1px solid var(--border); }
.ticket-row-wrap:last-child { border-bottom: none; }
.ticket-row-wrap:hover .star-btn { opacity: 1; }
.star-btn { opacity: 0.4; }
.star-btn.starred { opacity: 1; }

.theme-dark .star-btn:hover { background: var(--surface-2); }
.theme-dark .star-btn.starred { color: #fbbf24; }
.theme-dark .star-btn.starred .ico { fill: #fbbf24; }

/* ==========================================================================
   MESSAGE BUBBLE ENHANCEMENTS (ticket thread)
   ========================================================================== */
.msg-bubble {
  position: relative;
  animation: msgSlideIn .3s ease-out;
}
@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg {
  animation: msgFadeIn .4s ease-out;
}
@keyframes msgFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.msg-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
  flex-shrink: 0; box-shadow: 0 2px 6px rgba(0,0,0,.12);
  text-transform: uppercase;
}
.msg.mine .msg-avatar { background: var(--primary); }
.msg.other .msg-avatar { background: var(--violet-500, #7c3aed); }
.msg.staff .msg-avatar { background: #059669; }

/* Message bubble color refinement */
.msg.mine .msg-bubble {
  background: var(--primary-soft);
  border-color: var(--primary);
}
.msg.other .msg-bubble {
  background: var(--surface-2);
}
.msg.internal .msg-bubble {
  background: rgba(245,158,11,.08);
  border-color: rgba(245,158,11,.25);
  border-style: dashed;
}

/* ==========================================================================
   FLASH ANIMATIONS
   ========================================================================== */
.flash {
  animation: flashSlide .4s cubic-bezier(.4,0,.2,1);
}
@keyframes flashSlide {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}
[dir="rtl"] .flash {
  animation-name: flashSlideRtl;
}
@keyframes flashSlideRtl {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ==========================================================================
   BUTTON MICRO-INTERACTIONS
   ========================================================================== */
.btn { transition: all .2s cubic-bezier(.4,0,.2,1); }
.btn:active { transform: scale(.97); }
.btn-primary:hover { box-shadow: 0 4px 12px rgba(14,165,233,.3); }

/* ==========================================================================
   EMPTY STATE ANIMATION
   ========================================================================== */
.empty-state .ico {
  animation: floatBob 3s ease-in-out infinite;
}
@keyframes floatBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ==========================================================================
   BULK ACTIONS BAR (admin tickets)
   ========================================================================== */
.bulk-bar {
  display: none; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 14px;
  background: var(--primary-soft); border: 1px solid var(--primary);
  border-radius: var(--radius-lg);
  animation: flashSlide .3s ease-out;
}
.bulk-count { font-weight: 700; color: var(--primary-ink); font-size: 14px; }
.bulk-count span { font-size: 18px; }
.bulk-check-cell { width: 36px; text-align: center; }
.bulk-check-cell input[type="checkbox"] {
  width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary);
}
#checkAll { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }
.theme-dark .bulk-bar { background: rgba(14,165,233,.15); border-color: var(--primary); }

/* ==========================================================================
   QUICK REPLY TEMPLATES
   ========================================================================== */
.quick-reply-bar {
  display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); border-inline-start: 3px solid var(--primary);
}
.quick-reply-label {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700; color: var(--text-soft);
  white-space: nowrap; padding-block: 4px;
}
.quick-reply-label .ico { width: 16px; height: 16px; }
.quick-reply-chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.tpl-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; font-size: 12px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-pill); color: var(--text-soft);
  cursor: pointer; transition: all .15s;
}
.tpl-chip:hover { border-color: var(--primary); color: var(--primary-ink); background: var(--primary-soft); transform: translateY(-1px); }
.tpl-chip:active { transform: translateY(0); }
.tpl-chip.tpl-used { background: var(--primary); color: #fff; border-color: var(--primary); }
.tpl-global { color: #f59e0b; font-size: 10px; }
.tpl-chip:hover .tpl-global { color: #fbbf24; }
.theme-dark .quick-reply-bar { background: var(--bg-soft); }
.theme-dark .tpl-chip { background: var(--surface); }

/* ==========================================================================
   STAFF WORKLOAD WIDGET (admin dashboard)
   ========================================================================== */
.workload-list { display: flex; flex-direction: column; gap: 12px; }
.workload-row {
  display: grid; grid-template-columns: 180px 1fr 60px;
  align-items: center; gap: 12px;
}
.workload-info { min-width: 0; }
.workload-name { display: block; font-weight: 600; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workload-group { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workload-bar-wrap {
  height: 24px; background: var(--surface-2); border-radius: var(--radius-pill);
  overflow: hidden; position: relative;
}
.workload-bar {
  height: 100%; border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--primary) 0%, #0ea5e9 100%);
  transition: width .6s cubic-bezier(.4,0,.2,1);
  position: relative;
}
.workload-bar::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.2) 50%, transparent 100%);
  animation: workloadShine 2s ease-in-out infinite;
}
@keyframes workloadShine {
  0%, 100% { transform: translateX(-100%); }
  50% { transform: translateX(100%); }
}
.workload-bar.workload-urgent {
  background: linear-gradient(90deg, #f59e0b 0%, #ef4444 100%);
}
.workload-count { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.workload-num { font-weight: 700; font-size: 16px; color: var(--text); font-variant-numeric: tabular-nums; }
.workload-urgent-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  background: #ef4444; color: #fff; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 700;
}

@media (max-width: 640px) {
  .workload-row { grid-template-columns: 120px 1fr 50px; gap: 8px; }
  .workload-name { font-size: 12px; }
}

.theme-dark .workload-bar { background: linear-gradient(90deg, #0ea5e9 0%, #38bdf8 100%); }
.theme-dark .workload-bar.workload-urgent { background: linear-gradient(90deg, #f59e0b 0%, #ef4444 100%); }

/* ==========================================================================
   KNOWLEDGE BASE
   ========================================================================== */
.kb-filters { padding: 14px 16px; }

.kb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.kb-card {
  padding: 20px; text-decoration: none; color: inherit;
  transition: transform .2s, box-shadow .2s, border-color .2s;
  display: flex; flex-direction: column; gap: 10px;
}
.kb-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.kb-card-head { display: flex; align-items: center; gap: 8px; }
.kb-card-icon { width: 36px; height: 36px; border-radius: var(--radius); background: var(--primary-soft); color: var(--primary-ink); display: inline-flex; align-items: center; justify-content: center; }
.kb-card-icon .ico { width: 20px; height: 20px; }
.kb-card-cat { font-size: 11px; font-weight: 700; color: var(--text-mute); text-transform: uppercase; letter-spacing: .05em; }
.kb-card-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.4; }
.kb-card-excerpt { margin: 0; font-size: 13px; color: var(--text-soft); line-height: 1.5; flex: 1; }
.kb-card-meta { display: flex; gap: 8px; font-size: 12px; color: var(--text-mute); padding-top: 8px; border-top: 1px solid var(--border); }

.kb-article-title { margin: 0 0 8px; font-size: 24px; font-weight: 700; color: var(--text); line-height: 1.3; }
.kb-article-meta { display: flex; gap: 8px; align-items: center; }
.kb-article-body { font-size: 15px; line-height: 1.8; color: var(--text); }
.kb-article-body p { margin: 0 0 16px; }
.kb-article-feedback { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.kb-related-list { display: flex; flex-direction: column; gap: 8px; }
.kb-related-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: inherit; transition: all .15s; }
.kb-related-item:hover { border-color: var(--primary); background: var(--primary-soft); }
.kb-related-title { font-weight: 600; font-size: 14px; }

.theme-dark .kb-card-icon { background: rgba(14,165,233,.15); }

/* ==========================================================================
   STAR RATING (ticket satisfaction)
   ========================================================================== */
.star-rating { display: inline-flex; gap: 4px; direction: ltr; }
.star-rating-btn {
  width: 36px; height: 36px; padding: 0; border: none; background: none;
  cursor: pointer; color: var(--text-mute); transition: all .15s;
  display: inline-flex; align-items: center; justify-content: center;
}
.star-rating-btn .ico { width: 28px; height: 28px; transition: transform .15s; }
.star-rating-btn:hover { color: #f59e0b; transform: scale(1.15); }
.star-rating-btn:hover .ico { transform: scale(1.1); }
.star-rating-btn.active { color: #f59e0b; }
.star-rating-btn.active .ico { fill: #f59e0b; }

.rating-list { display: flex; flex-direction: column; gap: 12px; }
.rating-item {
  padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius);
  border-inline-start: 3px solid #f59e0b;
}
.rating-item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.rating-item-name { font-weight: 600; font-size: 13px; }
.rating-stars { display: inline-flex; gap: 1px; direction: ltr; }
.rating-item-comment { margin: 4px 0; line-height: 1.5; }

.btn-success { background: #059669 !important; color: #fff !important; border-color: #059669 !important; }

.theme-dark .rating-item { background: var(--bg-soft); }
.theme-dark .star-rating-btn { color: var(--text-mute); }
.theme-dark .star-rating-btn.active { color: #fbbf24; }
.theme-dark .star-rating-btn.active .ico { fill: #fbbf24; }

/* ==========================================================================
   LOGIN PAGE POLISH
   ========================================================================== */
.auth-shell {
  position: relative; overflow: hidden;
}
.auth-shell::before {
  content: ''; position: absolute; inset-block-start: -50%; inset-inline-end: -20%;
  width: 60%; height: 200%;
  background: radial-gradient(ellipse, rgba(14,165,233,.08) 0%, transparent 70%);
  pointer-events: none; z-index: 0;
}
.auth-card {
  position: relative; z-index: 1;
  animation: authCardIn .5s cubic-bezier(.4,0,.2,1);
}
@keyframes authCardIn {
  from { opacity: 0; transform: translateY(20px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================================
   LOADING SKELETON
   ========================================================================== */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-line { height: 14px; margin-bottom: 8px; }
.skeleton-line.short { width: 60%; }
.skeleton-line.medium { width: 80%; }
.skeleton-card { padding: 16px; border-radius: var(--radius); }

/* ==========================================================================
   FLASH TOAST
   ========================================================================== */
.flash.flash-success {
  background: rgba(5,150,105,.12);
  color: #059669;
  border: 1px solid rgba(5,150,105,.3);
}
.theme-dark .flash.flash-success {
  background: rgba(5,150,105,.2);
  color: #34d399;
}

/* ==========================================================================
   SETTINGS PAGE
   ========================================================================== */
.settings-list { display: flex; flex-direction: column; gap: 0; }
.setting-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 0; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .15s;
}
.setting-row:last-child { border-bottom: none; }
.setting-row:hover { background: var(--surface-2); margin: 0 -18px; padding-inline: 18px; }
.setting-info { flex: 1; }
.setting-label { display: block; font-weight: 600; font-size: 14px; color: var(--text); margin-bottom: 2px; }
.setting-desc { display: block; }

/* Switch toggle (reuse existing .switch but enhance) */
.switch {
  position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--border-strong); border-radius: 24px; transition: .3s;
}
.switch .slider::before {
  content: ''; position: absolute; height: 18px; width: 18px;
  inset-inline-start: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: .3s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }
[dir="rtl"] .switch input:checked + .slider::before { transform: translateX(-20px); }
.theme-dark .switch .slider { background: var(--surface-2); }
.theme-dark .switch input:checked + .slider { background: var(--primary); }

/* ==========================================================================
   ACTIVITY TIMELINE (dashboard)
   ========================================================================== */
.activity-timeline {
  display: flex; flex-direction: column;
  max-height: 400px; overflow-y: auto;
}
.activity-item {
  display: flex; gap: 12px; padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  transition: background .15s;
  animation: activitySlideIn .3s ease-out;
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--surface-2); }
@keyframes activitySlideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}
[dir="rtl"] .activity-item { animation-name: activitySlideInRtl; }
@keyframes activitySlideInRtl {
  from { opacity: 0; transform: translateX(8px); }
  to { opacity: 1; transform: translateX(0); }
}
.activity-icon {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.activity-icon .ico { width: 16px; height: 16px; color: #fff; }
.activity-emerald .activity-icon { background: #059669; }
.activity-blue .activity-icon { background: #0ea5e9; }
.activity-amber .activity-icon { background: #d97706; }
.activity-teal .activity-icon { background: #0d9488; }
.activity-content { flex: 1; min-width: 0; }
.activity-text { font-size: 13px; line-height: 1.5; }
.activity-actor { font-weight: 700; color: var(--text); }
.activity-action { color: var(--text-soft); margin-inline: 4px; }
.activity-target { color: var(--primary-ink); font-weight: 600; text-decoration: none; }
.activity-target:hover { text-decoration: underline; }
.activity-title { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-time { margin-top: 2px; }

/* Custom scrollbar for activity timeline */
.activity-timeline::-webkit-scrollbar { width: 6px; }
.activity-timeline::-webkit-scrollbar-track { background: transparent; }
.activity-timeline::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.activity-timeline::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

.theme-dark .activity-item:hover { background: var(--bg-soft); }

/* ==========================================================================
   TICKET TAGS
   ========================================================================== */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px; font-size: 12px; font-weight: 600;
  background: transparent; border: 1.5px solid var(--tag-color, var(--border));
  border-radius: var(--radius-pill); color: var(--tag-color, var(--text-soft));
  cursor: pointer; transition: all .15s;
}
.tag-chip:hover { background: var(--tag-color); color: #fff; transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.tag-chip.active { background: var(--tag-color); color: #fff; }
.tag-chip.active:hover { opacity: 0.85; }

/* ==========================================================================
   KEYBOARD SHORTCUT HELP MODAL
   ========================================================================== */
.shortcut-help-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.shortcut-help-modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); max-width: 480px; width: 90%;
  animation: modalIn .3s cubic-bezier(.4,0,.2,1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.shortcut-help-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.shortcut-help-head h2 { margin: 0; font-size: 18px; }
.shortcut-help-body { padding: 16px 20px; }
.shortcut-row {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.shortcut-row:last-child { border-bottom: none; }
.shortcut-row kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 36px; height: 30px; padding: 0 8px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); box-shadow: 0 2px 0 var(--border-strong);
  font-family: 'Vazirmatn', monospace; font-size: 13px; font-weight: 700;
  color: var(--text);
}
.theme-dark .shortcut-help-modal { background: var(--bg-elev); }
.theme-dark .shortcut-row kbd { background: var(--surface-2); }

/* ==========================================================================
   SIDEBAR NAV POLISH
   ========================================================================== */
.sidebar nav a, .drawer nav a {
  position: relative; overflow: hidden;
  transition: all .2s cubic-bezier(.4,0,.2,1);
}
.sidebar nav a::before, .drawer nav a::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 50%;
  width: 3px; height: 0; background: var(--primary);
  transform: translateY(-50%); transition: height .25s;
  border-radius: 0 3px 3px 0;
}
.sidebar nav a.active::before, .drawer nav a.active::before {
  height: 60%;
}
.sidebar nav a:hover, .drawer nav a:hover {
  transform: translateX(-2px);
}
[dir="rtl"] .sidebar nav a:hover, [dir="rtl"] .drawer nav a:hover {
  transform: translateX(2px);
}
.sidebar nav a .ico, .drawer nav a .ico {
  transition: transform .2s;
}
.sidebar nav a:hover .ico, .drawer nav a:hover .ico {
  transform: scale(1.1);
}

/* ==========================================================================
   COMMAND PALETTE (Ctrl+K)
   ========================================================================== */
.cmd-palette {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 15vh;
  animation: fadeIn .15s;
}
.cmd-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
}
.cmd-modal {
  position: relative; z-index: 1;
  width: 90%; max-width: 560px;
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: cmdModalIn .2s cubic-bezier(.4,0,.2,1);
}
@keyframes cmdModalIn {
  from { opacity: 0; transform: scale(.96) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.cmd-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.cmd-input-wrap .ico { width: 20px; height: 20px; color: var(--text-mute); flex-shrink: 0; }
.cmd-input-wrap input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 16px; color: var(--text); font-family: inherit;
}
.cmd-input-wrap input::placeholder { color: var(--text-mute); }
.cmd-input-wrap kbd {
  padding: 2px 8px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 11px; color: var(--text-mute);
}
.cmd-results { max-height: 400px; overflow-y: auto; padding: 8px; }
.cmd-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius);
  text-decoration: none; color: var(--text-soft);
  transition: all .1s; cursor: pointer;
}
.cmd-item:hover, .cmd-item.active {
  background: var(--primary-soft); color: var(--primary-ink);
}
.cmd-icon { width: 20px; height: 20px; flex-shrink: 0; display: inline-flex; }
.cmd-icon .ico { width: 20px; height: 20px; }
.cmd-label { flex: 1; font-size: 14px; font-weight: 500; }
.cmd-arrow { font-size: 12px; color: var(--text-mute); opacity: 0; transition: opacity .1s; }
.cmd-item.active .cmd-arrow { opacity: 1; }
.cmd-empty { padding: 24px; text-align: center; color: var(--text-mute); font-size: 14px; }

.theme-dark .cmd-modal { background: var(--bg-elev); }

/* ==========================================================================
   GRADIENT HEADER + CARD GLOW
   ========================================================================== */
.topbar {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border-block-end: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.theme-dark .topbar {
  background: linear-gradient(135deg, rgba(15,23,42,.95) 0%, rgba(30,41,59,.95) 100%);
}

/* Card hover glow */
.card {
  transition: box-shadow .25s ease, transform .25s ease, border-color .25s ease;
}
.card:hover {
  box-shadow: var(--shadow-sm);
}

/* Page head gradient */
.page-head {
  background: linear-gradient(135deg, var(--primary-soft) 0%, transparent 100%);
  padding: 18px 20px; border-radius: var(--radius-lg); margin-bottom: 18px;
  border-inline-start: 4px solid var(--primary);
}
.theme-dark .page-head {
  background: linear-gradient(135deg, rgba(14,165,233,.1) 0%, transparent 100%);
}

/* Stat card glow on hover */
.stat-card:hover::after {
  box-shadow: 0 0 20px currentColor;
  opacity: 0.15;
}

/* ==========================================================================
   SPARKLINE CHART (dashboard)
   ========================================================================== */
.sparkline-wrap { position: relative; padding: 10px 0; }
.sparkline-svg {
  width: 100%; height: auto; display: block;
  overflow: visible; max-height: 200px;
}
.spark-x-label {
  font-size: 10px; fill: var(--text-mute); font-weight: 600;
  font-family: inherit;
}
.spark-area {
  animation: sparkFadeIn .6s ease-out;
}
.spark-line {
  stroke-dasharray: 2000;
  stroke-dashoffset: 2000;
  animation: sparkDrawIn 1.2s ease-out forwards;
}
.spark-dot {
  cursor: pointer; transition: r .15s, stroke-width .15s;
  opacity: 0;
  animation: sparkDotIn .3s ease-out forwards;
  animation-delay: 1s;
}
.spark-dot:hover { r: 5; stroke-width: 3; }
@keyframes sparkFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes sparkDrawIn { to { stroke-dashoffset: 0; } }
@keyframes sparkDotIn { to { opacity: 1; } }
.sparkline-tooltip {
  position: absolute; transform: translate(-50%, -100%);
  background: var(--text); color: var(--surface);
  padding: 4px 10px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 600; white-space: nowrap;
  opacity: 0; transition: opacity .15s; pointer-events: none;
  z-index: 10;
}
.sparkline-stats {
  display: flex; gap: 24px; margin-top: 16px;
  padding-top: 16px; border-top: 1px solid var(--border);
}
.spark-stat { display: flex; flex-direction: column; gap: 4px; }
.spark-stat-label { font-size: 11px; color: var(--text-mute); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.spark-stat-value { font-size: 20px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
.toast-container {
  position: fixed; bottom: 24px; inset-inline-end: 24px; z-index: 10001;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-md); min-width: 280px; max-width: 400px;
  pointer-events: auto;
  transform: translateX(100%); opacity: 0;
  transition: transform .3s cubic-bezier(.4,0,.2,1), opacity .3s;
}
[dir="rtl"] .toast { transform: translateX(-100%); }
.toast.show { transform: translateX(0); opacity: 1; }
.toast.hide { transform: translateX(100%); opacity: 0; }
[dir="rtl"] .toast.hide { transform: translateX(-100%); }
.toast-icon {
  width: 24px; height: 24px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0; color: #fff;
}
.toast-msg { flex: 1; font-size: 14px; font-weight: 500; color: var(--text); }
.toast-close {
  background: none; border: none; color: var(--text-mute);
  cursor: pointer; font-size: 14px; padding: 4px; border-radius: var(--radius-sm);
}
.toast-close:hover { color: var(--text); background: var(--surface-2); }
.toast-success .toast-icon { background: #059669; }
.toast-error .toast-icon { background: #dc2626; }
.toast-warning .toast-icon { background: #d97706; }
.toast-info .toast-icon { background: #0ea5e9; }
.toast-success { border-inline-start: 3px solid #059669; }
.toast-error { border-inline-start: 3px solid #dc2626; }
.toast-warning { border-inline-start: 3px solid #d97706; }
.toast-info { border-inline-start: 3px solid #0ea5e9; }
.theme-dark .toast { background: var(--bg-elev); }

/* ==========================================================================
   LOADING SPINNER
   ========================================================================== */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--surface-2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

/* ==========================================================================
   PAGE TRANSITION
   ========================================================================== */
.content > * {
  animation: pageIn .3s ease-out;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   ONLINE STATUS INDICATOR
   ========================================================================== */
.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-mute); flex-shrink: 0;
}
.status-dot.online { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,.5); }
.status-dot.recent { background: #f59e0b; }
.status-dot.offline { background: var(--text-mute); }

/* ==========================================================================
   BREADCRUMBS
   ========================================================================== */
.breadcrumbs {
  margin-bottom: 14px;
  font-size: 13px;
}
.breadcrumbs ol {
  list-style: none; padding: 0; margin: 0;
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px;
}
.breadcrumb-item {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-mute);
}
.breadcrumb-item a {
  color: var(--text-soft); text-decoration: none;
  padding: 3px 8px; border-radius: var(--radius-sm);
  transition: all .15s;
}
.breadcrumb-item a:hover {
  color: var(--primary-ink); background: var(--primary-soft);
}
.breadcrumb-item.active {
  color: var(--text); font-weight: 600;
  padding: 3px 8px;
}
.breadcrumb-sep {
  color: var(--text-mute); opacity: .6; font-size: 14px;
}
[dir="rtl"] .breadcrumb-sep { transform: scaleX(-1); }

/* ==========================================================================
   CARD COLLAPSIBLE
   ========================================================================== */
.card[data-collapsible] .card-head {
  cursor: pointer; user-select: none;
}
.card[data-collapsible] .card-head h2 {
  display: flex; align-items: center; gap: 8px;
}
.card[data-collapsible] .card-head h2::after {
  content: ''; margin-inline-start: auto;
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--text-mute);
  transition: transform .25s;
}
.card.collapsed .card-head h2::after {
  transform: rotate(-90deg);
}
.card.collapsed .card-body,
.card.collapsed .card-foot,
.card.collapsed .table-wrap {
  display: none;
}
.card[data-collapsible] .card-head:hover {
  background: var(--surface-2);
}

/* ==========================================================================
   DARK MODE PERSISTENCE (no FOUC)
   ========================================================================== */
html.theme-dark { background: var(--bg); color-scheme: dark; }
html.theme-light { color-scheme: light; }

/* ==========================================================================
   ORGANIZATIONAL CHART
   ========================================================================== */
.org-chart-controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.org-stats { display: flex; gap: 8px; }
.org-controls-actions { display: flex; gap: 8px; }

/* Staff tree */
.org-tree { display: flex; flex-direction: column; gap: 4px; }
.org-node { position: relative; }
.org-node-card {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  transition: all .15s; cursor: default;
}
.org-node-card.has-staff { border-inline-start: 3px solid var(--primary); }
.org-node-card:hover { background: var(--surface-2); }
.org-toggle {
  width: 24px; height: 24px; border: none; background: none;
  cursor: pointer; color: var(--text-mute);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); transition: all .15s;
}
.org-toggle:hover { background: var(--surface-2); color: var(--primary); }
.org-toggle .ico { width: 16px; height: 16px; transition: transform .25s; }
.org-toggle[aria-expanded="false"] .ico { transform: rotate(-90deg); }
.org-toggle-placeholder { width: 24px; }
.org-title { font-weight: 600; font-size: 14px; flex: 1; }
.org-members {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px 12px 6px 44px;
}
.org-members-collapsed { display: none; }
.org-member {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; background: var(--primary-soft); border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 500;
}
.org-member-fac { font-size: 10px; }
.org-children {
  margin-inline-start: 20px;
  border-inline-start: 2px solid var(--border);
  padding-inline-start: 4px;
  display: flex; flex-direction: column; gap: 4px;
  overflow: hidden; transition: max-height .3s;
}
.org-children-collapsed { display: none; }

/* Faculty tree */
.org-faculty-list { display: flex; flex-direction: column; gap: 12px; }
.org-faculty-node { }
.org-faculty-card {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 18px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary-soft) 0%, var(--surface) 100%);
  border: 1px solid var(--primary); cursor: pointer;
  transition: all .15s;
}
.org-faculty-card:hover { box-shadow: var(--shadow-sm); }
.org-faculty-node.collapsed .org-faculty-body { display: none; }
.org-faculty-node.collapsed .org-chevron { transform: rotate(-90deg); }
.org-chevron { width: 18px; height: 18px; color: var(--primary); transition: transform .25s; }
.org-faculty-title { font-weight: 700; font-size: 15px; color: var(--text); flex: 1; }
.org-faculty-body {
  margin-inline-start: 16px;
  border-inline-start: 3px solid var(--primary);
  padding: 8px 0 8px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.org-dept-node { }
.org-dept-card {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); cursor: pointer;
  transition: all .15s;
}
.org-dept-card:hover { background: var(--primary-soft); }
.org-dept-node.collapsed .org-dept-body { display: none; }
.org-dept-node.collapsed .org-chevron { transform: rotate(-90deg); }
.org-dept-title { font-weight: 600; font-size: 13px; flex: 1; }
.org-dept-body { padding: 8px 0 8px 16px; }
.org-prof-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.org-prof-card {
  padding: 8px 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
  transition: all .15s;
}
.org-prof-card:hover { border-color: var(--primary); box-shadow: var(--shadow-xs); }
.org-prof-name { font-weight: 600; font-size: 13px; }
.org-prof-group { font-size: 11px; }

.theme-dark .org-faculty-card { background: linear-gradient(135deg, rgba(14,165,233,.15) 0%, var(--surface) 100%); }
.theme-dark .org-prof-card { background: var(--bg-elev); }

@media (max-width: 640px) {
  .org-prof-grid { grid-template-columns: 1fr; }
  .org-children { margin-inline-start: 12px; }
  .org-members { padding-inline-start: 28px; }
}

/* ==========================================================================
   THEME + LANGUAGE SELECTORS (preferences page)
   ========================================================================== */
.theme-selector, .locale-selector {
  display: inline-flex; gap: 8px;
}
.theme-option, .locale-option {
  position: relative; cursor: pointer; border: none; background: none; padding: 0; font: inherit;
}
.theme-option input, .locale-option input { display: none; }
.theme-option-label, .locale-option-label {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 20px; border-radius: var(--radius);
  border: 2px solid var(--border); background: var(--surface);
  font-size: 13px; font-weight: 600; color: var(--text-soft);
  transition: all .15s; min-width: 80px;
}
.theme-option:hover .theme-option-label,
.locale-option:hover .locale-option-label {
  border-color: var(--primary); color: var(--primary-ink);
}
.theme-option.active .theme-option-label,
.locale-option.active .locale-option-label {
  border-color: var(--primary); background: var(--primary-soft);
  color: var(--primary-ink);
}

/* i18n: language_desc */
.language_desc { }



/* ==========================================================================
   SIMPLE TREE (org chart) — file-explorer style, minimal
   ========================================================================== */
.org-tab-switcher { display: inline-flex; gap: 4px; }

.st-controls {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
}

.st-tree {
  font-family: 'Vazirmatn', sans-serif;
  font-size: 14px; line-height: 1.8;
  user-select: none;
}

/* Node */
.st-node { }

/* Row — just text, no boxes */
.st-row {
  display: flex; align-items: center; gap: 4px;
  padding: 2px 0; cursor: default;
  white-space: nowrap;
}
.st-row.st-leaf { cursor: default; }
.st-row:hover .st-label { color: var(--primary); }

/* Indentation spacer — creates the tree structure */
.st-indent {
  display: inline-block; width: 20px; height: 1px;
  flex-shrink: 0;
}

/* Toggle button */
.st-toggle {
  width: 16px; height: 16px; border: none; background: none;
  cursor: pointer; padding: 0; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.st-toggle:hover .st-tri { border-top-color: var(--primary); border-left-color: var(--primary); }
.st-toggle-spacer { width: 16px; flex-shrink: 0; }

/* Triangle icons — customizable via CSS */
.st-tri {
  display: inline-block; width: 0; height: 0;
  border-style: solid; transition: transform .15s;
}
.st-tri.st-open {
  border-width: 4px 3px 0 3px;
  border-color: var(--text-soft) transparent transparent transparent;
}
.st-tri.st-closed {
  border-width: 3px 0 3px 4px;
  border-color: transparent transparent transparent var(--text-soft);
}

/* Label — plain text */
.st-label {
  font-size: 14px; color: var(--text);
  transition: color .12s;
}
.st-leaf .st-label { font-weight: 400; }
.st-node > .st-row .st-label { font-weight: 600; }

/* Count badge — just parentheses text */
.st-count {
  font-size: 12px; color: var(--text-mute); font-weight: 400;
  font-variant-numeric: tabular-nums;
}

/* Leaf icon — small dot */
.st-leaf-icon {
  display: inline-block; width: 5px; height: 5px;
  border-radius: 50%; background: var(--text-mute);
  opacity: 0.5; flex-shrink: 0;
}

/* Role badge */
.st-role {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  padding: 0 5px; border-radius: 3px; margin-inline-start: 4px;
}
.st-role.role-staff { background: var(--primary); color: #fff; }
.st-role.role-prof { background: #059669; color: #fff; }
.st-role.role-manager { background: #d97706; color: #fff; }

/* Children container */
.st-children {
  /* No styling — just structural */
}

/* Dark mode */
.theme-dark .st-label { color: var(--text); }
.theme-dark .st-tri.st-open { border-top-color: var(--text-soft); }
.theme-dark .st-tri.st-closed { border-left-color: var(--text-soft); }
.theme-dark .st-leaf-icon { background: var(--text-soft); }
