/* CSS 变量由 app-theme.css 统一管理（浅色/深色主题切换），
   此处仅放置页面级组件样式 */

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.65;
  position: relative;
  overflow-x: hidden;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  position: relative;
  z-index: 1;
}

#loginView,
#mainView {
  position: relative;
  z-index: 1;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-lg {
  width: 22px;
  height: 22px;
}

.btn .icon {
  width: 16px;
  height: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand.centered {
  flex-direction: column;
  text-align: center;
  gap: 12px;
}

.brand.centered .brand-text {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--accent-gradient);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
}

.brand-icon.lg {
  width: 56px;
  height: 56px;
  border-radius: 18px;
}

.brand-icon.sm {
  width: 36px;
  height: 36px;
  border-radius: 12px;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 2.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: var(--aurora-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
}

.reveal {
  animation: riseIn 0.6s ease both;
  animation-delay: var(--delay, 0ms);
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Login View */
#loginView {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: 40px 16px;
}

.login-card {
  background: var(--bg-card);
  padding: 48px 40px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  max-width: 420px;
  width: 100%;
  text-align: center;
  backdrop-filter: none;
  position: relative;
  overflow: hidden;
}


.login-title {
  font-family: var(--font-serif);
  font-size: 1.85rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.login-subtitle {
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-size: 0.95rem;
}

/* Main View */
#mainView {
  display: none;
}

/* Header */
.header {
  margin-bottom: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 20px 26px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  backdrop-filter: none;
  position: relative;
  overflow: hidden;
}

.header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-primary);
  opacity: 0.4;
}

.header-left .brand-title {
  font-size: 1.85rem;
}

.header-left .brand-subtitle {
  font-size: 0.98rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  backdrop-filter: none;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: none;
}

.card>* {
  position: relative;
  z-index: 1;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.card-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* Status Section */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.status-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.status-indicator {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  position: relative;
  background: rgba(217, 119, 6, 0.08);
  color: var(--accent-primary);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.status-indicator.running {
  background: rgba(31, 122, 77, 0.14);
  color: var(--success);
  box-shadow: none;
}

.status-indicator.stopped {
  background: rgba(180, 35, 24, 0.12);
  color: var(--danger);
  box-shadow: none;
}

.status-indicator.info {
  background: rgba(217, 119, 6, 0.12);
  color: var(--accent-primary);
}

.status-indicator.accent {
  background: rgba(241, 179, 117, 0.2);
  color: var(--accent-secondary);
}

.status-info h3 {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-info p {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Buttons */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: #ffffff;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  min-height: 44px;
}

.btn:hover {
  border-color: rgba(217, 119, 6, 0.4);
  transform: none;
  box-shadow: var(--shadow-sm);
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.25);
}

.btn-primary {
  background: var(--aurora-gradient);
  border-color: transparent;
  color: white;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn-primary:hover::before {
  opacity: 1;
}

.btn-primary:hover {
  box-shadow: var(--shadow-md);
  transform: none;
  animation: none;
}

.btn-success {
  background: #1F7A4D;
  border-color: transparent;
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-success:hover {
  box-shadow: var(--shadow-md);
}

.btn-danger {
  background: #B42318;
  border-color: transparent;
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-danger:hover {
  box-shadow: var(--shadow-md);
}

/* Inputs */
.input-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.input-wrapper {
  flex: 1;
  min-width: 180px;
}

.input-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-family: inherit;
  transition: all var(--transition-fast);
  min-height: 44px;
}

input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: rgba(217, 119, 6, 0.55);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.2);
  background: var(--bg-secondary);
}

input[type="text"]::placeholder,
input[type="password"]::placeholder {
  color: var(--text-muted);
}

select {
  padding: 10px 14px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 44px;
}

select:focus {
  outline: none;
  border-color: rgba(217, 119, 6, 0.55);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.2);
}

/* Checkbox */
.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 0;
}

.checkbox-wrapper input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.checkbox-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Log Panel */
.log-container {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.log-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-primary);
  opacity: 0.25;
}

