:root {
  --bg: #0a0b0d;
  --bg2: #111318;
  --bg3: #181c24;
  --card: #13161e;
  --accent: #00e5a0;
  --accent2: #00b37a;
  --text: #f0f2f5;
  --muted: #6b7280;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #00e5a0;
  --info: #3b82f6;
  --sidebar-w: 240px;
  --mono: 'Space Mono', monospace;
  --sans: 'DM Sans', sans-serif;
  --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── AUTH ─────────────────────────────────────────────── */
.auth-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1.5rem;
  background: radial-gradient(ellipse at 50% 0%, rgba(0,229,160,0.06) 0%, transparent 60%), var(--bg);
}
.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%; max-width: 400px;
}
.auth-logo {
  font-family: var(--mono);
  font-size: 1rem;
  color: var(--accent);
  margin-bottom: 1.5rem;
  text-align: center;
}
.auth-logo span.logo-accent { color: var(--accent); }
.auth-card h1 {
  font-family: var(--mono);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  letter-spacing: -0.03em;
}
.auth-switch {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 0.875rem;
  color: var(--muted);
}
.auth-switch a { color: var(--accent); text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }
.divider {
  display: flex; align-items: center; gap: 1rem;
  margin: 1.25rem 0; color: var(--muted); font-size: 0.8rem;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── FORMS ────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block; font-size: 0.82rem; font-weight: 500;
  color: var(--muted); margin-bottom: 0.4rem; letter-spacing: 0.02em;
}
.form-group input, .form-input {
  width: 100%; padding: 0.7rem 0.9rem;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-family: var(--sans); font-size: 0.9rem;
  transition: border-color 0.15s;
  outline: none;
}
.form-group input:focus, .form-input:focus {
  border-color: var(--accent);
}
.form-group input::placeholder, .form-input::placeholder { color: var(--muted); }

/* ── BUTTONS ──────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.65rem 1.25rem; border-radius: var(--radius);
  font-family: var(--sans); font-weight: 700; font-size: 0.875rem;
  cursor: pointer; border: none; text-decoration: none;
  transition: all 0.15s; white-space: nowrap;
}
.btn-full { width: 100%; }
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: #00ffb0; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,229,160,0.25); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--border2); background: var(--bg2); }
.btn-danger { background: rgba(239,68,68,0.12); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.btn-success { background: rgba(0,229,160,0.12); color: var(--accent); border: 1px solid rgba(0,229,160,0.2); }
.btn-success:hover { background: rgba(0,229,160,0.2); }
.btn-google {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); gap: 0.6rem;
}
.btn-google:hover { border-color: var(--border2); background: var(--bg2); }
.btn-xs { padding: 0.3rem 0.7rem; font-size: 0.78rem; border-radius: 6px; }
.btn-icon {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 0.8rem; padding: 0.2rem 0.4rem;
  border-radius: 4px; transition: all 0.15s;
}
.btn-icon.btn-danger { color: var(--danger); }
.btn-icon:hover { background: var(--bg3); }

/* ── ALERTS ───────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem; border-radius: var(--radius);
  font-size: 0.875rem; margin-bottom: 1rem;
}
.alert-danger {
  background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2);
  color: #fca5a5;
}

/* ── LAYOUT ───────────────────────────────────────────── */
.dashboard-layout {
  display: flex; min-height: 100vh;
}

/* ── SIDEBAR ──────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 50;
}
.sidebar-logo {
  font-family: var(--mono); font-size: 0.9rem;
  color: var(--text); padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}
.logo-accent { color: var(--accent); }
.sidebar-nav {
  flex: 1; padding: 0.75rem 0.75rem;
  display: flex; flex-direction: column; gap: 2px;
}
.nav-link {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.75rem; border-radius: 8px;
  color: var(--muted); font-size: 0.875rem; font-weight: 500;
  text-decoration: none; transition: all 0.15s;
}
.nav-link:hover { background: var(--bg3); color: var(--text); }
.nav-link.active { background: rgba(0,229,160,0.1); color: var(--accent); }
.nav-icon { font-size: 1rem; width: 18px; text-align: center; }
.sidebar-user {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.75rem 1rem; border-top: 1px solid var(--border);
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(0,229,160,0.2); color: var(--accent);
  font-family: var(--mono); font-size: 0.8rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.admin-avatar { background: rgba(139,92,246,0.2); color: #a78bfa; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.8rem; font-weight: 700; color: var(--text); truncate: ellipsis; overflow: hidden; white-space: nowrap; }
.user-email { font-size: 0.72rem; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.logout-btn { color: var(--muted); text-decoration: none; font-size: 1rem; padding: 0.25rem; transition: color 0.15s; }
.logout-btn:hover { color: var(--danger); }

/* ── MAIN CONTENT ─────────────────────────────────────── */
.main-content {
  flex: 1; margin-left: var(--sidebar-w);
  padding: 2rem; max-width: calc(100vw - var(--sidebar-w));
  overflow-x: hidden;
}
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap;
}
.page-title {
  font-family: var(--mono); font-size: 1.5rem; font-weight: 700;
  letter-spacing: -0.03em; line-height: 1.2;
}
.page-sub { color: var(--muted); font-size: 0.875rem; margin-top: 0.25rem; }
.section-title {
  font-family: var(--mono); font-size: 1rem; font-weight: 700;
  margin-bottom: 1rem; letter-spacing: -0.02em;
}
.section-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem;
}
.link-all { font-size: 0.8rem; color: var(--accent); text-decoration: none; }
.link-all:hover { text-decoration: underline; }

