:root {
  --primary: #2f7ef7;
  --primary-light: #6cb2ff;
  --primary-dark: #1f63d9;
  --accent: #2f7ef7;
  --accent-light: rgba(47, 126, 247, 0.12);
  --secondary: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;

  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2d3d;
  --muted: #6b7280;
  --line: #e6edf7;

  --shadow-sm: 0 2px 8px rgba(31, 61, 120, 0.05);
  --shadow: 0 6px 18px rgba(31, 61, 120, 0.06);
  --shadow-md: 0 10px 24px rgba(31, 61, 120, 0.08);
  --shadow-lg: 0 14px 32px rgba(31, 61, 120, 0.1);
  --shadow-xl: 0 20px 44px rgba(31, 61, 120, 0.12);

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;

  --space-xs: 4px;
  --space-sm: 8px;
  --space: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 30px;
  --text-4xl: 36px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

.menu-link.admin-only,
.menu-dropdown .menu-link.admin-only {
  display: none;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 16px 0px 0;
}

.topbar {
  background: #ffffff;
  color: var(--text);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(31, 61, 120, 0.04);
  border-bottom: 1px solid #eef3fa;
}

.topbar-inner {
  padding: 0 var(--space);
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
  position: relative;
}

.brand {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1;
}

.brand:hover {
  opacity: 0.8;
}

.menu {
  display: flex;
  gap: 2px;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-left: auto;
}

.menu::-webkit-scrollbar {
  display: none;
}

.menu-link {
  color: #000000;
  text-decoration: none;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all 0.2s ease;
  font-size: 16px;
  white-space: nowrap;
  flex-shrink: 0;
}

.menu-link:hover {
  color: var(--primary);
  background: rgba(47, 126, 247, 0.08);
}

.menu-link.active {
  color: #fff;
  background: var(--primary);
  font-weight: 700;
  box-shadow: 0 6px 12px rgba(47, 126, 247, 0.22);
}

.user-area {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  flex-shrink: 0;
}

.user-btn {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 999px;
  border: 1px solid #d9e3f2;
  background: #fff;
  cursor: pointer;
  color: #5f6b7a;
  transition: all 0.2s ease;
}

.user-btn:hover {
  background: #f7faff;
  color: var(--primary);
  border-color: #cfe0fb;
}

.settings-dropdown {
  position: relative;
  display: inline-flex;
}

.settings-dropdown.active {
  z-index: 10010;
}

.settings-btn {
  padding: 7px 14px;
  font-size: 13px;
  border-radius: 999px;
  border: 1px solid #d9e3f2;
  background: #fff;
  cursor: pointer;
  color: #5f6b7a;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.settings-btn:hover {
  background: #f7faff;
  color: var(--primary);
  border-color: #cfe0fb;
}

.settings-btn::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid currentColor;
  margin-left: 2px;
  transition: transform 0.2s ease;
}

.settings-dropdown.active .settings-btn::after {
  transform: rotate(180deg);
}

.settings-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 160px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  display: none;
  z-index: 10011;
  overflow: hidden;
}

.settings-dropdown.active .settings-menu {
  display: block;
}

.settings-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: var(--text-sm);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-menu-item:hover {
  background: #f7faff;
}

.settings-menu-item.danger {
  color: var(--danger);
}

.settings-menu-item .badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
}

