/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --danger: #d93025;
  --success: #1e8e3e;
  --info: #1a73e8;
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text: #202124;
  --text-secondary: #5f6368;
  --border: #dadce0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --nav-height: 60px;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding-bottom: calc(var(--nav-height) + 20px);
  min-height: 100vh;
}

/* Container */
.container { max-width: 480px; margin: 0 auto; padding: 16px; }

/* Flash Messages */
.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.flash-success { background: #e6f4ea; color: #1e8e3e; }
.flash-error { background: #fce8e6; color: #d93025; }
.flash-info { background: #e8f0fe; color: #1a73e8; }

/* Submitted Notice (permanent, not auto-dismissed) */
.submitted-notice {
  padding: 12px 16px;
  border-radius: 8px;
  margin: 8px 16px;
  font-size: 14px;
  background: #e8f0fe;
  color: #1a73e8;
  border-left: 4px solid #1a73e8;
}

/* Login Page */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 16px;
}
.login-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 32px 24px; width: 100%; max-width: 360px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.login-title { text-align: center; font-size: 24px; color: var(--primary); margin-bottom: 4px; }
.login-subtitle { text-align: center; color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }

/* Forms */
.form-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 14px; font-weight: 600;
  color: var(--text); margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 16px; font-family: inherit;
  background: #fff; transition: border-color 0.2s;
  -webkit-appearance: none;
}
.form-group input:focus, .form-group select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(26,115,232,0.2);
}
.form-section-title {
  font-size: 16px; color: var(--primary); margin: 24px 0 12px;
  padding-bottom: 8px; border-bottom: 2px solid var(--primary);
}
.form-section-title:first-of-type { margin-top: 0; }
.required { color: var(--danger); }
.form-row { display: flex; gap: 12px; }
.form-group-half { flex: 1; min-width: 0; }

/* Buttons */
.btn {
  display: inline-block; padding: 12px 24px; border: none;
  border-radius: 8px; font-size: 16px; font-weight: 600;
  cursor: pointer; text-align: center; text-decoration: none;
  transition: all 0.2s; font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #e8f0fe; color: var(--primary); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; display: block; }
.btn-large { padding: 16px; font-size: 18px; }
.mt-sm { margin-top: 8px; }
.form-actions { margin-top: 24px; }

/* User Greeting */
.user-greeting { font-size: 20px; font-weight: 600; color: var(--text); margin-bottom: 8px; }

/* Page Header */
.page-header { margin-bottom: 16px; }
.page-header h1 { font-size: 20px; }
.hint { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

/* Month Navigation */
.month-nav {
  display: flex; align-items: center; justify-content: center; gap: 16px;
}
.month-arrow {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--card-bg); border: 1px solid var(--border);
  text-decoration: none; font-size: 18px; color: var(--text);
}
.month-title { font-size: 20px; min-width: 140px; text-align: center; }

/* Summary Bar */
.summary-bar {
  display: flex; gap: 8px; margin-bottom: 16px;
  background: var(--card-bg); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow);
}
.summary-item { flex: 1; text-align: center; }
.summary-label { display: block; font-size: 11px; color: var(--text-secondary); }
.summary-value { display: block; font-size: 16px; font-weight: 700; color: var(--primary); }

/* Entry Cards */
.entry-list { display: flex; flex-direction: column; gap: 8px; padding-bottom: 60px; }
.entry-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto; gap: 4px 12px;
  align-items: center;
}
.entry-date {
  font-size: 13px; color: var(--text-secondary); font-weight: 600;
  grid-row: 1; grid-column: 1;
}
.entry-details { grid-row: 1; grid-column: 2; }
.entry-hall { font-weight: 600; font-size: 15px; }
.entry-content { font-size: 13px; color: var(--text-secondary); }
.entry-amounts { grid-row: 1; grid-column: 3; text-align: right; }
.entry-fee { font-weight: 700; font-size: 15px; }
.entry-expense { font-size: 12px; color: var(--text-secondary); }
.entry-actions {
  grid-row: 2; grid-column: 1 / -1;
  display: flex; gap: 8px; padding-top: 8px;
  border-top: 1px solid var(--border); margin-top: 4px;
}
.inline-form { display: inline; }

/* Empty State */
.empty-state {
  text-align: center; padding: 40px 16px;
  color: var(--text-secondary); font-size: 14px;
}

/* Add Entry Button */
.add-entry-btn {
  position: fixed; bottom: calc(var(--nav-height) + 12px);
  left: 16px; right: 16px; max-width: 480px; margin: 0 auto;
  padding: 14px; border: 2px solid var(--primary); border-radius: 8px;
  background: var(--card-bg); color: var(--primary);
  font-size: 16px; font-weight: 600; text-align: center; text-decoration: none;
  box-shadow: var(--shadow);
  z-index: 100;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card-bg); border-top: 1px solid var(--border);
  display: flex; height: var(--nav-height);
  z-index: 1000;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-decoration: none; color: var(--text-secondary);
  font-size: 10px; gap: 2px;
}
.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 22px; }
.nav-label { font-weight: 500; }

