@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700;800;900&family=Outfit:wght@400;500;600;700;800;900&display=swap');

:root {
  --theme: #d63384;
  --theme-rgb: 214, 51, 132;
  --ink: #0f172a;
  --muted: #64748b;
  --line: rgba(226, 232, 240, 0.8);
  --surface: rgba(255, 255, 255, 0.75);
  --surface-2: rgba(248, 250, 252, 0.6);
  --nav: #0f172a;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 8px 32px rgba(15, 23, 42, 0.06);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.6);
  --glass-blur: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(at 0% 0%, rgba(214, 51, 132, 0.05) 0px, transparent 50%),
              radial-gradient(at 100% 100%, rgba(59, 130, 246, 0.05) 0px, transparent 50%),
              #f8fafc;
  background-attachment: fixed;
  font-family: 'Outfit', 'Noto Sans TC', system-ui, -apple-system, sans-serif;
  letter-spacing: 0.01em;
  min-height: 100vh;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  background: var(--nav);
  color: #fff;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--theme);
  font-weight: 800;
}

.brand-title {
  font-weight: 800;
  line-height: 1.3;
}

.brand-subtitle {
  color: #b8c2cf;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-item,
.icon-button,
.primary-button,
.secondary-button,
.ghost-button,
.segment {
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border-radius: 8px;
}

.nav-item {
  color: #d5deea;
  background: transparent;
  justify-content: flex-start;
  padding: 10px 12px;
}

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

.nav-item svg,
button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.main {
  padding: 24px;
  min-width: 0;
}

.page-shell,
.portal {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 22px;
}

.back-link {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.back-link span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.back-link svg {
  width: 20px;
  height: 20px;
}

.portal {
  min-height: 100vh;
  display: grid;
  align-content: center;
  gap: 24px;
}

.portal-hero {
  display: grid;
  gap: 18px;
}

.portal-hero .brand {
  color: #fff;
  background: var(--nav);
  width: fit-content;
  max-width: 100%;
  border-radius: 8px;
  padding: 12px;
}

.portal-hero h1 {
  font-size: clamp(30px, 5vw, 56px);
}

.portal-hero p {
  max-width: 760px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.portal-card {
  min-height: 180px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
  display: grid;
  align-content: space-between;
  gap: 12px;
}

.portal-card:hover {
  border-color: var(--theme);
}

.portal-card svg {
  width: 30px;
  height: 30px;
  color: var(--theme);
}

.portal-card span {
  font-size: 22px;
  font-weight: 900;
}

.portal-card strong {
  color: var(--muted);
  font-size: 13px;
}

.access-denied {
  min-height: 320px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
}

.access-denied svg {
  width: 46px;
  height: 46px;
  color: var(--danger);
}

.access-denied p {
  max-width: 520px;
  color: var(--muted);
  line-height: 1.7;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--theme);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 18px;
}

.topbar-actions,
.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.icon-button {
  width: 40px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

.primary-button {
  background: var(--theme);
  color: #fff;
  padding: 0 16px;
  font-weight: 800;
}

.secondary-button {
  background: #1f2a37;
  color: #fff;
  padding: 0 14px;
  font-weight: 700;
}

.ghost-button {
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.checkin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.panel,
.metric-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.panel {
  padding: 24px;
}

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

.panel-heading p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.status-pill {
  color: #096b3a;
  background: #e8f7ef;
  border: 1px solid #b7e4ca;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.invalid {
  color: #8a1f1f;
  background: #fff0f0;
  border-color: #f1c4c4;
}

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

.field {
  display: grid;
  gap: 7px;
}

[hidden] {
  display: none !important;
}

.field.wide {
  grid-column: 1 / -1;
}

.field span,
.signature-header span {
  color: #394556;
  font-size: 13px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  padding: 8px 11px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--theme);
  box-shadow: 0 0 0 3px rgba(214, 51, 132, 0.18);
}

.signature-area {
  margin-top: 16px;
}

.signature-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

#signatureCanvas {
  width: 100%;
  height: 210px;
  display: block;
  background: #fff;
  border: 2px dashed #b9c5d3;
  border-radius: 8px;
  touch-action: none;
}

.form-actions {
  margin-top: 16px;
  justify-content: space-between;
}

.submit-button {
  min-width: 148px;
}

.event-panel {
  display: grid;
  align-content: start;
  gap: 16px;
}

.checkin-info-panel {
  align-content: center;
}

.event-meta {
  display: grid;
  gap: 6px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.event-meta span,
.mini-metric span,
.metric-card span {
  color: var(--muted);
  font-size: 13px;
}

.event-meta strong {
  font-size: 20px;
}

.metric-stack {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.mini-metric {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 6px;
}

.mini-metric strong {
  font-size: 23px;
}

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

.checkin-note {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-2);
}

.checkin-note svg {
  width: 22px;
  height: 22px;
  color: var(--theme);
}

.checkin-note div {
  display: grid;
  gap: 4px;
}

.checkin-note strong {
  font-size: 14px;
}

.checkin-note span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.recent-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  display: grid;
  gap: 4px;
}

.recent-item strong {
  font-size: 15px;
}

.recent-item span {
  color: var(--muted);
  font-size: 12px;
}

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

.metric-card {
  padding: 18px;
  display: grid;
  gap: 9px;
}

.metric-card strong {
  font-size: 34px;
}

.table-panel {
  padding: 0;
  overflow: hidden;
}

.record-panel {
  margin-top: 18px;
}

.table-panel .panel-heading {
  padding: 18px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--line);
}

.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.segment {
  min-height: 32px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.segment.active {
  color: #fff;
  background: var(--ink);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  background: #f8fafc;
}

td {
  font-size: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}

.badge.ok {
  color: #096b3a;
  background: #e8f7ef;
}

.badge.wait {
  color: #7a4b00;
  background: #fff4d8;
}

.row-action {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

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

.signature-dialog::backdrop {
  background: rgba(16, 24, 40, 0.48);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-head span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.dialog-head strong {
  display: block;
  margin-top: 3px;
  font-size: 18px;
}

.dialog-body {
  min-height: 220px;
  display: grid;
  place-items: center;
  padding: 18px;
  background: var(--surface-2);
}

.dialog-body img {
  max-width: 100%;
  max-height: 360px;
  display: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.dialog-body p {
  color: var(--muted);
}

.settings-panel {
  margin-bottom: 18px;
}

.import-panel {
  margin-bottom: 18px;
}

.backup-panel {
  margin-bottom: 18px;
}

.inline-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.check-grid label {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.check-grid input {
  width: 16px;
  min-height: 16px;
  padding: 0;
  accent-color: var(--theme);
}

.search-field {
  min-width: min(320px, 100%);
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
}

.search-field svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.search-field input {
  border: 0;
  min-height: 38px;
  padding: 0;
  box-shadow: none;
}

.search-field input:focus {
  box-shadow: none;
}

textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  padding: 11px;
  outline: none;
  font: inherit;
  line-height: 1.6;
}

textarea:focus {
  border-color: var(--theme);
  box-shadow: 0 0 0 3px rgba(214, 51, 132, 0.18);
}

.link-panel {
  margin-bottom: 18px;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.link-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

.link-card span {
  display: block;
  color: var(--ink);
  font-weight: 900;
}

.link-card strong {
  color: var(--muted);
  font-size: 13px;
}

.link-card img {
  width: 104px;
  height: 104px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.link-card-body {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.link-card-controls {
  display: grid;
  gap: 10px;
  min-width: 0;
}

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

.copy-button,
.open-link-button {
  width: fit-content;
}

.qr-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.qr-details summary {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  font-weight: 900;
}

.qr-details img {
  display: block;
  width: 180px;
  height: 180px;
  margin-top: 12px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.guest-picker-dialog {
  width: min(560px, calc(100vw - 28px));
}

.guest-picker-search {
  margin-bottom: 12px;
}

.guest-picker-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
}

.guest-picker-item {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.guest-picker-item:hover {
  border-color: var(--theme);
  background: #fff8fb;
}

.guest-picker-item strong {
  font-size: 16px;
}

.guest-picker-item span,
.guest-picker-empty {
  color: var(--muted);
  font-size: 13px;
}

.auth-warning {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid #f1c4c4;
  border-radius: 8px;
  color: #8a1f1f;
  background: #fff0f0;
}

.auth-warning[hidden] {
  display: none;
}

.auth-warning svg {
  width: 22px;
  height: 22px;
}

.auth-warning span {
  display: block;
  margin-top: 4px;
  color: #8a1f1f;
  font-size: 13px;
  line-height: 1.5;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  background: #17202b;
  color: #fff;
  padding: 12px 14px;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 0.2s ease;
  box-shadow: var(--shadow);
}

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

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 12px;
    gap: 12px;
  }

  .brand-subtitle {
    max-width: 68vw;
  }

  .nav-tabs {
    grid-template-columns: repeat(3, 1fr);
  }

  .nav-item {
    justify-content: center;
  }

  .checkin-layout,
  .dashboard-grid,
  .portal-grid,
  .link-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .main {
    padding: 14px;
  }

  .topbar,
  .panel-heading,
  .page-header,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .page-header {
    display: flex;
  }

  h1 {
    font-size: 21px;
  }

  .field-grid,
  .settings-grid,
  .link-grid,
  .metric-stack,
  .dashboard-grid,
  .check-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .nav-item span {
    display: none;
  }

  th,
  td {
    white-space: normal;
    word-break: break-word;
    min-width: 90px;
    padding: 11px;
  }

  .page-shell,
  .portal {
    width: min(100vw - 20px, 1180px);
    padding: 12px 0;
  }

  .panel {
    padding: 14px;
  }

  .table-panel {
    padding: 0;
  }

  #signatureCanvas {
    height: 260px;
  }

  .link-card img {
    width: 96px;
    height: 96px;
  }

  .link-card-body {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .metric-card strong {
    font-size: 30px;
  }

  .dialog-head {
    align-items: flex-start;
  }
}

/* Premium Aesthetics Appends */

.local-mode-banner {
  background: linear-gradient(90deg, #fef3c7, #fde68a);
  border-bottom: 1px solid #fcd34d;
  color: #92400e;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(146, 64, 14, 0.05);
  position: relative;
  z-index: 1000;
  width: 100%;
}
.local-mode-banner svg {
  width: 18px;
  height: 18px;
  color: #b45309;
}

.panel:hover {
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
}

.metric-card {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}
.metric-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
  border-color: rgba(214, 51, 132, 0.3);
}

.success-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.3);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.success-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.success-card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 24px;
  padding: 44px 36px;
  width: min(440px, calc(100vw - 32px));
  text-align: center;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.15);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.success-overlay.active .success-card {
  transform: scale(1) translateY(0);
}
.success-icon-wrap {
  width: 84px;
  height: 84px;
  background: #e6fdf2;
  border: 4px solid #bbf7d0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 0 auto 24px;
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.2);
  animation: iconPulse 2s infinite;
}
.success-icon-wrap svg {
  width: 44px;
  height: 44px;
  color: #10b981;
}
.success-card h3 {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 900;
  color: #0f172a;
}
.success-card p {
  margin: 0 0 28px;
  font-size: 15px;
  color: #64748b;
  line-height: 1.6;
}
.success-close-btn {
  background: linear-gradient(135deg, var(--theme), #a21caf);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 12px 36px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(214, 51, 132, 0.25);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
}
.success-close-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(214, 51, 132, 0.35);
}
@keyframes iconPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 15px rgba(16, 185, 129, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

