:root {
  --app-bg: #eef3f9;
  --app-surface: rgba(255, 255, 255, 0.92);
  --app-surface-strong: #ffffff;
  --app-text: #162033;
  --app-text-muted: #5f6b7a;
  --app-border: rgba(18, 37, 63, 0.12);
  --app-shadow: 0 18px 50px rgba(19, 37, 63, 0.08);
  --app-shadow-soft: 0 10px 25px rgba(19, 37, 63, 0.06);
  --app-primary: #1f5eff;
  --app-primary-hover: #184bd2;
  --app-secondary: #eef3ff;
  --app-navbar-bg: rgba(255, 255, 255, 0.82);
  --app-footer-bg: rgba(255, 255, 255, 0.72);
  --app-success: #1f8f5f;
  --app-danger: #d64242;
}

body[data-theme="dark"] {
  --app-bg: #0b1220;
  --app-surface: rgba(15, 23, 42, 0.9);
  --app-surface-strong: #111a2e;
  --app-text: #e7edf7;
  --app-text-muted: #9fb0c7;
  --app-border: rgba(148, 163, 184, 0.18);
  --app-shadow: 0 18px 50px rgba(2, 6, 23, 0.45);
  --app-shadow-soft: 0 10px 25px rgba(2, 6, 23, 0.32);
  --app-primary: #7aa2ff;
  --app-primary-hover: #96b5ff;
  --app-secondary: rgba(122, 162, 255, 0.12);
  --app-navbar-bg: rgba(11, 18, 32, 0.82);
  --app-footer-bg: rgba(11, 18, 32, 0.7);
  --app-success: #49c98d;
  --app-danger: #ff7b7b;
}

body[data-theme="dark"] .app-table,
body[data-theme="dark"] .app-table tbody td,
body[data-theme="dark"] .app-table tbody th {
  color: #e7edf7;
}

body[data-theme="dark"] .app-table thead th,
body[data-theme="dark"] .app-table thead th a,
body[data-theme="dark"] .app-table thead th span.small {
  color: #d8e3f5 !important;
}

body[data-theme="dark"] .app-table tbody a,
body[data-theme="dark"] .app-table tbody .text-muted,
body[data-theme="dark"] .app-table tbody span,
body[data-theme="dark"] .app-table tbody td {
  color: #dfe7f5;
}

body[data-theme="dark"] .app-table tbody .btn-outline-secondary,
body[data-theme="dark"] .app-table tbody .btn-outline-primary {
  color: #dfe7f5;
}

html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  margin: 0;
  margin-bottom: 60px;
  background:
    radial-gradient(circle at top left, rgba(31, 94, 255, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(31, 94, 255, 0.08), transparent 24%),
    var(--app-bg);
  color: var(--app-text);
  transition: background-color 0.2s ease, color 0.2s ease;
}

body,
button,
input,
select,
textarea {
  font-family: "Segoe UI", "Microsoft JhengHei", sans-serif;
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 0.15rem rgba(31, 94, 255, 0.15), 0 0 0 0.35rem rgba(31, 94, 255, 0.12);
}

.app-shell {
  padding-bottom: 2rem;
}

.app-navbar {
  background: var(--app-navbar-bg);
  backdrop-filter: blur(14px);
  border-color: var(--app-border) !important;
}

.app-navbar .navbar-brand,
.app-navbar .nav-link,
.app-footer,
.app-footer a {
  color: var(--app-text) !important;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
}

.app-brand-logo {
  width: 2.4rem;
  height: 2.4rem;
  display: block;
}

.app-navbar-actions {
  align-items: center;
  gap: 0.5rem;
}

.app-theme-toggle {
  min-width: 6.6rem;
  border-radius: 999px;
}

.app-footer {
  background: var(--app-footer-bg);
  border-color: var(--app-border) !important;
}

.app-page {
  display: grid;
  gap: 1rem;
}

