:root {
  /* Light theme */
  --bg: #f5f7fb;
  --card: #ffffff;
  --muted: #6b7280;
  --text: #111827;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --danger: #dc2626;
  --ring: rgba(37, 99, 235, 0.25);
  --border: #e5e7eb;
  --shadow: 0 10px 25px rgba(0,0,0,0.08);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica Neue, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: radial-gradient(1200px 800px at 10% 10%, #ffffff 0%, var(--bg) 60%),
              radial-gradient(800px 600px at 90% 20%, #eef2ff 0%, transparent 50%),
              linear-gradient(180deg, #f8fafc, var(--bg));
  display: grid;
  place-items: center;
  padding: 24px;
}
.container {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(4px);
}
.header {
  padding: 24px 24px 8px;
  text-align: center;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  background: #f3f4f6;
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 999px;
}
.title {
  margin: 14px 0 6px;
  font-size: 20px;
  letter-spacing: 0.4px;
  color: var(--text);
  font-weight: 650;
}
.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
form { padding: 20px 24px 24px; }
.field { margin: 14px 0; }
label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.input {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
}
.input input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
}
.input button.icon-btn {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0 2px;
  line-height: 0;
}
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}
.remember {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  user-select: none;
  cursor: pointer;
}
.btn {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .05s ease, box-shadow .15s ease, background .2s ease;
}
.btn-primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-600));
  color: white;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.25);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { transform: translateY(1px); }

.footer {
  padding: 14px 24px 22px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--border);
  background: #fafafa;
}
.error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* Dashboard layout */
body.dashboard {
  display: block;
  padding: 0;
}
.dash-shell {
  width: 90vw;
  max-width: none;
  margin: 0;
  padding: 24px 48px 40px;
}
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.dash-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.top-categories {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 24px;
  margin-bottom: 28px;
  align-items: stretch;
}
.category-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 96px;
}
.category-title { font-weight: 700; font-size: 18px; }
.category-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.category-meta { margin-top: 8px; color: var(--muted); font-size: 12px; }
.count-badge {
  display: inline-block;
  min-width: 22px;
  text-align: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e5f3ff;
  color: #075985;
  border: 1px solid #bfdbfe;
  font-weight: 600;
}
.count-badge.big { font-size: 22px; padding: 6px 12px; min-width: 34px; }

/* Links inside category cards */
.category-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.category-links a {
  text-decoration: none;
  font-size: 13px;
  color: var(--primary);
  background: #eef2ff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  line-height: 1.3;
  word-break: break-all;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.category-links a:hover {
  background: #e0e7ff;
}
.category-links a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}
.category-links .copy-btn {
  align-self: flex-start;
  margin-top: 4px;
}

