:root {
  --bg: #0f1b1a;
  --panel: #142524;
  --panel-light: #1a2f2d;
  --accent: #22c55e;
  --accent-soft: #9ae6b4;
  --text: #ecfdf3;
  --muted: #9db8b0;
  --danger: #ef4444;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Sora", sans-serif;
  background: radial-gradient(circle at 10% 10%, #1b2f2c, #0f1b1a 55%, #0a1413 100%);
  color: var(--text);
  min-height: 100vh;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #11201f 0%, #0e1918 100%);
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid rgba(255, 255, 255, 0.04);
}

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

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.7);
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.5px;
}

.brand p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-item {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  padding: 12px 14px;
  text-align: left;
  border-radius: 12px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.35);
}

.sidebar-footer {
  margin-top: auto;
  font-size: 12px;
  color: var(--muted);
}

.content {
  padding: 26px 34px 30px;
}

.header,
.footer {
  background: var(--panel);
  padding: 18px 22px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.header h2 {
  margin: 0;
  font-size: 18px;
}

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

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text);
}

.panel {
  display: none;
  background: var(--panel);
  padding: 22px;
  border-radius: 18px;
  margin: 24px 0;
  box-shadow: var(--shadow);
}

.panel.active {
  display: block;
}

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

.panel-header h2 {
  margin: 0 0 4px;
  font-size: 22px;
}

.panel-header p {
  margin: 0;
  color: var(--muted);
}

.master-layout {
  display: grid;
  gap: 16px;
}

.api-response {
  background: var(--panel-light);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 240px;
  overflow: auto;
}

code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: "Courier New", monospace;
}

.status-pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.18);
  color: var(--accent-soft);
  font-size: 12px;
}

.inbox-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 18px;
}

.chat-list {
  background: var(--panel-light);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #0f1b1a;
  color: var(--text);
}

.chat-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 540px;
  overflow-y: auto;
}

.chat-item {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-item.active,
.chat-item:hover {
  background: rgba(34, 197, 94, 0.16);
}

.chat-item h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.chat-item p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.chat-detail {
  background: var(--panel-light);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  min-height: 560px;
}

.chat-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 12px;
}

.chat-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 0;
  overflow-y: auto;
}

.message {
  max-width: 70%;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 13px;
  line-height: 1.4;
}

.message.outgoing {
  align-self: flex-end;
  background: rgba(34, 197, 94, 0.25);
}

.chat-input {
  display: flex;
  gap: 10px;
}

.chat-input input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #0f1b1a;
  color: var(--text);
}

.btn {
  background: var(--accent);
  border: none;
  color: #0a1413;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

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

.label-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.label-pill {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.label-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.label-card {
  background: var(--panel-light);
  padding: 16px;
  border-radius: 14px;
}

.label-card h4 {
  margin: 0 0 8px;
}

.label-card p {
  margin: 0;
  color: var(--muted);
}

.broadcast-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
}

.toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.toggle-btn {
  flex: 1;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
}

.toggle-btn.active {
  border-color: rgba(34, 197, 94, 0.5);
  background: rgba(34, 197, 94, 0.18);
}

.broadcast-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.broadcast-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
}

.broadcast-item {
  background: var(--panel-light);
  padding: 12px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.broadcast-compose {
  background: var(--panel-light);
  padding: 18px;
  border-radius: 16px;
}

.broadcast-compose label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  margin-bottom: 12px;
  color: var(--muted);
}

.broadcast-compose select,
.broadcast-compose input[type="text"] {
  width: 100%;
  background: #0f1b1a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
}

.broadcast-compose select:focus,
.broadcast-compose input[type="text"]:focus {
  outline: none;
  border-color: rgba(34, 197, 94, 0.4);
}

.broadcast-compose textarea {
  width: 100%;
  background: #0f1b1a;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  margin-bottom: 12px;
}

.settings-form {
  display: grid;
  gap: 16px;
  max-width: 520px;
}

.settings-form label {
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.settings-form input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #0f1b1a;
  color: var(--text);
}

.settings-form .hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: -4px;
}

.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.doc-link {
  color: var(--accent-soft);
  text-decoration: none;
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 6px 12px;
  border-radius: 999px;
}

.doc-card {
  background: var(--panel-light);
  padding: 18px;
  border-radius: 16px;
  text-decoration: none;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.doc-card:hover {
  transform: translateY(-2px);
  border-color: rgba(34, 197, 94, 0.4);
}

.status-text {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.whatsapp-layout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.whatsapp-card {
  background: var(--panel-light);
  padding: 18px;
  border-radius: 16px;
  display: grid;
  gap: 14px;
}

.whatsapp-card h3 {
  margin: 0;
  font-size: 18px;
}

.whatsapp-card label {
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.whatsapp-card input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #0f1b1a;
  color: var(--text);
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.device-list {
  display: grid;
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
}

.device-item {
  background: rgba(255, 255, 255, 0.04);
  padding: 12px;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.device-item.active {
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.device-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.selected-device {
  font-size: 13px;
  color: var(--muted);
}

.qr-box {
  display: grid;
  gap: 8px;
  justify-items: start;
}

/* Data Table Styles */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 12px;
  margin-bottom: 12px;
}

.data-table thead {
  background: rgba(34, 197, 94, 0.08);
  border-bottom: 2px solid rgba(34, 197, 94, 0.2);
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--accent);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  transition: background-color 0.2s;
}

.data-table tbody tr:hover:not(.empty-row) {
  background: rgba(34, 197, 94, 0.05);
}

.data-table td {
  padding: 12px 16px;
  color: var(--text);
  font-size: 14px;
}

.data-table code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "Fira Code", "Courier New", monospace;
  font-size: 12px;
  color: var(--accent-soft);
}

.data-table .empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 24px 16px;
}

/* Search Input */
.search-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 12px;
  transition: all 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(255, 255, 255, 0.06);
}

