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

:root {
  --bg:      #0f172a;
  --surface: #1e293b;
  --border:  #334155;
  --muted:   #64748b;
  --text:    #e2e8f0;
  --accent:  #0ea5e9;
  --green:   #10b981;
  --red:     #ef4444;
  --orange:  #f59e0b;
}

body { font-family:'Segoe UI',Arial,sans-serif; background:var(--bg); color:var(--text); height:100vh; overflow:hidden; }

/* ══ LOGIN ══════════════════════════════════════════════════════ */
#loginScreen, #changePwdScreen {
  height:100vh; display:flex; align-items:center; justify-content:center;
  background: radial-gradient(ellipse at 60% 40%, #0c1e35 0%, #0f172a 70%);
}
.login-card {
  background:var(--surface); border:1px solid var(--border);
  border-radius:20px; padding:40px 36px; width:360px;
  display:flex; flex-direction:column; align-items:center; gap:12px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
.login-logo { font-size:2.8rem; }
.login-card h1 { font-size:1.5rem; font-weight:900; color:var(--accent); }
.login-card > p  { color:var(--muted); font-size:0.85rem; margin-bottom:4px; }
.login-form { width:100%; display:flex; flex-direction:column; gap:10px; }
.input-wrap {
  position:relative; display:flex; align-items:center;
}
.input-icon { position:absolute; left:13px; font-size:0.9rem; pointer-events:none; }
.input-wrap input {
  width:100%; padding:11px 40px 11px 38px;
  background:#0f172a; border:1px solid var(--border); color:var(--text);
  border-radius:10px; font-size:0.95rem; outline:none;
  transition:border-color 0.2s;
}
.input-wrap input:focus { border-color:var(--accent); }
.eye-btn {
  position:absolute; right:10px; background:none; border:none;
  cursor:pointer; font-size:0.9rem; opacity:0.5;
}
.btn-login {
  width:100%; padding:12px; background:var(--accent); color:white;
  border:none; border-radius:10px; font-size:1rem; font-weight:700;
  cursor:pointer; margin-top:4px; transition:background 0.2s;
}
.btn-login:hover { background:#0284c7; }
.error-msg { color:#f87171; font-size:0.82rem; text-align:center; min-height:18px; }

/* ══ LAYOUT ══════════════════════════════════════════════════════ */
#consoleScreen { display:flex; height:100vh; }

/* ── SIDEBAR ── */
.sidebar {
  width:230px; background:var(--surface); border-right:1px solid var(--border);
  display:flex; flex-direction:column; flex-shrink:0;
}
.sidebar-logo {
  padding:18px 16px; font-size:1rem; font-weight:800; color:var(--accent);
  border-bottom:1px solid var(--border);
  display:flex; align-items:center; gap:8px;
}
.badge-console {
  font-size:0.6rem; background:var(--accent); color:white;
  padding:2px 7px; border-radius:8px; font-weight:700; letter-spacing:1px;
}
nav { flex:1; padding:8px 0; overflow-y:auto; }
.nav-section {
  font-size:0.6rem; letter-spacing:2px; color:var(--muted);
  padding:12px 16px 4px; font-weight:700;
}
.nav-btn {
  display:block; width:100%; padding:10px 16px;
  background:none; border:none; color:#94a3b8;
  font-size:0.88rem; text-align:left; cursor:pointer;
  border-left:3px solid transparent; transition:all 0.15s;
}
.nav-btn:hover  { background:var(--bg); color:var(--text); }
.nav-btn.active { background:var(--bg); color:var(--accent); border-left-color:var(--accent); }

.sidebar-bottom {
  border-top:1px solid var(--border); padding:10px;
  display:flex; flex-direction:column; gap:6px;
}
.current-user {
  display:flex; align-items:center; gap:9px;
  padding:8px 10px; background:var(--bg); border-radius:10px;
}
.cu-avatar {
  width:32px; height:32px; border-radius:50%;
  background:var(--accent); color:white;
  display:flex; align-items:center; justify-content:center;
  font-size:0.85rem; font-weight:700; flex-shrink:0;
}
.cu-info { flex:1; min-width:0; }
.cu-info > div:first-child { font-size:0.82rem; font-weight:600; truncate; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.cu-role { font-size:0.7rem; color:var(--muted); }
.cu-settings { background:none; border:none; cursor:pointer; opacity:0.5; font-size:0.9rem; }
.cu-settings:hover { opacity:1; }
.btn-logout {
  width:100%; padding:8px; background:none; color:var(--muted);
  border:1px solid var(--border); border-radius:8px; font-size:0.82rem;
  cursor:pointer; transition:all 0.15s;
}
.btn-logout:hover { background:#1a0a0a; color:#fca5a5; border-color:#7f1d1d; }

.sidebar-stats {
  border-top:1px solid var(--border); padding:10px;
  display:flex; gap:8px;
}
.stat {
  flex:1; background:var(--bg); border-radius:8px; padding:8px;
  text-align:center; display:flex; flex-direction:column; gap:2px;
}
.stat span { font-size:1.3rem; font-weight:900; color:var(--muted); }
.stat.online span { color:var(--green); }
.stat small { font-size:0.6rem; color:#475569; letter-spacing:1px; }

/* ── MAIN ── */
.main { flex:1; overflow-y:auto; }
.panel { display:none; padding:28px 32px; }
.panel.active { display:block; }

.panel-header {
  display:flex; align-items:center; gap:14px; margin-bottom:22px; flex-wrap:wrap;
}
.panel-header h2 { font-size:1.35rem; font-weight:700; flex:1; }
.panel-header input[type="text"] {
  background:var(--surface); border:1px solid var(--border); color:var(--text);
  padding:8px 14px; border-radius:8px; font-size:0.88rem; outline:none; width:220px;
}
.panel-header input:focus { border-color:var(--accent); }
.btn-back {
  padding:7px 14px; background:var(--border); color:#94a3b8;
  border:none; border-radius:8px; cursor:pointer; font-size:0.82rem;
}

/* ══ CLIENTS GRID ══════════════════════════════════════════════ */
.clients-grid {
  display:grid; grid-template-columns:repeat(auto-fill, minmax(290px,1fr)); gap:14px;
}
.client-card {
  background:var(--surface); border:1px solid var(--border);
  border-radius:14px; padding:18px; cursor:pointer;
  transition:transform 0.15s, border-color 0.2s;
  border-top:3px solid var(--border);
}
.client-card:hover { transform:translateY(-2px); border-color:#475569; }
.client-card.online  { border-top-color:var(--green); }
.client-card.offline { border-top-color:#334155; }
.cc-head { display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:6px; }
.cc-name { font-size:0.95rem; font-weight:700; }
.cc-key  { font-size:0.68rem; color:#475569; font-family:monospace; margin-bottom:8px; }
.cc-meta { font-size:0.78rem; color:var(--muted); margin-bottom:10px; }
.cc-stats { display:flex; gap:14px; }
.cc-stat  { font-size:0.72rem; color:#475569; }
.cc-stat strong { color:#94a3b8; }

/* ══ STATUS PILL ══════════════════════════════════════════════ */
.status-pill {
  font-size:0.65rem; font-weight:700; padding:3px 11px;
  border-radius:10px; letter-spacing:1px;
}
.status-pill.online  { background:#0d2b22; color:var(--green); }
.status-pill.offline { background:var(--surface); color:#475569; border:1px solid var(--border); }

/* ══ FORM CARD ══════════════════════════════════════════════════ */
.form-card {
  background:var(--surface); border:1px solid var(--border);
  border-radius:14px; padding:22px;
  display:flex; flex-direction:column; gap:13px;
}
.form-card h3 { font-size:0.9rem; color:var(--muted); margin-bottom:4px; }
.form-card label, label {
  display:flex; flex-direction:column; gap:5px;
  font-size:0.8rem; color:#94a3b8;
}
.form-card input[type="text"],
.form-card input[type="password"],
input[type="text"], input[type="password"] {
  background:var(--bg); border:1px solid var(--border); color:var(--text);
  padding:9px 12px; border-radius:8px; font-size:0.88rem; outline:none;
}
input:focus { border-color:var(--accent) !important; }

.key-result {
  background:var(--bg); border:1px solid var(--green);
  border-radius:12px; padding:18px;
  display:flex; flex-direction:column; gap:8px;
}
.key-label { font-size:0.7rem; color:var(--muted); letter-spacing:2px; }
.key-value { font-size:1.2rem; font-weight:900; font-family:monospace; color:var(--green); letter-spacing:3px; }
.key-hint  { font-size:0.76rem; color:var(--muted); line-height:1.5; }
.btn-copy  {
  padding:7px 14px; background:#0d2b22; color:var(--green);
  border:1px solid var(--green); border-radius:7px; font-size:0.82rem;
  font-weight:600; cursor:pointer; align-self:flex-start;
}

/* ══ DÉTAIL CLIENT ══════════════════════════════════════════════ */
.detail-grid {
  display:grid; grid-template-columns:1fr 1fr; gap:16px; align-items:start;
}
@media(max-width:900px){ .detail-grid{ grid-template-columns:1fr; } }
.detail-col { display:flex; flex-direction:column; gap:14px; }

.card {
  background:var(--surface); border:1px solid var(--border);
  border-radius:12px; padding:16px 18px;
}
.card h3 {
  font-size:0.72rem; font-weight:700; color:var(--muted);
  letter-spacing:1.5px; text-transform:uppercase;
  margin-bottom:12px; display:flex; align-items:center; gap:6px;
}
.info-row {
  display:flex; justify-content:space-between; align-items:baseline;
  padding:6px 0; border-bottom:1px solid #0f172a;
  font-size:0.82rem; gap:10px;
}
.info-row .ir-label { color:var(--muted); flex-shrink:0; }
.info-row .ir-val   { color:var(--text); text-align:right; word-break:break-all; }
.info-row code {
  font-family:monospace; font-size:0.72rem; color:var(--accent);
  background:var(--bg); padding:2px 7px; border-radius:4px;
}
.live-dot {
  width:7px; height:7px; border-radius:50%; background:var(--green);
  animation:blink 1.2s infinite;
}
@keyframes blink{0%,100%{opacity:1}50%{opacity:0.2}}
.live-queues { display:flex; flex-direction:column; gap:7px; }
.lq-row {
  display:flex; align-items:center; gap:8px;
  background:var(--bg); border-radius:8px; padding:7px 11px;
}
.lq-name { font-size:0.82rem; font-weight:600; flex:1; }
.lq-cnt  { font-size:0.88rem; font-weight:900; }

.remote-list { display:flex; flex-direction:column; gap:6px; margin-bottom:10px; }
.remote-item {
  display:flex; align-items:center; gap:8px;
  background:var(--bg); border-radius:8px; padding:7px 11px;
}
.ri-dot  { width:9px; height:9px; border-radius:50%; flex-shrink:0; }
.ri-name { font-size:0.82rem; font-weight:600; flex:1; }
.ri-del  { padding:3px 9px; background:#3f0f0f; color:#fca5a5; border:none; border-radius:5px; font-size:0.72rem; cursor:pointer; }
.ri-empty{ font-size:0.78rem; color:#334155; padding:2px 0; }

.add-row { display:flex; gap:7px; align-items:center; flex-wrap:wrap; }
.add-row input { flex:1; min-width:80px; }
input[type="color"] {
  width:40px; height:34px; border:1.5px solid var(--border);
  border-radius:6px; padding:2px; background:var(--bg); cursor:pointer;
}

.danger-card { border-color:#451a1a; }
.danger-card h3 { color:#f87171; }
.btn-danger-sm {
  display:block; width:100%; padding:9px 12px; margin-bottom:6px;
  background:#1a0909; color:#fca5a5; border:1px solid #451a1a;
  border-radius:8px; font-size:0.82rem; cursor:pointer; text-align:left;
  transition:background 0.15s;
}
.btn-danger-sm:hover { background:#3f0f0f; }
.btn-danger-sm.hard  { background:#7f1d1d; color:white; border-color:#991b1b; }
.btn-danger-sm.hard:hover { background:#991b1b; }
.offline-warning {
  background:#1c1200; border:1px solid var(--orange); border-radius:10px;
  padding:12px 14px; font-size:0.82rem; color:var(--orange);
}

/* ══ USERS TABLE ══════════════════════════════════════════════ */
.users-table-wrap { overflow-x:auto; }
table { width:100%; border-collapse:collapse; font-size:0.84rem; }
thead th {
  text-align:left; padding:10px 14px;
  font-size:0.68rem; letter-spacing:1.5px; color:var(--muted);
  border-bottom:2px solid var(--border); font-weight:700;
}
tbody tr { border-bottom:1px solid #1e293b; transition:background 0.12s; }
tbody tr:hover { background:var(--surface); }
td { padding:12px 14px; vertical-align:middle; }
.td-avatar {
  width:32px; height:32px; border-radius:50%;
  background:var(--accent); color:white;
  display:inline-flex; align-items:center; justify-content:center;
  font-size:0.8rem; font-weight:700;
}
.td-avatar.inactive { background:#334155; color:var(--muted); }
.td-name { font-weight:600; }
.td-sub  { font-size:0.72rem; color:var(--muted); margin-top:2px; }
.td-badge {
  display:inline-block; padding:2px 9px; border-radius:8px;
  font-size:0.65rem; font-weight:700; letter-spacing:1px;
}
.td-badge.superadmin { background:#1c2a3f; color:#38bdf8; }
.td-badge.active     { background:#0d2b22; color:var(--green); }
.td-badge.inactive   { background:#1e1e1e; color:#475569; border:1px solid var(--border); }
.perm-chips { display:flex; flex-wrap:wrap; gap:4px; max-width:340px; }
.perm-chip {
  padding:2px 8px; background:var(--bg); border:1px solid var(--border);
  border-radius:6px; font-size:0.65rem; color:var(--muted);
}
.td-actions { display:flex; gap:6px; }
.btn-edit { padding:5px 12px; background:var(--surface); color:var(--text); border:1px solid var(--border); border-radius:6px; font-size:0.75rem; cursor:pointer; }
.btn-edit:hover { border-color:var(--accent); color:var(--accent); }
.btn-del  { padding:5px 12px; background:#1a0909; color:#fca5a5; border:1px solid #451a1a; border-radius:6px; font-size:0.75rem; cursor:pointer; }
.btn-del:hover { background:#3f0f0f; }

/* ══ BUTTONS ══════════════════════════════════════════════════ */
.btn-primary {
  padding:9px 18px; background:var(--accent); color:white;
  border:none; border-radius:8px; font-size:0.88rem;
  font-weight:700; cursor:pointer; white-space:nowrap; transition:background 0.15s;
}
.btn-primary:hover { background:#0284c7; }
.btn-secondary {
  padding:9px 18px; background:var(--border); color:var(--text);
  border:none; border-radius:8px; font-size:0.88rem;
  font-weight:600; cursor:pointer; transition:background 0.15s;
}
.btn-secondary:hover { background:#475569; }
.btn-xs {
  padding:4px 10px; background:var(--bg); color:var(--muted);
  border:1px solid var(--border); border-radius:5px; font-size:0.72rem; cursor:pointer;
}

/* ══ MODAL ══════════════════════════════════════════════════════ */
.modal-overlay {
  position:fixed; inset:0; background:rgba(0,0,0,0.75);
  display:flex; align-items:center; justify-content:center; z-index:100;
}
.modal {
  background:var(--surface); border:1px solid var(--border);
  border-radius:16px; padding:26px;
  width:700px; max-width:96vw; max-height:90vh; overflow-y:auto;
}
.modal h3 { font-size:1.1rem; font-weight:700; margin-bottom:18px; }
.modal-body { display:grid; grid-template-columns:1fr 1fr; gap:20px; }
@media(max-width:600px){ .modal-body{ grid-template-columns:1fr; } }
.modal-left  { display:flex; flex-direction:column; gap:12px; }
.modal-right { background:var(--bg); border-radius:10px; padding:14px; }
.modal-footer { display:flex; justify-content:flex-end; gap:10px; margin-top:20px; }

.label-toggle {
  display:flex !important; flex-direction:row !important;
  align-items:center; justify-content:space-between;
  background:var(--bg); border-radius:8px; padding:10px 12px;
  cursor:pointer;
}
.label-toggle span { font-size:0.85rem; color:var(--text); }

/* Toggle switch */
.toggle { position:relative; display:inline-block; width:40px; height:22px; }
.toggle input { opacity:0; width:0; height:0; }
.slider {
  position:absolute; inset:0; background:#334155; border-radius:22px; cursor:pointer;
  transition:background 0.2s;
}
.slider:before {
  content:''; position:absolute; width:16px; height:16px; border-radius:50%;
  background:white; left:3px; bottom:3px; transition:transform 0.2s;
}
.toggle input:checked + .slider { background:var(--accent); }
.toggle input:checked + .slider:before { transform:translateX(18px); }

/* Permissions */
.perm-title { font-size:0.68rem; font-weight:700; color:var(--muted); letter-spacing:1.5px; margin-bottom:10px; }
.perm-list  { display:flex; flex-direction:column; gap:6px; }
.perm-item  {
  display:flex; align-items:flex-start; gap:8px;
  padding:7px 9px; border-radius:7px; cursor:pointer;
  transition:background 0.12s;
}
.perm-item:hover { background:var(--surface); }
.perm-item input[type="checkbox"] { margin-top:2px; accent-color:var(--accent); width:14px; height:14px; flex-shrink:0; }
.perm-item-label { flex:1; }
.perm-key  { font-size:0.72rem; font-family:monospace; color:var(--accent); }
.perm-desc { font-size:0.76rem; color:var(--muted); margin-top:1px; }
.perm-shortcuts { display:flex; gap:6px; margin-top:10px; }

/* Feedback */
.feedback-msg { font-size:0.82rem; min-height:18px; }
.feedback-msg.ok  { color:var(--green); }
.feedback-msg.err { color:#f87171; }

/* Flash toast */
.toast {
  position:fixed; bottom:22px; right:22px;
  background:#0d2b22; color:var(--green); border:1px solid var(--green);
  border-radius:10px; padding:10px 20px; font-size:0.88rem; font-weight:700;
  z-index:999; transition:opacity 0.4s;
}
