* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft JhengHei", Arial, sans-serif;
  background: #f4f6fb;
  color: #1f2937;
}

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

.sidebar {
  width: 260px;
  background: #111827;
  color: #fff;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
}

.brand {
  margin-bottom: 36px;
}

.brand-main {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 2px;
}

.brand-sub {
  margin-top: 6px;
  color: #8b5cf6;
  font-size: 12px;
  letter-spacing: 2px;
  font-weight: 700;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar nav a {
  padding: 14px 16px;
  border-radius: 12px;
  color: #cbd5e1;
  cursor: pointer;
  text-decoration: none;
}

.sidebar nav a.active,
.sidebar nav a:hover {
  background: #7c3aed;
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  color: #94a3b8;
  font-size: 13px;
  line-height: 1.6;
  background: rgba(255,255,255,0.04);
  padding: 14px;
  border-radius: 14px;
}

.sidebar-footer p {
  margin: 6px 0;
}

.main {
  flex: 1;
  margin-left: 260px;
  padding: 32px;
  overflow: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.topbar h1 {
  margin: 0;
  font-size: 30px;
}

.topbar p {
  margin: 8px 0 0;
  color: #64748b;
}

.status-area {
  display: flex;
  gap: 10px;
  align-items: center;
}

.status-pill {
  background: #ede9fe;
  color: #6d28d9;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.gray {
  background: #f1f5f9;
  color: #64748b;
}

.status-pill.success {
  background: #dcfce7;
  color: #15803d;
}

.card {
  background: #fff;
  border-radius: 18px;
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  border: 1px solid #e5e7eb;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.card p {
  margin: 0 0 18px;
  color: #64748b;
}

.result-top {
  border: 1px solid #ddd6fe;
  background: linear-gradient(180deg, #ffffff, #faf7ff);
}

.result-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 15px;
  outline: none;
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

button {
  border: 0;
  border-radius: 12px;
  padding: 13px 18px;
  background: #7c3aed;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  background: #6d28d9;
}

button.outline {
  background: #fff;
  color: #7c3aed;
  border: 1px solid #7c3aed;
}

button.outline:hover {
  background: #f5f3ff;
}

button.danger {
  background: #ef4444;
}

button.danger:hover {
  background: #dc2626;
}

.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: #f1f5f9;
  color: #334155;
  font-size: 22px;
  line-height: 1;
}

.icon-btn:hover {
  background: #e2e8f0;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
}

.mailbox-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mailbox-card {
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 18px;
  background: #f8fafc;
}

.mailbox-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-weight: 800;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.form-grid.single {
  grid-template-columns: 1fr;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #374151;
  font-weight: 700;
  font-size: 14px;
}

.grid {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 22px;
}

.big-textarea {
  min-height: 220px;
  resize: vertical;
}

.content-textarea {
  min-height: 260px;
  resize: vertical;
}

.action-row {
  margin-top: 18px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 0;
}

.stats div {
  background: #f8fafc;
  border-radius: 16px;
  padding: 18px;
  text-align: center;
  border: 1px solid #e5e7eb;
}

.stats span {
  font-size: 30px;
  font-weight: 800;
  color: #7c3aed;
}

.stats p {
  margin: 6px 0 0;
}

.log-box {
  background: #0f172a;
  color: #d1fae5;
  border-radius: 16px;
  min-height: 420px;
  padding: 18px;
  font-family: Consolas, monospace;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow: auto;
}

.hint {
  margin-top: 12px;
  font-weight: 700;
}

.hint.success {
  color: #16a34a;
}

.hint.error {
  color: #dc2626;
}

.hidden {
  display: none;
}

.mini-note {
  color: #64748b;
  font-size: 13px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  padding: 12px;
  border-radius: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.68);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.modal.hide {
  display: none;
}

.modal-box {
  width: 480px;
  background: #fff;
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
}

.modal-box.small {
  width: 420px;
}

.modal-box.large {
  width: min(960px, 96vw);
}

.modal-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.modal-box h2 {
  margin: 0 0 10px;
}

.modal-box p {
  color: #64748b;
  line-height: 1.6;
}

.modal-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.modal-content {
  color: #334155;
  line-height: 1.8;
}

.license-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

.license-info div {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  padding: 14px;
  border-radius: 14px;
}

.license-info span {
  display: block;
  color: #64748b;
  font-size: 13px;
  margin-bottom: 6px;
}

.license-info strong {
  color: #7c3aed;
}

@media (max-width: 1100px) {
  .app {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    position: static;
  }

  .main {
    margin-left: 0;
  }

  .grid,
  .form-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

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

  .result-head,
  .topbar,
  .section-head {
    flex-direction: column;
  }
}

.body-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 18px;
}

.body-card {
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  background: #f8fafc;
  padding: 18px;
}

.body-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-weight: 800;
}

.body-textarea {
  min-height: 180px;
  resize: vertical;
}

.progress-wrap {
  margin: 18px 0;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 16px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  color: #475569;
  font-weight: 700;
  margin-bottom: 10px;
}

.progress-bar {
  height: 16px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7c3aed, #22c55e);
  border-radius: 999px;
  transition: width .25s ease;
}

.log-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 18px 0;
}

.log-summary div {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 18px;
  text-align: center;
}

.log-summary strong {
  display: block;
  font-size: 28px;
  color: #7c3aed;
}

.log-summary span {
  color: #64748b;
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-item {
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 16px;
  background: #ffffff;
  display: grid;
  grid-template-columns: 140px 120px 1fr;
  gap: 14px;
  align-items: center;
}

.activity-time {
  color: #64748b;
  font-size: 13px;
}

.activity-type {
  display: inline-flex;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 800;
  background: #ede9fe;
  color: #6d28d9;
}

.activity-type.send {
  background: #dcfce7;
  color: #15803d;
}

.activity-type.mailbox {
  background: #e0f2fe;
  color: #0369a1;
}

.activity-type.key {
  background: #fef3c7;
  color: #92400e;
}

.activity-desc {
  color: #334155;
  font-weight: 700;
}

@media (max-width: 1100px) {
  .activity-item {
    grid-template-columns: 1fr;
  }

  .log-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .progress-info {
    flex-direction: column;
    gap: 8px;
  }
}


.activity-type.content {
  background: #fae8ff;
  color: #a21caf;
}

.activity-type.system {
  background: #f1f5f9;
  color: #475569;
}

.custom-fields {
  margin-top: 16px;
}


.custom-fields {
  margin-top: 16px;
}


.media-box {
  margin: 18px 0;
  padding: 18px;
  border: 1px dashed #cbd5e1;
  border-radius: 16px;
  background: #f8fafc;
}

.media-box h3 {
  margin: 0 0 8px;
}

.modal-box.large {
  width: min(960px, 94vw);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-box.large .log-box {
  max-height: 58vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

#sendLog {
  font-size: 14px;
}

