/* ══════════════════════════════════════════════════════════════════════════
   ServiceDesk Simulator – Purple Dashboard Theme
   ══════════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0b0e1a;
  --bg-1:     #111527;
  --bg-2:     #151929;
  --bg-3:     #1a1f35;
  --bg-4:     #1e2640;
  --border:   #1e2a42;
  --border-h: #263352;

  --accent:       #7c3aed;
  --accent-h:     #9f7aea;
  --accent-light: #c4b5fd;
  --accent-dim:   rgba(124,58,237,.12);
  --accent-glow:  0 0 20px rgba(124,58,237,.25);

  --green:  #22c55e;
  --red:    #ef4444;
  --yellow: #eab308;
  --orange: #f97316;
  --blue:   #3b82f6;
  --pink:   #ec4899;

  --text:   #e2e8f0;
  --muted:  #64748b;
  --muted2: #94a3b8;

  --sidebar-w: 220px;
  --header-h: 56px;
  --stats-h: 96px;
  --radius: 8px;
  --radius-lg: 12px;

  /* Scroll bar */
  --sb-bg: #111527;
  --sb-thumb: #1e2a42;
}

html, body { height: 100%; font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 13px; line-height: 1.5; }

/* ── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--sb-bg); }
::-webkit-scrollbar-thumb { background: var(--sb-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-h); }

/* ══════════════════════════════════════════════════════════════════════════
   BODY LAYOUT
   ══════════════════════════════════════════════════════════════════════════ */

body { display: flex; height: 100vh; overflow: hidden; }

/* ══════════════════════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════════════════════ */

#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Brand */
#sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-icon-wrap {
  font-size: 22px;
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(124,58,237,.4);
}
.brand-name { font-size: 15px; font-weight: 800; letter-spacing: -.3px; }
.brand-sub  { font-size: 10px; color: var(--muted); letter-spacing: .5px; text-transform: uppercase; }

/* Nav */
#sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.nav-section {
  padding: 14px 16px 5px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .8px;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-left: 2px solid transparent;
  color: var(--muted2);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  text-align: left;
  position: relative;
}
.nav-item:hover  { background: rgba(255,255,255,.04); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--text); border-left-color: var(--accent); }
.ni-icon  { font-size: 15px; flex-shrink: 0; }
.ni-label { flex: 1; }
.ni-badge {
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
  line-height: 1.6;
}
.ni-badge.hidden { display: none; }

/* Sidebar User Card */
#sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#sidebar-avatar { flex-shrink: 0; }
#sidebar-avatar img { width: 32px; height: 32px; border-radius: 50%; display: block; }
#sidebar-user-info { flex: 1; min-width: 0; }
#sidebar-username { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sidebar-role { font-size: 10px; color: var(--muted); }
#btn-logout {
  background: transparent; border: none; cursor: pointer;
  color: var(--muted); font-size: 16px; padding: 4px;
  border-radius: 5px; transition: color .15s, background .15s; flex-shrink: 0;
}
#btn-logout:hover { color: var(--red); background: rgba(239,68,68,.1); }

/* ══════════════════════════════════════════════════════════════════════════
   MAIN AREA
   ══════════════════════════════════════════════════════════════════════════ */

#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Page Header */
#page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 0;
  flex-shrink: 0;
}
#page-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.3px;
  line-height: 1.2;
}
#page-sub { font-size: 11px; color: var(--muted); margin-left: 6px; }
#header-actions { display: flex; gap: 8px; }