/* Review Page */
.review-profile {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.review-profile h2 { font-size: 16px; margin-bottom: 12px; color: var(--primary); }
.review-table { width: 100%; font-size: 13px; }
.review-table th {
  text-align: left; padding: 4px 8px 4px 0;
  white-space: nowrap; color: var(--text-secondary); font-weight: 500; width: 80px;
}
.review-table td { padding: 4px 0; }
.review-entries {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.review-entries h2 { font-size: 16px; margin-bottom: 12px; color: var(--primary); }

/* Data Table */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -8px; padding: 0 8px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); }
.data-table th { text-align: left; font-weight: 600; white-space: nowrap; color: var(--text-secondary); font-size: 12px; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.total-row { background: #f8f9fa; }
.total-row td { border-top: 2px solid var(--primary); font-size: 14px; }

.submit-form { margin-top: 20px; }
.history-link { text-align: center; margin: 16px 0; }
.history-link a { color: var(--primary); font-size: 14px; }

/* Complete Page */
.complete-page { text-align: center; padding: 40px 0; }
.complete-icon { font-size: 64px; margin-bottom: 16px; }
.complete-page h1 { font-size: 24px; margin-bottom: 8px; }
.complete-message { color: var(--text-secondary); margin-bottom: 24px; }
.complete-summary {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 16px; margin-bottom: 24px; text-align: left;
}
.summary-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 15px; }
.summary-row.total { border-top: 2px solid var(--primary); font-weight: 700; font-size: 17px; margin-top: 4px; padding-top: 12px; }
.complete-actions { display: flex; flex-direction: column; gap: 8px; }

/* History */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
}
.history-month { font-weight: 700; font-size: 16px; min-width: 100px; }
.history-details { flex: 1; font-size: 13px; color: var(--text-secondary); }
.history-date { font-size: 12px; margin-top: 2px; }

/* Profile View (read-only) */
.profile-grid { display: flex; flex-direction: column; gap: 8px; }
.profile-item { display: flex; flex-wrap: wrap; font-size: 14px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.profile-item .label { min-width: 120px; color: var(--text-secondary); font-weight: 500; }
.profile-item .value { flex: 1; }

/* Logout */
.logout-link { text-align: center; margin-top: 20px; }
.logout-link a { color: var(--danger); font-size: 14px; }

/* Receipt Upload */
.receipt-dropzone {
  border: 2px dashed var(--border); border-radius: 8px;
  padding: 20px; text-align: center; cursor: pointer;
  color: var(--text-secondary); font-size: 14px;
  transition: border-color 0.2s, background 0.2s;
}
.receipt-dropzone:hover, .receipt-dropzone.dragover {
  border-color: var(--primary); background: #e8f0fe;
}
.receipt-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.receipt-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; background: #f8f9fa; border-radius: 8px;
}
.receipt-thumb {
  width: 48px; height: 48px; object-fit: cover; border-radius: 4px;
  flex-shrink: 0;
}
.receipt-pdf {
  display: flex; align-items: center; justify-content: center;
  background: var(--danger); color: #fff; font-size: 12px; font-weight: 700;
}
.receipt-mark {
  display: inline-block; background: var(--primary); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1;
  padding: 2px 4px; border-radius: 3px; vertical-align: middle;
  margin-left: 2px;
}
.receipt-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.receipt-delete { flex-shrink: 0; }

