:root {
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --border-color: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* AUTH SCREEN */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background: radial-gradient(circle at top, #1e293b, #0f172a);
}

.auth-card {
  background: rgba(30, 41, 59, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 20px;
}

.auth-card h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.auth-desc {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

/* FORMS */
.form-group {
  text-align: left;
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #cbd5e1;
  margin-bottom: 6px;
}

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

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  background: #0b1120;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

input:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #334155;
  color: #f1f5f9;
}
.btn-secondary:hover {
  background: #475569;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}
.btn-outline:hover {
  border-color: #64748b;
  color: var(--text-main);
}

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

.btn-block {
  width: 100%;
}

/* NAVBAR */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: #1e293b;
  border-bottom: 1px solid var(--border-color);
}

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

.logo-icon {
  font-size: 28px;
}

.logo-text .title {
  display: block;
  font-size: 18px;
  font-weight: 700;
}

.logo-text .sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-tag {
  background: #0f172a;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: #93c5fd;
  border: 1px solid #1e3a8a;
}

/* PULSE DOT */
.pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(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); }
}

.badge-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--success);
}

/* MAIN CONTENT */
.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 30px 20px;
}

/* STATS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 30px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 22px;
  border-radius: var(--radius);
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}
.stat-card:hover {
  transform: translateY(-2px);
  border-color: #475569;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.stat-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}

.stat-icon-badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

.active-badge {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.3);
}

.sent-badge {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.3);
}

.ssl-badge {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.active-val {
  color: #38bdf8;
  text-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}

.text-amber {
  color: #fbbf24;
}

.text-success {
  color: var(--success);
}

/* SECTION HEADER & TABS */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 14px;
}

.tabs {
  display: flex;
  gap: 10px;
}

.tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab.active {
  background: #334155;
  color: var(--text-main);
}

.actions {
  display: flex;
  gap: 10px;
}

.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

/* GATEWAYS GRID */
.gateways-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.gateway-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 0.2s, border-color 0.2s;
}

.gateway-card:hover {
  border-color: #475569;
  transform: translateY(-2px);
}

.gw-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.gw-name {
  font-size: 17px;
  font-weight: 700;
}

.gw-phone {
  font-size: 14px;
  color: #38bdf8;
  font-family: monospace;
  margin-top: 3px;
}

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

.gw-keys {
  background: #0b1120;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 11px;
}

.gw-key-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.gw-key-row:last-child {
  margin-bottom: 0;
}

.key-label {
  color: var(--text-muted);
}

.key-val {
  font-family: monospace;
  color: #a7f3d0;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.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: #475569;
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

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

input:checked + .slider:before {
  transform: translateX(20px);
}

.gw-actions {
  display: flex;
  gap: 8px;
}

/* LOGS TABLE */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow-x: auto;
}

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

.logs-table th {
  background: #172033;
  padding: 12px 16px;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
}

.logs-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #283548;
}

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

.badge-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge-sent { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.badge-failed { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.badge-pending { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }

/* MODALS */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  padding: 24px;
  box-shadow: var(--shadow);
}

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

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.readonly-badge {
  background: #0b1120;
  border: 1px solid var(--border-color);
  padding: 10px;
  border-radius: 8px;
  font-size: 14px;
  color: #93c5fd;
}

/* UTILITIES */
.hidden { display: none !important; }
.alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 14px;
}
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  background: var(--bg-card);
  border-radius: var(--radius);
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  border: 1px solid var(--primary);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 13px;
  z-index: 200;
  animation: slideIn 0.3s ease;
}

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

/* GUIDE & TUTORIAL STYLES */
.guide-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.guide-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}

.guide-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 14px;
}

.guide-lead {
  font-size: 0.95rem;
  color: #cbd5e1;
  line-height: 1.6;
  margin-bottom: 20px;
}

/* FLOW DIAGRAM */
.diagram-flow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.diagram-step {
  flex: 1;
  min-width: 170px;
  background: #0b1120;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
}

.step-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: #60a5fa;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.step-icon {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.step-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.diagram-arrow {
  font-size: 1.4rem;
  color: #3b82f6;
  font-weight: bold;
}

/* TUTORIAL STEPS */
.tutorial-step {
  display: flex;
  gap: 18px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tutorial-step:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.step-num {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.8rem;
  height: fit-content;
  white-space: nowrap;
}

.step-content h4 {
  font-size: 1rem;
  font-weight: 600;
  color: #f1f5f9;
  margin-bottom: 6px;
}

.step-content p {
  font-size: 0.88rem;
  color: #cbd5e1;
  line-height: 1.5;
  margin-bottom: 6px;
}

.step-content ul {
  list-style: disc inside;
  font-size: 0.86rem;
  color: #94a3b8;
  line-height: 1.6;
  margin-left: 6px;
}

.step-content a {
  color: #38bdf8;
  text-decoration: underline;
}

/* CODE BOX */
.code-box {
  background: #0b1120;
  border: 1px solid #1e293b;
  border-radius: 10px;
  margin-top: 14px;
  overflow: hidden;
}

.code-header {
  background: #111827;
  padding: 8px 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-bottom: 1px solid #1e293b;
}

.code-box pre {
  padding: 16px;
  overflow-x: auto;
  font-family: monospace;
  font-size: 0.82rem;
  color: #a7f3d0;
  line-height: 1.5;
}

/* TIPS CARD */
.tip-card {
  border-left: 4px solid #f59e0b;
}

.tips-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tips-list li {
  font-size: 0.88rem;
  color: #cbd5e1;
  line-height: 1.5;
}

