:root {
  --bg: #0a0b0e;
  --surface: #16171c;
  --surface-2: #1e2026;
  --surface-3: #26282f;
  --border: #2c2e36;
  --text: #f1f1f3;
  --text-muted: #9a9ba3;
  --text-faint: #6b6c74;
  --accent: #f1f1f3;
  --accent-contrast: #0a0b0e;
  --danger: #e5484d;
  --danger-bg: #2a1616;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
}

img { max-width: 100%; display: block; }

.icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex-shrink: 0;
}
.icon-xl { width: 48px; height: 48px; }

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(10, 11, 14, 0.9);
  backdrop-filter: blur(10px);
  z-index: 20;
  gap: 16px;
  flex-wrap: wrap;
}

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

.brand-logo {
  width: 42px;
  height: 42px;
  color: var(--text);
}

.brand-text h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
}
.admin-badge .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #6bd08a;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-2); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { opacity: 0.9; }

.btn-link {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 6px 4px;
  text-decoration: underline;
}

.btn-block { width: 100%; }

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- Layout ---------- */

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 32px 100px;
}

.toolbar {
  margin-bottom: 22px;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 10px 18px;
  max-width: 420px;
  color: var(--text-muted);
}
.search-wrap input {
  border: none;
  background: transparent;
  outline: none;
  color: var(--text);
  font-size: 14px;
  width: 100%;
}
.search-wrap .icon { color: var(--text-faint); }

/* ---------- App grid & cards ---------- */

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
}

.app-card-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.app-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  color: var(--text-muted);
  overflow: hidden;
  flex-shrink: 0;
}
.app-icon img { width: 100%; height: 100%; object-fit: cover; }

.app-info h3 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
}

.app-info p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.app-meta {
  font-size: 12px;
  color: var(--text-faint);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.app-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  flex-wrap: wrap;
}

.app-actions .btn { flex: 1; }
.app-actions .icon-btn-square {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex: none;
}
.app-actions .icon-btn-square:hover { color: var(--text); background: var(--surface-3); }
.app-actions .icon-btn-square.danger:hover { color: var(--danger); }

.admin-row {
  display: flex;
  gap: 8px;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}

/* ---------- Empty state ---------- */

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.empty-state .icon-xl { margin: 0 auto 14px; color: var(--text-faint); }
.empty-state h3 { margin: 0 0 6px; color: var(--text); }

/* ---------- FAB ---------- */

.fab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 30;
}
.fab .icon { width: 24px; height: 24px; }
.fab:hover { transform: scale(1.05); }
.fab[hidden] { display: none; }

/* ---------- Modals ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-narrow { max-width: 380px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 17px; }

.modal-body { padding: 22px; }

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 14px 0 6px;
}
.field-label:first-child { margin-top: 0; }

.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
.input:focus { border-color: var(--text-muted); }
textarea.input { resize: vertical; }

.muted { color: var(--text-muted); font-size: 14px; margin: 0 0 14px; }
.small { font-size: 12px; }

.form-msg {
  min-height: 18px;
  font-size: 13px;
  margin: 10px 0 0;
  color: var(--danger);
}
.form-msg.success { color: #6bd08a; }

.btn-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

.qr-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.qr-image {
  width: 220px;
  height: 220px;
  background: #fff;
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 12px;
}
.link-row {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-top: 6px;
}
.link-row .input { text-overflow: ellipsis; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow);
  font-size: 13px;
  z-index: 100;
}

/* ---------- Responsive ---------- */

@media (max-width: 560px) {
  .topbar { padding: 16px 18px; }
  .container { padding: 20px 18px 100px; }
  .brand-text p { display: none; }
}
