:root {
  --bg: #08111f;
  --bg-soft: #0f172a;
  --panel: rgba(13, 20, 37, 0.78);
  --line: rgba(148, 163, 184, 0.16);
  --text: #e5edf8;
  --muted: #9dadc4;
  --accent: #54d3c2;
  --accent-strong: #36b7a7;
  --warning: #f5b841;
  --danger: #ef6c7d;
  --success: #5cd39a;
  --shadow: 0 28px 70px rgba(2, 6, 23, 0.38);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

html {
  min-height: 100%;
  font-size: 16px;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI Variable", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(84, 211, 194, 0.22), transparent 26%),
    radial-gradient(circle at 85% 8%, rgba(245, 184, 65, 0.12), transparent 20%),
    linear-gradient(180deg, #09111f 0%, #0d1527 52%, #08111f 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

.btn,
.form-control,
.form-select,
.input-group-text {
  border-radius: 12px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #7ee0d4);
  border-color: transparent;
  color: #062123;
  font-weight: 700;
}

.btn-primary:hover,
.btn-primary:focus {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #052124;
}

.btn-outline-light {
  border-color: rgba(226, 232, 240, 0.35);
  color: var(--text);
}

.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(226, 232, 240, 0.5);
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 1030;
  backdrop-filter: blur(18px);
  background: rgba(5, 10, 18, 0.72);
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  color: var(--text);
}

.brand-badge {
  display: inline-grid;
  place-items: center;
  width: 2.55rem;
  height: 2.55rem;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #84e2d7);
  color: #072027;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(84, 211, 194, 0.25);
}

.brand-mark strong,
.brand-mark small {
  display: block;
  line-height: 1.2;
}

.brand-mark small,
.nav-link {
  color: var(--muted);
}

.navbar-toggler {
  border-color: rgba(255, 255, 255, 0.14);
}

.navbar-toggler-icon {
  filter: invert(1);
}

.nav-link {
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  font-weight: 600;
}

.nav-link:hover,
.nav-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.nav-cta {
  margin-left: 0.25rem;
}

.app-main {
  flex: 1;
}

.app-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: rgba(4, 9, 16, 0.75);
}

.hero-card,
.surface-card,
.page-card,
.quick-link,
.tip-card,
.stat-card,
.form-card,
.history-card,
.detail-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.72fr);
  gap: 1.25rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  border-radius: var(--radius-xl);
}

.hero-copy h1,
.page-card h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.03;
  letter-spacing: -0.04em;
}

.hero-copy p,
.page-card p,
.tip-card p,
.empty-state p {
  color: var(--muted);
  line-height: 1.8;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 0.8rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.hero-panel {
  display: grid;
  gap: 0.85rem;
}

.hero-panel-card {
  padding: 1rem 1.05rem;
  border-radius: 18px;
  background: rgba(8, 15, 27, 0.68);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.hero-panel-label,
.stat-card span,
.timeline-meta,
.quick-link span,
.tip-card strong,
.section-head h2 {
  color: var(--muted);
}

.hero-panel-card strong,
.stat-card strong {
  display: block;
  margin-top: 0.2rem;
  font-size: 1.8rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.stat-card {
  padding: 1rem 1.1rem;
  border-radius: 20px;
}

.stat-card.accent {
  border-color: rgba(84, 211, 194, 0.32);
  background: linear-gradient(180deg, rgba(84, 211, 194, 0.16), rgba(13, 20, 37, 0.8));
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(290px, 0.6fr);
  gap: 1rem;
  margin-top: 1rem;
}

.contact-shell {
  display: grid;
  grid-template-columns: minmax(260px, 0.55fr) minmax(0, 1.45fr);
  gap: 1rem;
}

.contact-side,
.contact-main {
  min-width: 0;
}

.contact-stats {
  display: grid;
  gap: 1rem;
  margin-top: 1.2rem;
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
}

.btn-danger-soft {
  border-color: rgba(239, 108, 125, 0.45);
  color: #ffb4bf;
}

.btn-danger-soft:hover {
  background: rgba(239, 108, 125, 0.14);
  color: #ffd3d9;
}

.contact-import-card {
  margin-bottom: 1rem;
  padding: 1rem 1.05rem;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(8, 15, 27, 0.42);
}

.contact-import-form {
  display: grid;
  gap: 0.85rem;
}

.contact-import-form p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.contact-file-row,
.contact-search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.85rem;
  align-items: center;
}

.contact-search-form {
  margin-bottom: 1rem;
}

.contact-table-wrap {
  overflow-x: auto;
}

.contact-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(10, 18, 34, 0.58);
}

.contact-table th,
.contact-table td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  vertical-align: top;
}

.contact-table th {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: left;
  background: rgba(255, 255, 255, 0.03);
}

.contact-table td {
  color: var(--text);
}

.contact-table td small {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
}