/* Stats Row */
#stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 14px 20px 0;
  flex-shrink: 0;
}
.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
  transition: box-shadow .2s;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.sc-accent::after { background: linear-gradient(90deg, var(--accent), #9f7aea); }
.sc-green::after  { background: linear-gradient(90deg, var(--green), #4ade80); }
.sc-orange::after { background: linear-gradient(90deg, var(--orange), #fbbf24); }
.sc-blue::after   { background: linear-gradient(90deg, var(--blue), #06b6d4); }

.sc-icon {
  font-size: 22px;
  width: 44px; height: 44px;
  background: rgba(255,255,255,.05);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sc-body { flex: 1; min-width: 0; }
.sc-val {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
}
.sc-accent .sc-val { color: var(--accent-h); }
.sc-green .sc-val  { color: var(--green); }
.sc-orange .sc-val { color: var(--orange); }
.sc-blue .sc-val   { color: var(--blue); }
.sc-label { font-size: 11px; color: var(--muted); margin-top: 3px; }
.sc-sub {
  position: absolute;
  bottom: 10px; right: 14px;
  font-size: 10px; color: var(--muted);
}

/* Game Area */
#game-area {
  flex: 1;
  display: flex;
  overflow: hidden;
  padding: 14px 20px 16px;
  gap: 14px;
  min-height: 0;
}

/* ══════════════════════════════════════════════════════════════════════════
   QUEUE PANEL
   ══════════════════════════════════════════════════════════════════════════ */

#queue-panel {
  width: 262px;
  min-width: 262px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}
.queue-filters {
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.filter-btn {
  flex: 1; padding: 5px 4px;
  background: transparent; border: 1px solid var(--border-h);
  border-radius: 6px; color: var(--muted); font-size: 11px;
  cursor: pointer; transition: all .15s;
}
.filter-btn:hover  { border-color: var(--accent-h); color: var(--text); }
.filter-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent-h); }

#ticket-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

/* Ticket Card */
.ticket-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 11px;
  margin-bottom: 5px;
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
  position: relative;
}
.ticket-card:hover  { background: var(--bg-4); border-color: var(--border-h); }
.ticket-card.active { border-color: var(--accent); background: var(--accent-dim); box-shadow: var(--accent-glow); }
.ticket-card.new-pulse { animation: pulse .4s ease; }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.02)} }

.tc-top  { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.tc-id   { font-size: 10px; color: var(--muted); font-weight: 600; font-family: monospace; }
.tc-title{ font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.35; margin-bottom: 5px; }
.tc-meta { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
.tc-time { color: var(--muted); }
.tc-cat  { color: var(--muted2); }
.tc-sla-mini { height: 3px; background: var(--bg); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.tc-sla-fill { height: 100%; border-radius: 2px; transition: width .5s; }

/* Prio badges */
.tc-prio, .prio-badge {
  font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: .4px;
}
.prio-LOW      { background: rgba(34,197,94,.2);   color: var(--green); }
.prio-MEDIUM   { background: rgba(234,179,8,.2);   color: var(--yellow); }
.prio-HIGH     { background: rgba(249,115,22,.2);  color: var(--orange); }
.prio-CRITICAL { background: rgba(239,68,68,.2);   color: var(--red); }

/* ══════════════════════════════════════════════════════════════════════════
   WORK AREA
   ══════════════════════════════════════════════════════════════════════════ */

#work-area {
  flex: 1;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.tool-panel {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.tool-panel.hidden { display: none; }

/* Empty State */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; text-align: center; padding: 40px;
}
.empty-icon { font-size: 52px; margin-bottom: 16px; opacity: .7; }
.empty-state h2 { font-size: 18px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.empty-state p  { color: var(--muted); font-size: 13px; max-width: 320px; }
.empty-state .hint { font-size: 11px; margin-top: 6px; }
.empty-state.small { padding: 20px; }

/* Tool Header */
.tool-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
}
.tool-header h3 { font-size: 15px; font-weight: 700; flex: 1; }

/* ══════════════════════════════════════════════════════════════════════════
   TICKET DETAIL
   ══════════════════════════════════════════════════════════════════════════ */

#panel-ticket { padding: 0; }
#no-ticket-selected { flex: 1; display: flex; }
#ticket-detail { display: flex; flex-direction: column; gap: 14px; padding: 16px; flex: 1; }

#ticket-header-area {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
}
#ticket-id-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.ticket-id-label {
  font-size: 12px; font-weight: 700; color: var(--accent-h); font-family: monospace;
}
.cat-badge {
  font-size: 10px; padding: 2px 7px;
  background: var(--bg-4); color: var(--muted2);
  border-radius: 4px; border: 1px solid var(--border-h);
}
.status-badge {
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 4px;
}
.status-OPEN        { background: rgba(59,130,246,.2); color: var(--blue); }
.status-SLA_BREACHED{ background: rgba(249,115,22,.2); color: var(--orange); }
.status-RESOLVED    { background: rgba(34,197,94,.2);  color: var(--green); }
.status-INCORRECT   { background: rgba(239,68,68,.2);  color: var(--red); }

#td-title { font-size: 15px; font-weight: 700; margin: 4px 0 10px; line-height: 1.3; }

#td-sla-row {
  display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--muted);
}
#td-sla-bar-wrap {
  flex: 1; height: 5px; background: var(--bg); border-radius: 3px; overflow: hidden;
}
#td-sla-bar { height: 100%; border-radius: 3px; transition: width .5s, background .5s; }
#td-sla-remain { font-weight: 600; white-space: nowrap; }

