* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  background: #f5f6f8;
  color: #222;
}

.login-screen[hidden] { display: none; }
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-form {
  background: #fff;
  padding: 32px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  width: 280px;
  text-align: center;
}
.login-form h1 { font-size: 18px; margin-bottom: 20px; }
.login-form input {
  width: 100%;
  padding: 10px;
  margin-bottom: 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
}
.login-form button {
  width: 100%;
  padding: 10px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
.error-message { color: #dc2626; font-size: 13px; margin-top: 8px; }
.success-message { color: #16a34a; font-size: 13px; margin-top: 8px; }

.app { max-width: 1200px; margin: 0 auto; padding: 16px; }
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.app-header h1 { font-size: 20px; margin: 0; }
.header-actions { display: flex; gap: 8px; }

.secondary-btn {
  padding: 8px 14px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.secondary-btn:disabled { opacity: 0.5; cursor: default; }

.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input, .toolbar select {
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
}
#search-input { flex: 1; min-width: 200px; }

.table-wrap { overflow-x: auto; background: #fff; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  padding: 8px 10px;
  border-bottom: 1px solid #eee;
  text-align: left;
  white-space: nowrap;
}
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { background: #f0f4ff; }
td[contenteditable] { min-width: 80px; white-space: normal; }
td[contenteditable]:focus { background: #fffbe6; outline: 1px solid #f5c518; }
.items-cell { max-width: 220px; white-space: pre-wrap; }

.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; cursor: pointer; }

.delete-btn {
  padding: 4px 10px;
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
  font-size: 13px;
}

.card-list { display: none; }

.image-modal[hidden] { display: none; }
.image-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.image-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
}
.image-modal-content {
  position: relative;
  background: #fff;
  padding: 16px;
  border-radius: 8px;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.image-modal-content img { max-width: 100%; max-height: 75vh; object-fit: contain; }

@media (max-width: 768px) {
  .table-wrap { display: none; }
  .card-list { display: flex; flex-direction: column; gap: 10px; }
  .card {
    background: #fff;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  }
  .card-thumb { width: 100%; height: 160px; object-fit: cover; border-radius: 6px; margin-bottom: 8px; }
  .card-row { margin-bottom: 4px; font-size: 14px; display: flex; justify-content: space-between; }
  .card-comment { color: #666; font-size: 13px; justify-content: flex-start; }
  #search-input { width: 100%; }
}
