:root {
  --bg-main: #0A121F;
  --bg-sidebar: #0D1626;
  --bg-card: #111C2E;
  --bg-card-hover: #16243A;
  --bg-input: #152238;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(18, 184, 134, 0.35);
  
  --primary: #12B886;
  --primary-hover: #0EA276;
  --primary-light: rgba(18, 184, 134, 0.15);
  
  --danger: #EF4444;
  --danger-light: rgba(239, 68, 68, 0.15);
  --danger-glow: rgba(239, 68, 68, 0.4);
  
  --success: #12B886;
  --success-light: rgba(18, 184, 134, 0.15);
  
  --warning: #F59E0B;
  --warning-light: rgba(245, 158, 11, 0.15);
  
  --accent: #34D19A;
  --accent-teal: #199A91;
  
  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .logo-title, .kpi-value {
  font-family: var(--font-heading);
}

/* ==========================================================================
   AUTH SCREEN (LOGIN)
   ========================================================================== */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: radial-gradient(circle at 50% 20%, #0F2D2A 0%, #0A121F 70%);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px);
  animation: fadeIn 0.4s ease-out;
}

.brand-header {
  text-align: center;
  margin-bottom: 32px;
}

.shield-logo-wrap {
  width: 88px;
  height: 88px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-shield-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 18px rgba(18, 184, 134, 0.45));
}

.pulse-glow {
  animation: pulseGlow 3s infinite;
}

@keyframes pulseGlow {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(18, 184, 134, 0.35)); }
  50% { filter: drop-shadow(0 0 24px rgba(52, 209, 154, 0.65)); }
}

.auth-brand-name {
  font-size: 32px;
  letter-spacing: 1.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.brand-cod {
  color: var(--primary);
}

.brand-safe {
  color: #FFFFFF;
}

.brand-header .subtitle {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  margin-top: 6px;
  text-transform: uppercase;
}

.brand-header .sub-desc {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 4px;
}

.auth-form .form-group {
  margin-bottom: 20px;
}

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

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper svg {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
}

.input-wrapper input,
.form-control {
  width: 100%;
  padding: 12px 16px 12px 42px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: var(--transition);
}

.form-control:not(.input-wrapper input) {
  padding-left: 14px;
}

textarea.form-control {
  padding: 12px 14px;
  resize: vertical;
}

.input-wrapper input:focus,
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  font-family: var(--font-body);
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #FFF;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-secondary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-link {
  background: none;
  color: var(--accent);
  padding: 0;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-danger {
  background: var(--danger);
  color: #FFF;
}

.btn-danger:hover {
  background: #DC2626;
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   APP LAYOUT
   ========================================================================== */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-color);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.shield-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid rgba(18, 184, 134, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.sidebar-shield-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 1px;
}

.logo-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  background: var(--primary-light);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
}

.nav-menu {
  flex: 1;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.nav-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--primary);
  color: #FFF;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
}

.nav-icon-badge {
  position: relative;
  display: flex;
  align-items: center;
}

.badge-counter {
  position: absolute;
  top: -6px;
  right: -8px;
  background: var(--danger);
  color: #FFF;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  animation: pulse 1.5s infinite;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.user-meta {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.btn-icon:hover {
  background: var(--bg-card);
  color: var(--danger);
}

/* ==========================================================================
   MAIN CONTENT
   ========================================================================== */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  overflow-y: auto;
}

.top-bar {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left h2 {
  font-size: 20px;
  font-weight: 700;
}

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: blink 2s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tab-content {
  display: none;
  padding: 32px;
  animation: fadeIn 0.3s ease-out;
}

.tab-content.active {
  display: block;
}

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

/* ==========================================================================
   KPIS & METRICS
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

@media (max-width: 1280px) and (min-width: 769px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-glow);
}

.kpi-card.alert-card {
  border-color: var(--danger-glow);
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, var(--bg-card) 100%);
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  flex-shrink: 0;
}

.alert-card .kpi-icon {
  background: var(--danger-light);
  color: var(--danger);
}

.kpi-data {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.kpi-label {
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  margin: 3px 0 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.25;
}

.kpi-subtext {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.kpi-data .badge {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
  padding: 3px 8px;
  width: fit-content;
}

.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }

/* ==========================================================================
   PANEL CARDS & TABLES
   ========================================================================== */
.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}

.panel-card-flat {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 28px;
  margin-bottom: 24px;
}