.log-content {
  padding: 16px;
  max-height: 400px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
}

.log-content::-webkit-scrollbar {
  width: 6px;
}

.log-content::-webkit-scrollbar-track {
  background: transparent;
}

.log-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

/* Section Headers */
.section-header {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 24px 0 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-header::before {
  content: '';
  width: 4px;
  height: 18px;
  background: var(--accent-gradient);
  border-radius: 2px;
}

/* Account Rows */
.account-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.account-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 248, 240, 0.94));
  border: 1px solid var(--border-color);
  border-radius: 12px;
}

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  align-items: start;
}

.mapping-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mapping-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

@media (max-width: 600px) {
  .account-row {
    grid-template-columns: 1fr;
  }
}

/* Form Grid */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  padding: 14px 20px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  color: var(--text-primary);
  font-size: 0.9rem;
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  box-shadow: var(--shadow-sm);
}

.toast-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(120, 95, 75, 0.2);
}

.toast.success {
  border-left: 4px solid var(--success);
  background: rgba(31, 122, 77, 0.08);
}

.toast.error {
  border-left: 4px solid var(--danger);
  background: rgba(180, 35, 24, 0.08);
}

.toast.info {
  border-left: 4px solid var(--accent-primary);
  background: rgba(217, 119, 6, 0.08);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 12, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  backdrop-filter: none;
}

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

.modal {
  width: 100%;
  max-width: 1200px;
  max-height: 85vh;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.35s ease;
  box-shadow: var(--shadow-md);
  backdrop-filter: none;
}

@keyframes modalIn {
  from {
    transform: scale(0.9) translateY(20px);
    opacity: 0;
  }

  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 16px;
  position: relative;
}

.modal-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-primary);
  opacity: 0.35;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 1.18rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

/* Table */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: #ffffff;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.85rem;
  min-width: 800px;
}

.data-table th {
  text-align: left;
  padding: 14px 16px;
  background: rgba(217, 119, 6, 0.08);
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 2px solid var(--border-color);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(120, 95, 75, 0.18);
  color: var(--text-primary);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table tbody tr {
  transition: all var(--transition-fast);
  position: relative;
}

.data-table tbody tr::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--aurora-gradient);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.data-table tbody tr:hover {
  background: rgba(217, 119, 6, 0.06);
}

.data-table tbody tr:hover::before {
  opacity: 1;
}

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

.status-badge {
  display: inline-flex;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge.authorized {
  background: linear-gradient(135deg, rgba(31, 122, 77, 0.2), rgba(63, 169, 107, 0.2));
  color: var(--success);
}

.status-badge.expired {
  background: linear-gradient(135deg, rgba(180, 35, 24, 0.18), rgba(220, 38, 38, 0.18));
  color: var(--danger);
}

.status-badge.pending {
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.2), rgba(241, 179, 117, 0.2));
  color: var(--warning);
}

.status-badge.unauthorized {
  background: rgba(120, 95, 75, 0.16);
  color: #7A6F66;
}

.status-badge.none {
  background: transparent;
  color: #9ca3af;
  border: 1px dashed rgba(120, 95, 75, 0.45);
}

.cache-meta {
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Stat Chip */
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.stat-chip.success {
  background: linear-gradient(135deg, rgba(31, 122, 77, 0.18), rgba(63, 169, 107, 0.2));
  border-color: rgba(31, 122, 77, 0.4);
  color: var(--success);
}

.stat-chip.error {
  background: linear-gradient(135deg, rgba(180, 35, 24, 0.18), rgba(220, 38, 38, 0.18));
  border-color: rgba(180, 35, 24, 0.45);
  color: var(--danger);
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 24px 16px 60px;
  }

  .header {
    padding: 16px 18px;
  }

  .header-left .brand-title {
    font-size: 1.6rem;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .btn-group {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .modal-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal-controls {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Cell content truncation for long text */
.cell-truncate {
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-id {
  font-family: 'Fira Code', 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
