* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f7fa;
  color: #333;
  min-height: 100vh;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

h1 {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 20px;
  color: #1a1a2e;
}

h2 {
  font-size: 1rem;
  color: #555;
  margin-bottom: 12px;
}

/* フォーム */
.form-section {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 4px;
  font-weight: 600;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #dde1ea;
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: #2196F3;
}

.btn {
  display: inline-block;
  padding: 11px 20px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  font-weight: 600;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #2196F3;
  color: #fff;
  width: 100%;
}

.btn-primary:hover {
  opacity: 0.9;
}

/* 統計 */
.stats-section {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  flex: 1;
  background: #fff;
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.stat-card.lending {
  border-top: 3px solid #f44336;
}

.stat-card.returned {
  border-top: 3px solid #4caf50;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: #888;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: #1a1a2e;
}

/* フィルター */
.filter-section {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-btn {
  flex: 1;
  padding: 8px;
  border: 1.5px solid #dde1ea;
  border-radius: 8px;
  background: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  color: #555;
  transition: all 0.2s;
  font-weight: 600;
}

.filter-btn.active {
  background: #2196F3;
  border-color: #2196F3;
  color: #fff;
}

/* リスト */
.list-section {
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  min-height: 80px;
}

.key-list {
  list-style: none;
}

.key-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 8px;
  border-bottom: 1px solid #f0f2f5;
}

.key-item:last-child {
  border-bottom: none;
}

.key-info {
  flex: 1;
  min-width: 0;
}

.key-number {
  font-size: 1rem;
  font-weight: 700;
  color: #1a1a2e;
}

.key-borrower {
  font-size: 0.9rem;
  color: #555;
  margin-top: 2px;
}

.key-note {
  font-size: 0.8rem;
  color: #999;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.key-date {
  font-size: 0.75rem;
  color: #aaa;
  margin-top: 2px;
}

.status-badge {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s, transform 0.1s;
  white-space: nowrap;
}

.status-badge:active {
  transform: scale(0.95);
}

.status-lending {
  background: #ffebee;
  color: #c62828;
}

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

.delete-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #ccc;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s;
}

.delete-btn:hover {
  color: #f44336;
}

.empty-msg {
  text-align: center;
  color: #bbb;
  font-size: 0.9rem;
  padding: 20px 0;
}

/* レスポンシブ */
@media (max-width: 375px) {
  h1 {
    font-size: 1.3rem;
  }

  .stat-value {
    font-size: 1.3rem;
  }
}
