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

:root {
  --bg: #ffffff;
  --bg-secondary: #f8f9fb;
  --bg-sidebar: #f8f9fb;
  --bg-card: #ffffff;
  --bg-hover: #f1f3f7;
  --border: #e2e5ea;
  --border-light: #eef0f4;
  --text: #1a1d26;
  --text-secondary: #4a5064;
  --text-muted: #7c829a;
  --accent: #1a56db;
  --accent-hover: #1648b8;
  --accent-soft: #eef2ff;
  --accent-border: #c7d7fe;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #059669;
  --success-soft: #ecfdf5;
  --warning-soft: #fffbeb;
  --warning: #d97706;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
  --transition: 150ms ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

/* ── Top Header ── */

.top-header {
  height: 56px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.top-header-brand .logo {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.5px;
}

.top-header-brand h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
}

.top-header-brand h1 span {
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 6px;
  padding-left: 8px;
  border-left: 1px solid var(--border);
}

.top-header-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.top-header-nav a {
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: all var(--transition);
  font-weight: 500;
}

.top-header-nav a:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.top-header-nav .user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  padding: 5px 12px 5px 8px;
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-left: 4px;
}

.top-header-nav .user-pill .avatar {
  width: 22px;
  height: 22px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
}

.top-header-nav .user-pill strong {
  color: var(--text);
  font-weight: 500;
}

.top-header-nav .divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

/* ── Layout ── */

.layout {
  display: flex;
  min-height: calc(100vh - 56px);
}

.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}

.sidebar-label {
  padding: 0 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.sidebar-nav {
  flex: 1;
  padding: 0 12px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 450;
  transition: all var(--transition);
  margin-bottom: 1px;
}

.sidebar-nav a:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.sidebar-nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 550;
}

.sidebar-nav .lock-icon {
  font-size: 10px;
  opacity: 0.4;
}

.sidebar-footer {
  padding: 16px 20px 0;
  border-top: 1px solid var(--border-light);
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Main Content ── */

.main-content {
  flex: 1;
  padding: 40px 56px 80px;
  max-width: 860px;
}

.page-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
  margin-bottom: 6px;
}

.page-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 32px;
  line-height: 1.6;
}

.page-subtitle a { font-weight: 500; }

/* ── Wiki Content ── */

.wiki-content h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
  letter-spacing: -0.3px;
}

.wiki-content h3 {
  font-size: 17px;
  font-weight: 600;
  margin-top: 36px;
  margin-bottom: 10px;
  color: var(--text);
  letter-spacing: -0.1px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.wiki-content p {
  margin-bottom: 14px;
  color: var(--text-secondary);
  font-size: 14.5px;
  line-height: 1.75;
}

.wiki-content ul, .wiki-content ol {
  margin: 0 0 16px 20px;
  color: var(--text-secondary);
  font-size: 14.5px;
}

.wiki-content li {
  margin-bottom: 6px;
  line-height: 1.7;
}

.wiki-content li strong {
  color: var(--text);
  font-weight: 600;
}

.wiki-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 24px;
  font-size: 13.5px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.wiki-content table th,
.wiki-content table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  text-align: left;
}

.wiki-content table th {
  background: var(--bg-secondary);
  color: var(--text);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.wiki-content table td {
  color: var(--text-secondary);
}

.wiki-content table tr:last-child td {
  border-bottom: none;
}

.wiki-content table td strong {
  color: var(--text);
}

.wiki-content em {
  color: var(--text-muted);
}

/* ── Page List Cards ── */

.page-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}

.page-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: all var(--transition);
  color: var(--text);
  font-weight: 500;
  font-size: 14px;
}

.page-card:hover {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: var(--shadow);
}

.page-card .card-icon {
  width: 36px;
  height: 36px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.page-card:hover .card-icon {
  background: rgba(26, 86, 219, 0.1);
}

.page-card .card-body { flex: 1; }

.page-card .card-title { font-weight: 500; font-size: 14px; }

.page-card .card-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 1px;
}

.page-card:hover .card-meta { color: var(--accent); opacity: 0.7; }