.contact-table input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.surface-card,
.page-card {
  border-radius: var(--radius-xl);
  padding: 1.2rem;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-head h2 {
  margin: 0.15rem 0 0;
  color: var(--text);
  font-size: 1.35rem;
}

.text-link {
  color: var(--accent);
  font-weight: 700;
}

.empty-state {
  display: grid;
  gap: 0.7rem;
  place-items: start;
  padding: 1.5rem 0 0.5rem;
}

.timeline-list {
  display: grid;
  gap: 0.8rem;
}

.timeline-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.05rem;
  border-radius: 18px;
  background: rgba(10, 18, 34, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.11);
  transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.timeline-item:hover {
  transform: translateY(-1px);
  border-color: rgba(84, 211, 194, 0.3);
  background: rgba(12, 22, 41, 0.86);
}

.inbox-item {
  align-items: flex-start;
}

.timeline-main strong,
.quick-link strong {
  display: block;
  margin: 0.35rem 0;
  color: #fff;
}

.timeline-main small {
  color: var(--muted);
}

.timeline-meta {
  display: grid;
  justify-items: end;
  align-content: start;
  white-space: nowrap;
  font-size: 0.9rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.62rem;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.status-badge.sent {
  background: rgba(92, 211, 154, 0.16);
  color: #8ef0bf;
}

.status-badge.failed {
  background: rgba(239, 108, 125, 0.16);
  color: #ffb4bf;
}

.status-badge.pending {
  background: rgba(245, 184, 65, 0.16);
  color: #ffdca1;
}

.side-stack {
  display: grid;
  gap: 0.85rem;
  align-content: start;
}

.quick-link,
.tip-card {
  border-radius: 20px;
  padding: 1rem 1.05rem;
}

.quick-link {
  display: grid;
  gap: 0.25rem;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.quick-link:hover {
  transform: translateY(-1px);
  border-color: rgba(84, 211, 194, 0.28);
}

.tip-card p {
  margin: 0.35rem 0 0;
}

.form-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(290px, 0.65fr);
  gap: 1rem;
}

.form-main,
.form-side {
  min-width: 0;
}

.form-card {
  display: grid;
  gap: 1rem;
  padding: 1.2rem;
  border-radius: var(--radius-xl);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.field-span-2 {
  grid-column: span 2;
}

.form-label {
  font-weight: 700;
  color: var(--text);
}

.form-control,
.form-select {
  border-color: rgba(148, 163, 184, 0.22);
  background: rgba(255, 255, 255, 0.96);
}

.form-control:focus,
.form-select:focus {
  border-color: rgba(84, 211, 194, 0.65);
  box-shadow: 0 0 0 0.2rem rgba(84, 211, 194, 0.18);
}

.attachment-box {
  display: grid;
  gap: 0.65rem;
  padding: 1rem;
  border-radius: 18px;
  border: 1px dashed rgba(148, 163, 184, 0.24);
  background: rgba(255, 255, 255, 0.03);
}

.attachment-preview {
  color: var(--muted);
  font-size: 0.92rem;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.history-form {
  display: grid;
  gap: 1rem;
}

.history-actions,
.history-toolbar,
.history-card-title,
.history-check,
.history-select-all,
.attachment-list {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.history-toolbar {
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 0.9rem 1rem;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(8, 15, 27, 0.5);
}

.history-check,
.history-select-all {
  color: var(--text);
  font-weight: 700;
}

.history-check input,
.history-select-all input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.history-card {
  display: grid;
  gap: 0.9rem;
  padding: 1.1rem;
  border-radius: 20px;
}

.history-card-head,
.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.history-card-head h3,
.detail-card h1 {
  margin: 0;
}

.history-card-body {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
}

.history-card-title {
  align-items: flex-start;
}

.attachment-list {
  flex-wrap: wrap;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(84, 211, 194, 0.12);
  border: 1px solid rgba(84, 211, 194, 0.2);
  color: var(--text);
  font-size: 0.86rem;
}

.attachment-chip small {
  color: var(--muted);
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.24rem 0.58rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 1rem;
}

.detail-card {
  display: grid;
  gap: 1rem;
  padding: 1.2rem;
  border-radius: var(--radius-xl);
}

.detail-body {
  white-space: pre-wrap;
  line-height: 1.8;
  color: var(--muted);
}

.detail-value {
  color: var(--text);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.page-card h1 {
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.alert {
  border-radius: 18px;
}

@media (max-width: 1199.98px) {
  .hero-card,
  .contact-shell,
  .content-grid,
  .form-shell,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid,
  .history-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767.98px) {
  .hero-actions,
  .contact-actions,
  .section-head,
  .history-card-head,
  .detail-row,
  .timeline-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .timeline-meta {
    justify-items: start;
  }

  .history-toolbar,
  .history-card-title,
  .attachment-list {
    align-items: flex-start;
  }

  .contact-file-row,
  .contact-search-form {
    grid-template-columns: 1fr;
  }

  .stats-grid,
  .history-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .field-span-2 {
    grid-column: span 1;
  }

  .hero-copy h1 {
    font-size: clamp(1.9rem, 8vw, 2.8rem);
  }
}