.search-input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 0;
  flex-wrap: wrap;
}

.pagination-info {
  font-size: 13px;
  color: var(--muted);
}

.pagination-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  min-width: auto;
}

.btn-sm.active {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--accent);
}

.qr-box img {
  width: 200px;
  height: 200px;
  object-fit: contain;
  border-radius: 12px;
  background: #0f1b1a;
  display: none;
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-shell {
  width: min(420px, 90vw);
  padding: 24px;
}

.login-card {
  background: var(--panel);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
}

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

.login-brand h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

.login-brand p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.login-form input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #0f1b1a;
  color: var(--text);
}

/* Broadcast Controls */
.broadcast-controls {
  margin-top: 12px;
  padding: 12px;
  background: var(--panel-light);
  border-radius: 12px;
}

.broadcast-controls label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.broadcast-controls input[type="number"] {
  width: 120px;
  background: #0f1b1a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 14px;
}

.broadcast-button-group {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

/* Progress Bar */
.progress-bar {
  width: 100%;
  height: 24px;
  background: var(--panel-light);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 12px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  transition: width 0.3s ease;
  width: 0%;
}

.progress-text {
  text-align: center;
  margin-top: 6px;
  font-size: 13px;
  color: var(--muted);
}

/* Broadcast Log */
.broadcast-log {
  margin-top: 12px;
  max-height: 300px;
  overflow-y: auto;
  background: var(--panel-light);
  border-radius: 12px;
  padding: 12px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
}

.log-entry {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.log-entry:last-child {
  border-bottom: none;
}

.log-info {
  color: #60a5fa;
}

.log-success {
  color: #22c55e;
}

.log-error {
  color: #ef4444;
}

/* File Upload Input */
.broadcast-compose input[type="file"] {
  width: 100%;
  padding: 10px;
  background: var(--panel-light);
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.broadcast-compose input[type="file"]:hover {
  border-color: rgba(34, 197, 94, 0.4);
}

.hint {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* Data Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.data-table th {
  background: var(--panel-light);
  padding: 12px;
  text-align: left;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
}

.data-table tr:hover {
  background: var(--panel-light);
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.link {
  color: #60a5fa;
  text-decoration: none;
}

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

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.3);
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .nav {
    flex-direction: row;
    gap: 8px;
  }

  .inbox-layout,
  .broadcast-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .content {
    padding: 18px;
  }

  .panel {
    padding: 18px;
  }

  .chat-detail {
    min-height: 420px;
  }
}

/* ====================================
   Broadcast Log Styles
   ==================================== */

.log-filter-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.log-filter-tab {
  background: var(--panel-light);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.log-filter-tab:hover {
  background: rgba(34, 197, 94, 0.1);
  border-color: var(--accent);
}

.log-filter-tab.active {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

.count-badge {
  background: rgba(255, 255, 255, 0.15);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.log-filter-tab.active .count-badge {
  background: rgba(0, 0, 0, 0.15);
}

.broadcast-log-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-size: 14px;
}

.broadcast-log-table thead {
  background: var(--panel-light);
  border-bottom: 2px solid rgba(255, 255, 255, 0.08);
}

.broadcast-log-table th {
  padding: 12px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-soft);
}

.broadcast-log-table td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.broadcast-log-table tbody tr:hover {
  background: rgba(34, 197, 94, 0.05);
}

.progress-bar {
  position: relative;
  width: 100%;
  height: 24px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #16a34a);
  transition: width 0.3s ease;
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-pending {
  background: rgba(234, 179, 8, 0.15);
  color: #fcd34d;
}

.status-processing {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.status-completed {
  background: rgba(34, 197, 94, 0.15);
  color: var(--accent-soft);
}

.status-failed {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.status-paused {
  background: rgba(168, 85, 247, 0.15);
  color: #d8b4fe;
}

.status-cancelled {
  background: rgba(156, 163, 175, 0.15);
  color: #d1d5db;
}

.btn-action {
  background: var(--panel-light);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
  margin-right: 4px;
}

.btn-action:hover {
  background: rgba(34, 197, 94, 0.1);
  border-color: var(--accent);
}

.btn-cancel {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-cancel:hover {
  background: rgba(239, 68, 68, 0.1);
}

.btn-resume {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-edit {
  border-color: #3b82f6;
  color: #93c5fd;
}

.btn-edit:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: #3b82f6;
}

#broadcast-schedule-fields {
  margin-top: 10px;
  padding: 10px;
  background: rgba(59, 130, 246, 0.05);
  border-radius: 6px;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

#broadcast-schedule-fields label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

#broadcast-schedule-time {
  display: block;
  width: 100%;
  max-width: 250px;
  background: var(--panel-light);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 14px;
}

#broadcast-schedule-time:focus {
  outline: none;
  border-color: var(--accent);
}
