/* ═══════════════════════════════════════════════════════════════
   PH en Linea — Design System v3.0
   Premium SaaS Dashboard
   ═══════════════════════════════════════════════════════════════ */

:root {
  color-scheme: light;

  /* Core palette */
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --line: #e2e8f0;
  --line-light: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;
  --placeholder: #94a3b8;

  /* Brand */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #dbeafe;
  --primary-subtle: #eff6ff;
  --accent: #0ea5e9;

  /* Status */
  --green: #10b981;
  --green-bg: #ecfdf5;
  --amber: #f59e0b;
  --amber-bg: #fffbeb;
  --red: #ef4444;
  --red-bg: #fef2f2;
  --purple: #8b5cf6;
  --purple-bg: #f5f3ff;

  /* Sidebar */
  --sidebar-w: 264px;
  --sidebar-bg: #0f172a;
  --sidebar-bg-2: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-text-hover: #e2e8f0;
  --sidebar-active-bg: rgba(59,130,246,0.12);
  --sidebar-active-text: #ffffff;
  --sidebar-accent: #3b82f6;
  --sidebar-border: rgba(255,255,255,0.06);

  /* Sizing */
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.04);

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Reset ─────────────────────────────────────────────────── */

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

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

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

::selection { background: rgba(37,99,235,0.15); color: var(--text); }

/* ── Scrollbar ─────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(100,116,139,0.2); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(100,116,139,0.35); }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ═══════════════════════════════════════════════════════════════
   SHELL LAYOUT
   ═══════════════════════════════════════════════════════════════ */

.shell {
  height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  overflow: hidden;
}

body[data-auto-refresh="messages"] .shell {
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════ */

.sidebar {
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, #0c1629 50%, var(--sidebar-bg-2) 100%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid rgba(255,255,255,0.06);
  padding: 0;
  position: relative;
  z-index: 10;
}

body[data-auto-refresh="messages"] .sidebar {
  padding: 0;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, #0c1629 50%, var(--sidebar-bg-2) 100%);
  color: var(--sidebar-text);
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* ── Sidebar Header / Brand ─── */

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  text-align: center;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 0;
  font-weight: 700;
  font-size: 18px;
}

body[data-auto-refresh="messages"] .brand {
  justify-content: center;
  margin-bottom: 0;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-mark {
  width: auto;
  height: auto;
  display: grid;
  place-items: center;
  font-weight: 800;
}

body[data-auto-refresh="messages"] .brand-mark {
  border-radius: 8px;
  background: transparent;
  color: #ffffff;
  width: auto;
  height: auto;
  overflow: visible;
}

.brand-logo {
  width: 150px;
  height: auto;
  display: block;
  filter: drop-shadow(0 2px 16px rgba(59,130,246,0.3));
  transition: transform 0.4s var(--ease), filter 0.4s var(--ease);
}

.sidebar-header:hover .brand-logo,
.brand:hover .brand-logo {
  transform: scale(1.06);
  filter: drop-shadow(0 6px 24px rgba(59,130,246,0.5));
}

.brand span:last-child,
body[data-auto-refresh="messages"] .brand span:last-child {
  display: block;
  color: #ffffff;
  font-size: 0;
}

/* ── Sidebar User Profile ─── */

.sidebar-user {
  padding: 16px 16px;
  margin: 12px 12px 0;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.sidebar-user:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.1);
}

.sidebar-user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(59,130,246,0.3);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.sidebar-user:hover .sidebar-user-avatar {
  transform: scale(1.05);
  box-shadow: 0 6px 18px rgba(59,130,246,0.4);
}

.sidebar-user-info {
  min-width: 0;
  flex: 1;
}

.sidebar-user-name {
  display: block;
  color: #f1f5f9;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(59,130,246,0.15);
  color: #60a5fa;
}

/* ── Online status dot in user block ─── */
.sidebar-user-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.2), 0 0 8px rgba(16,185,129,0.4);
  flex-shrink: 0;
  animation: sb-pulse-online 2s ease-in-out infinite;
}

@keyframes sb-pulse-online {
  0%, 100% { box-shadow: 0 0 0 3px rgba(16,185,129,0.2), 0 0 8px rgba(16,185,129,0.4); }
  50% { box-shadow: 0 0 0 5px rgba(16,185,129,0.1), 0 0 16px rgba(16,185,129,0.3); }
}

/* ── Sidebar Section Label ─── */

.sidebar-section {
  padding: 20px 20px 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(148,163,184,0.5);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-section::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(148,163,184,0.15), transparent);
}

/* ── Sidebar Navigation ─── */

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  flex: 1;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.2s var(--ease);
  position: relative;
  text-decoration: none;
  border: 1px solid transparent;
}

body:not([data-auto-refresh="messages"]) .nav a {
  width: auto;
  height: auto;
  min-height: 44px;
  padding: 10px 14px;
}

/* Nav icon container */
.nav-icon {
  width: 34px;
  height: 34px;
  min-width: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  flex-shrink: 0;
  transition: all 0.25s var(--ease);
}

.nav-icon svg { width: 17px; height: 17px; }

/* Nav label + description wrapper */
.nav-label-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.nav-label-wrap > span:first-child {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.3;
}

/* Nav hover */
.nav a:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.08);
  color: #f1f5f9;
  transform: translateX(4px);
}

.nav a:hover .nav-icon {
  background: rgba(255,255,255,0.12);
  color: #fff;
  transform: scale(1.08);
}

/* Nav active */
.nav a.active {
  background: linear-gradient(135deg, rgba(59,130,246,0.15) 0%, rgba(139,92,246,0.1) 100%);
  border-color: rgba(59,130,246,0.25);
  color: #f1f5f9;
  box-shadow: 0 2px 12px rgba(59,130,246,0.1);
}

.nav a.active .nav-icon {
  background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(59,130,246,0.4);
}

body[data-auto-refresh="messages"] .nav a.active,
body[data-auto-refresh="messages"] .nav a:hover {
  background: linear-gradient(135deg, rgba(59,130,246,0.15) 0%, rgba(139,92,246,0.1) 100%);
  color: #ffffff;
}

/* Active indicator bar */
.nav a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: linear-gradient(180deg, #3b82f6, #8b5cf6);
  border-radius: 0 3px 3px 0;
  transition: height 0.25s var(--ease);
}

.nav a.active::before { height: 65%; }

/* Nav item description (subtitle below label) */
.nav-desc {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: rgba(148,163,184,0.5);
  margin-top: 1px;
  transition: color 0.2s var(--ease);
}
.nav a:hover .nav-desc { color: rgba(148,163,184,0.7); }
.nav a.active .nav-desc { color: rgba(191,219,254,0.6); }

/* ── Sidebar Separator ─── */

.sidebar-divider {
  height: 1px;
  margin: 8px 20px;
  background: var(--sidebar-border);
}

/* ── Sidebar Footer ─── */

.sidebar-footer {
  margin-top: auto;
  padding: 12px 12px 16px;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-footer-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-back {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s var(--ease);
}

.sidebar-back:hover {
  background: rgba(255,255,255,0.06);
  color: #e2e8f0;
}

.sidebar-back svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  color: rgba(203,213,225,0.7);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.25s var(--ease);
  text-decoration: none;
  border: 1px solid transparent;
}

.sidebar-logout:hover {
  background: rgba(239,68,68,0.08);
  border-color: rgba(239,68,68,0.2);
  color: #fca5a5;
  transform: translateX(4px);
}

.sidebar-logout svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform 0.2s var(--ease);
}

.sidebar-logout:hover svg {
  transform: translateX(2px);
}

.sidebar-version {
  display: block;
  font-size: 10px;
  color: rgba(148,163,184,0.25);
  letter-spacing: 0.04em;
  text-align: center;
  padding-top: 12px;
}

/* ═══════════════════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════════════════ */

.main {
  padding: 0;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--bg);
}

body[data-auto-refresh="messages"] .main { padding: 0; }

#page-content {
  min-height: 0;
  display: block;
  overflow: auto;
  padding: 0 28px 28px;
  animation: fadeInUp 0.3s ease-out;
}

body[data-auto-refresh="messages"] #page-content {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  padding-right: 0;
  padding: 0;
}

/* ── Topbar ─── */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px 28px 16px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
}

body[data-auto-refresh="messages"] .topbar { display: none; }

h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.025em;
  color: var(--text);
  font-weight: 700;
  line-height: 1.2;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* ── Topbar User ─── */

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════
   PILLS / BADGES
   ═══════════════════════════════════════════════════════════════ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pill.ok {
  color: #059669;
  border-color: #a7f3d0;
  background: var(--green-bg);
}

.pill.warn {
  color: #d97706;
  border-color: #fde68a;
  background: var(--amber-bg);
}

/* Role badges */
.pill.role-superadmin { background: #1e293b; color: #fff; border-color: #334155; font-size: 11px; }
.pill.role-admin { background: #2563eb; color: #fff; border-color: #3b82f6; }
.pill.role-asistente { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.pill.role-contabilidad { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.pill.role-consejo { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; }
.pill.role-portero { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.pill.role-residente { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.pill.role-propietario { background: #ccfbf1; color: #115e59; border-color: #5eead4; }
.pill.role-default { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }

.pill.active { background: #dcfce7; color: #166534; border-color: #86efac; }
.pill.inactive { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.pill.community-plan { background: #ede9fe; color: #5b21b6; border-color: #c4b5fd; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; }

/* ═══════════════════════════════════════════════════════════════
   STATS CARDS
   ═══════════════════════════════════════════════════════════════ */

.grid { display: grid; gap: 16px; }

.stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  transition: all 0.2s var(--ease);
  box-shadow: var(--shadow-xs);
}

.stat::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
  border-radius: 0 4px 4px 0;
}

.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat strong {
  display: block;
  font-size: 30px;
  line-height: 1;
  margin-bottom: 6px;
  color: var(--text);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.stat span { color: var(--muted); font-size: 13px; }

/* ═══════════════════════════════════════════════════════════════
   PANELS / CARDS
   ═══════════════════════════════════════════════════════════════ */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  margin-top: 16px;
  overflow: hidden;
  animation: fadeInUp 0.3s ease-out both;
}

.panel:nth-child(2) { animation-delay: 0.05s; }
.panel:nth-child(3) { animation-delay: 0.1s; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
  color: var(--text);
  font-weight: 700;
}

.head-count {
  font-weight: 500;
  color: var(--muted);
  font-size: 0.9em;
}

.panel-body { padding: 16px 20px; }

.table-wrap { overflow: auto; }

/* ═══════════════════════════════════════════════════════════════
   NOTICES / FLASH
   ═══════════════════════════════════════════════════════════════ */

.notice {
  border: 1px solid #93c5fd;
  background: var(--primary-subtle);
  color: #1e40af;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin: 0 0 16px;
  font-size: 13px;
  font-weight: 500;
}

body[data-auto-refresh="messages"] .notice {
  flex: 0 0 auto;
  margin: 0;
  border-radius: 0;
}

.danger-note {
  border-color: #fca5a5;
  background: var(--red-bg);
  color: #991b1b;
}

/* ═══════════════════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════════════════ */

.form-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.form-grid.campaign { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.field { display: grid; gap: 5px; }
.field.wide { grid-column: 1 / -1; }

label, .label {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

input, select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

textarea { min-height: 84px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

input::placeholder, textarea::placeholder { color: var(--placeholder); }

.check {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.check input { width: 16px; min-height: 16px; }

/* ── Form groups (admin) ─── */

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input, .form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  box-sizing: border-box;
}

.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  background: #fff;
}

.admin-form { padding: 24px; }

.form-actions {
  display: flex;
  gap: 10px;
  padding-top: 8px;
}

.inline-form {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-radius: 8px;
  margin: 12px 16px;
  flex-wrap: wrap;
  align-items: center;
}

.inline-form input, .inline-form select {
  padding: 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  min-width: 100px;
}

.inline-form input:focus, .inline-form select:focus {
  outline: none;
  border-color: var(--primary);
}

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════ */

.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

button, .button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

button:hover, .button:hover {
  border-color: #cbd5e1;
  background: var(--surface-2);
  box-shadow: var(--shadow-xs);
}

.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(37,99,235,0.25);
}

.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
  transform: translateY(-1px);
}

.danger {
  color: var(--red);
  border-color: #fecaca;
  background: var(--red-bg);
}

.danger:hover { background: #fee2e2; }

.button.small { padding: 5px 12px; font-size: 12px; min-height: 32px; }
.button.outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.button.outline:hover { background: var(--primary-subtle); }

/* ═══════════════════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════════════════ */

table { width: 100%; border-collapse: collapse; }

th, td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-light);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

tbody tr { transition: background 0.1s var(--ease); }
tbody tr:hover { background: rgba(37,99,235,0.02); }
tr:last-child td { border-bottom: 0; }

.muted { color: var(--muted); }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left;
  padding: 10px 16px;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--line);
}
.data-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line-light);
  color: var(--text);
}
.data-table tr:hover td { background: rgba(37,99,235,0.02); }
.data-table .empty { text-align: center; color: var(--muted); padding: 2rem; }

/* ═══════════════════════════════════════════════════════════════
   STATUS BADGES
   ═══════════════════════════════════════════════════════════════ */

.status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status.sent, .status.dry-run, .status.open, .status.received {
  background: var(--green-bg); color: #059669;
}

.status.failed, .status.logged_out, .status.closed, .status.stopped, .status.bridge_offline {
  background: var(--red-bg); color: #dc2626;
}

.status.draft, .status.qr, .status.starting, .status.restarting, .status.pairing_code {
  background: var(--primary-light); color: #1d4ed8;
}

.empty {
  padding: 40px 16px;
  color: var(--muted);
  text-align: center;
  background: var(--surface);
  font-size: 14px;
}

/* ═══════════════════════════════════════════════════════════════
   COMMUNITY CARDS (Admin Dashboard)
   ═══════════════════════════════════════════════════════════════ */

.dashboard-banner {
  margin-bottom: 1.5rem;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.dashboard-banner img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.community-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  padding: 16px 20px;
}

.community-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all 0.2s var(--ease);
  box-shadow: var(--shadow-xs);
}

.community-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(37,99,235,0.15);
}

.community-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.community-card-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.community-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.mini-stat {
  text-align: center;
  padding: 10px 6px;
  background: var(--surface-2);
  border-radius: 8px;
  border: 1px solid var(--line-light);
}

.mini-stat strong {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.mini-stat span {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.community-card-footer { display: flex; gap: 8px; }

/* ═══════════════════════════════════════════════════════════════
   QUICK LINKS
   ═══════════════════════════════════════════════════════════════ */

.quick-links {
  display: flex;
  gap: 10px;
  padding: 20px;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════════
   SUB-AREA TAG
   ═══════════════════════════════════════════════════════════════ */

.sub-area-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--purple-bg);
  color: var(--purple);
  margin-left: 6px;
}

/* ═══════════════════════════════════════════════════════════════
   CARDS (Generic)
   ═══════════════════════════════════════════════════════════════ */

.cards { display: grid; gap: 16px; margin-top: 16px; }
.cards.two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  transition: all 0.2s var(--ease);
  box-shadow: var(--shadow-xs);
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: rgba(37,99,235,0.12);
}

.card h3 { margin: 0 0 10px; font-size: 15px; color: var(--text); font-weight: 700; }
.card p, .card li { color: var(--text-secondary); font-size: 14px; line-height: 1.6; }
.card ul { margin: 0; padding-left: 18px; }

@media (max-width: 920px) { .cards.two-up { grid-template-columns: 1fr; } }

/* ═══════════════════════════════════════════════════════════════
   PULSE DOT (status indicator)
   ═══════════════════════════════════════════════════════════════ */

.pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 2px;
}

.pulse-dot.ok {
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(16,185,129,0.5);
  animation: pulse-green 2s infinite;
}

.pulse-dot.warn {
  background: var(--amber);
  box-shadow: 0 0 0 0 rgba(245,158,11,0.5);
  animation: pulse-amber 2s infinite;
}

@keyframes pulse-green {
  0% { box-shadow: 0 0 0 0 rgba(16,185,129,0.5); }
  70% { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
  100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); }
}