#ticket-body {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}

/* Section Card */
.section-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.section-title {
  font-size: 11px; font-weight: 700; color: var(--muted2); text-transform: uppercase;
  letter-spacing: .6px; margin-bottom: 10px;
}

/* Reporter */
.reporter-row { display: flex; gap: 6px; font-size: 12px; margin-bottom: 3px; }
.reporter-key { color: var(--muted); min-width: 90px; flex-shrink: 0; }
.reporter-val { color: var(--text); }

/* Description */
#td-desc {
  font-size: 12px; color: var(--muted2); line-height: 1.6;
  white-space: pre-wrap; font-family: inherit; overflow-wrap: break-word;
}

/* Chat */
#chat-card { display: flex; flex-direction: column; }
#td-chat-log { flex: 1; max-height: 200px; overflow-y: auto; margin-bottom: 10px; }
.chat-msg { margin-bottom: 8px; }
.chat-from-user    .chat-name { color: var(--blue); }
.chat-from-support .chat-name { color: var(--accent-h); }
.chat-name { font-size: 10px; font-weight: 700; margin-bottom: 2px; }
.chat-text { font-size: 12px; color: var(--text); }
.chat-time { font-size: 10px; color: var(--muted); }
#chat-input-row { display: flex; gap: 6px; }
#chat-input { flex: 1; }

/* Resolve Form */
#resolve-form { flex-shrink: 0; }
.form-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap;
}
.form-row label { min-width: 165px; font-size: 12px; color: var(--muted2); flex-shrink: 0; }
.form-row input,
.form-row select { flex: 1; min-width: 120px; }
#res-btn-row { margin-top: 4px; }
#res-service-row { display: flex; }
#res-service-row.hidden { display: none; }

/* ══════════════════════════════════════════════════════════════════════════
   INPUTS & FORMS
   ══════════════════════════════════════════════════════════════════════════ */

input[type=text], input[type=email], input[type=password], select, textarea {
  background: var(--bg-4);
  border: 1px solid var(--border-h);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(124,58,237,.2); }
input::placeholder { color: var(--muted); }
select option { background: var(--bg-2); }
.search-input { width: 200px; }