/* ── STATS GRID ───────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem; margin-bottom: 2rem;
}
.stats-grid-wide { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
}
.stat-label { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-family: var(--mono); font-size: 1.75rem; font-weight: 700; color: var(--text); }
.stat-value.accent { color: var(--accent); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger { color: var(--danger); }

/* ── LICENSE CARDS ────────────────────────────────────── */
.license-list { display: flex; flex-direction: column; gap: 1rem; }
.license-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.5rem;
}
.license-card.expired { opacity: 0.7; border-style: dashed; }
.license-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.license-key-wrap { display: flex; align-items: center; gap: 0.5rem; }
.license-key {
  font-family: var(--mono); font-size: 0.8rem; color: var(--accent);
  background: rgba(0,229,160,0.07); border: 1px solid rgba(0,229,160,0.15);
  padding: 0.3rem 0.6rem; border-radius: 6px;
}
.copy-btn {
  background: none; border: none; cursor: pointer;
  font-size: 0.85rem; padding: 0.25rem; border-radius: 4px;
  transition: background 0.15s;
}
.copy-btn:hover { background: var(--bg3); }
.license-badges { display: flex; gap: 0.4rem; align-items: center; }
.license-meta-row {
  display: flex; gap: 1.5rem; flex-wrap: wrap;
  font-size: 0.8rem; color: var(--muted); margin-bottom: 1.25rem;
}
.license-meta-row strong { color: var(--text); }
.days-left { color: var(--accent); font-weight: 700; }
.days-left.warning { color: var(--warning); }
.devices-section { border-top: 1px solid var(--border); padding-top: 1rem; }
.devices-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem;
}
.devices-title { font-size: 0.8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.device-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0; border-bottom: 1px solid var(--border);
}
.device-row:last-child { border-bottom: none; }
.device-icon { font-size: 1.1rem; }
.device-info { flex: 1; }
.device-name { font-size: 0.875rem; font-weight: 500; }
.device-meta { font-size: 0.75rem; color: var(--muted); margin-top: 1px; }
.no-devices { font-size: 0.875rem; color: var(--muted); padding: 0.5rem 0; }

/* ── EMPTY STATE ──────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 4rem 2rem;
  background: var(--card); border: 1px dashed var(--border2);
  border-radius: 12px;
}
.empty-icon { font-size: 2.5rem; margin-bottom: 1rem; }
.empty-state h3 { font-family: var(--mono); margin-bottom: 0.5rem; }
.empty-state p { color: var(--muted); margin-bottom: 1.5rem; font-size: 0.9rem; }

/* ── BADGES ───────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 0.2rem 0.6rem;
  border-radius: 100px; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.03em;
}
.badge-success { background: rgba(0,229,160,0.12); color: var(--accent); border: 1px solid rgba(0,229,160,0.2); }
.badge-danger { background: rgba(239,68,68,0.12); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.badge-warning { background: rgba(245,158,11,0.12); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }
.badge-muted { background: var(--bg3); color: var(--muted); border: 1px solid var(--border); }
.badge-blue { background: rgba(59,130,246,0.12); color: #60a5fa; border: 1px solid rgba(59,130,246,0.2); }
.badge-purple { background: rgba(139,92,246,0.12); color: #a78bfa; border: 1px solid rgba(139,92,246,0.2); }

/* ── TABLE ────────────────────────────────────────────── */
.table-wrap {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; overflow-x: auto;
  margin-bottom: 1.5rem;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 0.75rem 1rem;
  font-size: 0.72rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border); background: var(--bg3);
}
.data-table td {
  padding: 0.85rem 1rem; font-size: 0.875rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.cell-primary { font-weight: 500; }
.cell-sub { font-size: 0.75rem; color: var(--muted); margin-top: 1px; }
.cell-muted { color: var(--muted); font-size: 0.82rem; }
.cell-with-avatar { display: flex; align-items: center; gap: 0.6rem; }
.mini-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(0,229,160,0.15); color: var(--accent);
  font-size: 0.72rem; font-weight: 700; font-family: var(--mono);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.key-code {
  font-family: var(--mono); font-size: 0.78rem; color: var(--accent);
  background: rgba(0,229,160,0.07); padding: 0.2rem 0.4rem; border-radius: 4px;
}
.action-btns { display: flex; gap: 0.4rem; }

/* ── SEARCH ───────────────────────────────────────────── */
.search-form { display: flex; gap: 0.5rem; align-items: center; }
.search-input {
  padding: 0.55rem 0.9rem;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-family: var(--sans); font-size: 0.875rem; outline: none;
  transition: border-color 0.15s; min-width: 240px;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--muted); }