@keyframes pulse-amber {
  0% { box-shadow: 0 0 0 0 rgba(245,158,11,0.5); }
  70% { box-shadow: 0 0 0 8px rgba(245,158,11,0); }
  100% { box-shadow: 0 0 0 0 rgba(245,158,11,0); }
}

/* ═══════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════════════ */

/* ── LOGIN: SPLIT LAYOUT ─────────────────────────────────── */

.login-body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #0b1120;
}

.login-split {
  display: flex;
  min-height: 100vh;
}

/* Left branding panel */
.login-brand {
  flex: 0 0 50%;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 3rem;
  position: relative;
  overflow: hidden;
}

.login-brand::before {
  content: '';
  position: absolute;
  top: -30%;
  left: -20%;
  width: 80%;
  height: 80%;
  background: radial-gradient(circle, rgba(37,99,235,0.15) 0%, transparent 60%);
  pointer-events: none;
}

.login-brand::after {
  content: '';
  position: absolute;
  bottom: -20%;
  right: -15%;
  width: 60%;
  height: 60%;
  background: radial-gradient(circle, rgba(139,92,246,0.12) 0%, transparent 60%);
  pointer-events: none;
}

.login-brand-content {
  position: relative;
  z-index: 1;
  max-width: 420px;
  text-align: center;
  animation: fadeInUp 0.6s ease-out;
}

.login-brand-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.login-brand-logo img {
  height: 140px;
  width: auto;
  filter: drop-shadow(0 4px 20px rgba(37,99,235,0.4));
}

.login-brand-title {
  font-size: 2.25rem;
  font-weight: 800;
  color: #f1f5f9;
  margin: 0 0 0.75rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.login-brand-tagline {
  font-size: 1.05rem;
  color: #94a3b8;
  line-height: 1.6;
  margin: 0 0 2.5rem;
}

.login-brand-features {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.login-feature {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 1rem 1.25rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  transition: background 0.2s, border-color 0.2s;
}

.login-feature:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.1);
}

.login-feature-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(37,99,235,0.15);
  border-radius: 10px;
  color: #60a5fa;
}

.login-feature div strong {
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
  color: #e2e8f0;
  margin-bottom: 2px;
}

.login-feature div span {
  font-size: 0.8rem;
  color: #64748b;
  line-height: 1.4;
}

.login-brand-footer {
  position: absolute;
  bottom: 2rem;
  left: 0;
  right: 0;
  text-align: center;
  color: #475569;
  font-size: 0.75rem;
  z-index: 1;
}

/* Right form panel */
.login-form-panel {
  flex: 0 0 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  background: #ffffff;
}

.login-form-wrapper {
  width: 100%;
  max-width: 380px;
  animation: fadeInUp 0.5s ease-out 0.15s both;
}

.login-mobile-logo {
  display: none;
  text-align: center;
  margin-bottom: 2rem;
}

.login-mobile-logo img {
  height: 52px;
  width: auto;
}

.login-welcome h2 {
  font-size: 1.75rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 0.5rem;
  letter-spacing: -0.02em;
}

.login-welcome p {
  font-size: 0.95rem;
  color: #64748b;
  margin: 0 0 2rem;
}

.login-error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-error::before {
  content: '!';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* Suspended community banner */
.login-suspended {
  background: #fef2f2; border: 1px solid #fecaca; border-radius: 12px;
  padding: 20px; text-align: center; margin-bottom: 1.5rem;
}
.suspended-icon { margin-bottom: 4px; }

.login-form .form-group { margin-bottom: 1.25rem; }

.login-form .form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input-icon-wrap {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
  transition: color 0.15s;
}

.input-icon-wrap input {
  width: 100%;
  padding: 13px 14px 13px 44px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #f8fafc;
  color: #0f172a;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  box-sizing: border-box;
}

.input-icon-wrap input::placeholder {
  color: #94a3b8;
}

.input-icon-wrap input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  background: #fff;
}

.input-icon-wrap:focus-within .input-icon {
  color: #2563eb;
}

