:root {
  --indigo: #4338CA;
  --indigo-light: #6366F1;
  --bg: #F5F6FB;
  --card-bg: #FFFFFF;
  --text: #1F2330;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --danger: #DC2626;
  --success: #16A34A;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--indigo-light), var(--indigo));
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 32px; height: 32px; border-radius: 8px; }
.brand h1 { font-size: 20px; margin: 0; font-weight: 700; }

.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.sync-status { font-size: 12px; opacity: 0.85; margin-right: 4px; }

.icon-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,0.28); }

.primary-btn {
  background: white;
  color: var(--indigo);
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
.primary-btn:hover { background: #EEF2FF; }

.secondary-btn {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
.secondary-btn.small { padding: 6px 10px; font-size: 12px; }
.secondary-btn:hover { background: #F3F4F6; }

.danger-btn {
  background: #FEF2F2;
  color: var(--danger);
  border: 1px solid #FECACA;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}
.danger-btn:hover { background: #FEE2E2; }

main { padding: 24px; max-width: 1200px; margin: 0 auto; }

section { margin-bottom: 36px; }

h2 {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  margin-bottom: 14px;
}

.count-badge {
  background: var(--indigo);
  color: white;
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
  font-weight: 600;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.event-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.08s ease;
}
.event-card:hover { transform: translateY(-2px); }

.card-grid.past .event-card { opacity: 0.72; }

.card-thumb {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--indigo-light), var(--indigo));
}

.card-thumb-fallback {
  width: 100%;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  background: linear-gradient(135deg, var(--indigo-light), var(--indigo));
}

.card-body { padding: 14px; flex: 1; display: flex; flex-direction: column; gap: 6px; }

.card-type-badge {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--indigo);
  background: #EEF2FF;
  padding: 2px 8px;
  border-radius: 999px;
}

.card-title { font-size: 16px; font-weight: 700; margin: 0; line-height: 1.25; }

.card-meta { font-size: 13px; color: var(--text-muted); display: flex; flex-direction: column; gap: 2px; }

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.card-cost { font-weight: 700; color: var(--text); }
.card-platform { color: var(--text-muted); font-size: 12px; }

.empty-state { color: var(--text-muted); font-size: 14px; padding: 18px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); }
.empty-state.hidden, .hidden { display: none !important; }

.banner {
  margin: 0 24px;
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #991B1B;
  font-size: 14px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal {
  background: white;
  border-radius: var(--radius);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
}
.modal.wide { max-width: 640px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 17px; }

.close-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.modal-body { padding: 18px 20px; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  gap: 8px;
}
.footer-right { display: flex; gap: 8px; margin-left: auto; }

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

input, select {
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--indigo-light); outline-offset: 1px; }
input[readonly] { background: #F9FAFB; color: var(--text-muted); }

.hint { font-size: 12px; color: var(--text-muted); margin: 4px 0 12px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}
.form-grid .span-2 { grid-column: 1 / -1; }

.receipt-box {
  background: #EEF2FF;
  border: 1px dashed #C7D2FE;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 18px;
}
.receipt-label { display: block; font-weight: 700; margin-bottom: 8px; font-size: 13px; }

.thumbnail-preview-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
#f-thumbnailPreview { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: white;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 200;
  box-shadow: var(--shadow);
}
.toast.error { background: var(--danger); }

@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .app-header { padding: 12px 16px; }
  main { padding: 16px; }
}

/* Lock screen */
.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--indigo-light), var(--indigo));
  padding: 16px;
}

.lock-box {
  background: white;
  border-radius: var(--radius);
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
  padding: 32px 28px;
  text-align: center;
  max-width: 300px;
  width: 100%;
}
.lock-icon { width: 56px; height: 56px; border-radius: 12px; margin-bottom: 10px; }
.lock-box h2 { margin: 0 0 2px; font-size: 18px; }
.lock-box .hint { margin: 4px 0 0; }

#pinInput {
  display: block;
  width: 100%;
  margin: 16px 0 12px;
  text-align: center;
  font-size: 26px;
  letter-spacing: 10px;
  padding: 10px;
}

.lock-unlock-btn { width: 100%; padding: 10px; background: var(--indigo); color: white; }
.lock-unlock-btn:hover { background: var(--indigo-light); }

.hint.error { color: var(--danger); margin-top: 10px; margin-bottom: 0; }