.content-split-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.panel-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.data-table th {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: var(--transition);
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 260px;
}

.search-box svg {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
}

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

.filters-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.filters-row .form-control {
  padding: 10px 14px;
  font-size: 13px;
  width: auto;
}

/* ==========================================================================
   BADGES & STATUS
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-danger { background: var(--danger-light); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-success { background: var(--success-light); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning { background: var(--warning-light); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-primary { background: var(--primary-light); color: var(--primary); border: 1px solid rgba(99, 102, 241, 0.3); }
.badge-muted { background: rgba(255, 255, 255, 0.05); color: var(--text-muted); border: 1px solid var(--border-color); }

/* ==========================================================================
   CENTRAL SOS & LIVE MAP
   ========================================================================== */
.sos-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 24px;
  height: calc(100vh - 160px);
}

.sos-feed-column {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.feed-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.feed-header h3 {
  font-size: 15px;
}

.sos-cards-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sos-item-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.sos-item-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

.sos-item-card.critical {
  border-left: 4px solid var(--danger);
  background: linear-gradient(90deg, rgba(239, 68, 68, 0.06) 0%, var(--bg-input) 100%);
}

.sos-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.sos-user-name {
  font-weight: 700;
  font-size: 14px;
}

.sos-type {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sos-address {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 10px;
}

.sos-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.sos-map-column {
  display: flex;
  flex-direction: column;
}

.map-card {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.map-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.map-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
}

.badge-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--success);
}

.interactive-map {
  flex: 1;
  width: 100%;
  min-height: 400px;
}

/* ==========================================================================
   PLANS GRID
   ========================================================================== */
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

.plan-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 28px;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: var(--transition);
}

.plan-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.plan-badge-tag {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--primary-light);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.plan-name {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.plan-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 20px;
  min-height: 40px;
}

.plan-price-box {
  margin-bottom: 24px;
}

.plan-price {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
}

.plan-period {
  font-size: 13px;
  color: var(--text-muted);
}

.plan-features-list {
  list-style: none;
  margin-bottom: 28px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.plan-features-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.plan-features-list li.active {
  color: var(--text-primary);
}

.plan-features-list li svg {
  flex-shrink: 0;
}

.plan-stats-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ==========================================================================
   SETTINGS
   ========================================================================== */
.settings-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 24px;
}

.form-group-toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 16px 0;
  font-size: 13px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-secondary);
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--primary);
  border-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(20px);
  background-color: #FFF;
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