/* ── COUNT BADGE ──────────────────────────────────────── */
.count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0,229,160,0.1); color: var(--accent);
  font-family: var(--mono); font-size: 0.75rem;
  padding: 0.1rem 0.6rem; border-radius: 100px;
  border: 1px solid rgba(0,229,160,0.2); vertical-align: middle;
  margin-left: 0.5rem;
}

/* ── PAGINATION ───────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 1rem; padding: 1rem 0;
}
.page-info { font-size: 0.82rem; color: var(--muted); }

/* ── TWO COL ──────────────────────────────────────────── */
.two-col {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1.5rem; margin-top: 1.5rem;
}

/* ── MODAL ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-box {
  background: var(--card); border: 1px solid var(--border2);
  border-radius: 14px; padding: 1.75rem; width: 100%; max-width: 400px;
}
.modal-box h3 { font-family: var(--mono); font-size: 1rem; margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.25rem; }

/* ── TOAST ────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999;
  background: var(--accent); color: #000;
  font-weight: 700; font-size: 0.875rem;
  padding: 0.75rem 1.25rem; border-radius: 8px;
  animation: slideIn 0.2s ease;
}
@keyframes slideIn {
  from { transform: translateY(1rem); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; max-width: 100vw; padding: 1rem; }
  .two-col { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .search-input { min-width: 160px; }
}

/* ── FILTER TABS ──────────────────────────────────────────── */
.filter-tabs {
  display: flex; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.filter-tab {
  padding: .35rem .85rem; border-radius: 100px; font-size: .8rem; font-weight: 500;
  text-decoration: none; color: var(--muted);
  border: 1px solid var(--border); background: transparent; transition: all .15s;
}
.filter-tab:hover { border-color: var(--border2); color: var(--text); }
.filter-tab.active { background: rgba(0,229,160,.1); color: var(--accent); border-color: rgba(0,229,160,.25); }


/* ── HEADER BUTTONS & EMPTY PLANS ────────────────────────── */
.header-btns { display: flex; gap: .5rem; flex-wrap: wrap; }
.empty-plans { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; margin-top: .5rem; }

/* ── MOBILE TOPBAR ────────────────────────────────────────── */
.mobile-topbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: 56px; padding: 0 1.25rem;
  align-items: center; justify-content: space-between;
  background: var(--bg2); border-bottom: 1px solid var(--border);
}
.mobile-menu-btn {
  background: none; border: 1px solid var(--border2);
  color: var(--text); font-size: 1.2rem;
  width: 40px; height: 40px; border-radius: 8px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.mobile-menu-btn:hover { background: var(--bg3); }

/* ── MOBILE OVERLAY ───────────────────────────────────────── */
.mobile-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 148;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
}
.mobile-overlay.visible { display: block; }

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .mobile-topbar { display: flex; }

  /* Sidebar: ascuns in stanga, z-index peste overlay */
  .sidebar {
    position: fixed !important;
    top: 0 !important; bottom: 0 !important;
    left: -280px !important;
    width: 260px !important;
    z-index: 200 !important;
    transition: left .25s cubic-bezier(.4,0,.2,1) !important;
    background: var(--bg2) !important;
    border-right: 1px solid var(--border) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow-y: auto !important;
  }
  .sidebar.mobile-open {
    left: 0 !important;
    box-shadow: 8px 0 30px rgba(0,0,0,0.5) !important;
  }

  .main-content {
    margin-left: 0 !important;
    padding: 1rem !important;
    padding-top: 68px !important;
    max-width: 100vw !important;
  }

  .page-header { flex-direction: column; align-items: flex-start; gap: .75rem; }
  .header-btns { width: 100%; }
  .header-btns .btn { flex: 1; text-align: center; justify-content: center; }

  .stats-grid { grid-template-columns: 1fr 1fr !important; }

  .license-header { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .license-key { font-size: .7rem; word-break: break-all; }
  .license-meta-row { flex-direction: column; gap: .25rem; }

  .two-col { grid-template-columns: 1fr !important; }
  .charts-row { grid-template-columns: 1fr !important; }
  .charts-row-3 { grid-template-columns: 1fr !important; }

  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 580px; }

  .filter-tabs { gap: .3rem; }
  .filter-tab { font-size: .72rem; padding: .3rem .65rem; }
  .search-form { flex-wrap: wrap; width: 100%; }
  .search-input { min-width: 0 !important; flex: 1; }
  .pagination { flex-wrap: wrap; justify-content: center; }

  /* Admin sidebar pe mobile */
  .sidebar .sidebar-nav { padding-top: 1rem; }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr !important; }
  .empty-plans { flex-direction: column; }
  .empty-plans .btn { width: 100%; justify-content: center; }
}