.app-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.app-eyebrow {
  margin: 0 0 0.4rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--app-primary);
}

.app-page-title,
.auth-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
}

.app-page-subtitle,
.auth-subtitle {
  margin: 0.45rem 0 0;
  color: var(--app-text-muted);
}

.app-section,
.auth-card,
.modal-content {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 1.1rem;
  box-shadow: var(--app-shadow);
}

.app-section {
  padding: 1.25rem;
}

.app-alert {
  border: 1px solid transparent;
  box-shadow: var(--app-shadow-soft);
}

.app-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem 1.25rem;
  align-items: center;
}

.app-table-shell {
  overflow: hidden;
}

.app-table {
  margin-bottom: 0;
}

.app-table thead th {
  padding-top: 1rem;
  padding-bottom: 1rem;
  color: var(--app-text-muted);
  border-bottom-color: var(--app-border);
}

.app-table tbody td,
.app-table tbody th {
  border-color: var(--app-border);
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  --bs-table-accent-bg: rgba(31, 94, 255, 0.04);
}

body[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
  --bs-table-accent-bg: rgba(122, 162, 255, 0.08);
}

.section-title {
  margin-bottom: 1rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.form-control,
.form-select,
.input-group-text {
  background-color: var(--app-surface-strong);
  border-color: var(--app-border);
  color: var(--app-text);
}

.form-control::placeholder {
  color: var(--app-text-muted);
}

.form-text,
.text-muted,
.form-label,
.form-check-label {
  color: var(--app-text-muted) !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--app-primary), var(--app-primary-hover));
  border-color: transparent;
}

.btn-outline-primary {
  color: var(--app-primary);
  border-color: rgba(31, 94, 255, 0.35);
}

.btn-outline-secondary {
  color: var(--app-text);
  border-color: var(--app-border);
}

.btn-danger {
  border-color: transparent;
}

.auth-page {
  min-height: calc(100vh - 12rem);
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(100%, 720px);
  padding: 2rem;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: var(--app-secondary);
  color: var(--app-primary);
  font-weight: 700;
}

.auth-form {
  margin-top: 1.5rem;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin: 1.5rem 0 0.75rem;
  color: var(--app-text-muted);
  font-size: 0.9rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--app-border);
}

.google-login-btn {
  font-weight: 600;
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
}

.theme-option {
  cursor: pointer;
}

.theme-option-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-option-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem;
  border-radius: 1rem;
  border: 1px solid var(--app-border);
  background: var(--app-surface-strong);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.theme-option:hover .theme-option-body {
  transform: translateY(-1px);
  box-shadow: var(--app-shadow-soft);
}

.theme-option-input:checked + .theme-option-body {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 0.2rem rgba(31, 94, 255, 0.12);
}

.theme-option-title {
  font-weight: 700;
  color: var(--app-text);
}

.theme-option-text {
  color: var(--app-text-muted);
  font-size: 0.92rem;
}

.captcha-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: center;
}

.captcha-code {
  min-width: 180px;
  padding: 0.85rem 1rem;
  border-radius: 0.9rem;
  border: 1px dashed var(--app-border);
  background: var(--app-surface-strong);
  font-weight: 700;
  letter-spacing: 0.18em;
}

.captcha-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.upload-access-shell {
  max-width: 560px;
}

.download-shell {
  max-width: 560px;
}

.progress {
  background-color: rgba(127, 127, 127, 0.18);
}

.modal-content {
  background: var(--app-surface-strong);
}

.badge {
  font-weight: 600;
  letter-spacing: 0.03em;
}

.table a,
.app-page a {
  color: var(--app-primary);
}

.table a:hover,
.app-page a:hover {
  color: var(--app-primary-hover);
}

@media (max-width: 767.98px) {
  .auth-card,
  .app-section {
    padding: 1rem;
  }

  .app-page-title,
  .auth-title {
    font-size: 1.6rem;
  }

  .app-stats {
    display: grid;
  }
}