@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

:root {
  --bg:      #18181b;
  --surface: #1f1f24;
  --card:    #26262b;
  --border:  #323238;
  --orange:  #e07b2a;
  --text:    #ebebed;
  --sub:     #8c8c96;
  --dim:     #50505a;
  --green:   #3d7a58;
  --red:     #7a3d3d;
  --shadow:  0 1px 3px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.25);
  --r:       6px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Poppins', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--orange); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  font-family: 'Menlo', 'SF Mono', monospace;
  font-size: 0.82em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--sub);
}

/* Nav */
nav {
  height: 72px;
  display: flex;
  align-items: center;
  padding: 0;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 100;
}

.brand {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--orange);
}
.brand-sub {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-left: 4px;
}

.nav-links { display: flex; align-items: center; gap: 2px; margin-left: 20px; }
.nav-links a {
  color: var(--sub);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 5px;
  transition: color 0.15s, background 0.15s;
}
.nav-links a:hover { color: var(--text); background: var(--surface); text-decoration: none; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r);
  font-size: 0.82rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity 0.12s, background 0.12s;
}
.btn:hover { opacity: 0.85; text-decoration: none; }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { opacity: 1; background: color-mix(in srgb, var(--orange) 88%, #fff); }
.btn-ghost {
  background: transparent;
  color: var(--sub);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--dim); background: var(--surface); opacity: 1; }
.btn-danger { background: var(--red); color: #e0a0a0; }
.btn-danger:hover { opacity: 1; }
.btn-sm { padding: 4px 10px; font-size: 0.77rem; border-radius: 5px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* Card */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px;
  box-shadow: var(--shadow);
}

/* Layout */
.wrap      { max-width: 800px;  margin: 0 auto; padding: 0 24px; }
.wrap-wide { max-width: 1040px; margin: 0 auto; padding: 0 24px; }

.page      { max-width: 800px;  margin: 0 auto; padding: 48px 24px; }
.page-wide { max-width: 1040px; margin: 0 auto; padding: 48px 24px; }

.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 72px);
  text-align: center;
  padding: 24px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* Stat cards */
.stat-val {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Tabs */
.tab-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--sub);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  padding: 8px 14px;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.12s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--orange); font-weight: 600; }

/* Typography */
h1, h2, h3 {
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.sub   { color: var(--sub); }
.dim   { color: var(--dim); }
.mono  { font-family: 'Menlo', 'SF Mono', monospace; font-size: 0.85em; }
.small { font-size: 0.8rem; }
.label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

/* Dividers */
.divider { height: 1px; background: var(--border); margin: 18px 0; }
hr { border: none; border-top: 1px solid var(--border); }

/* Profile row */
.pfp { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.pfp img {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--surface);
  object-fit: cover;
}

/* Table */
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
th {
  text-align: left;
  padding: 8px 12px;
  color: var(--dim);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--sub); }
td:first-child { color: var(--text); font-weight: 500; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: color-mix(in srgb, var(--surface) 50%, transparent); }

/* Pagination */
.pager {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
}

/* Spinner */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Inputs */
.input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 7px 11px;
  color: var(--text);
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--orange); }
.input::placeholder { color: var(--dim); }

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2350505a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-green { background: color-mix(in srgb, var(--green) 20%, transparent); color: #5fb880; border: 1px solid color-mix(in srgb, var(--green) 35%, transparent); }
.badge-red   { background: color-mix(in srgb, var(--red) 20%, transparent);   color: #e08888; border: 1px solid color-mix(in srgb, var(--red) 35%, transparent); }
.badge-dim   { background: color-mix(in srgb, var(--dim) 15%, transparent);   color: var(--sub); border: 1px solid var(--border); }

/* Nav inner container */
.nav-inner {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Nav brand link */
a.nav-brand { display: flex; align-items: center; text-decoration: none; }
.nav-links a.active { color: var(--text); }

/* Nav user pill */
.nav-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 6px 6px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}
.nav-pill:hover { background: color-mix(in srgb, var(--surface) 80%, var(--text)); }
.nav-pill-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }

/* Nav dropdown menu */
.nav-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  min-width: 168px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  z-index: 200;
  padding: 4px;
}
.nav-menu a, .nav-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--sub);
  border-radius: 4px;
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  width: 100%;
  text-align: left;
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
}
.nav-menu a:hover, .nav-menu button:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav-menu .danger:hover { color: #e08888; background: color-mix(in srgb, var(--red) 15%, transparent); }
.nav-menu-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Admin overview tiles */
.admin-tile {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 22px 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  text-decoration: none;
  color: var(--text);
  transition: background 0.18s, box-shadow 0.18s, transform 0.18s;
  box-shadow: var(--shadow);
}
.admin-tile:hover { background: color-mix(in srgb, var(--surface) 40%, var(--card)); box-shadow: 0 8px 28px rgba(0,0,0,0.35), 0 2px 8px rgba(0,0,0,0.2); text-decoration: none; color: var(--text); transform: translateY(-2px); }
.admin-tile-icon {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  background: color-mix(in srgb, var(--orange) 12%, transparent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--orange);
}
.admin-tile-icon svg { width: 22px; height: 22px; }
.admin-tile-body { flex: 1; min-width: 0; }
.admin-tile-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; }
.admin-tile-desc  { font-size: 0.8rem; color: var(--sub); line-height: 1.55; }
.admin-tile-arrow {
  flex-shrink: 0;
  color: var(--dim);
  transition: transform 0.2s, color 0.15s;
}
.admin-tile:hover .admin-tile-arrow { transform: translateX(5px); color: var(--orange); }