/* ── Info Banner ── */

.info-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-lg);
  margin-bottom: 28px;
  font-size: 13.5px;
  color: var(--accent);
  line-height: 1.6;
}

.info-banner .banner-icon {
  font-size: 16px;
  margin-top: 1px;
  flex-shrink: 0;
}

.info-banner a { font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

/* ── Auth Pages ── */

.auth-page {
  display: flex;
  min-height: 100vh;
}

.auth-panel-left {
  flex: 1;
  background: var(--accent);
  background: linear-gradient(135deg, #1a56db 0%, #1e40af 50%, #1e3a8a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  position: relative;
  overflow: hidden;
}

.auth-panel-left::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 80%;
  height: 200%;
  background: rgba(255,255,255,0.03);
  border-radius: 50%;
}

.auth-panel-left::after {
  content: '';
  position: absolute;
  bottom: -40%;
  left: -20%;
  width: 60%;
  height: 150%;
  background: rgba(255,255,255,0.02);
  border-radius: 50%;
}

.auth-branding {
  position: relative;
  z-index: 1;
  color: #fff;
  max-width: 360px;
}

.auth-branding .logo-lg {
  width: 44px;
  height: 44px;
  background: rgba(255,255,255,0.15);
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 28px;
  backdrop-filter: blur(4px);
}

.auth-branding h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

.auth-branding p {
  font-size: 15px;
  opacity: 0.75;
  line-height: 1.7;
}

.auth-panel-right {
  width: 480px;
  min-width: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
}

.auth-card h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}

.auth-card .subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
}

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 9px 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all var(--transition);
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-group input::placeholder {
  color: #b0b5c4;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.btn:hover { background: var(--accent-hover); color: #fff; box-shadow: var(--shadow); }

.btn-full { width: 100%; }

.btn-sm { padding: 6px 14px; font-size: 13px; }

.btn-outline {
  background: var(--bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg-hover); color: var(--text); box-shadow: none; }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }

.error-msg {
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 18px;
  line-height: 1.5;
}

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

.auth-footer a { font-weight: 500; }

/* ── Admin ── */

.flash-msg {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 24px;
  line-height: 1.5;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 36px;
}

.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.invite-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.invite-desc {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.6;
}

.invite-form-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.admin-section {
  margin-bottom: 40px;
}

.admin-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  letter-spacing: -0.1px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.admin-table th, .admin-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.admin-table th {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-table td {
  color: var(--text-secondary);
}

.admin-table td strong {
  color: var(--text);
  font-weight: 600;
}

.admin-table tr:last-child td { border-bottom: none; }

.admin-table code {
  background: var(--bg-secondary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.code-badge {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.badge-used, .code-badge.badge-used {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
}

.badge-active {
  background: var(--success-soft);
  color: var(--success);
}

.badge-neutral {
  background: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1;
}

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

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.inline-form label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.inline-form input {
  padding: 6px 10px;
  width: 72px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.inline-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ── 404 ── */

.not-found {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  background: var(--bg-secondary);
}

.not-found h1 {
  font-size: 80px;
  color: var(--border);
  font-weight: 700;
  letter-spacing: -2px;
}

.not-found p {
  color: var(--text-muted);
  margin: 8px 0 28px;
  font-size: 15px;
}

/* ── Responsive ── */

@media (max-width: 900px) {
  .auth-panel-left { display: none; }
  .auth-panel-right { width: 100%; min-width: 100%; }
}

@media (max-width: 768px) {
  .top-header { padding: 0 16px; }
  .top-header-brand h1 span { display: none; }

  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    min-width: 100%;
    height: auto;
    position: relative;
    top: 0;
    border-right: none;
    border-bottom: 1px solid var(--border-light);
    padding: 12px 0;
  }
  .sidebar-label { display: none; }
  .sidebar-nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 12px; }
  .sidebar-nav a { padding: 6px 10px; font-size: 13px; }
  .sidebar-footer { display: none; }
  .main-content { padding: 24px 16px 60px; }

  .page-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .invite-form-row { flex-direction: column; }
}
