* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f5f5;
  color: #333;
  max-width: 680px;
  margin: 0 auto;
  min-height: 100vh;
}

header {
  background: #fff;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 {
  font-size: 18px;
  flex: 1;
}

.back-link {
  color: #333;
  text-decoration: none;
  font-size: 26px;
  padding: 2px 6px 0 2px;
  line-height: 1;
}

.btn-add {
  padding: 6px 18px;
  border: none;
  background: #4a90d9;
  color: #fff;
  font-size: 16px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}

.btn-add:hover {
  background: #357abd;
}

/* Header Action Buttons */
.btn-header {
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}

.btn-header:hover {
  background: #f5f5f5;
}

.btn-header-danger {
  color: #e74c3c;
  border-color: #e74c3c;
}

.btn-header-danger:hover {
  background: #fdf0ef;
}

main {
  padding: 12px 16px 80px;
}

/* Card List */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  background: #fff;
  border-radius: 8px;
  padding: 14px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: box-shadow 0.15s;
}

.card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.card-date {
  font-size: 13px;
  color: #888;
}

/* Project Card */
.project-card {
  padding: 16px;
}

.project-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.project-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.project-date {
  color: #999;
}

.project-stats {
  color: #e67e22;
  font-weight: 500;
}

/* Completed Projects Section */
.completed-section {
  margin-top: 16px;
}

.completed-section.hidden {
  display: none;
}

.completed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #fff;
  border-radius: 8px;
  font-size: 14px;
  color: #999;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  margin-bottom: 8px;
}

.completed-header:hover {
  background: #fafafa;
}

.completed-list.hidden {
  display: none;
}

.project-done {
  opacity: 0.6;
}

.project-done:hover {
  opacity: 0.85;
}

/* Toast Message */
.toast-msg {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 200;
  pointer-events: none;
  transition: opacity 0.3s;
}

.toast-msg.hidden {
  display: none;
}

.card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 14px;
}

.card-label {
  color: #888;
  flex-shrink: 0;
  margin-right: 12px;
}

.card-amount {
  font-weight: 600;
  color: #e67e22;
}

/* Item Card */
.item-card {
  padding: 12px 14px;
}

.item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.item-category {
  font-size: 15px;
  font-weight: 600;
}

.item-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.item-date {
  font-size: 12px;
  color: #aaa;
}

.item-note {
  font-size: 13px;
  color: #666;
  margin: 2px 0 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Status Tags */
.status-tag {
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.status-未申请 {
  background: #e8e8e8;
  color: #666;
  border-color: #ccc;
}

.status-已申请 {
  background: #e3f2fd;
  color: #1976d2;
  border-color: #90caf9;
}

.status-已到账 {
  background: #e8f5e9;
  color: #388e3c;
  border-color: #a5d6a7;
}

.status-tag.active {
  transform: scale(1.05);
  font-weight: 600;
}

/* Status Selector (detail page) */
.status-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status-selector .status-tag:not(.active) {
  opacity: 0.5;
}

.status-selector .status-tag:not(.active):hover {
  opacity: 0.8;
}

/* Dialog */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.dialog-overlay.hidden {
  display: none;
}

.dialog {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 320px;
  max-width: 90vw;
}

.dialog h2 {
  font-size: 16px;
  margin-bottom: 16px;
}

.dialog p {
  font-size: 15px;
  color: #333;
  margin-bottom: 20px;
  line-height: 1.5;
}

.dialog input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 10px;
}

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.btn-cancel {
  padding: 8px 16px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.btn-confirm {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  background: #4a90d9;
  color: #fff;
  cursor: pointer;
}

/* Forms */
form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

form label {
  font-size: 13px;
  color: #666;
  margin-top: 4px;
}

form input, form select, form textarea {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

.btn-submit {
  padding: 12px;
  border: none;
  border-radius: 6px;
  background: #4a90d9;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  margin-top: 8px;
}

.btn-submit:hover {
  background: #357abd;
}

.btn-delete {
  padding: 12px;
  border: 1px solid #e74c3c;
  border-radius: 6px;
  background: #fff;
  color: #e74c3c;
  font-size: 15px;
  cursor: pointer;
  margin-top: 8px;
  width: 100%;
}

.btn-delete:hover {
  background: #fdf0ef;
}

/* AI Input Bar */
.ai-input-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.ai-input-bar input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.ai-input-bar input:focus {
  border-color: #4a90d9;
}

.btn-send {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: #4a90d9;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.btn-send:hover {
  background: #357abd;
}

.btn-send:disabled {
  background: #a0c4e8;
  cursor: not-allowed;
}

/* AI Status */
.ai-status {
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.ai-status.hidden {
  display: none;
}

.ai-status.ai-success {
  background: #e8f5e9;
  color: #2e7d32;
}

.ai-status.ai-error {
  background: #fbe9e7;
  color: #c62828;
}

/* Detail page */
.detail-section {
  margin-bottom: 16px;
}

.detail-label {
  font-size: 13px;
  color: #666;
  margin-bottom: 6px;
}

.detail-page input,
.detail-page select,
.detail-page textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

/* Responsive */
@media (max-width: 480px) {
  body { max-width: 100%; }
}

/* Select Button */
.btn-select {
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-select:hover {
  background: #f5f5f5;
}

/* Item Card with Checkbox */
.item-card {
  display: flex;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
}

.item-check {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  flex-shrink: 0;
  cursor: pointer;
  border-right: 1px solid #f0f0f0;
}

.item-check.show {
  display: flex;
}

.check-box {
  width: 20px;
  height: 20px;
  border: 2px solid #ccc;
  border-radius: 50%;
  transition: all 0.15s;
}

.check-box.checked {
  background: #4a90d9;
  border-color: #4a90d9;
  position: relative;
}

.check-box.checked::after {
  content: '✓';
  color: #fff;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  font-weight: bold;
}

.item-body {
  flex: 1;
  padding: 12px 14px;
  cursor: pointer;
  min-width: 0;
}

.item-card.checked {
  background: #f0f7ff;
}

/* Batch Action Bar */
.batch-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 680px;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  padding: 10px 16px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 50;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
}

.batch-bar.hidden {
  display: none;
}

.batch-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.batch-count {
  font-size: 13px;
  color: #333;
  white-space: nowrap;
}

.batch-actions {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex: 1;
}

.batch-btn {
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}

.batch-btn:hover {
  background: #f5f5f5;
}

.batch-status {
  border-color: #4a90d9;
  color: #4a90d9;
}

.batch-status:hover {
  background: #e3f0ff;
}

.batch-cancel {
  color: #e74c3c;
  border-color: #e74c3c;
}
