:root {
  --ink: #14231f;
  --muted: #66726d;
  --paper: #f7f4ec;
  --white: #fffefa;
  --green: #1f5c4f;
  --green-deep: #163e36;
  --teal: #3c8d8e;
  --coral: #d8745f;
  --gold: #d6aa4e;
  --line: rgba(20, 35, 31, 0.16);
  --soft: rgba(255, 254, 250, 0.72);
  --shadow: 0 22px 70px rgba(18, 46, 39, 0.13);
  --sans: "DM Sans", "Noto Sans TC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(61, 142, 143, 0.18), transparent 34%),
    linear-gradient(315deg, rgba(216, 116, 95, 0.16), transparent 36%),
    var(--paper);
  font-family: var(--sans);
  line-height: 1.6;
}

a {
  color: inherit;
}

button,
input,
textarea,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 0 4vw;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 254, 250, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  border-radius: 4px;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav a,
.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--white);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.button.primary {
  color: white;
  border-color: var(--green-deep);
  background: var(--green-deep);
}

.button.danger {
  color: #8d2d22;
  border-color: rgba(216, 116, 95, 0.42);
  background: rgba(216, 116, 95, 0.12);
}

.button.full {
  width: 100%;
}

.app-shell {
  width: min(1180px, 92vw);
  margin: 38px auto 80px;
}

.portal-hero {
  min-height: 330px;
  display: grid;
  align-content: end;
  padding: clamp(32px, 7vw, 78px);
  margin-bottom: 20px;
  color: #fffefa;
  background: linear-gradient(125deg, #123f38, #1f5c4f 56%, #427d75);
  border-radius: 8px;
}

.portal-hero .eyebrow,
.portal-hero p {
  color: rgba(255, 254, 250, 0.82);
}

.portal-hero h1,
.login-intro h1 {
  margin: 0 0 12px;
  font-size: clamp(38px, 6vw, 68px);
  line-height: 1.08;
}

.portal-hero > p:last-child {
  max-width: 650px;
  margin: 0;
  font-size: 18px;
}

.access-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.9fr);
  gap: 32px;
  align-items: center;
  padding: clamp(24px, 4vw, 42px);
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.access-panel h2,
.login-card h2 {
  margin: 0 0 8px;
  font-size: 28px;
}

.access-panel p {
  color: var(--muted);
}

.access-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.access-form .status-message {
  grid-column: 1 / -1;
  margin: 0;
}

.public-note {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.public-note > div {
  display: grid;
  gap: 5px;
  padding: 22px;
  background: var(--white);
}

.public-note span {
  color: var(--muted);
  font-size: 14px;
}

.login-layout {
  min-height: 60vh;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 0.8fr);
  gap: clamp(32px, 8vw, 120px);
  align-items: center;
}

.login-intro p {
  max-width: 540px;
  color: var(--muted);
  font-size: 18px;
}

.login-card {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.hero-panel,
.panel,
.loading-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  align-items: end;
  padding: clamp(24px, 5vw, 46px);
  margin-bottom: 20px;
}

.hero-panel h1 {
  max-width: 760px;
  margin: 0 0 12px;
  font-size: clamp(34px, 6vw, 62px);
  line-height: 1.05;
}

.hero-panel p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}

.hero-actions,
.export-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.table-search {
  display: grid;
  gap: 5px;
  min-width: min(100%, 280px);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.table-search input { min-height: 38px; }
.table-actions { display: flex; gap: 8px; }
.table-actions .button { min-height: 36px; padding: 7px 10px; }

.staff-row td { background: rgba(216, 116, 95, 0.12); }
.staff-row td:first-child { color: #8d2d23; font-weight: 900; }
.staff-pill { color: #8d2d23; border-color: rgba(216, 116, 95, 0.5); background: rgba(216, 116, 95, 0.16); }

.participant-dialog {
  width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--white);
  box-shadow: var(--shadow);
}

.participant-dialog::backdrop { background: rgba(20, 35, 31, 0.48); }
.participant-dialog form { display: grid; gap: 14px; padding: 24px; }
.participant-dialog .panel-heading { margin-bottom: 4px; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); color: var(--ink); font-size: 24px; line-height: 1; cursor: pointer; }
.check-field { color: var(--muted); font-weight: 700; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.stat-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.stat-card strong {
  display: block;
  font-size: 32px;
  line-height: 1;
}

.stat-card span {
  color: var(--muted);
  font-weight: 700;
}

.workspace-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.panel,
.loading-card {
  padding: 22px;
  margin-bottom: 18px;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.panel h2,
.loading-card h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.18;
}

.file-field,
.input-label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--muted);
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--white);
}

input,
select {
  min-height: 44px;
  padding: 9px 12px;
}

textarea {
  min-height: 160px;
  padding: 12px;
  resize: vertical;
}

.hint,
.status-message {
  color: var(--muted);
  font-size: 14px;
}

.status-message.success {
  color: var(--green);
  font-weight: 800;
}

.status-message.error {
  color: #a13a2d;
  font-weight: 800;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

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

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.copy-link {
  max-width: 260px;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--green-deep);
  background: rgba(31, 92, 79, 0.12);
  font-size: 13px;
  font-weight: 800;
}

.pill.warn {
  color: #9b3e2d;
  background: rgba(216, 116, 95, 0.16);
}

.schedule-list,
.course-days {
  display: grid;
  gap: 14px;
}

.day-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  overflow: hidden;
}

.day-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(31, 92, 79, 0.07);
  font-weight: 900;
}

.session-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

.session-card {
  min-height: 148px;
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.session-card input {
  width: auto;
  min-height: auto;
}

.session-card.selected {
  border-color: var(--green);
  background: rgba(31, 92, 79, 0.08);
}

.session-card.sold-out {
  color: var(--muted);
  background: rgba(20, 35, 31, 0.04);
}

.session-title {
  font-weight: 900;
  line-height: 1.25;
}

.session-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.period-block {
  border-top: 1px solid var(--line);
}

.period-heading {
  padding: 14px 16px 0;
  font-weight: 900;
}

.ticket-mini {
  width: min(340px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.ticket-mini strong {
  display: block;
  font-size: 22px;
}

.qr-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
}

.qr-box {
  width: 184px;
  min-height: 184px;
  display: grid;
  place-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.qr-box svg {
  width: 156px;
  height: 156px;
}

.checkin-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.checkin-card h3 {
  margin: 0 0 8px;
}

.checkin-list {
  display: grid;
  gap: 10px;
}

@media (max-width: 900px) {
  .topbar,
  .hero-panel,
  .workspace-grid,
  .qr-panel,
  .access-panel,
  .login-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    padding: 14px 4vw;
  }

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

@media (max-width: 560px) {
  .stats-grid,
  .session-grid,
  .public-note,
  .access-form {
    grid-template-columns: 1fr;
  }

  .nav a,
  .button {
    width: 100%;
  }
}