/* Assignment Cards (staff side) */
.assignment-list { display: flex; flex-direction: column; gap: 10px; padding-bottom: 60px; }
.assignment-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.assignment-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.assignment-date { font-size: 14px; font-weight: 600; color: var(--text); }
.assignment-type {
  display: inline-block; padding: 2px 10px;
  border-radius: 12px; font-size: 12px; font-weight: 600;
}
.type-survey { background: #e8f0fe; color: var(--primary); }
.type-attend { background: #e6f4ea; color: var(--success); }
.type-other { background: #f8f9fa; color: var(--text-secondary); }
.assignment-hall { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.assignment-event { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.assignment-fee { font-size: 15px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }

.assignment-actions {
  display: flex; gap: 8px; margin-bottom: 8px;
}
.assignment-actions .btn-toggle-expense {
  flex: 1;
}
.btn-completed {
  background: #e6f4ea !important; color: var(--success) !important;
  border: 1px solid var(--success) !important; cursor: default;
}
.btn-toggle-expense {
  margin-bottom: 8px;
}

.expense-form {
  margin-top: 8px; padding-top: 12px;
  border-top: 1px solid var(--border);
}
.expense-form .form-group { margin-bottom: 10px; }
.expense-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.expense-form input, .expense-form textarea {
  width: 100%; padding: 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 15px; font-family: inherit;
}

.receipt-section { margin-top: 12px; }
.receipt-section label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.receipt-gallery {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px;
}
.assignment-card .receipt-item {
  position: relative; display: inline-block;
}
.assignment-card .receipt-item img {
  width: 80px; height: 80px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--border);
}
.btn-delete-receipt {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--danger); color: #fff; border: none;
  font-size: 14px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.receipt-upload { margin-top: 6px; padding: 8px; border-radius: 8px; transition: background 0.2s, border-color 0.2s; }
.receipt-upload.dragover { background: #e8f0fe; outline: 2px dashed var(--primary); }

/* Photo Action Sheet */
.photo-action-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 9999; align-items: flex-end; justify-content: center;
}
.photo-action-overlay.active { display: flex; }
.photo-action-sheet {
  background: #fff; border-radius: 14px 14px 0 0; width: 100%; max-width: 480px;
  padding: 8px 0 env(safe-area-inset-bottom, 8px); animation: slideUp 0.2s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.photo-action-sheet .action-btn {
  display: block; width: 100%; padding: 16px; font-size: 17px;
  text-align: center; border: none; background: none; cursor: pointer;
  color: #007aff; border-bottom: 1px solid #e5e5e5;
}
.photo-action-sheet .action-btn:active { background: #f0f0f0; }
.photo-action-sheet .action-cancel {
  color: #007aff; font-weight: 600; border-bottom: none; margin-top: 6px;
}

.empty-state {
  text-align: center; padding: 40px 16px;
  color: var(--text-secondary); font-size: 15px;
}

/* Schedule Cards (staff side) */
.schedule-list { display: flex; flex-direction: column; gap: 10px; padding-bottom: 60px; }
.schedule-card {
  background: var(--card-bg); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.schedule-card.schedule-confirmed {
  border-left: 4px solid var(--success);
}
.schedule-card.schedule-my-confirm {
  border-left: 4px solid var(--primary);
  background: #f0f6ff;
}
.schedule-card.schedule-answered {
  background: #e8f5e9; border-left: 4px solid #4caf50; opacity: 0.85;
}
.schedule-card.schedule-answered .schedule-responded {
  color: #2e7d32; font-weight: 700;
}
.schedule-card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.schedule-date { font-size: 15px; font-weight: 700; color: var(--text); }
.schedule-hall { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.schedule-event { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.schedule-fee { font-size: 15px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }

.schedule-actions {
  display: flex; gap: 10px;
}
.btn-respond {
  flex: 1; padding: 12px; border: 2px solid var(--border);
  border-radius: 8px; font-size: 16px; font-weight: 700;
  cursor: pointer; text-align: center; font-family: inherit;
  background: var(--card-bg); color: var(--text);
  transition: all 0.2s;
}
.btn-available { border-color: var(--success); color: var(--success); }
.btn-available.selected { background: var(--success); color: #fff; }
.btn-unavailable { border-color: var(--danger); color: var(--danger); }
.btn-unavailable.selected { background: var(--danger); color: #fff; }

.schedule-responded {
  text-align: center; font-size: 13px; color: var(--success);
  margin-top: 6px; font-weight: 600;
}

.schedule-badge {
  padding: 8px 12px; border-radius: 8px;
  font-size: 14px; font-weight: 600; text-align: center;
}
.badge-my-confirm { background: #e8f0fe; color: var(--primary); }

/* Closed schedule card (confirmed for another staff) */
.schedule-card-closed {
  display: flex; align-items: center; gap: 8px;
  background: #f8f9fa; border-radius: 8px;
  padding: 10px 14px; font-size: 13px;
  color: var(--text-secondary);
}
.closed-date { font-weight: 600; white-space: nowrap; }
.closed-hall { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.closed-status {
  white-space: nowrap; font-size: 12px; font-weight: 600;
  color: var(--text-secondary); background: #eee;
  padding: 2px 8px; border-radius: 10px;
}

/* Header Bar */
.header-bar {
  display: flex; justify-content: flex-end; align-items: center;
  padding: 6px 16px; background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}
.header-logout {
  font-size: 13px; color: var(--danger); text-decoration: none; font-weight: 500;
  padding: 4px 12px; border: 1px solid var(--danger); border-radius: 6px;
}

/* Nav badge */
.nav-item { position: relative; }
.nav-badge {
  position: absolute; top: 2px; right: 50%; transform: translateX(18px);
  min-width: 20px; height: 20px; line-height: 20px;
  background: #d93025; color: #fff; font-size: 12px; font-weight: 700;
  text-align: center; border-radius: 10px; padding: 0 5px;
}

/* Same day note */
.same-day-note { font-size: 11px; color: #999; margin-top: 4px; }

/* Submit responses button */
.btn-submit-responses {
  display: inline-block; padding: 14px 40px;
  background: var(--primary); color: #fff; border: none; border-radius: 8px;
  font-size: 16px; font-weight: 600; cursor: pointer;
}
.btn-submit-responses:active { background: var(--primary-dark, #1557b0); }
.submit-message { margin-top: 12px; color: var(--success, #1e8e3e); font-size: 15px; font-weight: 600; }

/* PWA standalone mode */
@media (display-mode: standalone) {
  body { padding-top: env(safe-area-inset-top, 0); }
}
