/* ─── Reset & Base ──────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f0f2f5; color: #333; line-height: 1.5; }
a { color: #0d6efd; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Nav ───────────────────────────────────── */
.nav { background: #075e54; color: #fff; padding: 0 20px; }
.nav-inner { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; height: 50px; }
.nav-brand { font-weight: 700; font-size: 16px; }
.nav-links { display: flex; gap: 16px; }
.nav-link { color: #fff; opacity: 0.85; font-size: 14px; }
.nav-link:hover { opacity: 1; text-decoration: none; }
.nav-link.active { opacity: 1; font-weight: 600; }

/* ─── Containers ────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 24px 20px; }
.container h2 { margin-bottom: 20px; font-size: 22px; color: #111; }

/* ─── Cards ─────────────────────────────────── */
.card { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin-bottom: 16px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.mb-20 { margin-bottom: 20px; }

/* ─── Buttons ───────────────────────────────── */
.btn { display: inline-block; padding: 7px 16px; border: none; border-radius: 6px; font-size: 14px; cursor: pointer; background: #e9ecef; color: #333; transition: background 0.15s; }
.btn:hover { background: #dee2e6; text-decoration: none; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-primary { background: #075e54; color: #fff; }
.btn-primary:hover { background: #054d44; }
.btn-warn { background: #f59f00; color: #fff; }
.btn-danger { background: #e03131; color: #fff; }
.btn-danger:hover { background: #c92a2a; }

/* ─── Forms ─────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 4px; font-size: 14px; }
.form-input { width: 100%; padding: 8px 12px; border: 1px solid #ced4da; border-radius: 6px; font-size: 14px; transition: border-color 0.15s; }
.form-input:focus { border-color: #075e54; outline: none; box-shadow: 0 0 0 3px rgba(7,94,84,0.15); }
.form-inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-inline .form-input { width: auto; flex: 1; min-width: 120px; }
.form-vertical .form-group { margin-bottom: 16px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; }

/* ─── Alerts ────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; font-size: 14px; }
.alert-success { background: #d3f9d8; color: #2b8a3e; }
.alert-error { background: #ffe3e3; color: #c92a2a; }
.alert-warning { background: #fff3bf; color: #e67700; }

/* ─── Tables ────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #eee; }
.table th { font-weight: 600; color: #555; font-size: 12px; text-transform: uppercase; }
.table tbody tr:hover { background: #f8f9fa; }
.table-logs td { font-size: 13px; }
.log-time { white-space: nowrap; font-size: 12px; color: #888; }
.log-ip { font-size: 12px; color: #aaa; }

/* ─── Badges ────────────────────────────────── */
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-ok { background: #d3f9d8; color: #2b8a3e; }
.badge-warn { background: #fff3bf; color: #e67700; }
.badge-error { background: #ffe3e3; color: #c92a2a; }

/* ─── Login ─────────────────────────────────── */
.login-bg {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(37, 211, 102, 0.20), transparent 32%),
    linear-gradient(135deg, #10201e, #075e54 52%, #128c7e);
}
.login-card {
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(255,255,255,0.55);
  border-radius: 18px;
  padding: 36px 32px 32px;
  width: 420px;
  max-width: 100%;
  box-shadow: 0 24px 70px rgba(0,0,0,0.26);
}
.login-header { text-align: center; margin-bottom: 26px; }
.login-header h1 { font-size: 26px; color: #0b3f39; margin-top: 10px; letter-spacing: 0; }
.login-icon {
  width: 64px;
  height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: #e8f8ef;
  color: #075e54;
  font-size: 34px;
  box-shadow: inset 0 0 0 1px rgba(7,94,84,0.08);
}
.login-sub { color: #61706d; font-size: 14px; margin-top: 5px; }
.login-form .form-group { margin-bottom: 16px; }
.login-form label {
  color: #263a36;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 7px;
}
.login-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.login-input-icon {
  position: absolute;
  left: 14px;
  font-size: 15px;
  opacity: 0.62;
  pointer-events: none;
}
.login-input-wrap input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px 12px 44px;
  border: 1px solid #d7e1de;
  border-radius: 12px;
  background: #f9fbfa;
  color: #17211f;
  font-size: 15px;
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
}
.login-input-wrap input::placeholder { color: #9aa8a5; }
.login-input-wrap input:focus {
  border-color: #128c7e;
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 4px rgba(18,140,126,0.14);
}
.login-form .btn {
  padding: 14px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 800;
  margin-top: 8px;
  box-shadow: 0 10px 22px rgba(7,94,84,0.22);
}
@media (max-width: 480px) {
  .login-bg { padding: 16px; align-items: flex-start; padding-top: 52px; }
  .login-card { padding: 30px 22px 24px; border-radius: 16px; }
  .login-header h1 { font-size: 24px; }
}

/* ─── QR Page ───────────────────────────────── */
.qr-page { text-align: center; }
.qr-card { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.qr-image-wrapper { background: #fff; padding: 20px; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.qr-image { max-width: 280px; }
.qr-info { max-width: 400px; }
.qr-steps { background: #f8f9fa; padding: 12px 16px; border-radius: 6px; font-size: 14px; line-height: 1.8; text-align: left; }
.qr-warn { color: #e67700; font-size: 13px; }
.qr-success { text-align: center; padding: 20px; }

/* ─── Inst card ─────────────────────────────── */
.inst-card { padding: 0; }
.inst-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid #eee; }
.inst-name { font-weight: 600; font-size: 15px; }
.inst-body { padding: 14px 16px; font-size: 13px; }
.inst-body p { margin-bottom: 4px; }
.inst-actions { display: flex; gap: 8px; padding: 14px 16px; border-top: 1px solid #eee; flex-wrap: wrap; }

/* ─── Misc ──────────────────────────────────── */
.text-muted { color: #888; font-size: 14px; }
.link-back { font-size: 14px; display: inline-block; margin-bottom: 12px; }
.spinner { width: 40px; height: 40px; border: 4px solid #e9ecef; border-top: 4px solid #075e54; border-radius: 50%; animation: spin 0.8s linear infinite; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.access-point { background: #f8f9fa; padding: 12px 16px; border-radius: 6px; font-size: 14px; display: flex; align-items: center; }
.access-point code { font-size: 16px; }
pre { background: #f8f9fa; padding: 12px 16px; border-radius: 6px; font-size: 12px; overflow-x: auto; }
.flash-msgs { margin-top: 16px; }
.qr-container { margin-top: 8px; padding: 12px; background: #f8f9fa; border-radius: 6px; text-align: center; }
.qr-container img { display: block; margin: 0 auto; }
.qr-tip { font-size: 11px; color: #888; margin-top: 6px; }
.qr-spinner { font-size: 13px; color: #888; padding: 20px; }

/* ─── Chat improvements ──────────────────────── */
.chat-list-item.new-chat strong { font-weight: 800; color: #111; }
.chat-list-item .preview { font-size: 13px; color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-sender { font-size: 11px; color: #666; font-weight: 600; margin-bottom: 2px; }
.msg-new { border: 1px solid #ffd43b; background: #fff9db !important; }
.msg-new.msg-out { background: #f0ffd3 !important; border-color: #94d82d; }
.msg-media-wrapper { margin-bottom: 4px; }
.msg-media { max-width: 280px; max-height: 280px; border-radius: 6px; display: block; }
