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

:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --panel: #1c232d;
  --line: #2d3746;
  --text: #e6edf3;
  --text-dim: #8b98a8;
  --accent: #00b56a;
  --accent-dark: #008f50;
  --danger: #e04e4e;
  --online: #00c97a;
  --offline: #888;
}

html, body { height: 100%; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.screen { min-height: 100vh; }
.hidden { display: none !important; }

/* ---------- LOGIN ---------- */
#login-screen {
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 0%, #13262b 0%, var(--bg) 55%);
}
.login-card {
  width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 32px; box-shadow: 0 20px 50px rgba(0,0,0,.5);
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo h1 { font-size: 26px; letter-spacing: .5px; }
.login-logo h1 span { color: var(--accent); }
.login-logo p { color: var(--text-dim); margin-top: 4px; }
.logo-badge {
  width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; font-weight: 800; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
}
.logo-badge.sm { width: 30px; height: 30px; margin: 0; font-size: 15px; border-radius: 8px; }

#login-form label { display: block; color: var(--text-dim); font-size: 13px; margin: 12px 0 6px; }
#login-form input {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; padding: 11px; font-size: 14px; outline: none;
}
#login-form input:focus { border-color: var(--accent); }
.login-err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }
#login-btn {
  width: 100%; margin-top: 10px; background: var(--accent); color: #fff;
  border: none; border-radius: 8px; padding: 12px; font-size: 15px; font-weight: 700; cursor: pointer;
}
#login-btn:hover { background: #00c97a; }
#login-btn:disabled { background: #376; cursor: default; }

/* ---------- TOPBAR ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 22px; background: var(--bg2); border-bottom: 1px solid var(--line);
}
.topbar-title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.topbar-user { display: flex; align-items: center; gap: 14px; color: var(--text-dim); }
button.link { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 14px; }

/* ---------- LAYOUT ---------- */
.layout { display: flex; height: calc(100vh - 55px); }
.list-panel {
  width: 320px; min-width: 320px; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; background: var(--bg2);
}
.list-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.list-head h2 { font-size: 16px; }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 15px; }

.agent-list { flex: 1; overflow-y: auto; padding: 8px; }
.empty { color: var(--text-dim); text-align: center; padding: 30px 10px; font-size: 14px; }

.agent-item {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; margin-bottom: 8px; cursor: pointer;
}
.agent-item:hover { border-color: var(--accent); }
.agent-item.selected { border-color: var(--accent); background: #1c2a25; }
.agent-name { font-weight: 600; }
.agent-status { font-size: 12px; margin-top: 2px; }
.agent-status .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.chip-offline .dot { background: var(--offline); }
.chip-online .dot { background: var(--online); }
.agent-status.chip-online { color: var(--online); }
.agent-status.chip-offline { color: var(--text-dim); }
.agent-meta { font-size: 12px; color: var(--text-dim); margin-top: 5px; }
.agent-off .agent-name { color: var(--text-dim); }

/* ---------- SESSION ---------- */
.session-panel { flex: 1; display: flex; flex-direction: column; }
.session-placeholder {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-dim); gap: 10px;
}
.ph-icon { font-size: 48px; opacity: .4; }
.session-body { flex: 1; display: flex; flex-direction: column; padding: 14px; }
.session-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.session-title { font-size: 15px; font-weight: 600; flex: 1; }
.session-badge { font-size: 12px; padding: 4px 10px; border-radius: 20px; background: var(--bg2); border: 1px solid var(--line); color: var(--text-dim); }
.session-badge.active { color: var(--online); border-color: var(--online); }

.session-actions { display: flex; gap: 8px; }
.btn {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 8px 14px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.btn:hover { background: #00c97a; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: var(--panel); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--bg2); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #f06060; }

.stage { flex: 1; min-height: 0; border: 1px solid var(--line); border-radius: 10px; background: #12161d; overflow: hidden; position: relative; }
.canvas-wrap { width: 100%; height: 100%; position: relative; display: flex; align-items: center; justify-content: center; }
#screen-canvas { max-width: 100%; max-height: 100%; cursor: crosshair; }
.canvas-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(13,17,23,.7); color: var(--text); font-size: 16px; text-align: center; padding: 20px;
}

/* ---------- CHAT ---------- */
.chat-panel { height: 150px; min-height: 150px; margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; overflow: hidden; }
.chat-log { flex: 1; overflow-y: auto; padding: 10px; }
.chat-msg { margin-bottom: 6px; font-size: 13px; }
.chat-msg .who { font-weight: 600; color: var(--accent); }
.chat-msg.agent .who { color: #4aa3ff; }
.chat-input-row { display: flex; border-top: 1px solid var(--line); }
.chat-input-row input {
  flex: 1; background: var(--bg2); border: none; color: var(--text); padding: 10px; outline: none;
}
.chat-input-row .btn { border-radius: 0; }

/* responsive */
@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .list-panel { width: 100%; min-width: 0; border-right: none; border-bottom: 1px solid var(--line); max-height: 40vh; }
}