/* ══════════════════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px; border: none; border-radius: var(--radius);
  font-size: 12px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn-primary      { background: var(--accent); color: #fff; }
.btn-primary:hover{ background: #6d28d9; }
.btn-success      { background: rgba(34,197,94,.2); color: var(--green); border: 1px solid rgba(34,197,94,.3); }
.btn-success:hover{ background: rgba(34,197,94,.3); }
.btn-ghost        { background: transparent; color: var(--muted2); border: 1px solid var(--border-h); }
.btn-ghost:hover  { background: var(--bg-3); color: var(--text); }
.btn-danger       { background: rgba(239,68,68,.2); color: var(--red); border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover { background: rgba(239,68,68,.3); }

.btn-primary-sm   { padding: 5px 10px; font-size: 11px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); cursor: pointer; font-family: inherit; font-weight: 600; }
.btn-primary-sm:hover { background: #6d28d9; }
.btn-ghost-sm     { padding: 5px 10px; font-size: 11px; background: transparent; color: var(--muted2); border: 1px solid var(--border-h); border-radius: var(--radius); cursor: pointer; font-family: inherit; font-weight: 600; transition: all .15s; }
.btn-ghost-sm:hover { background: var(--bg-3); color: var(--text); }
.btn-danger-sm    { padding: 4px 8px; font-size: 11px; background: rgba(239,68,68,.15); color: var(--red); border: 1px solid rgba(239,68,68,.3); border-radius: var(--radius); cursor: pointer; font-family: inherit; font-weight: 600; }
.btn-danger-sm:hover { background: rgba(239,68,68,.3); }
.btn-svc-restart  { padding: 4px 8px; font-size: 11px; border: none; border-radius: 5px; cursor: pointer; font-family: inherit; transition: all .15s; }
.btn-svc-restart.running { background: rgba(255,255,255,.07); color: var(--muted2); }
.btn-svc-restart.running:hover { background: var(--accent-dim); color: var(--accent-h); }
.btn-svc-restart.stopped { background: rgba(34,197,94,.15); color: var(--green); }
.btn-svc-restart.stopped:hover { background: rgba(34,197,94,.25); }

/* AD action buttons */
.ad-action-btn {
  display: inline-block; padding: 3px 8px; border-radius: 5px; border: none;
  font-size: 11px; cursor: pointer; font-family: inherit; margin: 1px; transition: all .12s;
}
.ad-btn-reset  { background: rgba(59,130,246,.15); color: var(--blue); }
.ad-btn-reset:hover { background: rgba(59,130,246,.3); }
.ad-btn-unlock { background: rgba(34,197,94,.15);  color: var(--green); }
.ad-btn-unlock:hover { background: rgba(34,197,94,.3); }
.ad-btn-perms  { background: rgba(234,179,8,.15);  color: var(--yellow); }
.ad-btn-perms:hover { background: rgba(234,179,8,.3); }

/* ══════════════════════════════════════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════════════════════════════════════ */

.badge {
  display: inline-block; padding: 2px 7px; font-size: 10px; font-weight: 700;
  border-radius: 10px; letter-spacing: .2px;
}
.badge-accent { background: var(--accent-dim); color: var(--accent-h); border: 1px solid rgba(124,58,237,.3); }
.badge-green  { background: rgba(34,197,94,.15);  color: var(--green); }
.badge-blue   { background: rgba(59,130,246,.15); color: var(--blue); }
.badge-yellow { background: rgba(234,179,8,.15);  color: var(--yellow); }
.badge-red    { background: rgba(239,68,68,.15);  color: var(--red); }

/* ══════════════════════════════════════════════════════════════════════════
   ACTIVE DIRECTORY PANEL
   ══════════════════════════════════════════════════════════════════════════ */

.table-wrap { flex: 1; overflow: auto; }

.data-table {
  width: 100%; border-collapse: collapse;
}
.data-table th {
  text-align: left; font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
  padding: 9px 12px; border-bottom: 1px solid var(--border);
  background: var(--bg-3); position: sticky; top: 0; z-index: 1;
}
.data-table td {
  padding: 9px 12px; border-bottom: 1px solid var(--border);
  font-size: 12px; vertical-align: middle;
}
.data-table tr:hover td { background: var(--bg-4); }
.data-table tr:last-child td { border-bottom: none; }

.account-locked  { color: var(--red); font-size: 11px; }
.account-ok      { color: var(--green); font-size: 11px; }
.pw-expired      { color: var(--yellow); font-size: 11px; }
.pw-ok           { color: var(--green); font-size: 11px; }

.group-chip {
  display: inline-block; padding: 1px 6px; margin: 1px;
  background: var(--bg-4); color: var(--muted2);
  border-radius: 4px; font-size: 10px; border: 1px solid var(--border-h);
}
.action-apply-row {
  display: flex; align-items: center; gap: 5px; font-size: 11px;
  color: var(--muted); margin-top: 4px; flex-wrap: wrap;
}
.ad-ticket-sel { min-width: 130px; }

