:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2e3347;
  --text: #e4e4e7;
  --text2: #9ca3af;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --orange: #f97316;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* Layout */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  flex-shrink: 0;
}

.sidebar .logo {
  padding: 0 20px 20px;
  font-size: 20px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text2);
  transition: all .15s;
}

.sidebar nav a:hover, .sidebar nav a.active {
  color: var(--text);
  background: var(--surface2);
}

.main {
  flex: 1;
  padding: 24px 32px;
  overflow-y: auto;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 24px;
}

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-bottom: 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.card h3 { font-size: 14px; color: var(--text2); margin-bottom: 8px; }
.card .value { font-size: 28px; font-weight: 700; }

/* Agent cards */
.agent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.agent-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; background: var(--surface2);
}

.agent-info { flex: 1; }
.agent-info .name { font-weight: 600; font-size: 15px; }
.agent-info .role { font-size: 12px; color: var(--text2); }

.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.offline { background: var(--red); }
.status-dot.busy { background: var(--yellow); }

/* Table */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text2); font-size: 13px; font-weight: 500; }
td { font-size: 14px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  transition: all .15s;
}
.btn:hover { border-color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: var(--red); border-color: var(--red); }

/* Badge */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 12px; font-weight: 500;
}
.badge-pending { background: rgba(234,179,8,.15); color: var(--yellow); }
.badge-in_progress { background: rgba(99,102,241,.15); color: var(--primary); }
.badge-done { background: rgba(34,197,94,.15); color: var(--green); }
.badge-urgent { background: rgba(239,68,68,.15); color: var(--red); }
.badge-high { background: rgba(249,115,22,.15); color: var(--orange); }
.badge-normal { background: rgba(156,163,175,.1); color: var(--text2); }
.badge-low { background: rgba(156,163,175,.05); color: var(--text2); }

/* Form */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 8px 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 14px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { min-height: 80px; resize: vertical; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 24px; width: 480px; max-width: 90vw; max-height: 80vh; overflow-y: auto;
}
.modal h2 { margin-bottom: 16px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.kanban-col { background: var(--surface); border-radius: 12px; padding: 16px; min-height: 200px; }
.kanban-col h3 { font-size: 14px; color: var(--text2); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.kanban-col h3 .count { background: var(--surface2); border-radius: 10px; padding: 0 8px; font-size: 12px; }
.kanban-item {
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; margin-bottom: 8px; cursor: pointer; transition: border-color .15s;
}
.kanban-item:hover { border-color: var(--primary); }
.kanban-item .title { font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.kanban-item .meta { font-size: 12px; color: var(--text2); display: flex; gap: 10px; }

/* Reports */
.report-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; margin-bottom: 16px;
}
.report-card .header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.report-card .header .agent { font-weight: 600; }
.report-card .header .date { font-size: 13px; color: var(--text2); }
.report-card .content { font-size: 14px; line-height: 1.8; white-space: pre-wrap; }

/* Messages */
.msg-item {
  display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border);
}
.msg-item .avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.msg-item .body { flex: 1; }
.msg-item .body .top { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.msg-item .body .from { font-weight: 600; font-size: 14px; }
.msg-item .body .time { font-size: 12px; color: var(--text2); }
.msg-item .body .text { font-size: 14px; }

/* Login */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.login-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 40px; width: 360px; text-align: center;
}
.login-box h1 { font-size: 24px; margin-bottom: 8px; }
.login-box p { color: var(--text2); font-size: 14px; margin-bottom: 24px; }
.login-box .btn { width: 100%; justify-content: center; margin-top: 8px; }
.login-box .error { color: var(--red); font-size: 13px; margin-top: 8px; display: none; }

/* Toolbar */
.toolbar { display: flex; gap: 10px; margin-bottom: 20px; align-items: center; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { padding: 16px; }
  .kanban { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
}