.settings-menu-info {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.settings-menu-email {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-menu-points {
  font-size: var(--text-xs);
  color: var(--primary);
  margin-top: 2px;
  font-weight: 600;
}

.settings-menu-divider {
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

.settings-menu-section {
  padding: 6px 14px 4px;
  font-size: var(--text-xs);
  color: #64748b;
  font-weight: 700;
}

.hero {
  text-align: center;
  padding: var(--space-2xl) 0;
  margin-bottom: var(--space-xl);
}

.hero h1 {
  font-size: var(--text-4xl);
  font-weight: 800;
  margin-bottom: var(--space);
  color: var(--text);
  line-height: 1.2;
}

.hero p {
  font-size: var(--text-lg);
  color: var(--muted);
  max-width: 600px;
  margin: 0 auto;
}

.btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 20px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: var(--text-base);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  text-decoration: none;
}

.btn-compact {
  min-height: 34px;
  min-width: 64px;
  padding: 0 14px;
  font-size: 13px;
  line-height: 1;
  border-radius: 8px;
  flex-shrink: 0;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  pointer-events: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 8px 16px rgba(47, 126, 247, 0.2);
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 10px 20px rgba(47, 126, 247, 0.24);
}

.btn-secondary {
  background: #fff;
  color: #5f6b7a;
  border: 1px solid #d9e3f2;
}

.btn-secondary:hover {
  background: #f7faff;
  border-color: #cfe0fb;
  color: var(--primary);
}

.btn-refresh {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid #d9e3f2;
  background: #fff;
  color: #5f6b7a;
  box-shadow: none;
  flex-shrink: 0;
}

.btn-refresh:hover {
  background: #f7faff;
  border-color: #cfe0fb;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.btn-refresh svg {
  width: 14px;
  height: 14px;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #0da271;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: var(--space-xl);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space);
}

.panel h2 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
}

.panel-sub {
  margin: var(--space-sm) 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.panel-actions {
  display: flex;
  gap: var(--space-sm);
}

.layout {
  display: grid;
  gap: var(--space);
  margin-top: var(--space);
}

.layout-2col {
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
}

.layout-equal {
  grid-template-columns: 1fr 1fr;
}

.form-grid {
  display: grid;
  gap: var(--space);
  margin-top: var(--space);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.field-full {
  grid-column: 1 / -1;
}

label {
  font-weight: 600;
  color: var(--text);
  font-size: var(--text-sm);
}

input, textarea, select {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  background: white;
  transition: all 0.2s ease;
  width: 100%;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 126, 247, 0.12);
}

textarea {
  min-height: 120px;
  resize: vertical;
  font-family: inherit;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space);
}

table th {
  text-align: left;
  padding: 12px var(--space-sm);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  color: var(--muted);
  font-size: var(--text-xs);
  white-space: nowrap;
  background: #fafcff;
}

table td {
  padding: 12px var(--space-sm);
  border-bottom: 1px solid var(--line);
  font-size: var(--text-sm);
}

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

.toolbar {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space);
  flex-wrap: wrap;
}

.text-center {
  text-align: center;
}

.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space); }
.mt-3 { margin-top: var(--space-lg); }
.mt-4 { margin-top: var(--space-xl); }

.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space); }
.mb-3 { margin-bottom: var(--space-lg); }
.mb-4 { margin-bottom: var(--space-xl); }

.menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid #d9e3f2;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  color: #5f6b7a;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.menu-toggle:hover {
  background: #f7faff;
  color: var(--primary);
}

.menu-toggle svg {
  width: 20px;
  height: 20px;
}

.menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 180px;
  background: white;
  border: 1px solid #e6edf7;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 200;
  overflow: hidden;
}

.menu-dropdown.active {
  display: block;
}

.menu-dropdown .menu-link {
  display: block;
  padding: 10px 16px;
  font-size: 16px;
  border-radius: 0;
  color: #000000;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.15s ease;
}

.menu-dropdown .menu-link:hover {
  background: #f7faff;
  color: var(--primary);
}

.menu-dropdown .menu-link.active {
  color: #fff;
  background: var(--primary);
  font-weight: 700;
}

@media (max-width: 1024px) {
  .page {
    padding: var(--space) var(--space-lg) var(--space-2xl);
  }

  .topbar-inner {
    padding: 0 var(--space-lg);
  }

  .hero h1 {
    font-size: var(--text-3xl);
  }

  .hero p {
    font-size: var(--text-base);
  }
}

@media (max-width: 768px) {
  .page {
    padding: var(--space) var(--space) var(--space-2xl);
  }

  .topbar-inner {
    height: 64px;
    padding: 0 var(--space);
    flex-direction: row;
    align-items: center;
    gap: var(--space-sm);
  }

  .menu {
    display: none;
  }

  .menu-toggle {
    display: flex;
    margin-left: auto;
    margin-right: 15px;
  }

  .menu-dropdown {
    left: auto;
    right: 0;
  }

  .menu-link {
    padding: 8px 12px;
    font-size: 16px;
  }

   .user-area {
    flex-shrink: 0;
   }

  .hero {
    padding: var(--space-xl) 0;
  }

  .hero h1 {
    font-size: var(--text-2xl);
  }

  .hero p {
    font-size: var(--text-sm);
  }

  .panel {
    padding: var(--space);
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space);
  }

  .panel-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .layout-equal {
    grid-template-columns: 1fr;
  }

  table {
    font-size: var(--text-sm);
  }

  table th, table td {
    padding: var(--space-sm) var(--space-xs);
  }
}

