/* ===== NINE2VPN Support — Design System v2 ===== */

:root {
  --bg:        #06090f;
  --bg-elev:   #0b1220;
  --bg-elev-2: #111b2c;
  --bg-elev-3: #182538;
  --border:     rgba(255, 255, 255, 0.07);
  --border-dim: rgba(255, 255, 255, 0.04);
  --text:      #dce4f0;
  --text-dim:  #7d8fa8;
  --text-faint:#3c4f68;
  --primary:       #5d60ef;
  --primary-hover: #6e70f5;
  --primary-dim:   rgba(93, 96, 239, 0.14);
  --success: #10b981;
  --warning: #f59e0b;
  --danger:  #f43f5e;
  --info:    #0ea5e9;
  --radius:    8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow:    0 8px 32px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --sidebar-w: 216px;
  --topbar-h:  54px;
}

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

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.09); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== Login ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 900px 500px at 50% -5%, #101e3a, var(--bg));
}
.login-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px 40px;
  width: 380px;
  box-shadow: var(--shadow);
}
.login-card h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}
.login-card .sub {
  color: var(--text-dim);
  margin-bottom: 26px;
  font-size: 13px;
}
.login-error {
  background: rgba(244, 63, 94, 0.1);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.25);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 12px;
}

/* ===== App layout ===== */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 20;
}

.brand {
  padding: 18px 16px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.2px;
  border-bottom: 1px solid var(--border-dim);
  margin-bottom: 4px;
}
.brand .logo {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav { padding: 6px 8px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 500;
  font-size: 13.5px;
  margin-bottom: 1px;
  transition: background 0.1s, color 0.1s;
}
.nav a:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.nav a.active { background: var(--primary-dim); color: #a5a8ff; }
.nav a .ico {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.75;
}
.nav a:hover .ico { opacity: 1; }
.nav a.active .ico { opacity: 1; }
.nav a .badge-count {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  font-weight: 700;
}

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--border-dim);
}
.agent-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-dim);
  border: 1px solid rgba(93, 96, 239, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 11.5px;
  color: #a5a8ff;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}
.agent-chip .meta { overflow: hidden; min-width: 0; }
.agent-chip .meta .nm {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-chip .meta .rl { font-size: 11.5px; color: var(--text-faint); }

/* ===== Main area ===== */
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 14px;
  background: rgba(6, 9, 15, 0.8);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h2 {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.15px;
}
.topbar .spacer { flex: 1; }
.status-select {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.1s, color 0.1s;
}
.status-select:hover { border-color: rgba(255, 255, 255, 0.14); color: var(--text); }
.status-select:focus { outline: none; border-color: var(--primary); }

.content { padding: 22px 24px; flex: 1; }

/* ===== Cards / KPI ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.kpi .label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin-bottom: 10px;
}
.kpi .value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text);
}
.kpi .value.danger  { color: var(--danger); }
.kpi .value.success { color: var(--success); }

.grid-2   { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.card h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin-bottom: 14px;
}

@media (max-width: 1000px) { .grid-2, .grid-2-1 { grid-template-columns: 1fr; } }

/* ===== Buttons ===== */
.btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  line-height: 1;
  white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, 0.04); border-color: rgba(255, 255, 255, 0.14); color: var(--text); }
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: #fda4af; border-color: rgba(244, 63, 94, 0.28); }
.btn.danger:hover { background: rgba(244, 63, 94, 0.1); border-color: rgba(244, 63, 94, 0.5); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }

/* ===== Forms ===== */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 6px;
}
input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color 0.1s, background 0.1s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(93, 96, 239, 0.55);
  background: var(--bg-elev);
}
textarea { resize: vertical; min-height: 88px; }
select { cursor: pointer; }

