*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --bg: #f0f4f8;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 48px 20px;
}

.container-wide {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px;
}

.header {
  text-align: center;
  margin-bottom: 40px;
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.875rem;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--bg);
}

.footer-link {
  text-align: center;
  margin-top: 24px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.2);
  width: 100%;
  max-width: 440px;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1.125rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 4px;
}

.modal-body {
  padding: 24px;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.result-item:last-child {
  border-bottom: none;
}

.result-label {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.result-value {
  font-weight: 600;
  font-size: 0.95rem;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-true {
  background: #dcfce7;
  color: var(--success);
}

.badge-false {
  background: #fee2e2;
  color: var(--danger);
}

.badge-active {
  background: #dcfce7;
  color: var(--success);
}

.badge-inactive {
  background: #fef3c7;
  color: var(--warning);
}

/* Admin */
.admin-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.admin-nav h1 {
  font-size: 1.5rem;
}

.admin-nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-user {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.section {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.section h2 {
  font-size: 1.125rem;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.add-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

@media (max-width: 640px) {
  .add-form {
    grid-template-columns: 1fr;
  }
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

tbody td {
  padding: 12px;
  border-top: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover {
  background: #f8fafc;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.toast {
  position: fixed;
  top: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: 8px;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 2000;
  animation: fadeIn 0.3s ease;
  max-width: 320px;
}

.toast-success {
  background: var(--success);
}

.toast-error {
  background: var(--danger);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.error-msg {
  color: var(--danger);
  font-size: 0.875rem;
  margin-top: 8px;
  display: none;
}

.error-msg.show {
  display: block;
}

.hidden {
  display: none !important;
}