/* ══════════════════════════════════════════════════════════════════════════
   SERVER ROOM
   ══════════════════════════════════════════════════════════════════════════ */

#server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
}
.server-card {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  transition: border-color .15s, box-shadow .15s;
}
.server-card:hover { border-color: var(--border-h); }
.srv-header {
  display: flex; justify-content: space-between;
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.srv-name { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.srv-role { font-size: 11px; color: var(--muted); margin-top: 2px; }
.srv-ip   { font-size: 12px; color: var(--accent-light); font-family: monospace; text-align: right; }
.srv-status { font-size: 10px; color: var(--muted); text-align: right; margin-top: 2px; }

.svc-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 12px;
}
.svc-row:last-child { border-bottom: none; }
.svc-name  { flex: 1; display: flex; align-items: center; gap: 6px; }
.svc-badge {
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 4px;
}
.svc-badge.running  { background: rgba(34,197,94,.15); color: var(--green); }
.svc-badge.stopped  { background: rgba(239,68,68,.15); color: var(--red); }
.svc-badge.critical { background: rgba(239,68,68,.15); color: var(--red); border-radius: 50%; width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; padding: 0; }

/* Status dots */
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-ok   { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-err  { background: var(--red); box-shadow: 0 0 6px var(--red); box-shadow: 0 0 6px rgba(234,179,8,.5); }
.dot-warn { background: var(--yellow); box-shadow: 0 0 6px rgba(234,179,8,.4); }

/* ══════════════════════════════════════════════════════════════════════════
   KNOWLEDGE BASE
   ══════════════════════════════════════════════════════════════════════════ */

#kb-layout { display: flex; gap: 14px; flex: 1; min-height: 0; }
#kb-list {
  width: 220px; min-width: 220px;
  overflow-y: auto; border-right: 1px solid var(--border);
  padding-right: 10px;
}
#kb-article { flex: 1; overflow-y: auto; padding: 0 4px; }
#kb-article h3 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.kb-cat-label { font-size: 10px; color: var(--muted); margin-bottom: 14px; }
.kb-body { font-size: 12.5px; line-height: 1.75; color: var(--muted2); white-space: pre-wrap; }
.kb-body strong { color: var(--text); font-weight: 700; }
.kb-body code { font-family: monospace; background: var(--bg-4); padding: 1px 5px; border-radius: 4px; color: var(--accent-light); }
.kb-item {
  padding: 10px 8px; border-radius: var(--radius); cursor: pointer;
  transition: background .12s; margin-bottom: 2px;
}
.kb-item:hover  { background: var(--bg-3); }
.kb-item.active { background: var(--accent-dim); border-left: 2px solid var(--accent); }
.kb-item-cat   { font-size: 9px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 2px; }
.kb-item-title { font-size: 12px; color: var(--text); line-height: 1.3; }

/* ══════════════════════════════════════════════════════════════════════════
   REMOTE DESKTOP
   ══════════════════════════════════════════════════════════════════════════ */

#remote-content { display: flex; flex-direction: column; gap: 14px; }
#remote-terminal { border-radius: var(--radius-lg); overflow: hidden; }
.terminal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 14px;
  background: var(--bg-4); border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--accent-h);
}
#remote-screen {
  background: #0d1117; border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  font-family: 'Courier New', monospace; font-size: 12px;
  height: 260px;
  display: flex; flex-direction: column; overflow: hidden;
}
#remote-output {
  flex: 1; overflow-y: auto; padding: 12px 16px; color: #58a6ff; line-height: 1.7;
}
.remote-line { color: #8b949e; }
.remote-line span { color: #58a6ff; }
#remote-taskbar {
  border-top: 1px solid #30363d; padding: 6px 12px;
  display: flex; gap: 10px; background: #161b22; flex-shrink: 0;
}
.taskbar-item { font-size: 10px; color: #8b949e; }
.taskbar-item.active { color: #58a6ff; }

/* ══════════════════════════════════════════════════════════════════════════
   PROFILE PANEL
   ══════════════════════════════════════════════════════════════════════════ */

.profile-header {
  display: flex; align-items: center; gap: 20px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 24px;
  margin-bottom: 18px;
}
.profile-avatar { width: 80px; height: 80px; border-radius: 50%; flex-shrink: 0; border: 3px solid var(--accent-dim); }
.profile-info {}
.profile-name    { font-size: 20px; font-weight: 800; letter-spacing: -.3px; margin-bottom: 3px; }
.profile-email   { font-size: 12px; color: var(--muted);  margin-bottom: 4px; }
.profile-joined  { font-size: 11px; color: var(--muted); }

.profile-stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
.profile-stat-card {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 18px;
  text-align: center;
}
.psc-val {
  font-size: 28px; font-weight: 800; letter-spacing: -1px;
  line-height: 1; margin-bottom: 6px;
}
.psc-val.accent { color: var(--accent-h); }
.psc-val.green  { color: var(--green); }
.psc-val.blue   { color: var(--blue); }
.psc-val.orange { color: var(--orange); }
.psc-val.red    { color: var(--red); }
.psc-label { font-size: 11px; color: var(--muted); }

/* ══════════════════════════════════════════════════════════════════════════
   LEADERBOARD PANEL
   ══════════════════════════════════════════════════════════════════════════ */

.lb-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.lb-header h2 { font-size: 16px; font-weight: 800; }

.lb-table { width: 100%; }
.lb-user  { display: flex; align-items: center; gap: 8px; }
.lb-avatar { width: 28px; height: 28px; border-radius: 50%; }
.lb-score { font-weight: 700; }
.lb-score.accent { color: var(--accent-h); }

tr.rank-1 td { background: rgba(234,179,8,.05); }
tr.rank-2 td { background: rgba(148,163,184,.04); }
tr.rank-3 td { background: rgba(249,115,22,.04); }
.rank-num { font-size: 16px; text-align: center; }

/* ══════════════════════════════════════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════════════════════════════════════ */

.modal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.65); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .15s ease;
}
.modal.hidden { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--bg-2);
  border: 1px solid var(--border-h);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%; max-width: 440px;
  box-shadow: 0 25px 60px rgba(0,0,0,.5);
  animation: slideUp .2s cubic-bezier(.34,1.56,.64,1);
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }

