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

:root {
  --bg: #f7f7f5;
  --white: #ffffff;
  --black: #0d0d0d;
  --border: #e4e4e0;
  --text: #111;
  --muted: #888;
  --accent: #7c3aed;
  --accent2: #059669;
  --danger: #dc2626;
  --warn: #d97706;
  --font: 'DM Sans', system-ui, sans-serif;
  --font-head: 'Syne', system-ui, sans-serif;
  --sidebar-w: 240px;
  --radius: 12px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
}

a { color: inherit; text-decoration: none; }

/* ── LOGIN ────────────────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--black);
}

.login-wrap { width: 100%; max-width: 420px; padding: 2rem; }

.login-card {
  background: var(--white);
  border-radius: 20px;
  padding: 2.5rem;
  text-align: center;
}

.login-logo {
  font-family: var(--font-head);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 1.5rem;
}

.login-title {
  font-family: var(--font-head);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.login-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 2rem; }

.login-form { text-align: left; display: flex; flex-direction: column; gap: 1rem; }

.afg { display: flex; flex-direction: column; gap: 0.35rem; }
.afg label { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.5px; color: var(--muted); text-transform: uppercase; }

.afg input, .afg textarea, .afg select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s;
}

.afg input:focus, .afg textarea:focus, .afg select:focus { border-color: var(--accent); background: var(--white); }
.afg select option { color: var(--text); }

.err-msg { color: var(--danger); font-size: 0.85rem; min-height: 1.2rem; text-align: center; }

.a-btn-primary {
  width: 100%;
  background: var(--black);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  padding: 0.85rem 1.5rem;
  font-family: var(--font-head);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.a-btn-primary:hover { background: var(--accent); }
.a-btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.login-hint { margin-top: 1.5rem; font-size: 0.78rem; color: var(--muted); }
.login-hint code { background: var(--bg); padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.82rem; }

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

/* Sidebar */
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--black);
  color: #eee;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  padding: 1.5rem 0;
}

.sidebar-logo {
  font-family: var(--font-head);
  font-size: 1.4rem;
  font-weight: 800;
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid #222;
  letter-spacing: -0.5px;
}

.sidebar-logo span { color: var(--accent); }

.sidebar-nav { flex: 1; padding: 1rem 0; display: flex; flex-direction: column; gap: 0.15rem; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.5rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: #888;
  border-left: 3px solid transparent;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
  cursor: pointer;
  border-top: none; border-right: none; border-bottom: none;
  background: none;
  font-family: var(--font);
  width: 100%;
  text-align: left;
}

.sidebar-link:hover, .sidebar-link.active {
  color: #fff;
  background: rgba(255,255,255,0.05);
  border-left-color: var(--accent);
}

.sidebar-link .icon { font-size: 1rem; width: 1.2rem; text-align: center; }

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #222;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-user { font-size: 0.78rem; color: #555; }
.sidebar-username { color: #aaa; font-weight: 600; }

.sidebar-logout {
  font-size: 0.82rem;
  color: var(--danger);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
  padding: 0;
}

.sidebar-logout:hover { text-decoration: underline; }

/* Main content */
.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: calc(100vw - var(--sidebar-w));
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.admin-title {
  font-family: var(--font-head);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.admin-subtitle { color: var(--muted); font-size: 0.85rem; margin-top: 0.15rem; }

/* ── Panels ───────────────────────────────────────────────────── */
.panel { display: none; }
.panel.active { display: block; }

/* ── Stats ────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}

.stat-card .s-num {
  font-family: var(--font-head);
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
}

.stat-card .s-label { font-size: 0.8rem; color: var(--muted); margin-top: 0.3rem; }

/* ── Table ────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.table-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.table-top h3 { font-size: 1rem; font-weight: 700; }

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

tbody tr { border-bottom: 1px solid var(--border); transition: background 0.15s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
tbody td { padding: 0.85rem 1.5rem; font-size: 0.88rem; vertical-align: middle; }

.badge {
  display: inline-block;
  padding: 0.18rem 0.6rem;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.badge-green { background: #d1fae5; color: #065f46; }
.badge-gray { background: #f3f4f6; color: #6b7280; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-blue { background: #dbeafe; color: #1e40af; }

.td-thumb {
  width: 48px; height: 36px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
  display: block;
}

.td-actions { display: flex; gap: 0.5rem; }

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text);
  font-family: var(--font);
}

.icon-btn:hover { background: var(--text); color: var(--white); border-color: var(--text); }
.icon-btn.danger:hover { background: var(--danger); border-color: var(--danger); color: var(--white); }

/* ── Buttons ──────────────────────────────────────────────────── */
.a-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}

.a-btn-sm { padding: 0.4rem 0.9rem; font-size: 0.8rem; }
.a-btn-dark { background: var(--black); color: var(--white); }
.a-btn-dark:hover { background: var(--accent); }
.a-btn-outline { background: none; border: 1px solid var(--border); color: var(--text); }
.a-btn-outline:hover { border-color: var(--black); background: var(--black); color: var(--white); }
.a-btn-danger { background: var(--danger); color: var(--white); }
.a-btn-danger:hover { opacity: 0.85; }
.a-btn-success { background: var(--accent2); color: var(--white); }
.a-btn-success:hover { opacity: 0.85; }

/* ── Modal ────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(4px);
}

.modal-backdrop.hidden { display: none; }

.modal {
  background: var(--white);
  border-radius: 20px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
}

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

.modal-title { font-family: var(--font-head); font-size: 1.2rem; font-weight: 700; }

.modal-close {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 32px; height: 32px;
  cursor: pointer;
  font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}

.modal-close:hover { background: var(--black); color: var(--white); border-color: var(--black); }

.modal-form { display: flex; flex-direction: column; gap: 1rem; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}

.upload-zone:hover, .upload-zone.drag { border-color: var(--accent); }

.upload-zone p { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }

.upload-preview {
  margin-top: 0.75rem;
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 8px;
  display: none;
}

.upload-preview.show { display: block; }

/* Range input */
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

/* Toast */
.a-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--black);
  color: var(--white);
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  font-size: 0.88rem;
  font-weight: 600;
  z-index: 9000;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.a-toast.show { opacity: 1; transform: translateY(0); }
.a-toast.success { background: var(--accent2); }
.a-toast.error { background: var(--danger); }

/* Message cards */
.msg-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: start;
}

.msg-card.unread { border-left: 3px solid var(--accent); }

.msg-name { font-weight: 700; font-size: 0.95rem; }
.msg-meta { font-size: 0.78rem; color: var(--muted); margin-top: 0.2rem; }
.msg-text { font-size: 0.9rem; color: var(--text); margin-top: 0.6rem; line-height: 1.6; }

.msg-list { display: flex; flex-direction: column; gap: 0.75rem; }

/* Skill range display */
.range-label { font-size: 0.85rem; font-weight: 700; color: var(--accent); }

/* Settings form */
.settings-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.settings-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 1.5rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--border); }

.settings-form { display: flex; flex-direction: column; gap: 1rem; }

/* View site link */
.view-site {
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.2s;
}

.view-site:hover { color: var(--text); }

@media (max-width: 768px) {
  .admin-sidebar { width: 100%; position: relative; height: auto; flex-direction: row; overflow-x: auto; }
  .admin-main { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
}