.code-snippet {
  margin-top: 10px;
  background: var(--bg-input);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-family: monospace;
  font-size: 13px;
  color: var(--accent);
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

.modal-card {
  width: 100%;
  max-width: 540px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-card.modal-lg {
  max-width: 760px;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

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

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
  font-size: 13px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  color: var(--text-primary);
  font-size: 13px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideInRight 0.3s ease-out;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--accent); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   WHATSAPP & CONEXÕES EVOLUTION (FAILOVER & MULTI-LINHAS)
   ========================================================================== */

/* Hero Header Moderno */
.whatsapp-hero-banner {
  background: radial-gradient(circle at 85% 20%, rgba(16, 185, 129, 0.15) 0%, rgba(14, 19, 34, 0.95) 70%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  margin-bottom: 24px;
}

.hero-brand {
  max-width: 680px;
}

.hero-badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  padding: 4px 12px;
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
  border-radius: 9999px;
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 10px;
}

.pulse-dot-green {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10B981;
  box-shadow: 0 0 8px #10B981;
  animation: pulseDot 1.8s infinite;
}

.whatsapp-hero-banner h2 {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 6px 0;
  letter-spacing: -0.3px;
}

.whatsapp-hero-banner p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.hero-action-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-primary-glow {
  background: linear-gradient(135deg, #10B981 0%, #059669 100%);
  color: #FFFFFF;
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35);
  transition: var(--transition);
}

.btn-primary-glow:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
  filter: brightness(1.08);
}

.btn-secondary-modern {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary-modern:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.btn-outline-light {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Ícones & Cores Específicas dos KPIs de WhatsApp */
.kpi-icon-whatsapp {
  background: rgba(16, 185, 129, 0.15);
  color: #10B981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.kpi-icon-backup {
  background: rgba(245, 158, 11, 0.15);
  color: #F59E0B;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.kpi-icon-strategy {
  background: rgba(56, 189, 248, 0.15);
  color: #38BDF8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.kpi-icon-dispatches {
  background: rgba(99, 102, 241, 0.15);
  color: #818CF8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.text-whatsapp {
  color: #34D399 !important;
}

.badge-dot-online {
  width: 8px;
  height: 8px;
  background-color: var(--success);
  border-radius: 50%;
  position: absolute;
  top: 8px;
  right: 12px;
  box-shadow: 0 0 8px var(--success);
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.alert-box-warning {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-top: 16px;
  color: #FDE68A;
}

.alert-box-warning .alert-icon {
  font-size: 24px;
  line-height: 1;
}

.alert-box-warning .alert-content strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
  color: #FBBF24;
}

.alert-box-warning .alert-content p {
  font-size: 13px;
  margin: 0;
  color: #F3F4F6;
  opacity: 0.9;
}

/* Grid de Instâncias */
.whatsapp-instances-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.instance-card {
  background: linear-gradient(180deg, #151D33 0%, #11172A 100%);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
  padding: 22px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.35);
}

.instance-card:hover {
  border-color: rgba(16, 185, 129, 0.4);
  transform: translateY(-3px);
  box-shadow: 0 12px 30px -8px rgba(0, 0, 0, 0.5);
}

.instance-card.is-primary {
  border-top: 3px solid #10B981;
}

.instance-card.is-backup {
  border-top: 3px solid #F59E0B;
}

.instance-card-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.instance-avatar-wrapper {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-full);
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

.instance-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.instance-avatar-placeholder {
  color: var(--text-secondary);
}

.instance-meta {
  flex: 1;
  min-width: 0;
}

.instance-meta-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.instance-meta-phone {
  font-size: 13px;
  color: #38BDF8;
  font-family: monospace;
  margin-bottom: 6px;
  font-weight: 600;
}

.instance-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge-role-primary {
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.35);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

.badge-role-backup {
  background: rgba(245, 158, 11, 0.15);
  color: #FBBF24;
  border: 1px solid rgba(245, 158, 11, 0.35);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

.status-indicator-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-weight: 700;
}

.status-indicator-tag.open {
  background: rgba(16, 185, 129, 0.18);
  color: #10B981;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.status-indicator-tag.close {
  background: rgba(239, 68, 68, 0.15);
  color: #F87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.status-indicator-tag.connecting {
  background: rgba(245, 158, 11, 0.15);
  color: #FBBF24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.instance-stats-box {
  background: rgba(11, 15, 25, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.instance-stat-item {
  display: flex;
  flex-direction: column;
}

.instance-stat-item span {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.instance-stat-item strong {
  font-size: 15px;
  color: var(--text-primary);
  font-weight: 700;
}

.instance-actions-footer {
  margin-top: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Layout de Configurações Dividido em 2 Painéis */
.whatsapp-settings-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 16px;
}

.settings-box-panel {
  background: rgba(11, 15, 25, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 20px;
}

.settings-box-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.settings-box-title svg {
  color: var(--primary);
}

.input-with-badge {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-badge input {
  padding-right: 44px;
}

.input-suffix {
  position: absolute;
  right: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
}

.toggle-cards-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toggle-card-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
  transition: var(--transition);
}

.toggle-card-item:hover {
  border-color: rgba(99, 102, 241, 0.3);
  background: var(--bg-card-hover);
}

.toggle-text {
  display: flex;
  flex-direction: column;
}

.toggle-text strong {
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.toggle-text span {
  font-size: 11px;
  color: var(--text-muted);
}

.template-variables-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.var-tag {
  cursor: pointer;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  color: #818CF8;
  transition: var(--transition);
}

.var-tag:hover {
  background: rgba(99, 102, 241, 0.3);
  color: #FFF;
  transform: translateY(-1px);
}

/* Mockup de Chat WhatsApp (Live Preview) */
.whatsapp-preview-box {
  background: #0B141A;
  border: 1px solid #222D34;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.wa-preview-header {
  background: #1F2C34;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.wa-preview-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #10B981;
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wa-preview-title {
  font-size: 13px;
  font-weight: 700;
  color: #E9EDEF;
  display: block;
}

.wa-preview-status {
  font-size: 11px;
  color: #8696A0;
}

.wa-preview-bubble {
  background: #005C4B;
  color: #E9EDEF;
  padding: 12px 14px;
  border-radius: 8px 0px 8px 8px;
  margin: 16px;
  max-width: 85%;
  margin-left: auto;
  position: relative;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.wa-preview-bubble p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.wa-preview-time {
  display: block;
  text-align: right;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 4px;
}

/* Modais QR Code & Pairing */
.tab-pills-center {
  display: inline-flex;
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.btn-pill {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-pill.active {
  background: var(--primary);
  color: #FFF;
  font-weight: 600;
}

.qr-frame {
  width: 260px;
  height: 260px;
  margin: 16px auto;
  background: #FFFFFF;
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-code-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.qr-instructions {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 380px;
  margin: 0 auto;
}

.qr-spinner-box {
  padding: 50px 20px;
}

.qr-status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.pulsing-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--warning);
  animation: pulseDot 1.5s infinite;
}

.pairing-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.pairing-code {
  font-size: 26px;
  letter-spacing: 4px;
  font-weight: 800;
  font-family: monospace;
  color: var(--success);
  display: block;
}

.test-result-panel {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  padding: 14px;
}

.test-result-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-weight: 600;
}

.test-result-content {
  font-family: monospace;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.4);
  padding: 10px;
  border-radius: var(--radius-sm);
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  color: #A7F3D0;
}

.text-warning-bold {
  color: #FBBF24;
  font-weight: 600;
  font-size: 12px;
}

/* Responsividade Completa */
@media (max-width: 1024px) {
  .content-split-grid,
  .settings-grid,
  .whatsapp-settings-layout {
    grid-template-columns: 1fr;
  }
  
  .sos-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
}

@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: auto;
  }
  
  .nav-menu {
    flex-direction: row;
    overflow-x: auto;
    padding: 10px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  
  .nav-menu::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    white-space: nowrap;
    padding: 8px 14px;
  }

  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
  }

  .top-bar .header-left h2 {
    font-size: 20px;
  }

  .top-bar .header-actions {
    width: 100%;
  }

  .top-bar .header-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .main-wrapper {
    padding: 16px;
  }

  .whatsapp-hero-banner {
    flex-direction: column;
    align-items: flex-start;
    padding: 20px 18px;
    gap: 16px;
  }

  .hero-brand h2 {
    font-size: 20px;
  }

  .hero-action-buttons {
    width: 100%;
    gap: 8px;
  }

  .hero-action-buttons .btn {
    flex: 1 1 auto;
    justify-content: center;
    font-size: 12px;
    padding: 8px 12px;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .kpi-card {
    padding: 16px;
  }

  .whatsapp-instances-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .instance-card {
    padding: 18px 16px;
  }

  .instance-actions-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .instance-actions-footer .btn {
    width: 100%;
    justify-content: center;
  }

  .form-row-2 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .settings-box-panel {
    padding: 16px 14px;
  }

  .wa-preview-bubble {
    max-width: 100%;
    margin: 10px;
  }
}

@media (max-width: 480px) {
  .hero-action-buttons {
    flex-direction: column;
  }

  .hero-action-buttons .btn {
    width: 100%;
  }

  .instance-actions-footer {
    grid-template-columns: 1fr;
  }
}

/* ========================================================
   NOTIFICAÇÕES & UPLOAD DE APK
   ======================================================== */
.apk-dropzone {
  border: 2px dashed rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.04);
  border-radius: 12px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
}

.apk-dropzone:hover, .apk-dropzone.dragover {
  border-color: #6366F1;
  background: rgba(99, 102, 241, 0.1);
  transform: translateY(-1px);
}

.dropzone-icon {
  color: #818CF8;
  margin-bottom: 8px;
}

.apk-file-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 10px 14px;
  border-radius: 10px;
  color: #10B981;
}

.badge-notif-type {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
}

.badge-notif-GENERAL {
  background: rgba(59, 130, 246, 0.15);
  color: #60A5FA;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-notif-UPDATE {
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-notif-SECURITY_ALERT {
  background: rgba(239, 68, 68, 0.15);
  color: #F87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-notif-INFO {
  background: rgba(139, 92, 246, 0.15);
  color: #A78BFA;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.badge-priority-CRITICAL {
  background: #DC2626;
  color: #FFF;
  font-weight: 800;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}

.badge-priority-HIGH {
  background: rgba(245, 158, 11, 0.2);
  color: #FBBF24;
  font-weight: 700;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-priority-NORMAL {
  color: var(--text-secondary);
  font-size: 11px;
}