/* Result modal */
.result-box { text-align: center; max-width: 340px; }
.result-icon-big  { font-size: 52px; margin-bottom: 10px; line-height: 1; }
.result-title { font-size: 20px; font-weight: 800; margin-bottom: 12px; letter-spacing: -.3px; }
.result-points { font-size: 36px; font-weight: 800; letter-spacing: -1px; }
.result-points.pos { color: var(--green); }
.result-points.neg { color: var(--red); }

/* ══════════════════════════════════════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════════════════════════════════════ */

#toast-area { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column-reverse; gap: 8px; }

.toast {
  padding: 10px 16px; border-radius: var(--radius);
  font-size: 12.5px; font-weight: 500;
  box-shadow: 0 8px 25px rgba(0,0,0,.4);
  border: 1px solid transparent;
  animation: toastIn .25s ease;
  max-width: 340px;
}
@keyframes toastIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-out { animation: toastOut .3s ease forwards; }
@keyframes toastOut { to { transform: translateX(20px); opacity: 0; } }

.toast-info    { background: var(--bg-3); border-color: var(--border-h); color: var(--text); }
.toast-success { background: rgba(34,197,94,.15); border-color: rgba(34,197,94,.3); color: var(--green); }
.toast-error   { background: rgba(239,68,68,.15); border-color: rgba(239,68,68,.3); color: var(--red); }
.toast-warning { background: rgba(249,115,22,.15); border-color: rgba(249,115,22,.3); color: var(--orange); }

/* ══════════════════════════════════════════════════════════════════════════
   UTILITY
   ══════════════════════════════════════════════════════════════════════════ */