/* Multi-select dropdown */
.multiselect { position: relative; display: inline-block; }
.multiselect-btn {
  width: 100%;
  text-align: left;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 7px 28px 7px 11px;
  color: var(--text);
  font-size: 0.82rem;
  font-family: inherit;
  transition: border-color 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2350505a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.multiselect-btn:focus { outline: none; border-color: var(--orange); }
.multiselect-btn.open { border-color: var(--orange); }
.multiselect-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 200;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  min-width: 100%;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.multiselect-dropdown::-webkit-scrollbar { width: 5px; }
.multiselect-dropdown::-webkit-scrollbar-track { background: transparent; }
.multiselect-dropdown::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.multiselect-dropdown::-webkit-scrollbar-thumb:hover { background: var(--dim); }
.multiselect-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text);
  transition: background 0.1s;
  user-select: none;
}
.multiselect-opt:hover { background: var(--surface); }
.multiselect-opt input { accent-color: var(--orange); width: 14px; height: 14px; cursor: pointer; flex-shrink: 0; }
.multiselect-empty { padding: 10px 12px; color: var(--dim); font-size: 0.82rem; }

/* Footer */
footer {
  padding: 24px;
  color: var(--dim);
  font-size: 0.76rem;
  border-top: 1px solid var(--border);
  text-align: center;
}
footer a { color: inherit; text-decoration: none; }
footer a:hover { color: inherit; text-decoration: underline; }

/* Nav hamburger + drawer (hidden on desktop, shown on mobile) */
.nav-left { display: flex; align-items: center; }
.nav-right { position: relative; display: flex; align-items: center; }
.nav-burger {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px;
  margin-right: 10px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.nav-burger:hover { background: var(--surface); }

.nav-drawer {
  display: none;
  position: fixed;
  top: 72px;
  left: 0;
  right: 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 150;
}
.nav-drawer a {
  display: block;
  color: var(--sub);
  font-size: 1rem;
  font-weight: 500;
  padding: 12px 14px;
  border-radius: 6px;
  text-decoration: none;
}
.nav-drawer a:hover, .nav-drawer a.active {
  color: var(--text);
  background: var(--surface);
  text-decoration: none;
}
.nav-drawer.open { display: flex; }

.nav-scrim {
  display: none;
  position: fixed;
  inset: 72px 0 0 0;
  background: rgba(0,0,0,0.5);
  z-index: 140;
}
.nav-scrim.open { display: block; }

/* Mobile */
@media (max-width: 760px) {
  nav { height: 64px; }
  .nav-inner { padding: 0 16px; }
  .nav-burger { display: inline-flex; }
  .nav-links { display: none; }
  .nav-drawer { top: 64px; }
  .nav-scrim { top: 64px; }

  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .page, .page-wide { padding: 28px 16px; }
  .wrap, .wrap-wide { padding: 0 16px; }
  h1 { font-size: 1.75rem !important; }
  h2 { font-size: 1.15rem !important; }

  .card { padding: 16px; }
  table { font-size: 0.82rem; }
  th, td { padding: 8px 6px; }

  .input, select.input, textarea.input { max-width: 100%; }

  /* scrollable tabs */
  .tab-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 14px;
  }
  .tab-nav::-webkit-scrollbar { display: none; }
  .tab-nav { scrollbar-width: none; }
  .tab-btn { flex-shrink: 0; white-space: nowrap; padding: 8px 12px; }

  /* save bar goes full width */
  #save-bar {
    left: 12px !important;
    right: 12px !important;
    bottom: 12px !important;
    justify-content: space-between;
  }

  .admin-tile { padding: 16px; gap: 14px; }
  .admin-tile-icon { width: 40px; height: 40px; }
  .profile-actions { flex-direction: column; }
  .status-bar-row .slot { min-width: 0; }
}

@media (max-width: 480px) {
  .nav-pill span { display: none; }
  .nav-pill { padding: 4px 6px 4px 4px; }

  .card { padding: 14px; }
  .tab-btn { font-size: 0.82rem; padding: 8px 10px; }
}
