:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-soft: #243247;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --line: rgba(148, 163, 184, 0.22);
  --blue: #38bdf8;
  --indigo: #6366f1;
  --danger: #fb7185;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.18), transparent 32rem),
    linear-gradient(135deg, #020617 0%, var(--bg) 52%, #111827 100%);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.86);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0;
}

.logo {
  display: grid;
  flex: 0 0 3.25rem;
  width: 3.25rem;
  height: 3.25rem;
  place-items: center;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, var(--blue), var(--indigo));
  color: white;
  font-size: 1.35rem;
  font-weight: 900;
  box-shadow: 0 0 34px rgba(56, 189, 248, 0.35);
}

.brand-kicker,
.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--blue);
  font-size: 0.78rem;
  letter-spacing: 0;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 800;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.05rem, 2.4vw, 1.65rem);
}

h2 {
  font-size: clamp(1.25rem, 3vw, 1.8rem);
}

h3 {
  font-size: 1.05rem;
}

.page-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
}

.main-tabs,
.sub-tabs {
  display: flex;
  gap: 0.5rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: rgba(30, 41, 59, 0.7);
  overflow-x: auto;
}

.main-tab,
.sub-tab,
.primary-btn {
  min-height: 2.65rem;
  border: 0;
  border-radius: 0.55rem;
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.main-tab,
.sub-tab {
  flex: 1;
  padding: 0.7rem 1rem;
  background: transparent;
}

.main-tab.active,
.sub-tab.active,
.primary-btn {
  background: linear-gradient(135deg, #2563eb, var(--indigo));
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.24);
}

.page-panel,
.sub-panel {
  display: none;
}

.page-panel.active,
.sub-panel.active {
  display: block;
}

.page-panel {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: rgba(30, 41, 59, 0.72);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}

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

.primary-btn {
  padding: 0 1rem;
}

.dropzone {
  display: grid;
  min-height: 9.5rem;
  place-items: center;
  gap: 0.35rem;
  margin-bottom: 1rem;
  padding: 1.25rem;
  border: 1px dashed rgba(56, 189, 248, 0.75);
  border-radius: 0.8rem;
  background: rgba(15, 23, 42, 0.72);
  text-align: center;
  cursor: pointer;
  transition: 0.2s ease;
}

.dropzone.dragging {
  border-color: white;
  background: rgba(37, 99, 235, 0.18);
}

.dropzone input {
  display: none;
}

.dropzone-title {
  font-size: 1.05rem;
  font-weight: 800;
}

.dropzone-text {
  color: var(--muted);
  font-size: 0.92rem;
}

.table-wrap,
.chart-box,
.mail-panel {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.58);
  overflow: hidden;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 0.92rem;
}

th {
  color: #bfdbfe;
  background: rgba(30, 41, 59, 0.88);
}

tr:hover td {
  background: rgba(56, 189, 248, 0.06);
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 1rem;
}

.dashboard-grid.active {
  display: grid;
}

.chart-box {
  min-height: 390px;
  padding: 1rem;
}

.mail-panel {
  padding: 1rem;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  padding: 0.9rem;
  color: var(--text);
  background: var(--panel-soft);
  line-height: 1.7;
}

.danger-text {
  color: var(--danger);
  font-weight: 900;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  transform: translateY(150%);
  padding: 0.75rem 1rem;
  border: 1px solid rgba(56, 189, 248, 0.38);
  border-radius: 0.65rem;
  background: #082f49;
  color: white;
  opacity: 0;
  transition: 0.22s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 760px) {
  .brand {
    align-items: flex-start;
  }

  .section-head,
  .mail-head {
    align-items: stretch;
    flex-direction: column;
  }

  .main-tabs,
  .sub-tabs {
    flex-direction: column;
  }

  .dashboard-grid.active {
    display: block;
  }

  .chart-box {
    min-height: 320px;
  }

  table {
    min-width: 640px;
  }
}