/* ===== Tables ===== */
.table-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 10px 16px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
}
td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-dim);
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.1s; cursor: pointer; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.022); }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge.open    { background: rgba(14, 165, 233, 0.12); color: #67d4f8; }
.badge.human   { background: rgba(245, 158, 11, 0.12); color: #fcd34d; }
.badge.pending { background: rgba(139, 92, 246, 0.12); color: #c4b5fd; }
.badge.closed  { background: rgba(255, 255, 255, 0.06); color: var(--text-faint); }
.badge.urgent  { background: rgba(244, 63, 94, 0.13); color: #fda4af; }
.badge.high    { background: rgba(245, 158, 11, 0.12); color: #fcd34d; }
.badge.normal  { background: rgba(93, 96, 239, 0.12); color: #a5a8ff; }
.badge.low     { background: rgba(255, 255, 255, 0.06); color: var(--text-faint); }
.badge.dot::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.sla-dot  { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.sla-ok   { background: var(--success); }
.sla-warn { background: var(--warning); }
.sla-bad  { background: var(--danger); }

.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.status-dot.online  { background: var(--success); box-shadow: 0 0 6px rgba(16, 185, 129, 0.5); }
.status-dot.away    { background: var(--warning); }
.status-dot.offline { background: var(--text-faint); }

/* ===== Toolbar / Filters ===== */
.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar input, .toolbar select { width: auto; }
.toolbar .search { min-width: 240px; }

.seg {
  display: flex;
  gap: 2px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.seg button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 12.5px;
  font-weight: 500;
  transition: background 0.1s, color 0.1s;
}
.seg button.active { background: var(--primary); color: #fff; font-weight: 600; }
.seg button:not(.active):hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }

/* ===== Kanban ===== */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.kanban-col {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  min-height: 200px;
}
.kanban-col h4 {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-faint);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2px;
}
.kanban-col h4 span {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
}
.kanban-card {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 7px;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.kanban-card:hover { border-color: rgba(93, 96, 239, 0.45); background: var(--bg-elev-3); }
.kanban-card .kc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  font-size: 11px;
  color: var(--text-faint);
}
.kanban-card .kc-body {
  font-size: 12.5px;
  color: var(--text);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
@media (max-width: 1100px) { .kanban { grid-template-columns: 1fr 1fr; } }

/* ===== Chat ===== */
.chat-layout {
  display: grid;
  grid-template-columns: 295px 1fr;
  gap: 10px;
  height: calc(100vh - var(--topbar-h) - 44px);
}
.chat-list {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-y: auto;
}
.chat-list-item {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-dim);
  cursor: pointer;
  transition: background 0.1s;
}
.chat-list-item:hover { background: rgba(255, 255, 255, 0.025); }
.chat-list-item.active { background: var(--primary-dim); }
.chat-list-item .cl-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 3px;
  align-items: baseline;
}
.chat-list-item .cl-name { font-weight: 600; font-size: 13px; }
.chat-list-item .cl-preview {
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-main {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
}
.chat-head {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-head .spacer { flex: 1; }
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg {
  max-width: 70%;
  padding: 9px 13px;
  border-radius: var(--radius-lg);
  font-size: 13.5px;
  line-height: 1.5;
}
.msg .who {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin-bottom: 4px;
}
.msg.user      { background: var(--bg-elev-2); align-self: flex-start; border-bottom-left-radius: 3px; }
.msg.assistant {
  background: var(--primary-dim);
  border: 1px solid rgba(93, 96, 239, 0.2);
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}
.msg.agent {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.18);
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}
.msg.system {
  align-self: center;
  background: transparent;
  color: var(--text-faint);
  font-size: 12px;
  font-style: italic;
}
.chat-input {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.chat-input textarea { min-height: 42px; max-height: 130px; }
.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 13px;
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal h3 {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.2px;
  margin-bottom: 16px;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ===== Toast ===== */
.toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  z-index: 200;
}
.toast {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-left: 2px solid var(--primary);
  padding: 10px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 230px;
  max-width: 310px;
  font-size: 13px;
  animation: slideIn 0.18s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.info    { border-left-color: var(--info); }

@keyframes slideIn {
  from { transform: translateX(28px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ===== Utilities ===== */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-faint);
  font-size: 13px;
}
.empty-state .big { font-size: 22px; margin-bottom: 10px; }
.loading { padding: 40px; text-align: center; color: var(--text-faint); font-size: 13px; }
.row-actions { display: flex; gap: 6px; }
.muted  { color: var(--text-dim); }
.tiny   { font-size: 12px; }
.stars  { color: #fbbf24; letter-spacing: 1px; }
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-dim);
}
.list-item:last-child { border-bottom: none; }
.list-item .li-main { flex: 1; min-width: 0; }
.spread { display: flex; justify-content: space-between; align-items: center; }
.mb     { margin-bottom: 14px; }
.flex   { display: flex; gap: 8px; align-items: center; }
.chart-box { position: relative; height: 240px; }
