:root {
  --royal-purple: #6B46C1;
  --soft-violet: #9F7AEA;
  --bg-color: #F3F4F6;
  --text-main: #1F2937;
  --text-light: #6B7280;
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
}

body {
  background: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
  padding: 24px;
}

/* Login View */
#login-view {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  min-height: 100vh;
}
.login-card {
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.login-card h2 {
  color: var(--royal-purple);
  margin-bottom: 8px;
}
.subtitle {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 24px;
}
.form-group {
  margin-bottom: 16px;
  text-align: left;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--text-light);
}
input, select {
  width: 100%;
  padding: 12px;
  border: 1px solid #D1D5DB;
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
input:focus, select:focus {
  border-color: var(--royal-purple);
}
.primary-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--royal-purple), var(--soft-violet));
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}
.primary-btn:active {
  transform: scale(0.98);
}
.primary-btn:hover {
  opacity: 0.9;
}
.msg {
  margin-top: 12px;
  font-size: 0.85rem;
  min-height: 1.2rem;
}
.msg.error { color: #EF4444; }
.msg.success { color: #10B981; }

/* Dashboard */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.brand {
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--royal-purple);
}
.text-btn {
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  margin-left: 16px;
}
.text-btn:hover { color: var(--text-main); }
.dashboard-content {
  padding: 32px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}
.generate-section {
  margin-bottom: 32px;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.section-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--royal-purple);
}

/* 药丸式 Segmented Tabs */
.tabs {
  display: flex;
  background: #E5E7EB;
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}
.tab-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-light);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}
.tab-btn:hover {
  color: var(--text-main);
}
.tab-btn.active {
  background: white;
  color: var(--royal-purple);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.quick-generate-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.quick-gen-btn {
  flex: 1;
  min-width: 140px;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 1rem;
}

.table-responsive {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
}
th, td {
  padding: 16px;
  border-bottom: 1px solid #E5E7EB;
}
th {
  color: var(--text-light);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
td {
  font-size: 0.95rem;
  color: var(--text-main);
}
.badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge.new { background: #E0E7FF; color: #4338CA; }
.badge.active { background: #D1FAE5; color: #065F46; }
.badge.used { background: #F3F4F6; color: #4B5563; }
.badge.revoked { background: #FEE2E2; color: #991B1B; }

.action-btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  margin-left: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.action-btn.deliver {
  background: #ECFDF5;
  color: #059669;
}
.action-btn.deliver:hover {
  background: #D1FAE5;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.action-btn.revoke {
  background: #FEF2F2;
  color: #DC2626;
}
.action-btn.revoke:hover {
  background: #FEE2E2;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.code-text {
  font-family: 'SFMono-Regular', Consolas, monospace;
  background: #F3F4F6;
  padding: 6px 10px;
  border-radius: 6px;
  font-weight: 600;
  letter-spacing: 1px;
}

.type-badge {
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-block;
}
.type-badge.membership {
  background: #FEF3C7;
  color: #D97706;
}
.type-badge.credits {
  background: #E0F2FE;
  color: #0369A1;
}

.value-cell {
  font-size: 1.25rem !important;
  font-weight: 700;
}
.value-cell.membership, .value-cell.trial {
  color: #D97706 !important;
}
.value-cell.credits {
  color: #0369A1 !important;
}
.value-cell .unit {
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0.8;
}

@media (max-width: 768px) {
  .dashboard-content { padding: 16px; }
  .navbar { padding: 16px; }
  
  .section-header {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
  .tabs {
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 4px;
  }
  .tab-btn {
    flex-shrink: 0;
  }
  
  /* 表格转独立卡片 */
  table, thead, tbody, th, td, tr {
    display: block;
  }
  thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }
  tr {
    background: white;
    margin-bottom: 16px;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    border: 1px solid #E5E7EB;
  }
  td {
    border-bottom: 1px solid #F3F4F6;
    position: relative;
    padding: 12px 0 12px 40%;
    text-align: right;
  }
  td:last-child {
    border-bottom: none;
    padding-bottom: 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
  }
  td:last-child::before {
    top: auto;
    transform: none;
    align-self: center;
  }
  td::before {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 0;
    width: 35%;
    white-space: nowrap;
    text-align: left;
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.85rem;
  }
  td:nth-of-type(1)::before { content: "创建时间"; }
  td:nth-of-type(2)::before { content: "兑换码"; }
  td:nth-of-type(3)::before { content: "类型"; }
  td:nth-of-type(4)::before { content: "面值"; }
  td:nth-of-type(5)::before { content: "状态"; }
  td:nth-of-type(6)::before { content: "使用者"; }
  td:nth-of-type(7)::before { content: "兑换时间"; }
  td:nth-of-type(8)::before { content: "操作"; }
  
  .glass-card {
    padding: 16px;
    background: transparent;
    box-shadow: none;
    border: none;
  }
}

/* Custom Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  animation: fadeIn 0.2s forwards;
}

.modal-card {
  background: white;
  padding: 24px;
  border-radius: 16px;
  width: 90%;
  max-width: 360px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  text-align: center;
  transform: scale(0.95);
  animation: scaleUp 0.2s forwards;
}

.modal-card h3 {
  margin-top: 0;
  margin-bottom: 12px;
  color: var(--text-main);
  font-size: 1.2rem;
}

.modal-card p {
  color: var(--text-light);
  margin-bottom: 24px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.modal-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  flex: 1;
  transition: all 0.2s;
}

.modal-btn.secondary {
  background: #F3F4F6;
  color: #4B5563;
}
.modal-btn.secondary:hover {
  background: #E5E7EB;
}

.modal-btn.primary {
  background: var(--royal-purple);
  color: white;
}
.modal-btn.primary:hover {
  opacity: 0.9;
}

.modal-btn.danger {
  background: #DC2626;
  color: white;
}
.modal-btn.danger:hover {
  background: #B91C1C;
}

@keyframes fadeIn {
  to { opacity: 1; }
}
@keyframes scaleUp {
  to { transform: scale(1); }
}
