/* ─── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px; color: #212529; background: #f0f2f5; }
a { color: #0d6efd; text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: 'Consolas', monospace; font-size: 13px; }

/* ─── Login ───────────────────────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,0.35); }
.login-logo { text-align: center; margin-bottom: 28px; }
.logo-icon { width: 56px; height: 56px; background: #25d366; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 800; color: #fff; margin-bottom: 10px; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: #1a1a2e; }
.login-logo p  { font-size: 13px; color: #6c757d; margin-top: 2px; }
.pass-wrap { position: relative; }
.pass-eye { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 16px; padding: 2px; }

/* ─── Navbar ──────────────────────────────────────────────────────────────── */
.admin-navbar { position: fixed; top: 0; left: 0; right: 0; height: 56px; background: #1a1a2e; display: flex; align-items: center; padding: 0 20px; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.navbar-brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { background: #25d366; color: #fff; font-weight: 800; font-size: 14px; padding: 4px 8px; border-radius: 6px; }
.brand-name { color: #fff; font-size: 16px; font-weight: 600; }
.navbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.nav-user { color: #adb5bd; font-size: 13px; }

/* ─── Layout ──────────────────────────────────────────────────────────────── */
.admin-body { padding-top: 56px; }
.admin-layout { display: flex; min-height: calc(100vh - 56px); }

/* ─── Sidebar ─────────────────────────────────────────────────────────────── */
.admin-sidebar { width: 220px; background: #fff; border-right: 1px solid #dee2e6; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-nav { list-style: none; padding: 12px 0; flex: 1; }
.sidebar-link { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: #495057; border-radius: 0; transition: background 0.15s; }
.sidebar-link:hover { background: #f8f9fa; text-decoration: none; }
.sidebar-link.active { background: #e7f1ff; color: #0d6efd; font-weight: 600; border-left: 3px solid #0d6efd; }
.sidebar-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer { padding: 12px 20px; border-top: 1px solid #dee2e6; }
.sidebar-status { font-size: 12px; color: #6c757d; }
.sidebar-status.connected { color: #198754; }
.sidebar-status.disconnected { color: #dc3545; }

/* ─── Main content ────────────────────────────────────────────────────────── */
.admin-main { flex: 1; padding: 24px; overflow-x: auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h2 { font-size: 22px; font-weight: 700; color: #1a1a2e; }
.breadcrumb { font-size: 12px; color: #6c757d; }

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card { background: #fff; border-radius: 10px; border: 1px solid #dee2e6; overflow: hidden; }
.card-header { padding: 14px 18px; font-weight: 600; font-size: 14px; background: #f8f9fa; border-bottom: 1px solid #dee2e6; display: flex; align-items: center; }
.card-body { padding: 18px; }
.card.mt-4 { margin-top: 20px; }
.card.mb-3 { margin-bottom: 16px; }
.card.mb-4 { margin-bottom: 20px; }

/* ─── Stats Grid ──────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-card { background: #fff; border-radius: 10px; border: 1px solid #dee2e6; padding: 16px; display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: #6c757d; margin-top: 3px; }

/* ─── Plans Grid ──────────────────────────────────────────────────────────── */
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.plan-card { background: #fff; border-radius: 10px; border: 1px solid #dee2e6; padding: 20px; text-align: center; }
.plan-card-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.plan-card-price { font-size: 22px; font-weight: 800; color: #1a1a2e; }
.plan-card-duration { font-size: 12px; color: #6c757d; margin-bottom: 10px; }
.plan-card-stats { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }

/* ─── Plan bar ────────────────────────────────────────────────────────────── */
.plan-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.plan-label { width: 70px; font-weight: 600; font-size: 13px; flex-shrink: 0; }
.plan-bar-track { flex: 1; height: 10px; background: #e9ecef; border-radius: 5px; overflow: hidden; }
.plan-bar-fill { height: 100%; border-radius: 5px; transition: width 0.4s; }
.plan-count { width: 28px; text-align: right; font-size: 13px; color: #495057; flex-shrink: 0; }

/* ─── Table ───────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { background: #f8f9fa; color: #495057; font-weight: 600; padding: 10px 14px; text-align: left; border-bottom: 2px solid #dee2e6; white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8f9fa; }
.table-sm th, .table-sm td { padding: 7px 12px; }
.user-email { font-weight: 500; }
.user-uid { font-size: 11px; color: #adb5bd; font-family: monospace; margin-top: 2px; }

/* ─── Badges ──────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; color: #fff; white-space: nowrap; }
.bg-success { background: #198754; }
.bg-danger  { background: #dc3545; }
.bg-warning { background: #ffc107; color: #212529 !important; }
.bg-secondary { background: #6c757d; }
.bg-primary { background: #0d6efd; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn { display: inline-block; padding: 8px 16px; border-radius: 6px; font-size: 14px; font-weight: 500; border: none; cursor: pointer; transition: opacity 0.15s; }
.btn:hover { opacity: 0.85; }
.btn-primary   { background: #0d6efd; color: #fff; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-success   { background: #198754; color: #fff; }
.btn-danger    { background: #dc3545; color: #fff; }
.btn-warning   { background: #ffc107; color: #212529; }
.btn-block     { display: block; width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-sm.btn-primary   { background: #0d6efd; color: #fff; border-radius: 5px; border: none; cursor: pointer; }
.btn-sm.btn-warning   { background: #ffc107; color: #212529; border-radius: 5px; border: none; cursor: pointer; }
.btn-sm.btn-danger    { background: #dc3545; color: #fff; border-radius: 5px; border: none; cursor: pointer; }
.btn-sm-link { font-size: 13px; color: #0d6efd; }
.actions-cell { display: flex; gap: 6px; }
.btn-icon { background: none; border: none; font-size: 18px; cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.btn-icon:hover { background: #f0f2f5; }

/* ─── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: #495057; margin-bottom: 5px; }
.form-control { width: 100%; padding: 8px 12px; border: 1px solid #ced4da; border-radius: 6px; font-size: 14px; color: #212529; background: #fff; outline: none; transition: border-color 0.15s; }
.form-control:focus { border-color: #86b7fe; box-shadow: 0 0 0 3px rgba(13,110,253,0.15); }
.form-control[disabled] { background: #e9ecef; color: #6c757d; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }
.form-hint { font-size: 12px; color: #6c757d; margin-top: 4px; display: block; }
textarea.form-control { resize: vertical; }

/* ─── Filters ─────────────────────────────────────────────────────────────── */
.filters-row form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ─── Alerts ──────────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.alert-success { background: #d1e7dd; color: #0a3622; border: 1px solid #a3cfbb; }
.alert-danger   { background: #f8d7da; color: #58151c; border: 1px solid #f1aeb5; }
.alert-warning  { background: #fff3cd; color: #664d03; border: 1px solid #ffe69c; }

/* ─── Status ──────────────────────────────────────────────────────────────── */
.status-badge { padding: 10px 16px; border-radius: 8px; font-weight: 600; display: inline-block; }
.status-ok  { background: #d1e7dd; color: #0a3622; }
.status-err { background: #fff3cd; color: #664d03; }

/* ─── Modals ──────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal-box { background: #fff; border-radius: 12px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #dee2e6; font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: #6c757d; padding: 2px 6px; }
.modal-close:hover { color: #212529; }
.modal-box form { padding: 20px; }
.modal-body { padding: 20px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; padding-top: 8px; }

/* ─── Code block ──────────────────────────────────────────────────────────── */
.code-block { background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 6px; padding: 12px 16px; font-size: 13px; overflow-x: auto; white-space: pre; }

/* ─── Utility ─────────────────────────────────────────────────────────────── */
.d-flex      { display: flex; }
.flex-wrap   { flex-wrap: wrap; }
.flex-1      { flex: 1; }
.gap-2       { gap: 8px; }
.ms-auto     { margin-left: auto; }
.mt-4        { margin-top: 20px; }
.text-center { text-align: center; }
.text-muted  { color: #6c757d; }
.text-danger { color: #dc3545; }
.align-items-end { align-items: flex-end; }
p.text-muted { margin-bottom: 8px; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .admin-sidebar { width: 56px; }
  .sidebar-label { display: none; }
  .admin-main { padding: 14px; }
  .stats-grid, .plans-grid { grid-template-columns: 1fr 1fr; }
}