@media (max-width: 480px) {
  .hero {
    padding: var(--space) 0;
  }

  .hero h1 {
    font-size: var(--text-xl);
  }

  .panel h2 {
    font-size: var(--text-lg);
  }

  .btn {
    padding: 10px 12px;
    font-size: var(--text-sm);
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media (max-width: 400px) {
  .topbar-inner {
    height: 64px;
    padding: 0 var(--space-sm);
    gap: 6px;
  }

  .brand {
    font-size: 18px;
    min-width: 0;
  }

  .user-area {
    gap: 6px;
    margin-left: auto;
  }

  .settings-btn {
    padding: 4px 8px;
    font-size: 12px;
  }
}

/* ========== Toast / Alert ========== */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10002;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast-item {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  border: 1px solid var(--line);
  font-size: var(--text-sm);
  color: var(--text);
  animation: toastIn 0.3s ease;
  min-width: 260px;
  max-width: 440px;
}

.toast-item.toast-leaving {
  animation: toastOut 0.25s ease forwards;
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
}

.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--primary); }

.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info { border-left: 3px solid var(--primary); }

.toast-close {
  margin-left: auto;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: none;
  background: transparent;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.toast-close:hover {
  color: var(--text);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-12px); }
}

/* ========== Confirm / Modal Alert ========== */
.modal-open {
  overflow: hidden;
}

.alert-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.56);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10010;
  padding: 20px;
  backdrop-filter: blur(8px);
}

.alert-modal-overlay.active {
  display: flex;
}

.alert-modal {
  position: relative;
  width: min(92vw, 430px);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 24px;
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.24);
  padding: 26px 28px 22px;
  animation: toastIn 0.22s ease;
}

.alert-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
  color: #64748b;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s ease;
}

.alert-modal-close:hover {
  background: rgba(148, 163, 184, 0.22);
  color: #0f172a;
}

.alert-modal-badge {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(59, 130, 246, 0.08));
}

.alert-modal-badge[data-variant="warning"] {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.16), rgba(251, 191, 36, 0.08));
}

.alert-modal-badge[data-variant="danger"] {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.14), rgba(248, 113, 113, 0.08));
}

.alert-modal-badge[data-variant="success"] {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.14), rgba(74, 222, 128, 0.08));
}

.alert-modal-icon {
  font-size: 34px;
  font-weight: 800;
  text-align: center;
  color: var(--primary);
}

.alert-modal[data-variant="warning"] .alert-modal-icon {
  color: var(--warning);
}

.alert-modal[data-variant="danger"] .alert-modal-icon {
  color: var(--danger);
}

.alert-modal[data-variant="success"] .alert-modal-icon {
  color: var(--success);
}

.alert-modal-title {
  text-align: center;
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 10px;
}

.alert-modal-msg {
  text-align: center;
  font-size: 15px;
  color: #475569;
  line-height: 1.7;
  margin-bottom: 20px;
  word-break: break-word;
}

.alert-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.alert-modal-actions .btn {
  min-width: 108px;
  min-height: 42px;
  border-radius: 12px;
}

@media (max-width: 640px) {
  .alert-modal {
    padding: 24px 18px 18px;
    border-radius: 20px;
  }

  .alert-modal-badge {
    width: 56px;
    height: 56px;
    border-radius: 18px;
  }

  .alert-modal-title {
    font-size: 18px;
  }

  .alert-modal-actions {
    flex-direction: column-reverse;
  }

  .alert-modal-actions .btn {
    width: 100%;
  }
}

/* ========== Password Reset Modal ========== */
.reset-pwd-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}
.reset-pwd-modal {
  background: #fff;
  border-radius: 16px;
  width: min(96%, 380px);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}
.reset-pwd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 0;
}
.reset-pwd-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.reset-pwd-close {
  background: none;
  border: 0;
  font-size: 24px;
  color: #8f9bbb;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.reset-pwd-close:hover {
  color: var(--text);
}
.reset-pwd-body {
  padding: 16px 20px 20px;
  display: grid;
  gap: 12px;
}
.reset-pwd-error {
  background: #fff3f3;
  border: 1px solid #ffd2d2;
  color: #c53f3f;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  display: none;
}
.reset-pwd-error.visible {
  display: block;
}
.pwd-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pwd-input-wrap input {
  width: 100%;
  height: 44px;
  padding: 0 40px 0 14px;
  border: 1px solid #d9e0ea;
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  background: #fff;
}
.pwd-input-wrap input:focus {
  border-color: #6a7cff;
  box-shadow: 0 0 0 3px rgba(92, 110, 248, 0.12);
}
.pwd-toggle-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 0;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 6px;
  color: #8f9bbb;
  line-height: 1;
}
.pwd-toggle-btn:hover {
  color: var(--text);
}