.login-btn {
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 0.75rem;
  box-shadow: 0 4px 14px rgba(37,99,235,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.login-btn:hover {
  background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(37,99,235,0.45);
}

.login-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.login-btn svg {
  transition: transform 0.2s;
}

.login-btn:hover svg {
  transform: translateX(3px);
}

.login-footer {
  text-align: center;
  margin-top: 2.5rem;
  color: #94a3b8;
  font-size: 0.8rem;
}

/* Mobile: stack layout, hide brand panel */
@media (max-width: 900px) {
  .login-split {
    flex-direction: column;
  }

  .login-brand {
    display: none;
  }

  .login-form-panel {
    flex: 1;
    min-height: 100vh;
    background: linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
    padding: 2rem 1.5rem;
  }

  .login-form-wrapper {
    background: #ffffff;
    border-radius: 20px;
    padding: 2.5rem 2rem;
    box-shadow: 0 25px 60px rgba(0,0,0,0.5);
    max-width: 400px;
  }

  .login-mobile-logo {
    display: block;
  }
}

/* ═══════════════════════════════════════════════════════════════
   DEVICE PAGE v2
   ═══════════════════════════════════════════════════════════════ */

/* Top bar */
.dv-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.dv-topbar-left { flex: 1; min-width: 200px; }

.dv-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.dv-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}

.dv-dot-on .dv-dot { background: #22c55e; box-shadow: 0 0 8px rgba(34,197,94,0.5); }
.dv-dot-wait .dv-dot { background: #f59e0b; animation: pulse 1.5s infinite; }
.dv-dot-off .dv-dot { background: #ef4444; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Grid */
.dv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .dv-grid { grid-template-columns: 1fr; }
}

.dv-col {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Cards */
.dv-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.5rem;
  transition: box-shadow 0.2s;
}

.dv-card:hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.dv-card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  margin-bottom: 1.25rem;
}

.dv-card-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 2px;
}

.dv-card-header p {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
}

.dv-card-icon {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dv-icon-green { background: rgba(34,197,94,0.1); color: #22c55e; }
.dv-icon-blue { background: rgba(37,99,235,0.1); color: #2563eb; }
.dv-icon-purple { background: rgba(139,92,246,0.1); color: #8b5cf6; }
.dv-icon-amber { background: rgba(245,158,11,0.1); color: #f59e0b; }
.dv-icon-teal { background: rgba(20,184,166,0.1); color: #14b8a6; }

/* Profile row */
.dv-profile-row {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1rem;
  background: var(--surface-2);
  border-radius: 12px;
  margin-bottom: 1rem;
}

.dv-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #64748b, #475569);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.dv-avatar-on {
  background: linear-gradient(135deg, #22c55e, #16a34a);
}

.dv-profile-info {
  flex: 1;
  min-width: 0;
}

.dv-profile-info strong {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dv-profile-info span {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}

.dv-conn-badge {
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.dv-conn-on { background: rgba(34,197,94,0.12); color: #16a34a; }
.dv-conn-off { background: rgba(239,68,68,0.1); color: #ef4444; }

/* QR area */
.dv-qr-area {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.dv-qr-area .qr-wrap {
  padding: 1rem;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.dv-qr-area .qr-wrap img {
  display: block;
  width: 220px;
  height: 220px;
}

.dv-qr-area .empty {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Action buttons */
.dv-actions-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.dv-actions-row form { flex: 1; min-width: 0; }

.dv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  width: 100%;
}

.dv-btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(37,99,235,0.25);
}
.dv-btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,0.35); }

.dv-btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}
.dv-btn-secondary:hover { background: var(--hover); border-color: var(--muted); }

.dv-btn-danger {
  background: rgba(239,68,68,0.08);
  color: #ef4444;
  border: 1px solid rgba(239,68,68,0.2);
}
.dv-btn-danger:hover { background: rgba(239,68,68,0.15); }

.dv-btn-full { width: 100%; margin-top: 1rem; }

/* Pairing form */
.dv-pairing-form { margin-top: 0.25rem; }

.dv-input-group {
  display: flex;
  gap: 0.5rem;
}

.dv-input-group input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--surface-2);
  transition: border-color 0.15s;
}

.dv-input-group input:focus {
  outline: none;
  border-color: var(--primary);
}

.dv-input-group .dv-btn { width: auto; flex-shrink: 0; }

/* Details grid */
.dv-details {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.dv-details-compact { margin-top: 1rem; }

.dv-detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  gap: 1rem;
}

.dv-detail-row:last-child { border-bottom: none; }

.dv-detail-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.dv-detail-value {
  font-size: 0.8rem;
  color: var(--text);
  text-align: right;
  word-break: break-all;
}

.dv-detail-value code {
  font-size: 0.75rem;
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 6px;
}

.dv-detail-error { color: var(--muted); }

/* Tags */
.dv-tag {
  margin-left: auto;
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.dv-tag-on { background: rgba(34,197,94,0.12); color: #16a34a; }
.dv-tag-off { background: rgba(239,68,68,0.08); color: #ef4444; }

/* Toggle switch */
.dv-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface-2);
  border-radius: 10px;
}

.dv-toggle input { display: none; }

.dv-toggle-slider {
  width: 44px;
  height: 24px;
  background: #cbd5e1;
  border-radius: 12px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.dv-toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.dv-toggle input:checked + .dv-toggle-slider {
  background: #22c55e;
}

.dv-toggle input:checked + .dv-toggle-slider::after {
  transform: translateX(20px);
}

.dv-toggle-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}

/* Fields */
.dv-field {
  margin-bottom: 1rem;
}

.dv-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dv-field input,
.dv-field textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  font-size: 0.875rem;
  font-family: inherit;
  background: var(--surface-2);
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
  resize: vertical;
}

.dv-field input:focus,
.dv-field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

.dv-field textarea { min-height: 80px; }

/* ═══════════════════════════════════════════════════════════════
   CHAT: MESSAGE DISPLAY
   ═══════════════════════════════════════════════════════════════ */

.message-body {
  max-width: 560px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.media-message { display: flex; align-items: center; gap: 10px; min-width: 0; }

.media-thumb {
  width: 92px; height: 92px;
  display: block; object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

audio { max-width: 260px; }
.media-link { color: var(--primary); font-weight: 600; }

/* Image modal */
.image-modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 24px;
  background: rgba(15,23,42,0.9);
}
.image-modal[hidden] { display: none; }
.image-modal img {
  max-width: min(92vw, 1200px); max-height: 88vh;
  display: block; border-radius: var(--radius); box-shadow: var(--shadow-xl); background: #fff;
}
.image-modal-close {
  position: fixed; top: 18px; right: 18px;
  min-width: 40px; width: 40px; height: 40px;
  border: 0; border-radius: 50%; background: #fff;
  color: var(--text); font-size: 22px; line-height: 1;
  box-shadow: var(--shadow-lg);
}
.image-modal-close:hover { background: var(--surface-2); }

/* ═══════════════════════════════════════════════════════════════
   CHAT: SHELL & PANELS
   ═══════════════════════════════════════════════════════════════ */

.chat-shell {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(340px, 31vw) minmax(0, 1fr);
  border: 0;
  border-radius: 14px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}

body[data-auto-refresh="messages"] .chat-shell {
  flex: 1 1 auto;
  height: auto;
}

#chat-refresh-area {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#chat-refresh-area .chat-shell {
  flex: 1 1 0;
  min-height: 0;
}

body[data-auto-refresh="community-chat"] #page-content {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 72px);
  overflow: hidden;
  padding-bottom: 0;
}

.conversation-list {
  min-width: 0;
  border-right: 1px solid #e2e8f0;
  background: #fff;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.conversation-head {
  min-height: 60px;
  padding: 14px 18px;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(135deg, #075e54 0%, #128c7e 100%);
  display: flex; align-items: center;
  justify-content: space-between; gap: 12px;
}

.conversation-head-actions { display: flex; align-items: center; gap: 8px; }

.conversation-head h2 {
  margin: 0; font-size: 1.05rem; color: #fff; font-weight: 700; letter-spacing: -.01em;
}

.chat-tab-bar {
  display: flex; gap: 4px; padding: 8px 12px; background: #f8fafc; border-bottom: 1px solid #e2e8f0;
}
.chat-tab {
  flex: 1; text-align: center; padding: 7px 0; font-size: .78rem; font-weight: 600;
  color: #64748b; text-decoration: none; border-radius: 8px;
  transition: all .15s;
}
.chat-tab:hover { background: #e2e8f0; color: #334155; }
.chat-tab-active { background: #fff; color: #128c7e; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.conversation-tools {
  display: grid; gap: 10px;
  padding: 10px 14px 12px;
  border-bottom: 1px solid #e2e8f0;
}

.account-selector { padding: 10px 14px 0; background: #ffffff; }
.account-selector label { display: grid; gap: 5px; }
.account-selector select {
  min-height: 38px; border: 0; border-radius: 999px;
  background: var(--surface-2); padding-inline: 14px; color: var(--text);
}

.chat-search { display: block; }
.chat-search span { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; }
.chat-search input {
  min-height: 40px; border: 0; border-radius: 999px;
  background: var(--surface-2); padding-inline: 18px;
}

.chat-filters { display: flex; gap: 8px; overflow: auto; }
.chat-filters button {
  min-height: 32px; border-radius: 999px; padding: 5px 12px; background: #ffffff;
}
.chat-filters button.active {
  background: var(--primary-light); border-color: #93c5fd; color: var(--primary);
}

.conversation-scroll { overflow: auto; }

.new-chat-form {
  display: grid; gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.new-chat-form[hidden] { display: none; }
.new-chat-form label { display: grid; gap: 4px; }
.new-chat-form textarea { min-height: 70px; }
.new-chat-actions { display: flex; gap: 8px; }

.conversation-item-wrap {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  border-bottom: 1px solid #f1f5f9;
  background: #ffffff;
  transition: all 0.15s ease;
}

.conversation-item-wrap:hover { background: #f0fdf4; }
.conversation-item-wrap.active {
  background: #ecfdf5;
  border-left: 3px solid #128c7e;
}

.conversation-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 12px 12px 16px;
  min-width: 0;
}

.conversation-delete-form { display: flex; align-items: center; padding-right: 8px; }
.icon-button.conversation-delete-button {
  min-width: 0; min-height: 30px; padding: 5px 8px;
  opacity: 0; font-size: 12px;
}
.conversation-item-wrap:hover .conversation-delete-button,
.conversation-delete-button:focus { opacity: 1; }

.chat-avatar {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
  color: #fff; font-weight: 700; font-size: .9rem;
  overflow: hidden;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.chat-avatar.has-photo { background: #dfe5e7; }
.chat-avatar img, .chat-avatar .chat-avatar-img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: 50%; }
.conversation-item-wrap:hover .chat-avatar { transform: scale(1.06); }

.conversation-main { min-width: 0; display: grid; gap: 3px; }
.conversation-row {
  min-width: 0; display: flex;
  align-items: center; justify-content: space-between; gap: 8px;
}
.conversation-row strong, .conversation-preview {
  min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.conversation-row time, .chat-header span, .bubble-meta {
  color: #667781; font-size: 12px;
}

.chat-count {
  min-width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 999px; background: var(--primary);
  color: #ffffff; font-size: 12px; font-weight: 700;
}

.chat-panel {
  min-width: 0; min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #efeae2;
}

.chat-header {
  min-height: 60px;
  padding: 10px 18px;
  display: flex; align-items: center; gap: 14px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}
.chat-header strong { display: block; font-size: .9rem; color: #1e293b; }
.chat-header span { display: block; font-size: .78rem; color: #64748b; }
.chat-header > div:not(.chat-header-actions) { min-width: 0; flex: 1; }
.chat-header-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.chat-header-actions .status {
  padding: 3px 10px; border-radius: 20px; font-size: .72rem; font-weight: 600;
  background: #f0fdf4; color: #128c7e; border: 1px solid #bbf7d0;
}
.chat-header-actions button, .compose-icon, .compose-send {
  min-width: 40px; width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 50%; background: transparent;
  color: #54656f; overflow: hidden; white-space: nowrap;
  transition: background .15s;
}
.chat-header-actions button:hover, .compose-icon:hover { background: #f1f5f9; }

.chat-thread {
  min-height: 0; overflow: auto;
  padding: 18px 7%; padding-bottom: 24px;
  display: flex; flex-direction: column; gap: 8px;
  overflow-anchor: none;
  background-color: #efeae2;
  background-image:
    radial-gradient(circle at 18px 18px, rgba(17,27,33,0.035) 1.5px, transparent 1.6px),
    radial-gradient(circle at 58px 46px, rgba(17,27,33,0.028) 1.5px, transparent 1.6px);
  background-size: 82px 82px;
}
.chat-bottom-anchor { min-height: 1px; overflow-anchor: auto; }
.chat-thread > *:not(.chat-bottom-anchor) { overflow-anchor: none; }

.bubble-row { display: flex; }
.bubble-row.in { justify-content: flex-start; }
.bubble-row.out { justify-content: flex-end; }

.bubble {
  max-width: min(620px, 70%);
  padding: 8px 12px; border: 0; border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(11,20,26,0.1);
  transition: box-shadow 0.15s ease;
}
.bubble-row.in .bubble { border-top-left-radius: 3px; }
.bubble-row.out .bubble { background: #d9fdd3; border-top-right-radius: 3px; }
.bubble:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.bubble-body { overflow-wrap: anywhere; }
.bubble-body .media-message { display: grid; gap: 6px; }
.bubble-body .media-thumb { width: min(260px, 100%); height: 220px; max-height: 220px; object-fit: cover; }
.bubble-meta { margin-top: 5px; display: flex; justify-content: flex-end; gap: 8px; }
.bubble-status { color: #0d5f43; }
.bubble-row { animation: fadeInUp 0.2s ease-out; }

/* Chat compose */
.chat-compose {
  display: grid;
  grid-template-columns: 42px 42px minmax(160px, 1fr) 42px 42px;
  gap: 8px; padding: 10px 16px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  align-items: center; position: sticky; bottom: 0; z-index: 1;
}
.chat-compose textarea {
  width: 100%; min-height: 44px; max-height: 120px;
  border: 1.5px solid #e2e8f0; border-radius: 22px; padding: 11px 18px; resize: none;
  font-size: .88rem; transition: border-color .15s;
}
.chat-compose textarea:focus { border-color: #25d366; outline: none; box-shadow: 0 0 0 3px rgba(37,211,102,.1); }
.compose-send {
  background: linear-gradient(135deg, #25d366, #128c7e); color: #ffffff;
  transition: filter .15s;
}
.compose-send:hover { filter: brightness(1.08); }

.property-compose { grid-template-columns: 42px minmax(0, 1fr) 42px; }
.property-compose textarea { min-height: 52px; border-radius: 22px; resize: vertical; }

/* Voice recording */
.voice-button.recording { background: var(--red-bg); border-color: #fca5a5; color: #dc2626; opacity: 1; cursor: default; }
.voice-icon {
  width: 22px; height: 22px; display: block; margin: auto;
  background-color: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 14c1.7 0 3-1.3 3-3V5c0-1.7-1.3-3-3-3S9 3.3 9 5v6c0 1.7 1.3 3 3 3Zm5-3c0 2.8-2.2 5-5 5s-5-2.2-5-5H5c0 3.5 2.6 6.4 6 6.9V21H8v2h8v-2h-3v-3.1c3.4-.5 6-3.4 6-6.9h-2Z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.chat-compose.is-recording { background: #fff7f6; }
.voice-recording-status {
  grid-column: 1 / -1; min-height: 38px;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border: 1px solid #fca5a5;
  border-radius: var(--radius); background: #fff;
  color: #dc2626; font-weight: 700;
}
.voice-recording-status::before {
  content: ""; width: 10px; height: 10px; flex: 0 0 auto;
  border-radius: 50%; background: #dc2626;
  box-shadow: 0 0 0 0 rgba(220,38,38,0.45);
  animation: recording-pulse 1s infinite;
}
.voice-recording-status[hidden] { display: none; }
@keyframes recording-pulse {
  70% { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
  100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); }
}

/* Attachments */
.attach-trigger { font-size: 28px; line-height: 1; font-weight: 300; }
.attach-menu-wrap { position: relative; }
.attach-menu {
  position: absolute; left: 0; bottom: 54px; min-width: 224px;
  display: grid; gap: 2px; padding: 8px;
  border: 1px solid var(--line); border-radius: 14px;
  background: #ffffff; box-shadow: var(--shadow-xl); z-index: 5;
}
.attach-menu[hidden] { display: none; }
.attach-menu button {
  width: 100%; display: flex; align-items: center; gap: 12px;
  justify-content: flex-start; border: 0; border-radius: 10px;
  min-height: 44px; padding: 8px 10px; background: #ffffff;
  color: var(--text); cursor: pointer; text-align: left;
}
.attach-menu button:hover { background: var(--surface-2); }
.attach-menu-icon {
  width: 34px; height: 34px; flex: 0 0 auto;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--green-bg); color: #059669;
  font-size: 10px; font-weight: 800; letter-spacing: 0;
}

/* Emoji panel */
.emoji-panel {
  position: absolute; left: 62px; bottom: 54px;
  width: min(320px, calc(100vw - 24px)); max-height: 230px;
  overflow: auto; display: grid;
  grid-template-columns: repeat(8, 1fr); gap: 4px; padding: 10px;
  border: 1px solid var(--line); border-radius: 14px;
  background: #ffffff; box-shadow: var(--shadow-xl); z-index: 6;
}
.emoji-panel[hidden] { display: none; }
.emoji-option {
  width: 34px; height: 34px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: transparent;
  cursor: pointer; font-size: 21px; line-height: 1;
}
.emoji-option:hover { background: var(--surface-2); }

/* Attachment preview + button */
.attach-button { display: none; }
.attach-button input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; pointer-events: none; }
.chat-file-input { display: none; }
.attachment-preview {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: minmax(0, 1fr) max-content;
  gap: 10px; align-items: start; padding: 10px;
  border: 1px solid #93c5fd; border-radius: var(--radius);
  background: var(--primary-subtle);
}
.attachment-preview[hidden] { display: none; }
.attachment-preview-main { min-width: 0; display: flex; gap: 10px; align-items: center; }
.attachment-preview img, .attachment-preview video {
  width: 92px; height: 92px; flex: 0 0 auto; object-fit: cover;
  border: 1px solid var(--line); border-radius: var(--radius); background: #ffffff;
}
.attachment-file-icon {
  width: 46px; height: 46px; flex: 0 0 auto;
  display: grid; place-items: center; border-radius: var(--radius);
  background: var(--primary-light); color: var(--primary); font-weight: 800;
}
.attachment-preview strong, .attachment-preview span { display: block; min-width: 0; overflow-wrap: anywhere; }
.attachment-preview span { color: var(--muted); font-size: 13px; margin-top: 2px; }

.attach-button {
  min-height: 38px; max-width: 190px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 12px; background: #ffffff; color: var(--text); cursor: pointer;
}
.attach-button span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-button input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; pointer-events: none; }

.chat-empty {
  height: 100%; display: grid; place-items: center;
  padding: 40px; color: #94a3b8; text-align: center;
  font-size: .9rem;
  background: #fafbfc;
  background-image: radial-gradient(circle at 50% 50%, rgba(37,211,102,.04) 0%, transparent 70%);
}

.chat-closed-banner {
  text-align: center; padding: 14px; font-size: .82rem; font-weight: 600;
  color: #64748b; background: #f8fafc; border-top: 1px solid #e2e8f0;
}

/* Chat detail cards */
.chat-detail-cards {
  padding: 12px 16px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}
.chat-detail-card {
  background: #fff;
  border-radius: 10px;
  padding: 14px 16px;
  border: 1px solid #e2e8f0;
}
.chat-detail-title {
  display: flex; align-items: center; gap: 6px;
  font-size: .82rem; font-weight: 700; color: #334155;
  margin: 0 0 10px;
}
.chat-detail-title svg { color: #64748b; }
.chat-detail-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 12px;
  font-size: .8rem;
}
.chat-detail-label { color: #94a3b8; font-weight: 500; }
.chat-detail-grid span:nth-child(even) { color: #1e293b; font-weight: 500; }

/* ═══════════════════════════════════════════════════════════════
   SETTINGS / DEVICES
   ═══════════════════════════════════════════════════════════════ */

.settings-list {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 10px 18px;
}

.device-grid { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: start; }

.device-link-grid {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 16px; align-items: stretch;
}

.qr-wrap {
  width: 100%; max-width: 360px; aspect-ratio: 1;
  display: grid; place-items: center;
  border: 2px dashed rgba(37,99,235,0.2);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--surface-2) 0%, var(--primary-subtle) 100%);
  padding: 16px;
  transition: all 0.3s var(--ease);
}
.qr-wrap:hover { border-color: rgba(37,99,235,0.35); box-shadow: 0 0 20px rgba(37,99,235,0.06); }
.qr-wrap img { width: 100%; height: auto; display: block; }

.device-actions {
  display: grid; gap: 12px; align-content: start;
  padding: 16px; border: 1px solid var(--line);
  border-radius: var(--radius-lg); background: var(--surface-2);
}
.device-actions strong, .device-actions span { display: block; }
.device-actions span { margin-top: 2px; color: var(--muted); font-size: 13px; }

.device-account-form {
  display: grid; grid-template-columns: minmax(240px, 1fr) max-content;
  gap: 10px; align-items: end; margin-top: 14px;
}

.device-row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.device-row-actions form { margin: 0; }

.profile-card {
  display: grid; grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px; align-items: center;
  padding: 14px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface-2);
  transition: all 0.15s var(--ease);
}
.profile-card:hover { box-shadow: var(--shadow-sm); border-color: rgba(37,99,235,0.15); }

.profile-avatar {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 800; font-size: 20px;
}
.profile-card strong, .profile-card span { display: block; overflow-wrap: anywhere; }
.profile-card span { color: var(--muted); margin-top: 2px; }

.pairing-card {
  display: grid; gap: 12px;
  padding: 18px; border: 1px solid rgba(37,99,235,0.2);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary-subtle) 0%, #dbeafe 100%);
  box-shadow: var(--shadow-xs);
}
.pairing-card strong, .pairing-card span { display: block; }
.pairing-card span { margin-top: 2px; color: var(--text-secondary); font-size: 13px; }

.device-action-row { display: flex; flex-wrap: wrap; gap: 8px; }
.device-action-row .actions { margin: 0; }

.settings-list.compact {
  grid-template-columns: 150px minmax(0, 1fr);
  padding: 16px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff;
}

.pairing-form {
  display: grid; grid-template-columns: minmax(220px, 1fr) max-content;
  gap: 10px; align-items: end;
}

.pairing-code-box {
  display: grid; gap: 4px; width: max-content; max-width: 100%;
  padding: 14px 16px; border: 1px solid rgba(37,99,235,0.2);
  border-radius: var(--radius); background: var(--primary-subtle);
}
.pairing-code-box span { color: var(--muted); font-size: 13px; }
.pairing-code-box strong {
  font-family: Consolas, "Courier New", monospace;
  font-size: 28px; letter-spacing: 0; color: var(--primary);
}

code { font-family: Consolas, "Courier New", monospace; }

/* ═══════════════════════════════════════════════════════════════
   MOBILE SIDEBAR TOGGLE
   ═══════════════════════════════════════════════════════════════ */

.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 20;
}

.mobile-menu-btn svg { width: 20px; height: 20px; }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
}

@media (max-width: 980px) {
  .mobile-menu-btn { display: flex; }

  .shell { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 20px 0 60px rgba(0,0,0,0.3);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
  }

  .sidebar-overlay.active { display: block; }

  .topbar { padding: 16px 20px 12px 68px; }

  #page-content { padding: 0 20px 20px; }

  .brand-logo { width: 140px; }

  .stats, .form-grid, .form-grid.campaign, .chat-shell {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main { padding: 0; overflow: visible; }

  .panel-body.device-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .topbar { display: grid; padding: 12px 16px 10px 60px; }
  .panel-head { display: grid; }

  .stats, .form-grid, .form-grid.campaign,
  .device-link-grid, .settings-list, .chat-shell {
    grid-template-columns: 1fr;
  }

  .community-grid { grid-template-columns: 1fr; }
  .community-stats-grid { grid-template-columns: repeat(2, 1fr); }

  .panel-body.device-grid { grid-template-columns: 1fr; }
  .pairing-form { grid-template-columns: 1fr; }
  .device-account-form { grid-template-columns: 1fr; }

  .chat-compose {
    grid-template-columns: 42px 42px minmax(0, 1fr) 42px 42px;
    gap: 6px; padding: 8px;
  }

  .emoji-panel {
    left: 8px; right: 8px; width: auto;
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }

  .chat-shell { height: calc(100vh - 148px); min-height: 0; }
  .conversation-list { border-right: 0; border-bottom: 1px solid var(--line); }
  .conversation-scroll { max-height: 280px; }
  .chat-panel { min-height: 520px; }
  .bubble { max-width: 92%; }

  .form-row { grid-template-columns: 1fr; }
  .inline-form { flex-direction: column; }
  .inline-form input, .inline-form select { width: 100%; }

  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  td { padding: 9px 0; }
  tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }

  #page-content { padding: 0 16px 16px; }
}

/* ═══════════════════════════════════════════════════════════════
   PH LOADING OVERLAY
   ═══════════════════════════════════════════════════════════════ */

.ph-loader {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(11, 17, 32, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ph-loader.active {
  opacity: 1;
  visibility: visible;
}

.ph-loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.ph-loader-img {
  width: 180px;
  height: 180px;
  object-fit: contain;
  animation: ph-pulse 1.8s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(59, 130, 246, 0.4));
}

.ph-loader-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: ph-spin 0.8s linear infinite;
}

.ph-loader-text {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  margin: 0;
  animation: ph-fade-text 1.8s ease-in-out infinite;
}

@keyframes ph-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.85; }
}

@keyframes ph-spin {
  to { transform: rotate(360deg); }
}

@keyframes ph-fade-text {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 0.4; }
}

/* ══════════════════════��═══════════════���════════════════════
   PORTERIA MODULE STYLES
   ════════════════════════════════════════════���══════════════ */

/* Form grid for porteria */
.form-grid.porteria {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  align-items: end;
}
.form-grid.porteria .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-grid.porteria .field.wide {
  grid-column: 1 / -1;
}
.form-grid.porteria .field label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.form-grid.porteria textarea {
  resize: vertical;
  min-height: 60px;
}

/* Tab bar */
.tab-bar {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.tab-link {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  text-decoration: none;
  color: #64748b;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  transition: all .2s;
}
.tab-link:hover {
  background: #e2e8f0;
  color: #334155;
}
.tab-link.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

/* Directorio */
.dir-avatar, .dir-avatar-initial {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  object-fit: cover;
}
.dir-avatar { border-radius: 50%; }

/* ── Directory Cards ──────────────────────────────────────── */
.dir-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}
.dir-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  transition: box-shadow .2s, border-color .2s;
}
.dir-card:hover {
  border-color: #c7d2fe;
  box-shadow: 0 4px 12px rgba(99,102,241,.1);
}
.dir-card-avatar {
  flex-shrink: 0;
}
.dir-card-avatar-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}
.dir-card-avatar-init {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.dir-card-info {
  flex: 1;
  min-width: 0;
}
.dir-card-name {
  font-weight: 600;
  font-size: 14px;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dir-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.dir-card-location {
  font-size: 12px;
  color: #64748b;
}
.dir-card-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.dir-action-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.dir-action-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 3px 8px rgba(0,0,0,.12);
}
.dir-action-msg {
  background: #3b82f6;
  color: #fff;
}
.dir-action-call {
  background: #25d366;
  color: #fff;
}
@media (max-width: 640px) {
  .dir-cards-grid {
    grid-template-columns: 1fr;
  }
}

.dir-msg-input {
  width: 160px;
  padding: 5px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
}
.pickup-input {
  width: 130px;
  padding: 5px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 13px;
}

/* Minuta feed */
.minuta-feed {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.minuta-entry {
  padding: 16px;
  border-left: 4px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 0 8px 8px 0;
  transition: border-color .2s;
}
.minuta-entry:hover {
  border-left-color: #2563eb;
}
.minuta-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 13px;
}
.minuta-entry h4 {
  margin: 0 0 6px;
  font-size: 15px;
  color: #1e293b;
}
.minuta-entry p {
  margin: 0;
  color: #475569;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

/* Minuta type pills */
.pill.novedad { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.pill.incidente { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }
.pill.observacion { background: #fef3c7; color: #d97706; border-color: #fcd34d; }
.pill.turno_inicio { background: #d1fae5; color: #059669; border-color: #6ee7b7; }
.pill.turno_fin { background: #e0e7ff; color: #4338ca; border-color: #a5b4fc; }
.pill.otro { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }

/* Priority pills */
.pill.urgente { background: #fee2e2; color: #dc2626; border-color: #fca5a5; font-weight: 700; }
.pill.alta { background: #fff7ed; color: #ea580c; border-color: #fdba74; }

/* Report number pill */
.pill.report-num { background: #1e293b; color: #fff; border-color: #334155; font-weight: 700; font-size: 12px; }

/* Minuta status pills */
.pill.status-abierta { background: #fef3c7; color: #d97706; border-color: #fcd34d; }
.pill.status-resuelta { background: #d1fae5; color: #059669; border-color: #6ee7b7; }
.pill.status-porteria { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }

/* Minuta media thumbnail */
.minuta-media { margin-top: 8px; }
.minuta-media img { max-width: 200px; max-height: 150px; border-radius: 6px; border: 1px solid #e2e8f0; object-fit: cover; cursor: pointer; }
.minuta-media img:hover { opacity: .85; }

/* Minuta action buttons */
.minuta-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* Success button */
.button.success { background: #059669; color: #fff; border-color: #047857; }
.button.success:hover { background: #047857; }

/* Warning button */
.button.warning { background: #d97706; color: #fff; border-color: #b45309; }
.button.warning:hover { background: #b45309; }

/* Encomienda type pills */
.pill.paquete { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.pill.sobre { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.pill.caja { background: #fef3c7; color: #d97706; border-color: #fcd34d; }
.pill.alimento { background: #d1fae5; color: #059669; border-color: #6ee7b7; }

/* Encomienda status pills */
.pill.pendiente { background: #fef3c7; color: #d97706; border-color: #fcd34d; }
.pill.notificado { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.pill.recogido { background: #d1fae5; color: #059669; border-color: #6ee7b7; }
.pill.devuelto { background: #e0e7ff; color: #4338ca; border-color: #a5b4fc; }

/* Visitante purpose pills */
.pill.visita { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.pill.delivery { background: #fef3c7; color: #d97706; border-color: #fcd34d; }
.pill.servicio { background: #e0e7ff; color: #4338ca; border-color: #a5b4fc; }
.pill.obra { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }

/* Autorizado status */
.pill.activo { background: #d1fae5; color: #059669; border-color: #6ee7b7; }
.pill.inactivo { background: #f1f5f9; color: #64748b; border-color: #cbd5e1; }
.pill.vencido { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }

/* Access log direction */
.dir-entrada { color: #059669; font-weight: 600; }
.dir-salida { color: #dc2626; font-weight: 600; }

/* Person type pills */
.pill.residente { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.pill.visitante { background: #fef3c7; color: #d97706; border-color: #fcd34d; }
.pill.autorizado { background: #d1fae5; color: #059669; border-color: #6ee7b7; }
.pill.proveedor { background: #e0e7ff; color: #4338ca; border-color: #a5b4fc; }

/* Parking status */
.pill.disponible { background: #d1fae5; color: #059669; border-color: #6ee7b7; }
.pill.asignado { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.pill.mantenimiento { background: #fee2e2; color: #dc2626; border-color: #fca5a5; }

/* Search input */
.search-input {
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  min-width: 220px;
}

/* ── Visitor Register Form ───────────────────────────────── */
.visitor-register-panel .panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.visitor-auth-badge {
  background: #d1fae5;
  color: #059669;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}
.visitor-register-form {
  padding: 0;
}
.visitor-form-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.visitor-photo-section {
  flex-shrink: 0;
}
.visitor-photo-upload {
  display: flex;
  cursor: pointer;
  width: 160px;
  height: 160px;
  border-radius: 16px;
  overflow: hidden;
  border: 2px dashed #cbd5e1;
  background: #f8fafc;
  transition: border-color .2s, background .2s;
}
.visitor-photo-upload:hover {
  border-color: #3b82f6;
  background: #eff6ff;
}
.visitor-photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: #94a3b8;
  gap: 8px;
}
.visitor-photo-placeholder span {
  font-size: 13px;
  font-weight: 600;
}
.visitor-photo-preview {
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 14px;
}
.visitor-fields-section {
  flex: 1;
  min-width: 0;
}
.visitor-fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.visitor-fields-grid .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.visitor-fields-grid .field label,
.visitor-fields-section > .field label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.visitor-fields-section > .field.wide {
  margin-top: 12px;
}
.visitor-submit-btn {
  margin-top: 16px;
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
}
.visitor-thumb {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  vertical-align: middle;
  margin-right: 8px;
}
.cedula-search-wrap {
  display: flex;
  gap: 6px;
  align-items: center;
}
.cedula-search-wrap input {
  flex: 1;
}
.cedula-search-wrap .button {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 12px;
}
.cedula-status {
  font-size: 11px;
  margin-top: 4px;
  display: block;
  min-height: 16px;
}
.cedula-ok { color: #059669; font-weight: 600; }
.cedula-warn { color: #d97706; }
.visitor-cedula-field {
  grid-column: 1 / -1;
}
.auth-actions {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  align-items: center;
}
.auth-actions .button.small {
  padding: 3px 8px;
  font-size: 11px;
  white-space: nowrap;
}
@media (max-width: 768px) {
  .visitor-form-layout {
    flex-direction: column;
    align-items: center;
  }
  .visitor-photo-upload {
    width: 140px;
    height: 140px;
  }
  .visitor-photo-preview {
    width: 140px;
    height: 140px;
  }
  .visitor-fields-grid {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 480px) {
  .visitor-fields-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Control Acceso: direction toggle ── */
.acceso-direction-section {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.acceso-dir-label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.acceso-dir-toggle {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.acceso-dir-toggle input[type="radio"] {
  display: none;
}
.acceso-dir-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  border-radius: 12px;
  border: 2px solid var(--line);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s;
  background: var(--surface);
  color: #64748b;
  min-width: 140px;
  justify-content: center;
}
.acceso-dir-opt:hover {
  border-color: #94a3b8;
}
.acceso-dir-toggle input[type="radio"]:checked + .acceso-dir-entrada {
  border-color: #22c55e;
  background: #f0fdf4;
  color: #16a34a;
}
.acceso-dir-toggle input[type="radio"]:checked + .acceso-dir-salida {
  border-color: #ef4444;
  background: #fef2f2;
  color: #dc2626;
}
.acceso-dir span.dir-entrada,
span.acceso-dir.dir-entrada {
  color: #16a34a;
  font-weight: 600;
}
.acceso-dir span.dir-salida,
span.acceso-dir.dir-salida {
  color: #dc2626;
  font-weight: 600;
}
/* Table direction badges */
.dir-entrada {
  color: #16a34a;
  font-weight: 600;
  font-size: 13px;
}
.dir-salida {
  color: #dc2626;
  font-weight: 600;
  font-size: 13px;
}
@media (max-width: 640px) {
  .acceso-direction-section {
    flex-direction: row;
    justify-content: center;
  }
  .acceso-dir-toggle {
    flex-direction: row;
  }
  .acceso-dir-opt {
    min-width: 120px;
    padding: 12px 16px;
  }
}

/* Table wrap overflow */
.table-wrap {
  overflow-x: auto;
}

/* Inline form in table */
td .inline-form {
  display: flex;
  gap: 4px;
  align-items: center;
}

@media (max-width: 920px) {
  .form-grid.porteria {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 640px) {
  .form-grid.porteria {
    grid-template-columns: 1fr;
  }
  .dir-msg-input {
    width: 100%;
  }
}

/* ── Mass Messaging ────────────────────────────────────────── */

.mass-panel .panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.mass-head-stats {
  display: flex;
  gap: 8px;
}
.mass-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.mass-compose-section {
  flex: 1;
  min-width: 0;
}
.mass-compose-card textarea {
  width: 100%;
  padding: 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 100px;
}
.mass-compose-card .field label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
  display: block;
}
.mass-attach-row {
  margin-top: 12px;
}
.mass-attach-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1.5px dashed #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
  color: #64748b;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.mass-attach-btn:hover {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #3b82f6;
}
.mass-recipients-section {
  width: 360px;
  flex-shrink: 0;
}
.mass-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.mass-toolbar label {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}
.mass-toolbar select {
  padding: 4px 8px;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  background: var(--surface);
}
.mass-select-all-lbl {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.mass-table-wrap {
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.mass-table {
  margin: 0;
  border: none;
}
.mass-table thead {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  z-index: 1;
}
.mass-table th,
.mass-table td {
  padding: 6px 10px;
  font-size: 12px;
}
.mass-table input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}
.mass-table input[type="checkbox"]:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
@media (max-width: 768px) {
  .mass-layout {
    flex-direction: column;
  }
  .mass-recipients-section {
    width: 100%;
  }
}

.pill-sm {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--text-secondary);
  font-weight: 600;
}

.pill-green {
  background: var(--green-bg);
  color: #059669;
}

.pill-red {
  background: var(--red-bg);
  color: #dc2626;
}

/* ── Resident Photo Avatars ────────────────────────────────── */

.resident-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--line);
}

.resident-avatar-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.file-input {
  padding: 8px;
  border: 1.5px dashed var(--line);
  border-radius: 8px;
  font-size: 0.82rem;
  background: var(--surface-2);
  cursor: pointer;
  width: 100%;
}

.file-input:hover {
  border-color: var(--primary);
  background: var(--primary-subtle);
}

/* ── Historial del Portero ────────────────────────────────── */

.history-timeline {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
  overflow: hidden;
}

.history-item:hover {
  background: var(--surface-2);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.history-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
}

.history-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border-radius: 8px;
  color: var(--primary);
}
.history-icon svg {
  width: 18px;
  height: 18px;
}

.history-action {
  flex: 1;
  min-width: 0;
}

.history-user {
  color: var(--text-secondary);
  font-size: 0.78rem;
  flex-shrink: 0;
}

.history-time {
  color: var(--text-secondary);
  font-size: 0.75rem;
  flex-shrink: 0;
  min-width: 110px;
  text-align: right;
}

.history-chevron {
  font-size: 0.65rem;
  color: var(--text-secondary);
  transition: transform .2s;
  flex-shrink: 0;
}

.history-item.expanded .history-chevron {
  transform: rotate(180deg);
}

.history-details {
  display: none;
  padding: 0 14px 12px 52px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.history-item.expanded .history-details {
  display: block;
}

.history-details p {
  margin: 6px 0;
}

.history-details strong {
  color: var(--text);
}

/* ── Parking Grid Visual ────────────────────────────────── */

.parking-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 1rem;
}

.parking-card {
  border-radius: 12px;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  position: relative;
}

.parking-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}

.parking-card.available {
  background: #e8f5e9;
  border: 2px solid #4caf50;
}
.parking-card.available.visitor {
  background: #fffde7;
  border: 2px solid #fbc02d;
}

.parking-card.occupied {
  background: #ffebee;
  border: 2px solid #f44336;
}
.parking-card.occupied.visitor {
  background: #fff8e1;
  border: 2px solid #f9a825;
}

.parking-card.maintenance {
  background: #fff3e0;
  border: 2px solid #ff9800;
}

.parking-card .space-number {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.parking-card .space-type-icon {
  font-size: 1.8rem;
  margin-bottom: 4px;
}

.parking-card .space-zone {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-bottom: 2px;
}
.parking-card .space-type-label {
  font-size: 0.68rem;
  color: #64748b;
  margin-bottom: 4px;
}

.parking-card .plate-tag {
  display: inline-block;
  background: #333;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 4px;
}

.parking-card .occupied-time {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.parking-card .space-status-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-top: 4px;
}

.parking-card.available .space-status-label { color: #2e7d32; }
.parking-card.occupied .space-status-label { color: #c62828; }
.parking-card.maintenance .space-status-label { color: #e65100; }

.parking-modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.parking-modal.active {
  display: flex;
}

.parking-modal-content {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
}

.parking-modal-content h3 {
  margin: 0 0 16px;
  font-size: 1.1rem;
}

.parking-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
  margin-bottom: 1rem;
}
/* Parking bulk creation */
.parking-bulk-hint {
  color: #64748b;
  font-size: 0.85rem;
  margin: 0 0 16px;
  line-height: 1.5;
}
.parking-bulk-hint b {
  color: #1e3a5f;
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: monospace;
}
.parking-single-add {
  margin-top: 4px;
}
.parking-single-add summary {
  cursor: pointer;
  color: #64748b;
  font-size: 0.85rem;
  font-weight: 500;
}
.parking-single-add summary:hover {
  color: #1e3a5f;
}
.parking-delete-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(220, 38, 38, 0.12);
  color: #dc2626;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  z-index: 2;
}
.parking-card:hover .parking-delete-btn {
  opacity: 1;
}
.parking-delete-btn:hover {
  background: #dc2626;
  color: #fff;
}
/* Masivos history */
.masivo-hist-item { padding: 12px 0; border-bottom: 1px solid #e2e8f0; }
.masivo-hist-item:last-child { border-bottom: none; }
.masivo-hist-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.masivo-hist-msg { background: #f7fafc; padding: 8px 12px; border-radius: 8px; margin: 6px 0; font-size: 0.88rem; color: #4a5568; border-left: 3px solid #667eea; }

/* ═══════════════════════════════════════════════════════════════
   Dashboard v2 - Banner, Charts, Stats Grid
   ═══════════════════════════════════════════════════════════════ */

.welcome-banner {
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 60%, #0ea5e9 100%);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 16px;
  color: #fff;
  animation: fadeInUp 0.4s ease-out;
}
.welcome-banner h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 4px;
}
.welcome-banner p {
  font-size: 0.85rem;
  opacity: 0.85;
  margin: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  animation: fadeInUp 0.4s ease-out both;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.stat-card:nth-child(2) { animation-delay: 0.05s; }
.stat-card:nth-child(3) { animation-delay: 0.1s; }
.stat-card:nth-child(4) { animation-delay: 0.15s; }
.stat-card:nth-child(5) { animation-delay: 0.2s; }
.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-info { display: flex; flex-direction: column; }
.stat-info strong {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.stat-info span {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Chart */
/* ── Chart ── */
.chart-summary {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 16px;
}
.chart-summary-total {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.chart-summary-label {
  font-size: 0.82rem;
  color: var(--muted);
}
.chart-wrap {
  position: relative;
  padding-left: 36px;
}
.chart-grid {
  position: absolute;
  inset: 0 0 24px 36px;
  pointer-events: none;
}
.chart-grid-line {
  position: absolute;
  left: 0; right: 0;
  border-bottom: 1px solid var(--line);
  height: 0;
}
.chart-grid-line span {
  position: absolute;
  right: calc(100% + 8px);
  top: -7px;
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.chart-container {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 200px;
  position: relative;
}
.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
  min-width: 0;
}
.chart-bar {
  width: 100%;
  max-width: 32px;
  background: linear-gradient(180deg, #3b82f6 0%, #93c5fd 100%);
  border-radius: 4px 4px 0 0;
  min-height: 3px;
  position: relative;
  transition: background 0.2s;
  animation: chartGrow 0.6s ease-out both;
  cursor: default;
}
.chart-bar:hover {
  background: linear-gradient(180deg, #2563eb 0%, #60a5fa 100%);
}
@keyframes chartGrow {
  from { transform: scaleY(0); transform-origin: bottom; }
  to   { transform: scaleY(1); transform-origin: bottom; }
}
.chart-val {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s;
}
.chart-col:hover .chart-val {
  opacity: 1;
}
.chart-label {
  font-size: 9px;
  color: var(--muted);
  margin-top: 6px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 48px;
  width: 100%;
}
.chart-col:nth-child(odd) .chart-label {
  /* Alternate visibility for dense labels */
}
.chart-empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem;
  font-size: 0.85rem;
  width: 100%;
}

/* Period selector */
.period-selector {
  display: flex;
  gap: 4px;
}
.period-btn {
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  text-decoration: none;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}
.period-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}
.period-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Dashboard grid (2 columns) */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
@media (max-width: 768px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Finance summary */
.finance-summary { display: flex; flex-direction: column; gap: 10px; }
.finance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-light);
}
.finance-row:last-child { border-bottom: none; }
.finance-row span { font-size: 0.85rem; color: var(--muted); }
.finance-row strong { font-size: 0.95rem; }
.finance-row.ok strong { color: #059669; }
.finance-row.warn strong { color: #d97706; }
.finance-row.danger strong { color: #dc2626; }
.text-danger { color: #dc2626 !important; }

/* Quick links grid */
.quick-links-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.quick-link-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 10px;
  border-radius: 10px;
  background: var(--surface-2);
  text-decoration: none;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  transition: all 0.2s ease;
  text-align: center;
}
.quick-link-card:hover {
  background: var(--primary-subtle);
  color: var(--primary);
  transform: translateY(-2px);
}
.quick-link-card svg { color: var(--primary); }

/* ═══════════════════════════════════════════════════════════════
   Resident Form Redesign
   ═══════════════════════════════════════════════════════════════ */

.resident-form-card .panel-head { user-select: none; }
.toggle-icon {
  transition: transform 0.3s ease;
  display: inline-flex;
  color: var(--muted);
}
.toggle-icon.rotated { transform: rotate(180deg); }

.resident-form-body {
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.3s ease;
  max-height: 600px;
  opacity: 1;
}
.resident-form-body.collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

.form-section {
  border: 1px solid var(--line-light);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  background: var(--surface-2);
}
.form-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  margin-bottom: 12px;
}
.form-section-content {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.form-row {
  display: flex;
  gap: 12px;
}
.form-row .field { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.form-row .field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.form-row .field input,
.form-row .field select,
.form-row .field textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.2s;
}
.form-row .field input:focus,
.form-row .field select:focus,
.form-row .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.form-fields-group { flex: 1; display: flex; flex-direction: column; gap: 10px; }

/* Photo upload area */
.photo-upload-area {
  width: 100px;
  height: 100px;
  border: 2px dashed var(--line);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  overflow: hidden;
}
.photo-upload-area:hover {
  border-color: var(--primary);
  background: var(--primary-subtle);
}
.photo-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.photo-preview span {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
}
.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

@media (max-width: 640px) {
  .form-section-content { flex-direction: column; }
  .form-row { flex-direction: column; }
  .photo-upload-area { width: 80px; height: 80px; }
  .quick-links-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ═══════════════════════════════════════════════════════════════
   Publications Cards
   ═══════════════════════════════════════════════════════════════ */

.pub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.pub-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  animation: pubCardIn 0.5s ease-out both;
}
@keyframes pubCardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.pub-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

/* Status border */
.pub-card.pub-status-active { border-left: 4px solid #10b981; }
.pub-card.pub-status-expired { border-left: 4px solid #ef4444; opacity: 0.8; }
.pub-card.pub-status-draft { border-left: 4px solid #f59e0b; }
.pub-card.pub-status-archived { border-left: 4px solid #94a3b8; }

/* Card image */
.pub-card-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface-2);
}
.pub-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.pub-card:hover .pub-card-image img {
  transform: scale(1.05);
}
.pub-card-pdf {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.pub-card-pdf span { font-size: 12px; color: var(--muted); font-weight: 600; }

/* Card body */
.pub-card-body { padding: 14px 16px 10px; }
.pub-card-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.pub-cat-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pub-cat-circular  { background: #dbeafe; color: #1d4ed8; }
.pub-cat-evento    { background: #ede9fe; color: #7c3aed; }
.pub-cat-aviso     { background: #ffedd5; color: #c2410c; }
.pub-cat-maint     { background: #d1fae5; color: #047857; }
.pub-cat-encuesta  { background: #cffafe; color: #0891b2; }
.pub-cat-general   { background: #f1f5f9; color: #475569; }

.pub-status-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}
.pub-status-badge.pub-status-active { background: #d1fae5; color: #047857; }
.pub-status-badge.pub-status-expired { background: #fee2e2; color: #dc2626; }
.pub-status-badge.pub-status-draft { background: #fef3c7; color: #92400e; }
.pub-status-badge.pub-status-archived { background: #e2e8f0; color: #475569; }

.pub-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
  line-height: 1.3;
}
.pub-card-caption {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 6px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pub-card-date {
  font-size: 11px;
  color: var(--placeholder);
}

/* Countdown */
.pub-countdown {
  font-size: 11px;
  color: var(--muted);
  margin: 4px 0;
  font-weight: 500;
}
.pub-countdown.urgent {
  color: #dc2626;
  font-weight: 700;
  animation: pulse 2s ease infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.pub-countdown.expired { color: #dc2626; }

/* Actions */
.pub-actions {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  border-top: 1px solid var(--line-light);
  flex-wrap: wrap;
}
.pub-action-btn {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  transition: all 0.2s;
}
.pub-action-btn:hover { background: var(--surface-2); }
.pub-action-btn.link { color: var(--primary); border-color: var(--primary-light); }
.pub-action-btn.link:hover { background: var(--primary-subtle); }
.pub-action-btn.toggle { color: #d97706; border-color: #fde68a; }
.pub-action-btn.edit { color: var(--muted); }
.pub-action-btn.reactivate { color: #059669; border-color: #a7f3d0; }
.pub-action-btn.reactivate:hover { background: #ecfdf5; }
.pub-action-btn.delete { color: #dc2626; border-color: #fecaca; }
.pub-action-btn.delete:hover { background: #fef2f2; }

/* Edit form inside card */
.pub-edit-form {
  padding: 10px 16px;
  border-top: 1px solid var(--line-light);
  background: var(--surface-2);
}
.pub-edit-form form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.pub-edit-form input, .pub-edit-form select {
  padding: 5px 8px;
  border: 1.5px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  flex: 1;
  min-width: 80px;
}
.pub-edit-form input:focus, .pub-edit-form select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Filters */
.pub-filters {
  display: flex;
  gap: 4px;
}
.pub-filter-btn {
  padding: 5px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface);
  color: var(--muted);
  transition: all 0.2s;
}
.pub-filter-btn:hover { background: var(--surface-2); color: var(--text); }
.pub-filter-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

@media (max-width: 640px) {
  .pub-grid { grid-template-columns: 1fr; }
  .pub-filters { flex-wrap: wrap; }
}

/* ═══════════════════════════════════════════════════════════════
   Cartera Styles
   ═══════════════════════════════════════════════════════════════ */

.cartera-config-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--text);
}
.cartera-config-bar strong { color: var(--primary); }

.cartera-list { display: flex; flex-direction: column; }
.cartera-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line-light);
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s;
}
.cartera-item:hover { background: rgba(37,99,235,0.02); }
.cartera-item:last-child { border-bottom: none; }
.cartera-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cartera-item-left strong { font-size: 0.9rem; display: block; }
.cartera-item-loc {
  font-size: 0.75rem;
  color: var(--muted);
  display: block;
}
.cartera-item-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cartera-saldo {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

/* Financial status pills */
.estado-al-dia { color: #059669; border-color: #a7f3d0; background: #ecfdf5; }
.estado-en-mora { color: #d97706; border-color: #fde68a; background: #fffbeb; }
.estado-critico { color: #dc2626; border-color: #fecaca; background: #fef2f2; }

.pill.danger { color: #dc2626; border-color: #fecaca; background: #fef2f2; }

.resident-profile h3 { margin: 0 0 4px; font-size: 1.1rem; }
.resident-profile p { margin: 0; font-size: 0.85rem; color: var(--muted); }

/* Notice variants */
.notice.warn {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

/* ═══════════════════════════════════════════════════════════════
   Multas Styles
   ═══════════════════════════════════════════════════════════════ */

.multa-list { display: flex; flex-direction: column; gap: 12px; }
.multa-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  animation: fadeInUp 0.4s ease-out both;
}
.multa-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-light);
  background: var(--surface-2);
}
.multa-card-header strong { font-size: 0.9rem; }
.multa-card-body { padding: 14px 16px; }
.multa-motivo { font-weight: 600; margin: 0 0 4px; font-size: 0.9rem; }
.multa-desc { font-size: 0.82rem; color: var(--muted); margin: 0 0 8px; }
.multa-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--muted);
}
.multa-meta strong { color: var(--text); }
.multa-actions {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  border-top: 1px solid var(--line-light);
  flex-wrap: wrap;
}

/* Form field standalone (outside form-row) */
.form-section > .field,
.panel-body > .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-section > .field label,
.panel-body > .field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.form-section > .field input,
.form-section > .field select,
.form-section > .field textarea,
.panel-body > .field input,
.panel-body > .field select,
.panel-body > .field textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.2s;
}
.form-section > .field input:focus,
.form-section > .field select:focus,
.form-section > .field textarea:focus,
.panel-body > .field input:focus,
.panel-body > .field select:focus,
.panel-body > .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* ── Facturas PH (community view) ──────────────────────────── */
.facturas-ph-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.factura-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  animation: pubCardIn 0.4s ease-out both;
}
.factura-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.10);
}
.factura-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #f0f0f0;
  background: #fafbfc;
}
.factura-periodo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.factura-periodo strong {
  font-size: 1.1rem;
}
.factura-plan-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  background: var(--primary-lighter, #e8f0fe);
  color: var(--primary, #1a73e8);
}
.factura-card-body {
  padding: 20px;
}
.factura-montos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.factura-monto-item {
  text-align: center;
}
.factura-monto-label {
  display: block;
  font-size: 0.75rem;
  color: #888;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.factura-monto-value {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
}
.factura-vence {
  text-align: center;
  padding-top: 10px;
  border-top: 1px solid #f0f0f0;
  color: #666;
}
.factura-pago-info {
  text-align: center;
  margin-top: 8px;
  color: #2e7d32;
}

/* ── WebRTC Citofonia Call Modals ── */
.call-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.call-modal-content {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #fff;
  border-radius: 24px;
  padding: 2.5rem 2rem;
  text-align: center;
  width: 320px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: callModalIn 0.3s ease;
}
@keyframes callModalIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.call-avatar-wrap {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea, #764ba2);
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
}
.call-avatar-wrap.incoming-pulse {
  animation: callPulse 1.5s ease-in-out infinite;
}
@keyframes callPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
  50% { box-shadow: 0 0 0 20px rgba(34, 197, 94, 0); }
}
.call-modal .call-name {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}
.call-modal .call-status {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 1.5rem;
}
.call-modal .call-timer {
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-bottom: 1.5rem;
  color: #22c55e;
}
.call-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}
.call-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.call-btn:hover {
  transform: scale(1.1);
}
.call-btn:active {
  transform: scale(0.95);
}
.call-btn-end {
  background: #ef4444;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}
.call-btn-end:hover {
  background: #dc2626;
}
.call-btn-answer {
  background: #22c55e;
  box-shadow: 0 4px 15px rgba(34, 197, 94, 0.4);
}
.call-btn-answer:hover {
  background: #16a34a;
}

/* ═══════════════════════════════════════════════════════════════
   RESIDENT PANEL
   ═══════════════════════════════════════════════════════════════ */

/* Dashboard quick links */
.dash-pub-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: var(--text); font-size: 0.88rem;
  transition: background 0.15s;
}
.dash-pub-item:hover { background: var(--bg); }
.dash-pub-item:last-child { border-bottom: none; }

/* Paz y Salvo Certificate — Professional Design */
.cert-container { max-width: 760px; margin: 0 auto; }
.cert-document {
  position: relative; overflow: hidden;
  background: #fff; border: 1px solid #d1d5db;
  border-radius: 12px; padding: 48px 44px;
  box-shadow: 0 2px 16px rgba(0,0,0,.06);
}
.cert-watermark {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%) rotate(-30deg);
  font-size: 5rem; font-weight: 900; color: rgba(22,163,106,.04);
  letter-spacing: 12px; white-space: nowrap; pointer-events: none; user-select: none;
}
.cert-header { display: flex; align-items: center; gap: 18px; margin-bottom: 4px; }
.cert-logo { width: 64px; height: 64px; border-radius: 12px; object-fit: contain; border: 1px solid #e5e7eb; }
.cert-logo-placeholder {
  width: 64px; height: 64px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: #eff6ff; border: 1px solid #bfdbfe;
}
.cert-header-text { flex: 1; }
.cert-community-name { font-size: 1.25rem; font-weight: 800; color: #1e293b; margin: 0; }
.cert-meta { font-size: 0.8rem; color: #64748b; margin: 2px 0 0; }
.cert-divider { height: 2px; background: linear-gradient(90deg, #2563eb 0%, #16a34a 100%); margin: 20px 0 24px; border-radius: 2px; }
.cert-title-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 24px; }
.cert-title { font-size: 1.3rem; font-weight: 800; color: #1e293b; margin: 0; letter-spacing: 0.5px; }
.cert-body-text { font-size: 0.92rem; line-height: 1.8; color: #334155; }
.cert-body-text p { margin: 10px 0; }
.cert-resident-card {
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 16px 20px; margin: 18px 0;
}
.cert-resident-row {
  display: flex; justify-content: space-between; padding: 7px 0;
  border-bottom: 1px solid #e2e8f0; font-size: 0.9rem;
}
.cert-resident-row:last-child { border-bottom: none; }
.cert-label { color: #64748b; font-weight: 600; }
.cert-value { color: #1e293b; font-weight: 700; }
.cert-footer {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-top: 32px; padding-top: 20px; border-top: 1px dashed #cbd5e1;
}
.cert-footer-left { flex: 1; }
.cert-date-line { font-size: 0.88rem; color: #334155; }
.cert-code { font-size: 0.78rem; color: #64748b; margin-top: 6px; font-family: monospace; letter-spacing: 0.5px; }
.cert-verify-note { font-size: 0.72rem; color: #94a3b8; margin-top: 4px; }
.cert-qr { flex-shrink: 0; width: 100px; height: 100px; }
.cert-qr svg { width: 100px !important; height: 100px !important; }
.cert-seal {
  margin-top: 20px; text-align: center;
  font-size: 0.72rem; color: #94a3b8;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.paz-y-salvo-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 24px; border-radius: 50px;
  font-weight: 700; font-size: 1rem;
}
.paz-y-salvo-badge.ok { background: #dcfce7; color: #166534; }
.paz-y-salvo-badge.danger { background: #fef2f2; color: #991b1b; }

/* Profile photo */
.perfil-photo { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; }
.perfil-photo-placeholder {
  width: 80px; height: 80px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 700; color: #fff;
}

/* Certificate responsive */
@media (max-width: 640px) {
  .cert-document { padding: 28px 20px; }
  .cert-watermark { font-size: 3rem; }
  .cert-header { flex-direction: column; text-align: center; gap: 10px; }
  .cert-title { font-size: 1.05rem; }
  .cert-title-row { flex-direction: column; gap: 6px; }
  .cert-footer { flex-direction: column; align-items: center; text-align: center; gap: 16px; }
  .cert-footer-left { text-align: center; }
  .cert-resident-row { flex-direction: column; gap: 2px; text-align: left; }
}

/* Print styles */
@media print {
  .sidebar, .topbar, .mobile-menu-btn, .sidebar-overlay,
  .no-print, .ph-loader, .nav, .sidebar-footer { display: none !important; }
  .shell { display: block !important; }
  .main { margin: 0 !important; padding: 0 !important; }
  #page-content { padding: 0 !important; }
  .cert-container { max-width: 100%; }
  .cert-document { border: 1px solid #999; box-shadow: none; border-radius: 0; }
  .cert-watermark { color: rgba(22,163,106,.06) !important; }
  body { background: #fff !important; color: #000 !important; }
}

/* Icon buttons (table actions) */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); cursor: pointer; transition: all 0.15s;
  padding: 0;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--bg); color: var(--text); border-color: var(--text-secondary); }
.icon-btn-danger:hover { background: #fef2f2; color: #dc2626; border-color: #fca5a5; }

/* Presence indicator dot */
.presence-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.presence-dot.online { background: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,.25); }
.presence-dot.offline { background: #94a3b8; }

/* ─── Directorio message modal ─── */
.dir-modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center; justify-content: center;
  animation: dirModalFadeIn .2s ease;
}
.dir-modal-overlay.active { display: flex; }

@keyframes dirModalFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes dirModalSlideUp {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.dir-modal-card {
  background: #fff;
  border-radius: 16px;
  width: 440px;
  max-width: 94vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2), 0 0 0 1px rgba(0,0,0,.05);
  animation: dirModalSlideUp .25s ease;
}

.dir-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #f1f5f9;
  position: relative;
}

.dir-modal-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #25d366, #128c7e);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.dir-modal-icon svg { width: 22px; height: 22px; }

.dir-modal-title {
  font-size: .95rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
  line-height: 1.3;
}

.dir-modal-subtitle {
  font-size: .78rem;
  color: #94a3b8;
  margin: 2px 0 0;
  line-height: 1.3;
}

.dir-modal-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: #f1f5f9;
  color: #64748b;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
  line-height: 1;
}
.dir-modal-close:hover { background: #e2e8f0; color: #1e293b; }

.dir-modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.dir-modal-body .field { margin: 0; }
.dir-modal-body .field label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 6px;
}

.dir-modal-textarea {
  width: 100%;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: .88rem;
  color: #1e293b;
  resize: vertical;
  min-height: 90px;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
  box-sizing: border-box;
}
.dir-modal-textarea:focus {
  outline: none;
  border-color: #25d366;
  box-shadow: 0 0 0 3px rgba(37,211,102,.12);
}
.dir-modal-textarea::placeholder { color: #cbd5e1; }

.dir-modal-attach {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dir-modal-attach-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1.5px dashed #cbd5e1;
  background: #f8fafc;
  color: #64748b;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.dir-modal-attach-btn:hover {
  border-color: #25d366;
  color: #25d366;
  background: #f0fdf4;
}
.dir-modal-attach-btn svg { flex-shrink: 0; }

.dir-modal-preview {
  display: none;
  width: 48px; height: 48px;
  border-radius: 8px;
  object-fit: cover;
  border: 2px solid #e2e8f0;
}
.dir-modal-preview[src] { display: block; }

.dir-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 20px;
  border-top: 1px solid #f1f5f9;
}

.dir-modal-cancel {
  padding: 9px 20px;
  border-radius: 9px;
  border: 1.5px solid #e2e8f0;
  background: #fff;
  color: #64748b;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.dir-modal-cancel:hover { background: #f8fafc; border-color: #cbd5e1; color: #475569; }

.dir-modal-send {
  padding: 9px 24px;
  border-radius: 9px;
  border: none;
  background: linear-gradient(135deg, #25d366, #128c7e);
  color: #fff;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
}
.dir-modal-send:hover { filter: brightness(1.08); box-shadow: 0 4px 12px rgba(37,211,102,.3); }

/* Modal responsive */
@media (max-width: 480px) {
  .dir-modal-card { width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; }
  .dir-modal-overlay.active { align-items: flex-end; }
  .dir-modal-header { padding: 16px 18px 14px; }
  .dir-modal-body { padding: 16px 18px; }
  .dir-modal-footer { padding: 14px 18px 18px; }
}

/* ─── Communication hub tabs (Chat PH / Historial) ─── */
.comm-hub-tabs {
  display: flex;
  gap: 4px;
  padding: 6px;
  background: #f1f5f9;
  border-radius: 12px;
  margin-bottom: 16px;
}
.comm-hub-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  color: #64748b;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}
.comm-hub-tab svg { flex-shrink: 0; opacity: .7; }
.comm-hub-tab:hover { background: #e2e8f0; color: #334155; }
.comm-hub-tab.active {
  background: #fff;
  color: #1e293b;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.comm-hub-tab.active svg { opacity: 1; color: #25d366; }

@media (max-width: 600px) {
  .comm-hub-tabs { gap: 2px; padding: 4px; }
  .comm-hub-tab { padding: 7px 12px; font-size: .78rem; }
  .comm-hub-tab span { display: none; }
  .comm-hub-tab svg { width: 18px; height: 18px; }
}

/* ─── Porteria dashboard menu ─── */
.porteria-menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.porteria-menu-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 12px;
  border: 1.5px solid #e2e8f0;
  background: #fff;
  text-decoration: none;
  color: inherit;
  transition: all .15s;
}
.porteria-menu-card:hover {
  border-color: #25d366;
  background: #f0fdf4;
  box-shadow: 0 2px 8px rgba(37,211,102,.1);
  transform: translateY(-1px);
}
.porteria-menu-icon {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  color: #128c7e;
  flex-shrink: 0;
}
.porteria-menu-info { flex: 1; min-width: 0; }
.porteria-menu-label {
  display: block;
  font-size: .9rem;
  font-weight: 700;
  color: #1e293b;
}
.porteria-menu-desc {
  display: block;
  font-size: .78rem;
  color: #94a3b8;
  margin-top: 2px;
}
.porteria-menu-arrow {
  color: #cbd5e1;
  flex-shrink: 0;
  transition: transform .15s;
}
.porteria-menu-card:hover .porteria-menu-arrow {
  color: #25d366;
  transform: translateX(3px);
}

/* Back to porteria link */
.back-to-porteria {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  margin-bottom: 12px;
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  color: #64748b;
  text-decoration: none;
  transition: all .15s;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}
.back-to-porteria:hover {
  color: #128c7e;
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.back-to-porteria svg { flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════
   PROFESSIONAL PROFILE PAGE
   ═══════════════════════════════════════════════════════════════ */

.pro-profile-wrap {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header card */
.pro-profile-header {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}
.pro-header-bg {
  height: 100px;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 50%, #38bdf8 100%);
}
.pro-header-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 24px 24px;
  margin-top: -48px;
  text-align: center;
}
.pro-avatar-wrap {
  position: relative;
  margin-bottom: 12px;
}
.pro-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #1e3a5f);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 4px solid var(--surface);
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  overflow: hidden;
}
.pro-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pro-avatar-initials {
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 1px;
}
.pro-avatar-edit {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--muted);
}
.pro-avatar-edit:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.pro-header-name {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px;
}
.pro-header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.pro-role-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pro-unit-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}
.pro-header-email {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 4px;
}

/* Section cards */
.pro-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
}
.pro-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.pro-section-header svg {
  color: var(--primary);
  flex-shrink: 0;
}
.pro-section-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

/* Form grid */
.pro-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.pro-form-single {
  grid-template-columns: 1fr;
}
.pro-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.pro-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.pro-input {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.pro-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.pro-input-disabled {
  background: var(--bg);
  color: var(--muted);
  cursor: not-allowed;
}

/* Password eye toggle */
.pro-input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pro-input-icon-wrap .pro-input {
  padding-right: 44px;
}
.pro-eye-toggle {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.pro-eye-toggle:hover {
  color: var(--primary);
  background: rgba(37,99,235,0.06);
}
.pro-eye-toggle .hidden { display: none; }

/* Form buttons */
.pro-form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.pro-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}
.pro-btn-primary {
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}
.pro-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37,99,235,0.35);
}
.pro-btn-secondary {
  background: linear-gradient(135deg, #475569, #334155);
  color: #fff;
  box-shadow: 0 2px 8px rgba(71,85,105,0.25);
}
.pro-btn-secondary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(71,85,105,0.35);
}

/* Profile responsive */
@media (max-width: 640px) {
  .pro-profile-wrap { gap: 14px; }
  .pro-header-bg { height: 80px; }
  .pro-header-content { margin-top: -40px; padding: 0 16px 20px; }
  .pro-avatar { width: 80px; height: 80px; }
  .pro-avatar-initials { font-size: 1.6rem; }
  .pro-section { padding: 18px 16px; }
  .pro-form-grid { grid-template-columns: 1fr; }
  .pro-form-actions { justify-content: stretch; }
  .pro-btn { width: 100%; justify-content: center; }
}

/* ═══════════════════════════════════════════════════════════════
   RESIDENT DASHBOARD REDESIGN
   ═══════════════════════════════════════════════════════════════ */

/* Porteria banner */
.rd-porteria-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 1px solid #bbf7d0;
  border-radius: 14px;
  padding: 16px 22px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.rd-porteria-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.rd-porteria-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(34,197,94,0.3);
}
.rd-porteria-info strong {
  display: block;
  font-size: 0.95rem;
  color: var(--text);
}
.rd-porteria-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: #64748b;
  margin-top: 2px;
}
.rd-call-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 50px;
  background: linear-gradient(135deg, #25d366, #128c7e);
  color: #fff;
  border: none;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(37,211,102,0.3);
}
.rd-call-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37,211,102,0.4);
}

/* Summary stat cards */
.rd-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.rd-stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.2s, box-shadow 0.2s;
  animation: fadeInUp 0.4s ease-out both;
}
.rd-stat:nth-child(2) { animation-delay: 0.06s; }
.rd-stat:nth-child(3) { animation-delay: 0.12s; }
.rd-stat:nth-child(4) { animation-delay: 0.18s; }
.rd-stat:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}
.rd-stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.rd-stat-icon.blue { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: #2563eb; }
.rd-stat-icon.red { background: linear-gradient(135deg, #fee2e2, #fecaca); color: #dc2626; }
.rd-stat-icon.amber { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #d97706; }
.rd-stat-icon.green { background: linear-gradient(135deg, #dcfce7, #bbf7d0); color: #16a34a; }
.rd-stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.rd-stat-label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}
.rd-stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 0.82rem;
  font-weight: 700;
}
.rd-stat-badge.ok {
  background: #dcfce7;
  color: #166534;
}
.rd-stat-badge.danger {
  background: #fee2e2;
  color: #991b1b;
}

/* Bottom grid: Publicaciones + Acceso Rapido */
.rd-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.rd-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.rd-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.rd-card-head svg { color: var(--primary); flex-shrink: 0; }
.rd-card-head h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.rd-pub-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--text);
  font-size: 0.88rem;
  transition: background 0.15s;
}
.rd-pub-item:last-child { border-bottom: none; }
.rd-pub-item:hover { background: #f8fafc; }
.rd-pub-cat {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  background: #e0e7ff;
  color: #3730a3;
  text-transform: capitalize;
  flex-shrink: 0;
}
.rd-pub-empty {
  padding: 24px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Quick access links */
.rd-quick-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px;
}
.rd-quick-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  border-radius: 12px;
  background: var(--bg);
  text-decoration: none;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  transition: all 0.2s;
  border: 1px solid transparent;
}
.rd-quick-link:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37,99,235,0.08);
}
.rd-quick-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  color: #2563eb;
  transition: all 0.2s;
}
.rd-quick-link:hover .rd-quick-icon {
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff;
}

/* Responsive */
@media (max-width: 768px) {
  .rd-stats { grid-template-columns: repeat(2, 1fr); }
  .rd-bottom-grid { grid-template-columns: 1fr; }
  .rd-quick-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .rd-stats { grid-template-columns: 1fr; }
  .rd-porteria-banner { flex-direction: column; align-items: stretch; text-align: center; }
  .rd-porteria-left { justify-content: center; }
  .rd-call-btn { width: 100%; justify-content: center; }
}

/* ═══════════════════════════════════════════════════════════════
   CARTERA (MI CARTERA) REDESIGN
   ═══════════════════════════════════════════════════════════════ */

.crt-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.crt-stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: transform 0.2s, box-shadow 0.2s;
  animation: fadeInUp 0.4s ease-out both;
}
.crt-stat:nth-child(2) { animation-delay: 0.06s; }
.crt-stat:nth-child(3) { animation-delay: 0.12s; }
.crt-stat:nth-child(4) { animation-delay: 0.18s; }
.crt-stat:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}
.crt-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.crt-stat-icon.blue { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: #2563eb; }
.crt-stat-icon.red { background: linear-gradient(135deg, #fee2e2, #fecaca); color: #dc2626; }
.crt-stat-icon.purple { background: linear-gradient(135deg, #ede9fe, #ddd6fe); color: #7c3aed; }
.crt-stat-icon.green { background: linear-gradient(135deg, #dcfce7, #bbf7d0); color: #16a34a; }
.crt-stat-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.crt-stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.1;
}
.crt-stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}
.crt-stat-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 14px;
  border-radius: 50px;
  font-size: 0.82rem;
  font-weight: 700;
  width: fit-content;
}
.crt-stat-badge.ok { background: #dcfce7; color: #166534; }
.crt-stat-badge.danger { background: #fee2e2; color: #991b1b; }

/* Sections */
.crt-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 16px;
}
.crt-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.crt-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.crt-section-title svg { color: var(--primary); flex-shrink: 0; }
.crt-section-title h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.crt-count {
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--bg);
  padding: 3px 10px;
  border-radius: 50px;
  font-weight: 500;
}

/* Table */
.crt-table-wrap { overflow-x: auto; }
.crt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.crt-table thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.crt-table thead th.r { text-align: right; }
.crt-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
.crt-table tbody td[style*="text-align:right"] { font-variant-numeric: tabular-nums; }
.crt-table tbody tr:last-child td { border-bottom: none; }
.crt-table tbody tr:hover { background: #f8fafc; }
.crt-table .empty {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
  .crt-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .crt-stats { grid-template-columns: 1fr; }
  .crt-section-head { flex-wrap: wrap; gap: 8px; }
}

/* ═══════════════════════════════════════════════════════════════
   BotPH Floating Assistant Widget
   ═══════════════════════════════════════════════════════════════ */
.botph-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  font-family: 'Inter', sans-serif;
}
.botph-fab {
  width: auto;
  height: auto;
  border-radius: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.2s ease, filter 0.2s ease;
  position: relative;
  overflow: visible;
}
.botph-fab:hover {
  transform: scale(1.1);
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.2));
}
.botph-fab:active { transform: scale(0.95); }
.botph-fab-img {
  width: 160px;
  height: 160px;
  object-fit: contain;
  border-radius: 0;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.15));
  animation: botph-float 3s ease-in-out infinite;
}
.botph-fab-pulse {
  display: none;
}
@keyframes botph-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes botph-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0; }
}
.botph-widget.open .botph-fab { display: none; }

/* Drawer */
.botph-drawer {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 100px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: botph-drawer-in 0.25s ease-out;
}
@keyframes botph-drawer-in {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.botph-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
  flex-shrink: 0;
}
.botph-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.botph-header-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: contain;
  background: #fff;
  padding: 4px;
}
.botph-header-name {
  font-size: 0.95rem;
  font-weight: 700;
}
.botph-header-status {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  gap: 5px;
}
.botph-online-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34,197,94,0.6);
  flex-shrink: 0;
}
.botph-header-actions { display: flex; gap: 4px; }
.botph-header-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
}
.botph-header-btn:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

/* Messages */
.botph-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f1f5f9;
  scroll-behavior: smooth;
}

/* Welcome */
.botph-welcome {
  text-align: center;
  padding: 28px 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.botph-welcome-img {
  width: 140px;
  height: 140px;
  object-fit: contain;
  margin-bottom: 14px;
  filter: drop-shadow(0 2px 8px rgba(37,99,235,0.25));
}
.botph-welcome-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 6px;
}
.botph-welcome-text {
  font-size: 0.82rem;
  color: #64748b;
  margin: 0 0 18px;
  line-height: 1.5;
}
.botph-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.botph-suggestion {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.botph-suggestion:hover {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
  transform: translateY(-1px);
}

/* Message bubbles */
.botph-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: botph-msg-in 0.2s ease-out;
}
@keyframes botph-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.botph-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.botph-msg.bot { align-self: flex-start; }
.botph-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: contain;
  flex-shrink: 0;
  margin-top: 2px;
}
.botph-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.84rem;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.botph-msg.bot .botph-msg-bubble {
  background: #ffffff;
  color: #0f172a;
  border-top-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.botph-msg.user .botph-msg-bubble {
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #ffffff;
  border-top-right-radius: 4px;
}
.botph-msg-time {
  font-size: 0.65rem;
  color: #94a3b8;
  margin-top: 4px;
  display: block;
}
.botph-msg.user .botph-msg-time {
  text-align: right;
  color: rgba(255,255,255,0.55);
}
.botph-msg-content {
  flex: 1;
  min-width: 0;
}
/* Bot image message */
.botph-msg-image {
  margin-top: 8px;
  position: relative;
  max-width: 100%;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}
.botph-msg-image img {
  display: block;
  width: 100%;
  max-width: 400px;
  height: auto;
  border-radius: 10px;
}
.botph-img-download {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  padding: 5px 12px;
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
  border-radius: 16px;
  font-size: 0.72rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s;
}
.botph-img-download:hover {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.botph-export-bar {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.botph-export-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #fff;
  color: #475569;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.botph-export-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #1e293b;
}
.botph-export-btn:active {
  transform: scale(0.95);
}
.botph-export-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}
.botph-export-btn svg {
  flex-shrink: 0;
}
.botph-export-spin {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #cbd5e1;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: botph-spin 0.6s linear infinite;
}
@keyframes botph-spin {
  to { transform: rotate(360deg); }
}

/* Document history panel */
.botph-docs-panel {
  position: absolute;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  z-index: 10;
  flex-direction: column;
  animation: fadeInUp 0.2s ease-out;
}
.botph-docs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}
.botph-docs-header h3 {
  margin: 0;
  font-size: 0.9rem;
  color: #1e3a5f;
  font-weight: 600;
}
.botph-docs-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.botph-docs-empty {
  text-align: center;
  color: #94a3b8;
  font-size: 0.85rem;
  padding: 32px 16px;
}
.botph-doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
  border: 1px solid transparent;
}
.botph-doc-item:hover {
  background: #f1f5f9;
  border-color: #e2e8f0;
}
.botph-doc-item svg {
  flex-shrink: 0;
  color: #94a3b8;
}
.botph-doc-fmt {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
}
.botph-doc-fmt-pdf { background: #dc2626; }
.botph-doc-fmt-docx { background: #2563eb; }
.botph-doc-fmt-xlsx { background: #16a34a; }
.botph-doc-info {
  flex: 1;
  min-width: 0;
}
.botph-doc-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: #1e293b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.botph-doc-meta {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 2px;
}

/* Typing indicator */
.botph-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
}
.botph-typing-dots {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: #ffffff;
  border-radius: 14px;
  border-top-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.botph-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: botph-bounce 1.4s infinite ease-in-out;
}
.botph-typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.botph-typing-dots span:nth-child(3) { animation-delay: 0.32s; }
@keyframes botph-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Error */
.botph-error {
  text-align: center;
  padding: 8px 14px;
  background: #fef2f2;
  color: #dc2626;
  border-radius: 10px;
  font-size: 0.78rem;
  border: 1px solid #fecaca;
}

/* Compose */
.botph-compose {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
}
.botph-input {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 0.84rem;
  font-family: inherit;
  resize: none;
  max-height: 100px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  color: #0f172a;
}
.botph-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.botph-input::placeholder { color: #94a3b8; }
.botph-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  box-shadow: 0 2px 6px rgba(37,99,235,0.3);
}
.botph-send-btn:disabled {
  background: #e2e8f0;
  color: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
}
.botph-send-btn:not(:disabled):hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(37,99,235,0.4);
}
/* Compose icon buttons (mic, attach) */
.botph-compose-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  padding: 0;
}
.botph-compose-icon:hover {
  background: #f1f5f9;
  color: #2563eb;
}
.botph-compose-icon:disabled {
  opacity: 0.4;
  cursor: wait;
}
.botph-compose-icon.recording {
  background: #fef2f2;
  color: #dc2626;
  animation: botph-mic-pulse 1s ease-in-out infinite;
}
@keyframes botph-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.3); }
  50% { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}
/* Suggest popup */
.botph-compose { position: relative; }
.botph-suggest-popup {
  position: absolute;
  bottom: 100%;
  left: 8px;
  right: 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.13);
  padding: 10px;
  margin-bottom: 6px;
  z-index: 20;
  animation: botph-popup-in 0.18s ease-out;
  max-height: 320px;
  overflow-y: auto;
}
@keyframes botph-popup-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.botph-suggest-popup-title {
  font-size: 0.68rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  padding: 0 4px;
}
/* Category block */
.botph-scat { margin-bottom: 4px; }
.botph-scat:last-child { margin-bottom: 0; }
.botph-scat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
  transition: all 0.15s;
}
.botph-scat-btn:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}
.botph-scat-btn svg:first-child { color: #2563eb; flex-shrink: 0; }
.botph-scat-arrow {
  margin-left: auto;
  color: #94a3b8;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.botph-scat.open .botph-scat-arrow { transform: rotate(180deg); }
.botph-scat.open .botph-scat-btn {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e40af;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}
/* Sub-options */
.botph-scat-opts {
  display: none;
  flex-direction: column;
  gap: 1px;
  background: #e2e8f0;
  border: 1px solid #e2e8f0;
  border-top: none;
  border-radius: 0 0 10px 10px;
  overflow: hidden;
}
.botph-scat.open .botph-scat-opts { display: flex; }
.botph-sopt {
  background: #fff;
  border: none;
  padding: 9px 14px 9px 36px;
  font-size: 0.78rem;
  color: #334155;
  cursor: pointer;
  text-align: left;
  transition: all 0.12s;
}
.botph-sopt:hover {
  background: #dbeafe;
  color: #1e40af;
}
#botph-suggest-btn.active {
  background: #dbeafe;
  color: #2563eb;
}
/* Welcome categories */
.botph-welcome-cats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.botph-wcat {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f0f7ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #1e40af;
  cursor: pointer;
  transition: all 0.15s;
}
.botph-wcat:hover {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
  transform: translateY(-1px);
}
.botph-wcat svg { flex-shrink: 0; }
.botph-welcome-hint {
  font-size: 0.72rem;
  color: #94a3b8;
  margin: 0;
  font-style: italic;
}
/* Attachment preview */
.botph-attach-preview {
  padding: 6px 14px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}
.botph-attach-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: #475569;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 10px;
}
.botph-attach-info span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.botph-attach-info svg {
  color: #2563eb;
  flex-shrink: 0;
}
.botph-attach-remove {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.botph-attach-remove:hover {
  color: #dc2626;
}

/* Responsive */
@media (max-width: 480px) {
  .botph-widget { bottom: 16px; right: 16px; }
  .botph-fab-img { width: 120px; height: 120px; }
  .botph-drawer {
    width: calc(100vw - 32px);
    height: calc(100vh - 120px);
    bottom: 64px;
    right: -8px;
  }
}
@media print { .botph-widget { display: none !important; } }

/* ═══════════════════════════════════════════════════════════════
   COMMUNITY CONFIG PAGE
   ═══════════════════════════════════════════════════════════════ */
.cfg-wrap {
  max-width: 780px;
  margin: 0 auto;
}
.cfg-notice {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 20px;
}
.cfg-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.cfg-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 24px;
}
.cfg-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.cfg-section-header svg {
  color: #2563eb;
  flex-shrink: 0;
}
.cfg-section-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.cfg-hint {
  font-size: 0.8rem;
  color: #64748b;
  margin: 0 0 16px;
}
.cfg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.cfg-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cfg-field-full {
  grid-column: 1 / -1;
}
.cfg-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
}
.cfg-field input {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.88rem;
  background: #f8fafc;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cfg-field input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
  background: #fff;
}
/* Logo area */
.cfg-logo-area {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.cfg-logo-preview {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: #f8fafc;
  padding: 4px;
}
.cfg-signature-preview {
  max-width: 180px;
  max-height: 80px;
  object-fit: contain;
  border: 2px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}
.cfg-logo-placeholder {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  border: 2px dashed #cbd5e1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: #f8fafc;
}
.cfg-logo-placeholder span {
  font-size: 0.65rem;
  color: #94a3b8;
}
.cfg-logo-upload {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid #2563eb;
  border-radius: 10px;
  color: #2563eb;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.cfg-logo-upload:hover {
  background: #eff6ff;
}
.cfg-logo-fname {
  font-size: 0.78rem;
  color: #64748b;
}
/* Preview */
.cfg-preview-doc {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px 20px;
  margin-top: 12px;
}
.cfg-preview-header {
  display: flex;
  align-items: center;
  gap: 14px;
}
.cfg-preview-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
}
.cfg-preview-header strong {
  font-size: 0.95rem;
  color: #0f172a;
}
.cfg-preview-header small {
  font-size: 0.75rem;
  color: #64748b;
}
/* Save button */
.cfg-actions {
  display: flex;
  justify-content: flex-end;
}
.cfg-btn-save {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(37,99,235,0.25);
}
.cfg-btn-save:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37,99,235,0.35);
}
.cfg-btn-save:active {
  transform: translateY(0);
}
@media (max-width: 640px) {
  .cfg-grid { grid-template-columns: 1fr; }
  .cfg-section { padding: 16px; }
}

/* ═══════════════════════════════════════════════════════════════
   USERS PAGE REDESIGN
   ═══════════════════════════════════════════════════════════════ */

/* Create user card */
.usr-create-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 18px;
}
.usr-create-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 20px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  transition: background 0.15s;
}
.usr-create-toggle:hover { background: #f8fafc; }
.usr-create-toggle-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.usr-create-toggle-left svg { color: var(--primary); }
.usr-toggle-icon {
  color: var(--muted);
  transition: transform 0.25s ease;
}
.usr-create-body {
  padding: 0 20px 20px;
  border-top: 1px solid var(--line);
}

/* Form fields */
.usr-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding-top: 18px;
}
.usr-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.usr-field-half {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.usr-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.usr-input {
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
}
.usr-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}
.usr-input::placeholder { color: #94a3b8; }

/* Form actions */
.usr-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.usr-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: 9px;
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.usr-btn-primary {
  background: linear-gradient(135deg, #2563eb, #1e40af);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,0.25);
}
.usr-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37,99,235,0.35);
}
.usr-btn-cancel {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--line);
}
.usr-btn-cancel:hover {
  background: #f1f5f9;
  color: var(--text);
}

/* Edit row */
.usr-edit-cell {
  background: #f8fafc;
  padding: 16px 20px;
  border-left: 3px solid var(--primary);
}
.usr-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

/* Responsive */
@media (max-width: 640px) {
  .usr-form-grid { grid-template-columns: 1fr; }
  .usr-edit-grid { grid-template-columns: 1fr; }
  .usr-form-actions { flex-direction: column-reverse; }
  .usr-btn { width: 100%; justify-content: center; }
}