.mono     { font-family: monospace; }
.text-muted { color: var(--muted); }
.text-muted2{ color: var(--muted2); }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-accent{ color: var(--accent-h); }
.hidden     { display: none !important; }
.loading-state { padding: 40px; text-align: center; color: var(--muted); }

/* ══════════════════════════════════════════════════════════════════════════
   V4.0 ADDITIONS — Group Chips, Typing Indicator, AD Actions
   ══════════════════════════════════════════════════════════════════════════ */

/* Group chip remove button */
.group-chip { position: relative; padding-right: 18px !important; }
.group-remove-btn {
  position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); font-size: 11px;
  cursor: pointer; padding: 0 1px; line-height: 1;
}
.group-remove-btn:hover { color: var(--red); }
.group-chips-wrap { display: flex; flex-wrap: wrap; gap: 2px; }

/* AD action stack */
.ad-action-stack { display: flex; flex-direction: column; gap: 3px; min-width: 140px; }
.ad-btn-disable { background: rgba(239,68,68,.15); color: var(--red); }
.ad-btn-disable:hover { background: rgba(239,68,68,.3); }
.ad-btn-enable  { background: rgba(34,197,94,.15); color: var(--green); }
.ad-btn-enable:hover  { background: rgba(34,197,94,.3); }

/* Typing indicator bubble */
.chat-typing-bubble {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; margin: 4px 0;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 10px; font-size: 11px; color: var(--muted); max-width: 220px;
}
.typing-dots { display: flex; gap: 3px; align-items: center; }
.typing-dots span {
  display: inline-block; width: 5px; height: 5px;
  background: var(--muted); border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: .2s; }
.typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce {
  0%,60%,100% { transform: translateY(0); opacity:.5; }
  30%          { transform: translateY(-4px); opacity:1; }
}
.typing-name { font-style: italic; font-size: 11px; }

/* System chat message */
.chat-system-msg {
  text-align: center; color: var(--muted); font-size: 10px;
  padding: 3px 8px; font-style: italic; margin: 4px auto;
}

/* Follow-up message — slightly different color */
.chat-followup .chat-text { border-left: 2px solid var(--yellow); padding-left: 6px; }

/* AD email sub-line */
.ad-email { font-size: 10px; margin-top: 1px; }

/* AD row expanded highlight */
.ad-row-expanded td { background: var(--bg-4) !important; }

/* Leaderboard */
.lb-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.lb-user   { display: flex; align-items: center; gap: 7px; }
.lb-avatar { border-radius: 50%; }
.lb-score  { font-weight: 700; }
.lb-table tr.rank-1 td { background: rgba(234,179,8,.06); }
.lb-table tr.rank-2 td { background: rgba(148,163,184,.04); }
.lb-table tr.rank-3 td { background: rgba(205,127,50,.04); }
.rank-num  { font-size: 16px; text-align: center; }

/* Profile */
.profile-header     { display: flex; align-items: flex-start; gap: 18px; padding: 20px; background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius-lg); margin-bottom: 16px; }
.profile-avatar     { width: 80px; height: 80px; border-radius: 50%; }
.profile-name       { font-size: 20px; font-weight: 700; }
.profile-email      { font-size: 12px; color: var(--muted); margin-top: 3px; }
.profile-joined     { font-size: 11px; color: var(--muted2); margin-top: 2px; }
.profile-stats-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(150px,1fr)); gap: 10px; }
.profile-stat-card  { background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px; text-align: center; }
.psc-val            { font-size: 24px; font-weight: 800; }
.psc-label          { font-size: 10px; color: var(--muted); margin-top: 3px; }
.psc-val.accent     { color: var(--accent-h); }
.psc-val.green      { color: var(--green); }
.psc-val.blue       { color: var(--blue); }
.psc-val.orange     { color: var(--orange); }
.psc-val.red        { color: var(--red); }

/* colors for accent */
.accent { color: var(--accent-h); }
.green  { color: var(--green); }
.blue   { color: var(--blue); }
.orange { color: var(--orange); }
.red    { color: var(--red); }