/* Copy button */
.category-links .copy-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: white;
  color: #111827;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s ease, box-shadow .15s ease;
  width: fit-content;
}
.category-links .copy-btn:hover { background: #f9fafb; }
.category-links .copy-btn:active { background: #f3f4f6; }
.category-links .copy-btn.copied { background: #dcfce7; border-color: #86efac; }

/* Accents */
.category-card.gold { border-top: 4px solid #f59e0b; }
.category-card.cash { border-top: 4px solid #10b981; }
.category-card.bike { border-top: 4px solid #9333ea; }

.dash-footer { text-align:center; color: var(--muted); font-size:12px; margin-top: 24px; }

@media (max-width: 900px) {
  .top-categories { grid-template-columns: 1fr; }
}

/* User search and results */
.user-section { margin-top: 28px; }
.user-search { margin-bottom: 12px; display: flex; justify-content: center; }
.user-search input {
  width: 100%;
  max-width: 520px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
}
.user-search input:focus { box-shadow: 0 0 0 3px var(--ring); }

.user-filters { display: flex; gap: 10px; justify-content: center; margin: 10px 0 14px; }
.filter-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #111827;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.filter-btn:hover { background: #f8fafc; }
.filter-btn.active { background: #eef2ff; border-color: #c7d2fe; color: #3730a3; }

.user-results { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: auto; }
.user-table { width: 100%; min-width: 720px; border-collapse: collapse; table-layout: fixed; }
.user-table thead { background: #f8fafc; }
.user-table th, .user-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-overflow: ellipsis; overflow: hidden; white-space: nowrap; font-size: 14px; vertical-align: middle; }
.user-table th:nth-child(1), .user-table td:nth-child(1) { text-align: left; }
.user-table th:nth-child(2), .user-table td:nth-child(2) { text-align: left; }
.user-table th:nth-child(3), .user-table td:nth-child(3) { text-align: left; }
/* Filled column */
.user-table th:nth-child(4), .user-table td:nth-child(4) { text-align: left; color: #000000; white-space: nowrap; }
/* Actions column */
.user-table th:nth-child(5), .user-table td:nth-child(5) { text-align: left; width: 140px; }
.user-table tbody tr:hover { background: #f9fafb; }
.user-empty { padding: 16px; color: var(--muted); }

.user-actions { display: inline-flex; gap: 4px; justify-content: flex-start; white-space: nowrap; }
.user-actions .btn-doc, .user-actions .btn-pdf {
  appearance: none;
  border: 1px solid var(--border);
  background: white;
  color: #111827;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}
.user-actions .btn-pdf { background: #fef2f2; border-color: #fecaca; }
.user-actions .btn-doc:hover { background: #f3f4f6; }
.user-actions .btn-pdf:hover { background: #fee2e2; }

/* Screen reader only */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Mobile tweaks */
@media (max-width: 600px) {
  /* Shell and header adjustments */
  .dash-shell { width: 100vw; padding: 16px; }
  .dash-header { position: relative; flex-direction: column; align-items: stretch; gap: 10px; min-height: 48px; padding-top: 8px; }
  .dash-title { justify-content: center; padding-right: 96px; }
  .dash-title .title { font-size: 18px; }
  /* Place logout button at top-right */
  #logout { position: absolute; top: 4px; right: 8px; align-self: auto; padding: 10px 14px; font-size: 14px; }

  /* Category cards */
  .top-categories { gap: 14px; }
  .category-card { padding: 14px 16px; }
  .category-title { font-size: 16px; }
  .count-badge.big { font-size: 18px; padding: 4px 10px; min-width: 30px; }
  .category-links { gap: 6px; }
  .category-links a { word-break: break-all; }

  /* Search and filters */
  .user-search input { font-size: 16px; } /* prevent iOS zoom */
  .user-filters { flex-wrap: wrap; gap: 8px; }
  .filter-btn { padding: 6px 10px; font-size: 12px; }

  /* Results table: keep scroll but reduce min width and font sizes */
  .user-results { border-radius: 10px; }
  .user-table { min-width: 560px; }
  .user-table th, .user-table td { padding: 10px 12px; font-size: 12px; }
  .user-actions { gap: 2px; }
  .user-actions .btn-doc, .user-actions .btn-pdf { padding: 4px 6px; font-size: 11px; }
}

/* Extra small phones */
@media (max-width: 480px) {
  .dash-shell { padding: 12px; }
  .dash-title .title { font-size: 17px; }
  .badge { transform: scale(0.95); transform-origin: left center; }
  #logout { padding: 8px 12px; font-size: 13px; }

  .category-card { padding: 12px 14px; }
  .category-sub { font-size: 12px; }
  .category-meta { font-size: 11px; }
  .category-links a { word-break: break-all; }
  .category-links .copy-btn { padding: 6px 10px; font-size: 12px; }

  .user-search input { padding: 10px 10px; font-size: 16px; }
  .filter-btn { padding: 5px 10px; font-size: 12px; }

  /* Make table more compact and allow wrapping to minimize horizontal scroll */
  .user-table { min-width: 100%; table-layout: auto; }
  .user-table th, .user-table td { white-space: normal; padding: 8px 10px; font-size: 12px; }
  .user-actions { flex-wrap: wrap; gap: 4px; }
  .user-actions .btn-doc, .user-actions .btn-pdf { padding: 4px 6px; font-size: 11px; }
}
