:root {
  --bg: #070a13;
  --bg-card: #0e1526;
  --bg-card-hover: #141e36;
  --border: #1e2942;
  --border-focus: #7c5cff;
  --text: #f0f4fc;
  --text-muted: #8b9bb4;
  --primary: #8b6aff;
  --primary-glow: rgba(139, 106, 255, 0.25);
  --cyan: #38bdf8;
  --green: #10b981;
  --green-glow: rgba(16, 185, 129, 0.2);
  --amber: #f59e0b;
  --red: #f43f5e;
  --red-glow: rgba(244, 63, 94, 0.2);
  --radius: 14px;
}

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

body {
  background-color: var(--bg);
  background-image:
    radial-gradient(
      ellipse 80% 50% at 50% -20%,
      rgba(120, 80, 240, 0.15),
      transparent
    ),
    radial-gradient(
      ellipse 60% 30% at 100% 50%,
      rgba(56, 189, 248, 0.08),
      transparent
    );
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Auth View */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 30px;
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.05);
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}

.brand-badge img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(139, 106, 255, 0.4);
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff, #b4c6ef);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--primary);
  text-transform: uppercase;
}

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

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  background: #080d19;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, #8b6aff, #6a46e5);
  color: #fff;
  box-shadow: 0 4px 14px rgba(106, 70, 229, 0.4);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #9d80ff, #7853f0);
  box-shadow: 0 6px 20px rgba(106, 70, 229, 0.6);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #182239;
  color: #d1dcfa;
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #202d4b;
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 11px;
  border-radius: 8px;
}

.btn-danger-outline {
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(244, 63, 94, 0.4);
}

.btn-danger-outline:hover {
  background: var(--red-glow);
  border-color: var(--red);
}

.btn-block {
  width: 100%;
}

.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 20px;
}

.alert-error {
  background: rgba(244, 63, 94, 0.15);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fda4af;
}

.alert-success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

/* App Layout */
.app-header {
  border-bottom: 1px solid var(--border);
  background: rgba(14, 21, 38, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.header-logo img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.header-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.server-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(16, 185, 129, 0.12);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.server-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

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

.user-badge {
  font-size: 12px;
  color: var(--text-muted);
  background: #111a2e;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* Dashboard Container */
.container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 30px 24px;
}

/* Stats Row */
.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);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition:
    transform 0.2s,
    border-color 0.2s;
}

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

.stat-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--cyan));
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  color: #fff;
}

.stat-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Controls Bar */
.controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  transition: all 0.2s;
}

.filter-pill:hover,
.filter-pill.active {
  background: #202d4b;
  color: #fff;
  border-color: var(--primary);
}

.search-box {
  min-width: 260px;
  position: relative;
}

.search-box input {
  padding-left: 36px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

/* Licenses Table Card */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

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

th {
  background: #090e1c;
  padding: 14px 18px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(30, 41, 66, 0.6);
  vertical-align: middle;
}

tr:hover td {
  background: rgba(20, 30, 54, 0.6);
}

.key-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  font-weight: 700;
  color: #c4b5fd;
  background: rgba(139, 106, 255, 0.12);
  border: 1px solid rgba(139, 106, 255, 0.3);
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.key-badge:hover {
  background: rgba(139, 106, 255, 0.25);
  border-color: var(--primary);
  color: #fff;
}

.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-active {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-expired {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-revoked {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.device-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  background: #090e1c;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: #94a3b8;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-badge.unbound {
  color: #64748b;
  border-style: dashed;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(3, 6, 14, 0.75);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.6);
  padding: 28px;
  position: relative;
}

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

.modal-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

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

.close-btn:hover {
  color: #fff;
}

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

.toast {
  background: #151f38;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.toast-success {
  border-left-color: var(--green);
}
.toast.toast-error {
  border-left-color: var(--red);
}

/* Activity Logs Drawer / Section */
.logs-card {
  margin-top: 30px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.log-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(30, 41, 66, 0.4);
  font-size: 12px;
}

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

.log-time {
  color: var(--text-muted);
  min-width: 130px;
  font-family: monospace;
}

.log-action {
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: #111a2f;
  color: var(--cyan);
}

.log-details {
  color: #cbd5e1;
  flex: 1;
}
